/* =================================================================
   night-forum ｜ 付費解鎖夜生活/SPA 體驗論壇
   風格：Modern Dark Editorial — 深炭灰 × 金 × 酒紅 × 流體玻璃
   Mobile-first；WCAG AA 對比；prefers-reduced-motion 降級
================================================================= */

:root {
  /* 底色系（深炭，非純黑） */
  --bg:        #0E0E12;
  --bg-2:      #101016;
  --surface:   #15151B;
  --elevated:  #1C1C24;
  --glass:     rgba(28, 28, 36, 0.62);
  --glass-line: rgba(255, 255, 255, 0.08);

  /* 金 / 酒紅 重點 */
  --gold:      #E7A94F;
  --gold-deep: #C9962F;
  --gold-soft: #F3D9A0;
  --wine:      #8C2F39;
  --wine-soft: #B0454F;

  /* 文字（深底 AA） */
  --text:   #ECECF1;
  --muted:  #9A9AA6;
  --faint:  #6E6E78;

  /* 線 / 狀態 */
  --border:  rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --success: #3FB97A;
  --danger:  #E0655A;
  --warn:    #E7A94F;

  /* 漸層 */
  --grad-gold:  linear-gradient(135deg, #F3D9A0 0%, #E7A94F 50%, #C9962F 100%);
  --grad-cta:   linear-gradient(135deg, #E7A94F 0%, #C9962F 100%);
  --grad-title: linear-gradient(120deg, #F3D9A0 0%, #E7A94F 55%, #C9962F 100%);
  --grad-wine:  linear-gradient(135deg, #B0454F 0%, #8C2F39 100%);

  /* 陰影 + 金色光暈 */
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 6px 18px rgba(0,0,0,.45);
  --sh-3: 0 18px 42px rgba(0,0,0,.55);
  --glow-gold: 0 8px 30px rgba(231,169,79,.28);

  /* 圓角 */
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 22px; --r-xl: 30px; --r-pill: 999px;

  /* 版面 */
  --maxw: 1180px;
  --pad: clamp(16px, 5vw, 32px);
  --header-h: 64px;

  /* 字型 */
  --font-serif: "Noto Serif TC", Georgia, "Times New Roman", serif;
  --font-body:  "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ring: 0 0 0 3px rgba(231,169,79,.32);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  background-image:
    radial-gradient(60% 50% at 6% -10%, rgba(231,169,79,.10), transparent 60%),
    radial-gradient(55% 45% at 100% 2%, rgba(140,47,57,.14), transparent 55%),
    radial-gradient(50% 40% at 50% 115%, rgba(231,169,79,.05), transparent 60%);
  background-attachment: fixed;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; margin: 0; color: var(--text); }
::selection { background: rgba(231,169,79,.28); color: #1A1206; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); position: relative; z-index: 1; }
.container-narrow { max-width: 760px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 600; background: var(--gold); color: #1A1206; padding: 10px 16px; border-radius: var(--r-pill); font-weight: 700; }
.skip-link:focus { left: 12px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

.muted { color: var(--muted); }
.gold-text { background: var(--grad-title); -webkit-background-clip: text; background-clip: text; color: transparent; }
[hidden] { display: none !important; }

/* =================================================================  按鈕  */
.btn {
  --btn-bg: var(--elevated);
  --btn-fg: var(--text);
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 12px 22px;
  border: 1px solid var(--border-2); border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 0.98rem; font-weight: 600; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  --btn-fg: #1A1206;
  background: var(--grad-cta); border-color: transparent;
  box-shadow: var(--sh-2), var(--glow-gold); font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: var(--sh-3), var(--glow-gold); }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.04); }
.btn-wine { background: var(--grad-wine); border-color: transparent; color: #fff; }
.btn-mini { min-height: 36px; padding: 7px 14px; font-size: 0.86rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.25); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =================================================================  Header  */
.site-header {
  position: sticky; top: 0; z-index: 300;
  height: var(--header-h);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: 16px; height: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-weight: 700; font-size: 1.18rem; color: var(--text); }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grad-cta); box-shadow: var(--glow-gold); }
.nav-spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { color: var(--muted); padding: 8px 12px; border-radius: var(--r-pill); font-size: 0.95rem; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: rgba(255,255,255,.05); }
.nav-acct { display: flex; align-items: center; gap: 8px; }
.nav-acct .who { color: var(--muted); font-size: 0.88rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =================================================================  Hero / 區塊  */
.hero { padding: clamp(40px, 8vw, 84px) 0 clamp(28px, 5vw, 48px); }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: var(--r-pill); border: 1px solid var(--border-2); background: rgba(231,169,79,.08); color: var(--gold-soft); font-size: 0.82rem; font-weight: 600; letter-spacing: .03em; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); margin: 18px 0 12px; letter-spacing: -.01em; }
.hero p.lede { color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.18rem); max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-stats { display: flex; gap: 28px; margin-top: 34px; flex-wrap: wrap; }
.hero-stats .stat b { font-family: var(--font-serif); font-size: 1.7rem; display: block; color: var(--gold); }
.hero-stats .stat span { color: var(--muted); font-size: 0.85rem; }

.section { padding: clamp(28px, 5vw, 52px) 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); }
.section-head a { font-size: 0.92rem; }

/* =================================================================  看板列表  */
.board-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.board-item {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .2s ease, transform .15s ease, box-shadow .2s ease;
}
.board-item:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--sh-2); }
.board-item .ico { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: rgba(231,169,79,.1); font-size: 1.5rem; }
.board-item .meta { flex: 1; min-width: 0; }
.board-item .meta h3 { font-size: 1.1rem; }
.board-item .meta p { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; }
.board-item .count { color: var(--gold); font-family: var(--font-serif); font-weight: 700; text-align: right; }
.board-item .count span { display: block; color: var(--faint); font-size: 0.75rem; font-weight: 400; font-family: var(--font-body); }

