/* 우리의 보드 — 미드나잇 갤러리 (design.md 기준) */

:root {
  --bg: #0B0A1F;
  --surface: #15123A;
  --violet: #2A1F6B;
  --gold: #D4AF63;
  --gold-light: #F6E3A8;
  --gold-dark: #B08D3C;
  --text: #F7F5FB;
  --text-muted: #B9B4D6;
  --ink: #1C1A2E;
  --ink-muted: #5E5A78;

  --card-pearl: #FFFFFF;
  --card-rose: #FFE4EC;
  --card-champagne: #FFF1CF;
  --card-mint: #DDF5EA;
  --card-lavender: #E7E1FF;

  --success: #3CCB8F;
  --warning: #FFB45C;
  --danger: #FF6B81;

  --grad-aurora: linear-gradient(120deg, #7C5CFF 0%, #E0529C 55%, #FFB45C 100%);
  --grad-gold: linear-gradient(135deg, #F6E3A8 0%, #D4AF63 50%, #B08D3C 100%);

  --radius-card: 16px;
  --radius-panel: 20px;
  --radius-control: 12px;

  --shadow-card: 0 1px 0 rgba(255,255,255,.6) inset, 0 10px 30px rgba(5,4,20,.35);
  --shadow-card-hover: 0 18px 44px rgba(5,4,20,.5), 0 0 0 1px rgba(212,175,99,.45);
  --shadow-gold: 0 6px 24px rgba(212,175,99,.35);

  --glass-bg: rgba(21,18,58,.62);
  --glass-border: 1px solid rgba(255,255,255,.10);
  --glass-blur: blur(18px) saturate(140%);

  --font-display: "Noto Serif KR", serif;
  --font-body: "Pretendard", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --ease: cubic-bezier(.2,.8,.2,1);
  --dur-fast: 150ms;
  --dur: 280ms;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, #2A1F6B 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #4A1D5E 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(212,175,99,.7);
  outline-offset: 2px;
}

/* ---------- 공통 조각 ---------- */

.glass {
  background: var(--glass-bg);
  border: var(--glass-border);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  background: var(--grad-aurora);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.aurora-line {
  width: 56px;
  height: 3px;
  border-radius: 999px;
  background: var(--grad-aurora);
}

.muted { color: var(--text-muted); }
.caption { font-size: 13px; line-height: 1.5; }

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-control);
  border: 1px solid rgba(255,255,255,.14);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.06); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  position: relative;
  overflow: hidden;
  border: 0;
  background: var(--grad-gold);
  color: var(--ink);
  box-shadow: var(--shadow-gold);
}
.btn-primary:hover { background: var(--grad-gold); filter: brightness(1.05); }
/* 주 버튼 위로 3초마다 빛이 한 번 스친다 */
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 3s var(--ease) infinite;
}
@keyframes sheen {
  0%, 70% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.12); }

/* 입력창 */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-muted); }
.input, .textarea {
  width: 100%;
  padding: 0 14px;
  height: 48px;
  border-radius: var(--radius-control);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { height: auto; min-height: 140px; padding: 12px 14px; resize: vertical; line-height: 1.65; }
.input::placeholder, .textarea::placeholder { color: rgba(185,180,214,.7); }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,99,.25);
}

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

