/* ============================================================
   base.css — Reset · CSS Variables · 共用排版
   LM.C 20th Anniversary Fan Site
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Cubic+11&family=Noto+Sans+TC:wght@300;400;500;700;900&family=Noto+Sans+JP:wght@300;400;500;700;900&display=swap');

/* ── BoutiqueBitmap9x9（精品點陣圖9×9）— 英文主字體，需自行托管 ── */
/* TODO: 將字型檔放至 fonts/ 資料夾後取消下方註解 */
/*
@font-face {
  font-family: 'BoutiqueBitmap9x9';
  src: url('../fonts/BoutiqueBitmap9x9.woff2') format('woff2'),
       url('../fonts/BoutiqueBitmap9x9.woff')  format('woff');
  font-weight: 400;
  font-style:  normal;
  font-display: swap;
}
@font-face {
  font-family: 'BoutiqueBitmap9x9';
  src: url('../fonts/BoutiqueBitmap9x9-Bold.woff2') format('woff2'),
       url('../fonts/BoutiqueBitmap9x9-Bold.woff')  format('woff');
  font-weight: 700;
  font-style:  normal;
  font-display: swap;
}
*/

/* ── CSS Variables ── */
:root {
  /* ---- Palette ---- */
  --color-bg:           #00072C;
  --color-bg-alt:       #00092e;
  --color-bg-elevated:  #0a1040;
  --color-surface:      #1a1d2e;
  --color-surface-2:    #232640;

  --color-red:          #8b2fff;
  --color-red-dim:      #5a1595;
  --color-red-glow:     rgba(139, 47, 255, 0.35);

  --color-blue:         #00c8ff;
  --color-blue-dim:     #0088b0;
  --color-blue-glow:    rgba(0, 200, 255, 0.30);

  --color-gold:         #ffb800;
  --color-gold-dim:     #a87800;
  --color-gold-glow:    rgba(255, 184, 0, 0.30);

  --color-text:         #f0f0f0;
  --color-text-sub:     #a0a4b8;
  --color-text-muted:   #555978;
  --color-border:       rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.18);

  /* ---- Design Tokens (from Mode 1.tokens.json) ---- */

  /* Text */
  --token-text-primary:  #222222;
  --token-text-secondary: #5C5166;
  --token-text-third:    #888888;
  --token-text-white:    #FFFFFF;
  --token-text-active:   #D93C89;

  /* Input */
  --token-input-red:     #D74149;
  --token-input-bg:      #FFFFFF;

  /* LMC Components */
  --token-lmc-title:          #222222;
  --token-lmc-stroke-default: #C1C1C1;
  --token-lmc-stroke-focus:   #9A9A9A;
  --token-lmc-bg:             #FFFFFF;
  --token-lmc-icon:           #5C5166;
  --token-lmc-card-top:       #F4B4E6;

  /* Stroke */
  --token-stroke-main:  #5C5166;
  --token-stroke-dark:  #C1C1C1;

  /* Background */
  --token-bg-main:        #00072C;
  --token-bg-message:     #BDB3FB;
  --token-bg-title:       #F4B4E6;
  --token-bg-title-line:  #D77EB9;
  --token-bg-white:       #FFFFFF;
  --token-bg-modal:       #FFFBF0;

  /* Button */
  --token-btn-primary:   #4836AB;
  --token-btn-secondary: #FFFFFF;
  --token-btn-third:     #D77EB9;

  /* Boys Theme */
  --token-boys-title:          #089F83;
  --token-boys-stroke-default: #A6C0C6;
  --token-boys-stroke-focus:   #859A9E;
  --token-boys-bg:             #F2FCFE;
  --token-boys-icon:           #446D65;
  --token-boys-card-top:       #37E2C2;

  /* Girls Theme */
  --token-girls-title:          #B14C49;
  --token-girls-stroke-default: #CFC5AA;
  --token-girls-stroke-focus:   #A69E88;
  --token-girls-bg:             #FFFBF0;
  --token-girls-icon:           #5F463C;
  --token-girls-card-top:       #FE9D9B;

  /* Ghost Theme */
  --token-ghost-title:          #FB935A;
  --token-ghost-stroke-default: #E8BAC2;
  --token-ghost-stroke-focus:   #BA959B;
  --token-ghost-bg:             #28101E;
  --token-ghost-icon:           #E8BAC2;
  --token-ghost-card-top:       #EE722E;

  /* Zombie Theme */
  --token-zombie-title:          #C0E12C;
  --token-zombie-stroke-default: #D4CAFE;
  --token-zombie-stroke-focus:   #AAA2CB;
  --token-zombie-bg:             #52276F;
  --token-zombie-icon:           #D4CAFE;
  --token-zombie-card-top:       #ADCD21;

  /* ViewToggle */
  --token-view-toggle-default: #C1B6FB;
  --token-view-toggle-active:  #4836AB;

  /* ---- Typography ---- */
  /* 主字體：Cubic 11（剛方體11號）日/中文，BoutiqueBitmap9x9（精品點陣圖9×9）英文 */
  --font-zh: 'Cubic 11', 'Noto Sans TC', sans-serif;
  --font-jp: 'Cubic 11', 'Noto Sans JP', sans-serif;
  --font-en: 'BoutiqueBitmap9x9', 'Cubic 11', monospace;

  /* System UI — 輸入欄位 / 留言板卡片（Figma 指定依系統平台顯示） */
  --font-system-jp: 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  --font-system-zh: 'PingFang TC',   'Noto Sans TC', system-ui, sans-serif;
  --font-system-en: 'SF Pro Text',   system-ui, sans-serif;
  --font-ui:        system-ui, -apple-system, sans-serif;

  /* Figma type scale: 9 / 12 / 14 / 16 / 17px */
  --fs-xs:   0.5625rem; /* 9px  — XSmall label */
  --fs-sm:   0.75rem;   /* 12px — Small label   */
  --fs-base: 0.875rem;  /* 14px — Secondary body */
  --fs-md:   1rem;      /* 16px — Standard body  */
  --fs-lg:   1.0625rem; /* 17px — Primary body (Cubic 11 main) */
  --fs-xl:   1.375rem;  /* 22px */
  --fs-2xl:  1.75rem;   /* 28px */
  --fs-3xl:  2.25rem;   /* 36px */
  --fs-4xl:  3rem;      /* 48px */
  --fs-5xl:  4rem;      /* 64px */

  --fw-light:   300;
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-bold:    700;
  --fw-black:   900;

  /* Figma line heights */
  --lh-tight:   1.176; /* 20/17 — primary body  */
  --lh-snug:    1.25;  /* 20/16 — standard body */
  --lh-normal:  1.5;   /* 24/16 or 21/14        */
  --lh-relaxed: 1.8;

  --ls-tight:   -0.03em;
  --ls-normal:  0;
  --ls-wide:    0.08em;
  --ls-wider:   0.16em;
  --ls-widest:  0.25em;

  /* ---- Spacing ---- */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;

  /* ---- Layout ---- */
  --max-width:     640px;
  --header-height: 56px;
  --z-base:        1;
  --z-header:      100;
  --z-modal:       200;
  --z-overlay:     300;
  --z-loading:     400;

  /* ---- Radius ---- */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* ---- Shadows ---- */
  --shadow-sm:   0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-red:  0 0 20px var(--color-red-glow), 0 0 60px var(--color-red-glow);
  --shadow-blue: 0 0 20px var(--color-blue-glow), 0 0 60px var(--color-blue-glow);
  --shadow-gold: 0 0 20px var(--color-gold-glow), 0 0 60px var(--color-gold-glow);

  /* ---- Transitions ---- */
  --ease-out:   cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-in:    cubic-bezier(0.55, 0.06, 0.68, 0.19);
  --ease-inout: cubic-bezier(0.46, 0.03, 0.52, 0.96);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --dur-fast:   150ms;
  --dur-base:   300ms;
  --dur-slow:   600ms;
  --dur-slower: 900ms;
}