/* =================================================================  主題卡  */
.thread-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.thread-card {
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border);
  transition: border-color .2s ease, transform .15s ease, box-shadow .25s ease;
}
.thread-card:hover { border-color: var(--border-2); transform: translateY(-3px); box-shadow: var(--sh-3); }
.thread-card .cover { aspect-ratio: 16 / 9; background: var(--elevated) center/cover no-repeat; position: relative; }
.thread-card .cover .tag { position: absolute; left: 12px; top: 12px; padding: 4px 12px; border-radius: var(--r-pill); background: rgba(14,14,18,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--gold-soft); font-size: 0.76rem; font-weight: 600; }
.thread-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.thread-card .body h3 { font-size: 1.14rem; line-height: 1.4; }
.thread-card .body p { color: var(--muted); font-size: 0.92rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.price-tag { font-family: var(--font-serif); font-weight: 700; color: var(--gold); }
.price-tag.free { color: var(--success); }
.badge-unlocked { display: inline-flex; align-items: center; gap: 5px; color: var(--success); font-size: 0.84rem; font-weight: 600; }
.badge-lock { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.84rem; }

/* =================================================================  文章頁  */
.article-head { padding: clamp(24px,5vw,44px) 0 8px; }
.breadcrumb { color: var(--faint); font-size: 0.86rem; margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); }
.article-title { font-size: clamp(1.7rem, 4.5vw, 2.8rem); letter-spacing: -.01em; }
.article-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 0.88rem; margin-top: 14px; flex-wrap: wrap; }
.article-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r-lg); margin: 22px 0; border: 1px solid var(--border); }
.article-body { font-family: var(--font-serif); font-size: 1.1rem; line-height: 1.95; max-width: 42rem; }
.article-body p { margin: 0 0 1.2em; }
.article-body h2, .article-body h3 { margin: 1.6em 0 .6em; }
.article-body img { border-radius: var(--r-md); margin: 1em 0; border: 1px solid var(--border); }
.article-body a { text-decoration: underline; }

.article-lede { font-family: var(--font-serif); font-size: 1.16rem; color: var(--muted); line-height: 1.9; max-width: 42rem; margin: 4px 0 22px; }