/* 칩 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { background: rgba(255,255,255,.14); }
.chip svg { width: 13px; height: 13px; }

/* 대화상자 */
dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 24px;
  border-radius: var(--radius-panel);
  color: var(--text);
  background: rgba(21,18,58,.92);
  border: var(--glass-border);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 30px 80px rgba(5,4,20,.6);
  overflow: auto;
}
dialog[open] { animation: pop var(--dur) var(--ease); }
dialog::backdrop { background: rgba(5,4,20,.7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
.dialog-title { font-size: 20px; line-height: 1.4; font-weight: 600; margin-bottom: 16px; }
.dialog-body { display: grid; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* 알림 메시지 */
.toast-area {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  z-index: 100;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  background: rgba(21,18,58,.95);
  border: var(--glass-border);
  box-shadow: 0 10px 30px rgba(5,4,20,.5);
  animation: rise var(--dur) var(--ease);
}
.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.toast.error::before { background: var(--danger); }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 첫 화면 ---------- */

.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: 64px 24px 80px;
}
.hero {
  max-width: 520px;
  margin: 0 auto 48px;
  padding: 40px 32px;
  border-radius: var(--radius-panel);
  text-align: center;
  display: grid;
  gap: 16px;
  justify-items: center;
}
.hero img { width: 64px; height: 64px; }
.hero h1 { font-size: 40px; line-height: 1.2; }
.hero form { display: grid; gap: 12px; width: 100%; margin-top: 8px; }
.hero .welcome { font-size: 17px; }

.section-heading { display: grid; gap: 10px; margin-bottom: 20px; }
.section-heading h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.3; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.board-tile {
  display: block;
  border-radius: var(--radius-card);
  overflow: hidden;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.board-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.board-tile .band { height: 72px; }
.board-tile .body { padding: 16px; display: grid; gap: 6px; }
.board-tile h3 { font-family: var(--font-display); font-size: 18px; line-height: 1.4; }
.board-tile p { color: var(--text-muted); font-size: 14px; overflow-wrap: anywhere; }
.board-tile .meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.empty-note {
  padding: 40px 24px;
  border-radius: var(--radius-panel);
  text-align: center;
  color: var(--text-muted);
}
.footer-link { margin-top: 48px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- 보드 화면 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  border-width: 0 0 1px 0;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand img { width: 28px; height: 28px; }
.brand .logo-text { font-size: 17px; }
.board-heading { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 12px; }
.board-heading h1 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-heading p {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* 자동 갱신 때 머리글 아래로 지나가는 오로라 선 */
.sync-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--grad-aurora);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}
.sync-line.run { animation: sweep 600ms var(--ease); }
@keyframes sweep {
  0% { transform: scaleX(0); opacity: 1; }
  80% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

.wall {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  min-height: calc(100vh - 64px);
}
.wall .col { flex: 1; min-width: 0; display: grid; gap: 16px; }

.board-empty {
  position: absolute;
  inset: 64px 0 0 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  pointer-events: none;
}
.board-empty svg { width: 120px; height: 80px; opacity: .7; }

.sentinel { height: 1px; }
.loading-more { padding: 8px 0 32px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* 게시글 카드 */
.card {
  position: relative;
  padding: 16px;
  border-radius: var(--radius-card);
  color: var(--ink);
  background: var(--card-pearl);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.card[data-color="rose"] { background: var(--card-rose); }
.card[data-color="champagne"] { background: var(--card-champagne); }
.card[data-color="mint"] { background: var(--card-mint); }
.card[data-color="lavender"] { background: var(--card-lavender); }

.card.is-new { animation: card-in var(--dur) var(--ease), card-glow 1.2s ease-out var(--dur); }
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes card-glow {
  from { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold), 0 0 28px rgba(212,175,99,.6); }
  to { box-shadow: var(--shadow-card), 0 0 0 2px transparent, 0 0 0 transparent; }
}

.card-title {
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 28px;
  overflow-wrap: anywhere;
}
.card-content {
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* 제목 없는 카드에서 글 메뉴 버튼(⋯)이 내용을 가리지 않게 한다 */
.card-menu-btn + .card-content { padding-right: 28px; }
.card-content.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-content a { color: #4B2FD6; text-underline-offset: 2px; }
.card-more {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--grad-aurora);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.card-author { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-date { margin-left: auto; white-space: nowrap; }

.card-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.card-menu-btn:hover { background: rgba(28,26,46,.08); }
.card-menu {
  position: absolute;
  top: 40px;
  right: 8px;
  z-index: 5;
  min-width: 112px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(5,4,20,.3), 0 0 0 1px rgba(28,26,46,.08);
  display: grid;
}
.card-menu button {
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.card-menu button:hover { background: rgba(28,26,46,.06); }
.card-menu button.danger { color: #D92D4B; }

/* 글쓰기 버튼 (오른쪽 아래) */
.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--grad-gold);
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-gold), 0 10px 30px rgba(5,4,20,.4);
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.fab:hover { transform: translateY(-2px) scale(1.04); filter: brightness(1.05); }

/* 글쓰기 대화상자 */
.composer-paper {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--card-pearl);
  color: var(--ink);
  transition: background var(--dur) var(--ease);
}
.composer-paper[data-color="rose"] { background: var(--card-rose); }
.composer-paper[data-color="champagne"] { background: var(--card-champagne); }
.composer-paper[data-color="mint"] { background: var(--card-mint); }
.composer-paper[data-color="lavender"] { background: var(--card-lavender); }
.composer-paper input, .composer-paper textarea {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  padding: 6px 4px;
}
.composer-paper input { font-size: 17px; font-weight: 600; }
.composer-paper textarea { min-height: 160px; resize: vertical; line-height: 1.65; }
.composer-paper ::placeholder { color: rgba(94,90,120,.7); }

.swatches { display: flex; gap: 10px; align-items: center; }
.swatches > span { font-size: 13px; color: var(--text-muted); margin-right: 4px; }
.swatch { position: relative; width: 32px; height: 32px; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  transition: box-shadow var(--dur-fast) var(--ease);
}
.swatch input:checked + i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--gold); }
.swatch input:focus-visible + i { outline: 3px solid rgba(212,175,99,.7); outline-offset: 4px; }

/* ---------- 관리자 화면 ---------- */

.admin { max-width: 960px; margin: 0 auto; padding: 40px 24px 80px; }
.admin-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--gold);
}
.admin-top h1 { font-family: var(--font-display); font-size: 24px; flex: 1; }
.login-panel {
  max-width: 400px;
  margin: 80px auto 0;
  padding: 32px;
  border-radius: var(--radius-panel);
  display: grid;
  gap: 16px;
}
.login-panel h1 { font-family: var(--font-display); font-size: 24px; text-align: center; }

.table-wrap { border-radius: var(--radius-panel); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid rgba(255,255,255,.10); white-space: nowrap; }
tr + tr td { border-top: 1px solid rgba(255,255,255,.06); }
td .title-link { font-weight: 600; text-decoration: none; }
td .title-link:hover { text-decoration: underline; }
td .desc { color: var(--text-muted); font-size: 13px; }
td .addr { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 좁은 화면 ---------- */

@media (max-width: 1023px) {
  .board-heading p { display: none; }
}

@media (max-width: 639px) {
  .home { padding: 32px 16px 64px; }
  .hero { padding: 28px 20px; }
  .hero h1 { font-size: 30px; }
  .topbar { height: 56px; padding: 0 12px; gap: 10px; }
  .brand .logo-text { display: none; }
  .board-heading h1 { font-size: 17px; }
  .wall { padding: 12px; gap: 12px; min-height: calc(100vh - 56px); }
  .wall .col { gap: 12px; }
  .board-empty { inset: 56px 0 0 0; }
  .fab { right: 16px; bottom: 16px; }
  .admin { padding: 24px 16px 64px; }
  /* 대화상자는 아래에서 올라오는 시트로 */
  dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0 0;
    border-radius: var(--radius-panel) var(--radius-panel) 0 0;
    padding: 20px 16px;
  }
  dialog[open] { animation: sheet var(--dur) var(--ease); }
  @keyframes sheet {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
}

/* 동작 줄이기를 켠 기기: 이동과 반짝임을 끈다 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .btn-primary::after { display: none; }
  .card:hover, .board-tile:hover, .btn:hover, .fab:hover { transform: none; }
}