/* ── 語言切換：設定 body data-lang ── */
:lang(zh), [data-lang='zh'] {
  --font-active:        var(--font-zh);
  --font-active-system: var(--font-system-zh);
}
:lang(ja), [data-lang='ja'] {
  --font-active:        var(--font-jp);
  --font-active-system: var(--font-system-jp);
}
[data-lang='en'] {
  --font-active:        var(--font-en);
  --font-active-system: var(--font-system-en);
}

/* ── Modern CSS Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 讓 GSAP ScrollTrigger 正常運作 */
  overflow-x: hidden;
}

body {
  font-family: var(--font-zh);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Language-aware font switching */
body[data-lang='zh'] {
  font-family: var(--font-zh);
}
body[data-lang='ja'] {
  font-family: var(--font-jp);
}
body[data-lang='en'] {
  font-family: var(--font-en);
}

/* System UI：輸入欄 / 留言板卡片 依語言切換 */
body[data-lang='zh'] .font-system,
body[data-lang='zh'] input,
body[data-lang='zh'] textarea {
  font-family: var(--font-system-zh);
}
body[data-lang='ja'] .font-system,
body[data-lang='ja'] input,
body[data-lang='ja'] textarea {
  font-family: var(--font-system-jp);
}
body[data-lang='en'] .font-system,
body[data-lang='en'] input,
body[data-lang='en'] textarea {
  font-family: var(--font-system-en);
}

img, video, canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* ── Layout Wrapper ── */
.app-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  /* 左右陰影給桌機視覺分隔 */
  box-shadow:
    -1px 0 0 rgba(255, 255, 255, 0.04),
     1px 0 0 rgba(255, 255, 255, 0.04),
    -20px 0 60px rgba(0, 0, 0, 0.6),
     20px 0 60px rgba(0, 0, 0, 0.6);
}

