/* ═══════════════════════════════════════════════════════════════
   오리즌 (Aurizon) — styles.css
   DESIGN.md frontmatter 1:1 미러. 색 이원화 규율:
   라즈베리(--accent) = firefly 히어로 + UI '인지 램프'(재생·블룸·공유·활성스텝·포커스·선택)만.
   정원 주조색 = --secondary(초록/시안), 식물 5종 = --plant-*(garden.js 소유).
   base :root = LIGHT '초원(Meadow)', 웜 페이퍼(no-JS 폴백)
   [data-theme="dark"] = '생물발광(Bioluminescent)', 심해 인디고.
   ═══════════════════════════════════════════════════════════════ */

/* ── 구조 토큰(공유 — 색/장식만 모드별) ───────────────────────── */
:root {
  --font-heading: 'Cabinet Grotesk', 'Pretendard', system-ui, sans-serif;
  --font-body: 'Geist', 'Pretendard', system-ui, 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', monospace;

  --fs-display: clamp(30px, 5vw, 46px); --lh-display: 1.05; --fw-display: 700;
  --fs-h1: 20px; --lh-h1: 1.2; --fw-h1: 700;
  --fs-h2: 13px; --lh-h2: 1.3; --fw-h2: 600;
  --fs-body: 14px; --lh-body: 1.62;
  --fs-micro: 11.5px; --lh-micro: 1.35;

  --sp-xs: 6px; --sp-sm: 10px; --sp-md: 16px; --sp-lg: 24px; --sp-xl: 40px;
  --r-base: 18px; --r-sm: 12px; --r-chip: 999px; --r-pill: 999px;

  --t-bloom: 560ms; --t-base: 220ms; --t-fast: 130ms;
  --t-sway: 1.9s; --t-pulse: 180ms;
  --ease-grow: cubic-bezier(.22, .68, .28, 1);
  --ease-settle: cubic-bezier(.4, .9, .3, 1);
  --ease-sway: cubic-bezier(.45, .05, .55, .95);

  --tray-w: 300px;
  --seed-chip: 60px;
  --transport-h: 64px;
  --thumb-w: 84px;
  --png-scale: 3;
}

/* ── LIGHT (base, native — '초원(Meadow)', 햇빛 아래 갓 깨어난 화단) ── */
:root,
:root[data-theme="light"] {
  --bg: #f4efe4; --surface: #fbf7ee; --surface-2: #ece4d3;
  --ink: #26201a; --muted: #6b6152; --faint: #a3977f;
  --line: #e0d6c2; --line-strong: #cbbca0;
  --accent: #b23a5b; --accent-deep: #8f2c48;
  --accent-soft: rgba(178, 58, 91, .12); --accent-glow: rgba(178, 58, 91, .28);
  --accent-ink: #fffaf3;
  --secondary: #4f9d54; --secondary-deep: #3c7d40;
  --accent-2: #d99a2e;
  --plant-roots: #5f6b34; --plant-vines: #4f9d54; --plant-blooms: #e6a5b4;
  --plant-stones: #9c9282; --plant-firefly: #b23a5b;
  --soil: #d8cbb0; --furrow: #e6ddca;
  --warn: #a8641a; --danger: #b03b2e;

  --grad-bg-glow: radial-gradient(1200px 720px at 80% -12%, var(--accent-soft) 0%, transparent 60%), radial-gradient(900px 640px at 12% 116%, rgba(79, 157, 84, .10), transparent 62%);
  --grad-accent: linear-gradient(150deg, var(--accent), var(--accent-deep));
  --grad-bloom-halo: radial-gradient(circle at 50% 50%, var(--accent-glow) 0%, transparent 70%);
  --grad-paper: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="140" height="140"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2"/></filter><rect width="140" height="140" filter="url(%23n)" opacity="0.035"/></svg>');

  --shadow-card: 0 1px 0 var(--line);
  --shadow-lift: 0 12px 34px -20px rgba(20, 30, 26, .42);
  --shadow-focus: 0 0 0 3px var(--accent-soft);
  --shadow-bloom: 0 0 0 2px var(--accent), 0 0 26px 2px var(--accent-glow);
  --shadow-step: 0 0 14px 1px var(--accent-glow);

  color-scheme: light;
}

