/* 오래된 지금 (The Long Now Clock) — styles.css
 *
 * DESIGN.md frontmatter themes.light/dark 를 1:1 미러.
 *   :root                    = no-JS 폴백(= native LIGHT '웜페이퍼 관측기구')
 *   :root[data-theme="light"] = 웜페이퍼 관측기구 (day observatory)
 *   :root[data-theme="dark"]  = 심야 성도 (midnight star-chart)
 * 캔버스는 이 토큰을 getComputedStyle 로 런타임에 읽는다(하드코딩 색 ❌).
 * --ring-px(96)·--r-now(8) = clock.js RING_PX·R_NOW 동일값(단일 진실).
 * 라즈베리(accent)는 오직 NOW/핀/포커스/CTA 3-신호에만.
 */

/* ── 구조 토큰 (공유 — 색·장식만 모드별) ───────────────────────── */
: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, 4.4vw, 44px);
  --fs-h1: 20px;
  --fs-scale-label: 13px;
  --fs-body: 14px;
  --fs-micro: 11.5px;

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

  /* 로그-스케일 상수 (clock.js 와 동일값 — 단일 진실) */
  --ring-px: 96px;
  --r-now: 8px;
  --now-dot: 10px;
  --pin-head: 12px;
  --readout-w: 300px;

  /* 모션 */
  --drift: 9s; --t-base: 260ms; --t-fast: 150ms; --damp: 0.92;
  --ease: cubic-bezier(.33,.66,.32,1);
  --ease-settle: cubic-bezier(.4,.9,.3,1);
}

/* ── LIGHT — 웜페이퍼 관측기구 (base = no-JS 폴백) ──────────────── */
:root,
:root[data-theme="light"] {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #232019;
  --muted: #7c766b;
  --faint: #a9a294;
  --line: #e6e1d6;
  --line-strong: #d6cfbf;

  --accent: #c02d63;
  --accent-deep: #9c2350;
  --accent-soft: rgba(192,45,99,.10);
  --accent-glow: rgba(192,45,99,.22);
  --accent-ink: #fffafc;

  --tick: #c8c1b2;
  --ring-line: #e0dacd;
  --now-halo: rgba(192,45,99,.07);

  --warn: #a8641a;
  --danger: #b03b2e;

  /* 장식 — 중심 NOW 단일 광원. 극절제(웜페이퍼 위 한 점의 온기). */
  --grad-bg-glow: radial-gradient(440px 440px at 50% 50%, var(--now-halo) 0%, transparent 66%);
  --grad-accent: linear-gradient(150deg, var(--accent), var(--accent-deep));
  --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.03"/></svg>');

  --shadow-card: 0 1px 0 var(--line);
  --shadow-lift: 0 14px 36px -20px rgba(30,24,14,.40);
  --shadow-focus: 0 0 0 3px var(--accent-soft);
  --shadow-pin: 0 0 0 2px var(--accent), 0 0 22px -2px var(--accent-glow);

  /* 스위처 브릿지 */
  --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(20,16,8,.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;

  color-scheme: light;
}

/* ── DARK — 심야 성도 (midnight star-chart) ─────────────────────── */
:root[data-theme="dark"] {
  --bg: #1a1712;
  --surface: #221e18;
  --surface-2: #141109;
  --ink: #f4f0e6;
  --muted: #b6afa1;
  --faint: #7d766a;
  --line: rgba(255,255,255,.10);
  --line-strong: rgba(255,255,255,.16);

  --accent: #e85286;
  --accent-deep: #c93e6e;
  --accent-soft: rgba(232,82,134,.16);
  --accent-glow: rgba(232,82,134,.34);
  --accent-ink: #1a0c11;

  --tick: rgba(244,240,230,.28);
  --ring-line: rgba(255,255,255,.09);
  --now-halo: rgba(232,82,134,.09);

  --warn: #d99441;
  --danger: #e2795f;

  /* 심야 성도 — 중심 NOW에서 새어나오는 단일 광원. 잉크블랙을 덮지 않게 절제. */
  --grad-bg-glow: radial-gradient(420px 420px at 50% 50%, var(--now-halo) 0%, transparent 66%);
  --grad-accent: linear-gradient(150deg, var(--accent), var(--accent-deep));

  --shadow-card: 0 1px 0 var(--line);
  --shadow-lift: 0 14px 36px -20px rgba(0,0,0,.55);
  --shadow-focus: 0 0 0 3px var(--accent-soft);
  --shadow-pin: 0 0 0 2px var(--accent), 0 0 22px -2px var(--accent-glow);

  --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(0,0,0,.5);

  --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;

  color-scheme: dark;
}

/* ── 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);
  color: var(--ink);
  background: var(--bg);
  background-image: var(--grad-paper), var(--grad-bg-glow);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}
.font-heading { font-family: var(--font-heading); }
.font-mono { font-family: var(--font-mono); }

/* ── 스테이지 · 다이얼 캔버스 ──────────────────────────────────── */
.stage { position: fixed; inset: 0; }
.dial {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.dial:active { cursor: grabbing; }
.dial:focus-visible { outline: none; }
.dial:focus-visible + .focus-frame,
.stage:has(.dial:focus-visible) .focus-frame { opacity: 1; }
.focus-frame {
  position: absolute; inset: 6px;
  border-radius: var(--r-base);
  box-shadow: inset 0 0 0 2px var(--accent-soft);
  pointer-events: none; opacity: 0;
  transition: opacity var(--t-fast);
}

/* ── 헤더 ──────────────────────────────────────────────────────── */
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  gap: var(--sp-md);
  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); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-heading);
  font-size: var(--fs-h1); font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-sub { font-size: var(--fs-micro); color: var(--muted); letter-spacing: 0.02em; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-sm); }