/* 未解鎖：內文圖的霧化預覽 gallery (伺服器只送 ~40px 低解析版，CSS 模糊僅為美觀) */
.locked-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-width: 42rem; margin: 8px 0 4px; }
.locked-gallery .blur-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-sm); filter: blur(6px) saturate(1.1); transform: scale(1.06); border: 1px solid var(--border); }

/* 鎖定時的「隱藏內容」視覺暗示：純裝飾模糊條 (非真實內文，無洩漏) */
.locked-preview { position: relative; max-width: 42rem; margin: 6px 0 0; }
.locked-preview .blur-lines { filter: blur(5px); user-select: none; opacity: .45; }
.locked-preview .blur-lines span { display: block; height: 0.95rem; margin: 0.75rem 0; border-radius: 4px; background: var(--elevated); }
.locked-preview .blur-lines span:nth-child(odd) { width: 92%; }
.locked-preview .blur-lines span:nth-child(3n) { width: 74%; }
.locked-preview::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, transparent 0%, transparent 30%, rgba(14,14,18,.85) 90%, var(--bg) 100%); }

/* 鎖定預覽：teaser 公開段 + 漸層遮罩 + 尾段模糊 + 浮層 lock card */
.article-teaser { position: relative; max-height: 22rem; overflow: hidden; font-family: var(--font-serif); font-size: 1.1rem; line-height: 1.95; max-width: 42rem; }
.article-teaser::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, transparent 42%, rgba(14,14,18,.7) 76%, rgba(14,14,18,.98) 100%); }
.article-teaser .teaser-tail { filter: blur(3px); user-select: none; }
.lock-zone { position: relative; margin: -3rem auto 0; max-width: 42rem; display: flex; justify-content: center; }
.lock-card {
  width: min(440px, 100%); text-align: center; padding: 28px 24px;
  background: var(--glass); -webkit-backdrop-filter: saturate(140%) blur(16px); backdrop-filter: saturate(140%) blur(16px);
  border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--sh-3), var(--glow-gold);
}
.lock-card .lock-ico { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: rgba(231,169,79,.12); color: var(--gold); }
.lock-card h3 { font-size: 1.2rem; margin-bottom: 6px; }
.lock-card .price { font-family: var(--font-serif); font-size: 2rem; color: var(--gold); margin: 10px 0 4px; }
.lock-card p { color: var(--muted); font-size: 0.9rem; margin: 6px 0 18px; }

/* =================================================================  表單  */
.auth-wrap { max-width: 420px; margin: clamp(36px,7vw,72px) auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: clamp(22px, 4vw, 34px); box-shadow: var(--sh-2); }
.card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.card .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.field label .req { color: var(--gold); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 1rem; font-family: inherit;
  color: var(--text); background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold-deep); box-shadow: var(--ring); }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.field .hint { color: var(--faint); font-size: 0.8rem; }
.field .error-text { color: var(--danger); font-size: 0.82rem; display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(224,101,90,.18); }
.field.has-error .error-text { display: block; }
.checkrow { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; color: var(--muted); }
.checkrow input { width: auto; margin-top: 3px; }
.form-foot { margin-top: 8px; }
.form-alt { text-align: center; color: var(--muted); font-size: 0.9rem; margin-top: 16px; }