/* 桌機時顯示側邊裝飾 */
@media (min-width: 641px) {
  body {
    background-color: #04040a;
  }
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
      radial-gradient(ellipse 50% 100% at 20% 50%, rgba(139, 47, 255, 0.04) 0%, transparent 70%),
      radial-gradient(ellipse 50% 100% at 80% 50%, rgba(0, 200, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }
  .app-wrapper {
    position: relative;
    z-index: 1;
  }
}

/* ── i18n 多語言顯示控制 ── */
[data-lang-zh],
[data-lang-ja],
[data-lang-en] {
  display: none;
}

body[data-lang='zh'] [data-lang-zh] { display: revert; }
body[data-lang='ja'] [data-lang-ja] { display: revert; }
body[data-lang='en'] [data-lang-en] { display: revert; }

/* 用 data-i18n 屬性的元素，JS 會替換 textContent */
[data-i18n] { }

/* ── 共用 UI 元素 ── */

/* Pill 標籤 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.pill--red   { background: var(--color-red-dim);  color: #c890ff; border: 1px solid var(--color-red); }
.pill--blue  { background: var(--color-blue-dim);  color: #60e0ff; border: 1px solid var(--color-blue); }
.pill--gold  { background: var(--color-gold-dim);  color: #ffd050; border: 1px solid var(--color-gold); }
.pill--ghost { background: transparent; color: var(--color-text-sub); border: 1px solid var(--color-border-hover); }

/* ── 按鈕（像素風格） ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border: 1px solid var(--token-stroke-main);
  border-radius: var(--r-md);
  font-family: var(--font-en);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  cursor: pointer;
  text-decoration: none;
  overflow: visible;
  transition:
    background var(--dur-fast) var(--ease-out),
    color       var(--dur-fast) var(--ease-out),
    transform   var(--dur-fast) var(--ease-out);
}

.btn:active { transform: scale(0.97); }

/* ── 四角像素裝飾點 ── */
.btn::before,
.btn::after {
  content: '';
  position: absolute;
  left: -3px;
  right: -3px;
  height: 3px;
  background:
    var(--token-stroke-main) 0 0       / 3px 3px no-repeat,
    var(--token-stroke-main) 100% 0    / 3px 3px no-repeat;
  pointer-events: none;
}
.btn::before { top:    -3px; }
.btn::after  { bottom: -3px; }

/* Primary — 紫色底 */
.btn--primary {
  background: var(--token-btn-primary);
  color: var(--token-text-white);
}
.btn--primary:hover { background: #5844c5; }
.btn--primary::before,
.btn--primary::after {
  background:
    var(--token-stroke-main) 0 0    / 3px 3px no-repeat,
    var(--token-stroke-main) 100% 0 / 3px 3px no-repeat;
}

/* Secondary / Outline — 白色底 */
.btn--secondary,
.btn--outline {
  background: var(--token-btn-secondary);
  color: var(--token-stroke-main);
}
.btn--secondary:hover,
.btn--outline:hover { background: #f5f3fc; }

/* Ghost — 用於深色背景上的透明按鈕 */
.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-sub);
  border-color: var(--color-border);
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.10);
  color: var(--color-text);
}
.btn--ghost::before,
.btn--ghost::after {
  background:
    var(--color-border) 0 0    / 3px 3px no-repeat,
    var(--color-border) 100% 0 / 3px 3px no-repeat;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-6) 0;
}