/* ── DARK ('생물발광(Bioluminescent)', 밤에 스스로 빛나는 같은 정원) ── */
:root[data-theme="dark"] {
  --bg: #0a1418; --surface: #0f2027; --surface-2: #070f13;
  --ink: #dfeee9; --muted: #8fa6a0; --faint: #5c716c;
  --line: rgba(120, 220, 210, .12); --line-strong: rgba(120, 220, 210, .20);
  --accent: #ff5f8d; --accent-deep: #d8436e;
  --accent-soft: rgba(255, 95, 141, .16); --accent-glow: rgba(255, 95, 141, .42);
  --accent-ink: #180810;
  --secondary: #2fd6c0; --secondary-deep: #1f9f92;
  --accent-2: #c6f24a;
  --plant-roots: #1f7a6e; --plant-vines: #2fd6c0; --plant-blooms: #b96ad8;
  --plant-stones: #5f7a7e; --plant-firefly: #ff5f8d;
  --soil: #0d2a30; --furrow: #112f36;
  --warn: #d99441; --danger: #e2795f;

  --grad-bg-glow: radial-gradient(1200px 720px at 80% -12%, var(--accent-soft) 0%, transparent 60%), radial-gradient(900px 640px at 12% 116%, rgba(47, 214, 192, .10), transparent 62%);
  --grad-accent: linear-gradient(150deg, var(--accent), var(--accent-deep));
  --grad-bloom-halo: radial-gradient(circle at 50% 50%, var(--accent-glow) 0%, transparent 70%);
  --grad-paper: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="140" height="140"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="2"/></filter><rect width="140" height="140" filter="url(%23n)" opacity="0.05"/></svg>');

  --shadow-card: 0 1px 0 var(--line);
  --shadow-lift: 0 14px 34px -18px rgba(0, 0, 0, .55);
  --shadow-focus: 0 0 0 3px var(--accent-soft);
  --shadow-bloom: 0 0 0 2px var(--accent), 0 0 26px 2px var(--accent-glow);
  --shadow-step: 0 0 14px 1px var(--accent-glow);

  color-scheme: dark;
}

/* ── 스위처 브릿지 (실제 변수명만 — 양 테마 오버라이드) ─────────── */
:root .i18n-switch, :root .theme-switch {
  --i18n-switch-bg: var(--surface); --i18n-switch-border: var(--line); --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft); --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--surface); --i18n-switch-menu-border: var(--line);
  --i18n-switch-shadow: 0 14px 34px -10px rgba(10, 20, 16, .34);
  --theme-switch-bg: var(--surface); --theme-switch-border: var(--line); --theme-switch-fg: var(--muted);
  --theme-switch-active-bg: var(--accent); --theme-switch-active-fg: var(--accent-ink); --theme-switch-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   Reset / base
   ═══════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
.font-heading { font-family: var(--font-heading); font-weight: 700; letter-spacing: -0.01em; }
.font-mono { font-family: var(--font-mono); }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--r-sm); }

/* ═══════════════════════════════════════════════════════════════
   Shell — 화단이 뷰포트를 지배
   ═══════════════════════════════════════════════════════════════ */
.site {
  position: fixed; inset: 0;
  background:
    var(--grad-bg-glow),
    var(--grad-paper),
    var(--bg);
  background-blend-mode: normal;
}
.stage { position: absolute; inset: 0; }
.garden {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ── 헤더 (얇게, 상단) ─────────────────────────────────────────── */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  z-index: 6;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: var(--sp-sm); }
.brand-mark {
  display: inline-flex; color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--font-heading); font-weight: 700; font-size: var(--fs-h1); color: var(--ink); }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: 0.02em; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-sm); }