/* =================================================================  Age gate  */
.age-gate { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px;
  background: rgba(8,8,11,.86); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.age-card { max-width: 460px; text-align: center; padding: 34px 28px; background: var(--elevated); border: 1px solid var(--border-2); border-radius: var(--r-xl); box-shadow: var(--sh-3); }
.age-card .age-ico { width: 66px; height: 66px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: rgba(231,169,79,.14); border: 1px solid var(--border-2); color: var(--gold); font-family: var(--font-serif); font-weight: 700; font-size: 1.5rem; }
.lock-ico svg, .lock-card .lock-ico svg { display: block; }
.badge-lock svg { vertical-align: -2px; }
.age-card h2 { font-size: 1.5rem; margin: 12px 0 10px; }
.age-card p { color: var(--muted); font-size: 0.94rem; margin: 0 0 22px; }
.age-card .age-actions { display: flex; flex-direction: column; gap: 10px; }
.age-card .fineprint { margin-top: 16px; font-size: 0.78rem; color: var(--faint); }

/* =================================================================  Modal  */
.modal { position: fixed; inset: 0; z-index: 450; display: grid; place-items: center; padding: 20px;
  background: rgba(8,8,11,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-card { width: min(520px, 100%); max-height: 88vh; overflow: auto; background: var(--elevated); border: 1px solid var(--border-2); border-radius: var(--r-lg); padding: 26px; box-shadow: var(--sh-3); position: relative; }
.modal-card h3 { font-size: 1.3rem; margin-bottom: 4px; }
.modal-x { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.modal-x:hover { color: var(--text); }

/* =================================================================  Toast  */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 700; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--elevated); color: var(--text); border: 1px solid var(--border-2); border-radius: var(--r-pill); padding: 11px 20px; font-size: 0.9rem; box-shadow: var(--sh-2); animation: toastin .3s ease; }
.toast.ok { border-color: rgba(63,185,122,.5); }
.toast.err { border-color: rgba(224,101,90,.5); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* =================================================================  雜項  */
.bank-box { background: var(--bg-2); border: 1px dashed var(--border-2); border-radius: var(--r-md); padding: 18px; margin: 16px 0; }
.bank-box .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.bank-box .row:last-child { border-bottom: none; }
.bank-box .row .k { color: var(--muted); font-size: 0.88rem; }
.bank-box .row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.copy-btn { cursor: pointer; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 30px; }
.pagination button { min-width: 40px; min-height: 40px; border-radius: var(--r-sm); border: 1px solid var(--border-2); background: var(--surface); color: var(--text); cursor: pointer; }
.pagination button.active { background: var(--grad-cta); color: #1A1206; border-color: transparent; font-weight: 700; }
.pagination button[disabled] { opacity: .4; pointer-events: none; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ico { font-size: 2.2rem; opacity: .6; }
.empty-state p { margin-top: 8px; }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--elevated) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
.skeleton.card { aspect-ratio: 16/9; }
@keyframes shimmer { to { background-position: -200% 0; } }

.alert { padding: 12px 16px; border-radius: var(--r-sm); font-size: 0.9rem; margin-bottom: 16px; }
.alert-error { background: rgba(224,101,90,.12); border: 1px solid rgba(224,101,90,.4); color: #F0A89E; }
.alert-info { background: rgba(231,169,79,.1); border: 1px solid rgba(231,169,79,.3); color: var(--gold-soft); }
.alert-ok { background: rgba(63,185,122,.12); border: 1px solid rgba(63,185,122,.4); color: #8FE0B4; }

.status-pill { display: inline-flex; padding: 3px 12px; border-radius: var(--r-pill); font-size: 0.8rem; font-weight: 600; }
.status-pending { background: rgba(231,169,79,.14); color: var(--gold-soft); }
.status-approved { background: rgba(63,185,122,.14); color: #8FE0B4; }
.status-rejected { background: rgba(224,101,90,.14); color: #F0A89E; }

/* =================================================================  Footer  */
.site-footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 36px 0; background: var(--bg-2); }
.site-footer .container { display: flex; flex-direction: column; gap: 14px; }
.footer-top { border-top: 2px solid; border-image: var(--grad-gold) 1; padding-top: 18px; }
.footer-disclaimer { color: var(--faint); font-size: 0.82rem; line-height: 1.7; }
.footer-disclaimer b { color: var(--wine-soft); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: 0.86rem; }

/* =================================================================  響應式  */
@media (min-width: 640px) {
  .board-grid { grid-template-columns: repeat(2, 1fr); }
  .thread-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .thread-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-inner { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: center; }
}
@media (max-width: 560px) {
  .nav-links { display: none; }
  .nav-links.show { display: flex; position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; background: var(--elevated); border-bottom: 1px solid var(--border); padding: 10px; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton { animation: none; }
}