/* 共用 section padding */
.section {
  padding: var(--sp-16) var(--sp-6);
}
.section--tight {
  padding: var(--sp-10) var(--sp-6);
}

/* Section heading */
.section-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-red);
  margin-bottom: var(--sp-3);
}
.section-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--color-text);
}

/* ── Overlay (共用 Modal 底層) ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal 底部滑出容器 ── */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--max-width);
  background: var(--color-bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--color-border-hover);
  z-index: calc(var(--z-modal) + 1);
  transition: transform var(--dur-slow) var(--ease-out);
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.bottom-sheet.is-open {
  transform: translateX(-50%) translateY(0);
}
.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  background: var(--color-border-hover);
  border-radius: var(--r-full);
  margin: var(--sp-3) auto var(--sp-6);
}
.bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6) var(--sp-4);
}
.bottom-sheet__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}
.bottom-sheet__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-sub);
  font-size: var(--fs-lg);
  transition: background var(--dur-fast) var(--ease-out);
}
.bottom-sheet__close:hover { background: rgba(255, 255, 255, 0.12); }
.bottom-sheet__body {
  padding: 0 var(--sp-6) var(--sp-10);
}

/* ── Placeholder 佔位色塊 ── */
/* TODO: replace with actual asset */
.placeholder-img {
  background: var(--color-surface);
  position: relative;
  overflow: hidden;
}
.placeholder-img::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ── 自訂捲軸（支援 WebKit） ── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--color-surface-2);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-red-dim);
}

/* ── Focus styles ── */
:focus-visible {
  outline: 2px solid var(--color-red);
  outline-offset: 2px;
}

/* ── Utility ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.no-scroll { overflow: hidden !important; }
.text-center { text-align: center; }
.text-red    { color: var(--color-red); }
.text-blue   { color: var(--color-blue); }
.text-gold   { color: var(--color-gold); }
.text-muted  { color: var(--color-text-sub); }

/* Glow text utility */
.glow-red  { text-shadow: 0 0 16px var(--color-red-glow),  0 0 40px var(--color-red-glow); }
.glow-blue { text-shadow: 0 0 16px var(--color-blue-glow), 0 0 40px var(--color-blue-glow); }
.glow-gold { text-shadow: 0 0 16px var(--color-gold-glow), 0 0 40px var(--color-gold-glow); }