/* ── 시드 배지 (좌하단) ────────────────────────────────────────── */
.seed-badge {
  position: absolute; left: var(--sp-md);
  bottom: calc(var(--transport-h) + env(safe-area-inset-bottom) + var(--sp-md));
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-sm) var(--sp-md);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  z-index: 5;
  pointer-events: none;
}
.seed-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--faint); }
.seed-name { font-family: var(--font-heading); font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.1; }
.seed-num { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); }
.seed-streak { font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   팔레트 트레이 (데스크톱 우측 플로팅 / 모바일 하단 시트)
   ═══════════════════════════════════════════════════════════════ */
.tray {
  position: absolute; top: 56px; right: var(--sp-md);
  width: var(--tray-w); max-height: calc(100% - 56px - var(--transport-h) - var(--sp-lg));
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-base);
  box-shadow: var(--shadow-card), var(--shadow-lift);
  backdrop-filter: blur(14px) saturate(1.1);
  z-index: 7;
  overflow: hidden;
}
.tray-handle { display: none; }
.tray-body { display: flex; flex-direction: column; overflow: hidden; }
.tray-scroll { padding: var(--sp-md); overflow-y: auto; }
.tray-heading {
  font-family: var(--font-heading); font-weight: 700;
  font-size: var(--fs-h2); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: var(--sp-sm);
  display: flex; align-items: center; gap: 6px;
}
.tray-heading::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--secondary);
}

/* ── 씨앗 칩 5종 ───────────────────────────────────────────────── */
.seeds { display: flex; flex-direction: column; gap: var(--sp-sm); }
.seed-chip {
  display: flex; align-items: center; gap: var(--sp-md);
  padding: 8px var(--sp-sm);
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--r-chip);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  text-align: left; width: 100%;
}
.seed-chip:hover { transform: translateX(2px); }
.seed-chip.is-active { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.seed-swatch {
  flex: 0 0 auto;
  width: var(--seed-chip); height: var(--seed-chip);
  border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--line);
}
.seed-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.seed-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.seed-tip { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 갤러리 (압화 표본첩) ──────────────────────────────────────── */
.gallery { margin-top: var(--sp-lg); }
.gallery-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-sm);
}
.gallery-track { display: flex; gap: var(--sp-sm); overflow-x: auto; padding-bottom: 4px; }
.gallery-empty {
  font-size: 11.5px; color: var(--faint);
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: var(--sp-md); text-align: center;
}
.gallery-thumb {
  flex: 0 0 auto; width: var(--thumb-w);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface-2);
  padding: 0; transition: box-shadow var(--t-fast), transform var(--t-fast);
  position: relative;
}
.gallery-thumb:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.gallery-thumb canvas { display: block; width: 100%; height: auto; }
.gallery-thumb-num {
  display: block; font-family: var(--font-mono); font-size: 10px;
  color: var(--muted); padding: 3px 6px; text-align: center;
}
.thumb-remove {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--muted); display: grid; place-items: center;
  font-size: 13px; line-height: 1; border: 1px solid var(--line);
}
.thumb-remove:hover { color: var(--danger); border-color: var(--danger); }
.gallery-count.is-warn { color: var(--warn); }

/* ═══════════════════════════════════════════════════════════════
   트랜스포트 바 (하단)
   ═══════════════════════════════════════════════════════════════ */
.transport {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--sp-md));
  transform: translateX(-50%);
  height: var(--transport-h);
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 0 var(--sp-sm) 0 var(--sp-md);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  box-shadow: var(--shadow-card), var(--shadow-lift);
  backdrop-filter: blur(14px) saturate(1.1);
  z-index: 8;
}
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 44px; padding: 0 var(--sp-md);
  border: 1px solid var(--line); border-radius: var(--r-chip);
  background: var(--surface-2); color: var(--ink);
  font-weight: 600; font-size: 13px;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn svg { flex: 0 0 auto; }