/* ── 스케일 배지 (현재 줌 의미어) ──────────────────────────────── */
.scale-badge {
  position: absolute; top: calc(var(--sp-md) + 44px); left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-xs) var(--sp-md);
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  pointer-events: none;
  backdrop-filter: blur(6px);
  max-width: 80vw;
}
.scale-badge-name {
  font-family: var(--font-body); font-size: var(--fs-body); font-weight: 600;
  color: var(--ink); white-space: nowrap;
}
.scale-badge-num {
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted);
}

/* ── 액션군 (핀 · 공유) ────────────────────────────────────────── */
.actions {
  position: absolute; right: var(--sp-lg); bottom: var(--sp-lg);
  display: flex; flex-direction: column; gap: var(--sp-sm);
  align-items: flex-end;
}
.btn {
  font-family: var(--font-body); font-size: var(--fs-body); font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 10px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink);
  transition: transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  backdrop-filter: blur(6px);
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn svg { flex: none; }
.btn-pin {
  background: var(--grad-accent); color: var(--accent-ink);
  border-color: transparent;
}
.btn-pin.pulse { animation: pinPulse 500ms var(--ease); }
@keyframes pinPulse { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 100% { box-shadow: var(--shadow-pin); } }
.btn-share {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.btn-icon { padding: 10px; }

/* ── 도래 배지 (조용한 개수) ───────────────────────────────────── */
.soon-badge {
  position: absolute; left: var(--sp-lg); bottom: var(--sp-lg);
  display: none; align-items: center; gap: var(--sp-xs);
  padding: 8px 14px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--r-pill);
  color: var(--accent); font-size: var(--fs-body); font-weight: 600;
  pointer-events: auto; cursor: pointer;
  min-height: 40px;
}
.soon-badge.show { display: inline-flex; }
.soon-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
@media (prefers-reduced-motion: no-preference) {
  .soon-badge.show .dot { animation: breathe 2.4s ease-in-out infinite; }
}
@keyframes breathe { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

/* ── zoom 힌트 (미세 어포던스, 1회) ────────────────────────────── */
.zoom-hint {
  position: absolute; left: 50%; bottom: calc(var(--sp-lg) + 4px);
  transform: translateX(-50%);
  font-size: var(--fs-micro); color: var(--faint);
  pointer-events: none;
  opacity: 0; transition: opacity 1.4s var(--ease);
  white-space: nowrap; text-align: center;
}
.zoom-hint.show { opacity: 1; }
.zoom-hint.hide { opacity: 0; }

/* ── 팝오버 (핀 드롭/편집/삭제) ────────────────────────────────── */
.popover {
  position: absolute; z-index: 40;
  width: var(--readout-w); max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-base); box-shadow: var(--shadow-lift);
  padding: var(--sp-md);
  display: none;
}
.popover.show { display: block; }
.popover-title {
  font-family: var(--font-body); font-size: var(--fs-body); font-weight: 600;
  color: var(--ink); margin-bottom: 2px;
}
.popover-time {
  font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted);
  margin-bottom: var(--sp-sm); word-break: break-word;
}
.popover-src {
  font-family: var(--font-body); font-size: var(--fs-micro); color: var(--muted);
  margin-top: var(--sp-xs);
}
.popover textarea {
  width: 100%; min-height: 62px; resize: vertical;
  font-family: var(--font-body); font-size: var(--fs-body); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}
.popover textarea::placeholder { color: var(--faint); }
.popover textarea:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.popover-row { display: flex; gap: var(--sp-sm); justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.popover-row .grow { margin-right: auto; }
.btn-sm {
  font-family: var(--font-body); font-size: var(--fs-micro); font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 12px; cursor: pointer; background: var(--surface-2); color: var(--ink);
  min-height: 38px;
}
.btn-sm:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn-sm.primary { background: var(--grad-accent); color: var(--accent-ink); border-color: transparent; }
.btn-sm.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-sm.ghost { background: transparent; }

/* ── 토스트 ────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sp-xl) + 8px);
  transform: translate(-50%, 12px);
  background: var(--ink); color: var(--bg);
  font-size: var(--fs-body); font-weight: 500;
  padding: 10px 18px; border-radius: var(--r-pill);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 60; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-warn { background: var(--warn); color: #fff; }

/* ── 반응형: 모바일 하단 바 ────────────────────────────────────── */
@media (max-width: 900px) {
  .actions { right: 50%; transform: translateX(50%); flex-direction: row; bottom: calc(var(--sp-md) + env(safe-area-inset-bottom)); }
  .soon-badge { left: 50%; transform: translateX(-50%); bottom: calc(var(--sp-md) + 60px + env(safe-area-inset-bottom)); }
  .zoom-hint { bottom: calc(var(--sp-md) + 60px + env(safe-area-inset-bottom)); }
  .scale-badge { top: calc(var(--sp-md) + 48px); }
  .topbar { padding: var(--sp-sm) var(--sp-md); }
}

/* ── 스위처 위젯 (양 테마 가독) ────────────────────────────────── */
.i18n-switch { --i18n-switch-bg: var(--i18n-switch-bg); }

@media (prefers-reduced-motion: reduce) {
  .btn, .toast, .zoom-hint { transition: none; }
  .soon-badge .dot { animation: none; }
}

[dir="rtl"] .actions { right: auto; left: var(--sp-lg); }
[dir="rtl"] .soon-badge { left: auto; right: var(--sp-lg); }