.btn-accent {
  background: var(--grad-accent); color: var(--accent-ink);
  border-color: transparent;
}
.btn-accent:hover { box-shadow: var(--shadow-bloom); }
.btn-play { min-width: 108px; justify-content: center; }
.btn-play.is-playing { box-shadow: var(--shadow-bloom); }
.btn-bloom { }
.btn-ghost { background: transparent; }
.btn-icon {
  height: 44px; width: 44px; padding: 0; justify-content: center;
}
.btn .lbl-play { display: inline; }
.btn.is-playing .lbl-play { display: none; }
.btn .lbl-stop { display: none; }
.btn.is-playing .lbl-stop { display: inline; }

/* ── 스텝 표시자 = firefly 점열 ────────────────────────────────── */
.step-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 0 var(--sp-sm);
}
.step-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint); opacity: .5;
  transition: background var(--t-pulse), opacity var(--t-pulse), box-shadow var(--t-pulse), transform var(--t-pulse);
}
.step-dot.is-active {
  background: var(--accent); opacity: 1;
  box-shadow: var(--shadow-step);
  transform: scale(1.35);
}
@media (max-width: 560px) { .step-indicator { display: none; } }

/* ═══════════════════════════════════════════════════════════════
   온보딩 코치마크 (1회, 비잠금)
   ═══════════════════════════════════════════════════════════════ */
.onboarding {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  pointer-events: none;
  animation: fadeIn var(--t-base) var(--ease-grow);
}
.onboarding[hidden] { display: none; }
.coach {
  pointer-events: auto;
  max-width: 340px; margin: var(--sp-md);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-base);
  box-shadow: var(--shadow-lift);
  backdrop-filter: blur(16px);
  padding: var(--sp-lg);
}
.coach-title { font-size: 17px; margin-bottom: var(--sp-md); color: var(--ink); line-height: 1.25; }
.coach-steps { list-style: none; display: flex; flex-direction: column; gap: var(--sp-sm); margin-bottom: var(--sp-lg); }
.coach-steps li { display: flex; gap: var(--sp-sm); align-items: flex-start; font-size: 13px; color: var(--muted); }
.coach-dot {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.btn-coach {
  width: 100%; height: 44px; border: none; border-radius: var(--r-chip);
  background: var(--grad-accent); color: var(--accent-ink);
  font-weight: 700; font-size: 14px;
  transition: box-shadow var(--t-fast);
}
.btn-coach:hover { box-shadow: var(--shadow-bloom); }

/* ═══════════════════════════════════════════════════════════════
   토스트
   ═══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--transport-h) + env(safe-area-inset-bottom) + var(--sp-lg) + 20px);
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--bg);
  padding: 10px var(--sp-md); border-radius: var(--r-chip);
  font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 2147483001; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-warn { background: var(--warn); color: #fff; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ═══════════════════════════════════════════════════════════════
   반응형 — <900px: 트레이를 하단 시트로
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {
  .tray {
    top: auto; right: 0; left: 0; bottom: 0;
    width: 100%; max-height: 62%;
    border-radius: var(--r-base) var(--r-base) 0 0;
    transform: translateY(calc(100% - 46px));
    transition: transform var(--t-base) var(--ease-settle);
  }
  .tray.open { transform: translateY(0); }
  .tray-handle {
    display: flex; align-items: center; justify-content: center;
    height: 46px; width: 100%; border: none; background: transparent;
    flex: 0 0 auto;
  }
  .tray-grip { width: 44px; height: 5px; border-radius: 999px; background: var(--line-strong); }
  .tray-scroll { max-height: calc(62vh - 46px); }
  .seed-badge {
    bottom: calc(var(--transport-h) + env(safe-area-inset-bottom) + 52px);
  }
  .transport { bottom: calc(env(safe-area-inset-bottom) + 52px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* RTL (ar) */
[dir="rtl"] .seed-chip { text-align: right; }
[dir="rtl"] .seed-chip:hover { transform: translateX(-2px); }
[dir="rtl"] .seed-badge { left: auto; right: var(--sp-md); }
[dir="rtl"] .tray { right: auto; left: var(--sp-md); }
@media (max-width: 899px) { [dir="rtl"] .tray { left: 0; right: 0; } }
