/* ============================================================
   Seoul K-Screen Map — Design System
   Cinematic dark UI. Metro-native mental model.
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
/* `[hidden]` ships in the UA sheet, so ANY class rule setting `display` beats it.
   Promote it once here instead of patching each component. */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Tokens ---------- */
:root {
  /* Surfaces — near-black, slightly warm (film stock, not blue-tech) */
  --bg:          #0a0a0c;
  --bg-1:        #101014;
  --bg-2:        #16161c;
  --bg-3:        #1e1e26;
  --line:        #26262f;
  --line-soft:   #1c1c23;

  /* Text */
  --fg:          #f4f3f0;
  --fg-1:        #b8b6b0;
  --fg-2:        #7c7a75;
  --fg-3:        #4e4d4a;

  /* Accent — projector amber. Warm, filmic, distinct from every metro line. */
  --accent:      #ffb340;
  --accent-hi:   #ffc76b;
  --accent-lo:   #b87a1e;
  --accent-glow: rgba(255, 179, 64, .22);

  --ok:          #4ade80;
  --danger:      #ff6b6b;

  /* Seoul Metro line colors — factual wayfinding, aids recognition */
  --l1: #0052a4;  --l2: #00a84d;  --l3: #ef7c1c;  --l4: #00a5de;
  --l5: #996cac;  --l6: #cd7c2f;  --l7: #747f00;  --l8: #e6186c;
  --l9: #bdb092;  --gyeongui: #77c4a3;  --airport: #0090d2;  --sinbundang: #d4003b;

  /* Type */
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
          'Segoe UI', system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;

  /* Space / radius / motion */
  --r-sm: 8px; --r: 14px; --r-lg: 20px; --r-xl: 28px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --dur: .38s;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px -6px rgba(0,0,0,.6);
  --shadow-3: 0 24px 60px -12px rgba(0,0,0,.75);

  --header-h: 60px;
}

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

/* ---------- Base ---------- */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  letter-spacing: -0.011em;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Film grain — the single texture that sells "cinema" without imagery */
body::after {
  content: '';
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 9999;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(10) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0) }      10% { transform: translate(-2%,-3%) }
  20% { transform: translate(-4%,2%) }        30% { transform: translate(2%,-4%) }
  40% { transform: translate(-1%,3%) }        50% { transform: translate(-3%,1%) }
  60% { transform: translate(3%,0) }          70% { transform: translate(0,2%) }
  80% { transform: translate(1%,-1%) }        90% { transform: translate(-2%,2%) }
}

/* ---------- Type scale ---------- */
.h-display {
  font-size: clamp(2.4rem, 7vw, 5.2rem);
  line-height: .98;
  letter-spacing: -0.045em;
  font-weight: 800;
}
.h1 { font-size: clamp(1.7rem, 3.6vw, 2.6rem); line-height: 1.1; letter-spacing: -.032em; font-weight: 750; }
.h2 { font-size: clamp(1.25rem, 2.2vw, 1.6rem); line-height: 1.2; letter-spacing: -.024em; font-weight: 700; }
.h3 { font-size: 1.0625rem; line-height: 1.3; letter-spacing: -.016em; font-weight: 650; }
.body { font-size: .9375rem; color: var(--fg-1); }
.small { font-size: .8125rem; color: var(--fg-2); }
.micro {
  font-size: .6875rem; letter-spacing: .09em; text-transform: uppercase;
  font-weight: 650; color: var(--fg-2); font-feature-settings: 'tnum';
}
.mono { font-family: var(--mono); font-size: .8125rem; letter-spacing: -.02em; }

/* ---------- Layout ---------- */
.wrap { width: min(1240px, 100% - 2.5rem); margin-inline: auto; }
@media (max-width: 640px) { .wrap { width: min(1240px, 100% - 1.75rem); } }

/* ---------- Header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line-soft);
}
/* No `width:100%` here — it would beat `.wrap`'s own width rule (same
   specificity, declared later) and push the header flush to the screen edge. */
.hdr__in { display: flex; align-items: center; gap: 1.25rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 750; letter-spacing: -.03em; font-size: .975rem; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--accent-hi), var(--accent-lo));
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,.09) inset, 0 2px 10px var(--accent-glow);
}
.brand__mark svg { width: 15px; height: 15px; }
.hdr__spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 40px; padding: 0 1.05rem;
  border-radius: 10px;
  font-size: .875rem; font-weight: 650; letter-spacing: -.012em;
  white-space: nowrap;
  transition: transform .16s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #241701;
  font-weight: 720;
  box-shadow: 0 1px 0 rgba(255,255,255,.28) inset, 0 4px 16px -4px var(--accent-glow);
}
.btn--primary:hover { filter: brightness(1.07); box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 6px 22px -4px var(--accent-glow); }

.btn--ghost { background: var(--bg-2); color: var(--fg); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--bg-3); border-color: #33333f; }

.btn--quiet { color: var(--fg-1); padding-inline: .6rem; }
.btn--quiet:hover { color: var(--fg); background: var(--bg-2); }

.btn--lg { height: 50px; padding: 0 1.6rem; font-size: .9375rem; border-radius: 12px; }
.btn--block { display: flex; width: 100%; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(1.5rem, 4vw, 3rem); }
.hero::before {
  content: ''; position: absolute; z-index: -1;
  top: -20%; left: 50%; transform: translateX(-50%);
  width: min(900px, 120vw); aspect-ratio: 1;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 62%);
  opacity: .5; pointer-events: none;
}
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .34rem .75rem .34rem .5rem;
  border: 1px solid var(--line); border-radius: 100px;
  background: var(--bg-1);
  margin-bottom: 1.4rem;
}
.hero__eyebrow b { color: var(--accent); font-weight: 700; }
.hero h1 { max-width: 17ch; margin-bottom: 1.25rem; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero__sub { max-width: 52ch; font-size: clamp(.975rem, 1.6vw, 1.125rem); color: var(--fg-1); margin-bottom: 2rem; }
.hero__cta { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: pulse 2.4s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* ---------- Metro map ---------- */
.mapstage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(255,179,64,.05), transparent 70%),
    var(--bg-1);
  overflow: hidden;
  box-shadow: var(--shadow-3);
}
.mapstage__bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-2) 60%, transparent);
}
.mapstage__body { position: relative; aspect-ratio: 16 / 11; min-height: 380px; }
@media (max-width: 720px) { .mapstage__body { aspect-ratio: 3 / 4; min-height: 460px; } }
#metro { width: 100%; height: 100%; touch-action: none; cursor: grab; }
#metro.is-panning { cursor: grabbing; }

/* map primitives */
.mline { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 5.5; opacity: .78; }
.mline--dim { opacity: .16; transition: opacity var(--dur) var(--ease); }

.mstation { cursor: pointer; }
.mstation circle.hit { fill: transparent; }
.mstation circle.dot {
  fill: var(--bg); stroke: var(--fg-2); stroke-width: 2.4;
  transition: fill .22s var(--ease), stroke .22s var(--ease), r .22s var(--ease);
}
.mstation text {
  fill: var(--fg-2); font-size: 9px; font-weight: 620; letter-spacing: -.02em;
  pointer-events: none; transition: fill .22s var(--ease);
  paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; stroke-linejoin: round;
}
.mstation:hover circle.dot { stroke: var(--accent); r: 7; }
.mstation:hover text { fill: var(--fg); }

/* stations that actually have filming locations */
.mstation.has circle.dot { fill: var(--accent); stroke: var(--accent-hi); }
.mstation.has text { fill: var(--fg-1); font-weight: 680; }
.mstation.has .halo {
  fill: var(--accent); opacity: .18;
  animation: halo 3.2s var(--ease-io) infinite;
  transform-box: fill-box; transform-origin: center;
}
@keyframes halo {
  0%, 100% { transform: scale(1); opacity: .18; }
  50%      { transform: scale(1.9); opacity: 0; }
}
.mstation.is-active circle.dot { fill: var(--accent-hi); stroke: #fff; r: 8; }
.mstation.is-active text { fill: var(--fg); }
.mstation.is-muted { opacity: .2; }

.mapstage__hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  padding: .4rem .8rem; border-radius: 100px;
  background: color-mix(in srgb, var(--bg-3) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  pointer-events: none;
  transition: opacity .3s;
}
.mapstage__zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoombtn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg-3) 88%, transparent);
  border: 1px solid var(--line); color: var(--fg-1);
  backdrop-filter: blur(8px);
  transition: background .2s, color .2s;
}
.zoombtn:hover { background: var(--bg-3); color: var(--fg); }

/* ---------- Line legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: .4rem; }
.legend__i {
  display: inline-flex; align-items: center; gap: .38rem;
  padding: .2rem .55rem .2rem .3rem;
  border-radius: 100px; border: 1px solid var(--line);
  font-size: .6875rem; font-weight: 650; color: var(--fg-2);
  transition: border-color .2s, color .2s, background .2s;
}
.legend__i:hover, .legend__i[aria-pressed="true"] { color: var(--fg); background: var(--bg-2); border-color: #33333f; }
.legend__sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- Sheet (station detail) ---------- */
.sheet {
  position: fixed; z-index: 200; inset: auto 0 0 auto;
  width: min(440px, 100%); height: 100dvh;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
  will-change: transform;
}
.sheet.is-open { transform: none; }

@media (max-width: 640px) {
  .sheet {
    inset: auto 0 0 0; width: 100%; height: min(82dvh, 100dvh);
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
}
.sheet__grip { display: none; }
@media (max-width: 640px) {
  .sheet__grip { display: block; width: 38px; height: 4px; border-radius: 99px; background: var(--line); margin: .6rem auto .2rem; flex: none; }
}
.sheet__hd {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: 1.1rem 1.15rem .9rem;
  border-bottom: 1px solid var(--line-soft); flex: none;
}
.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: .9rem 1.15rem 1.5rem; }
.sheet__body::-webkit-scrollbar { width: 8px; }
.sheet__body::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 99px; border: 2px solid var(--bg-1); }

.scrim {
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ---------- Station badge ---------- */
.stn-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 .4rem; flex: none;
  border-radius: 100px; font-size: .8125rem; font-weight: 750; color: #fff;
  font-feature-settings: 'tnum';
  box-shadow: 0 0 0 2px rgba(255,255,255,.14) inset;
}

/* ---------- Location card ---------- */
.loc {
  position: relative;
  border: 1px solid var(--line-soft); border-radius: var(--r);
  background: var(--bg-2);
  padding: .9rem .95rem;
  margin-bottom: .65rem;
  transition: border-color .2s, background .2s, transform .16s var(--ease);
}
.loc:hover { border-color: var(--line); background: var(--bg-3); }
.loc__top { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .5rem; }
.loc__poster {
  width: 40px; height: 54px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 1.35rem;
  background: linear-gradient(150deg, var(--bg-3), var(--bg-1));
  border: 1px solid var(--line);
}
.loc__title { font-weight: 690; font-size: .9375rem; letter-spacing: -.018em; }
.loc__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .18rem; }
.loc__scene {
  font-size: .8125rem; color: var(--fg-1); line-height: 1.5;
  padding: .55rem .65rem; border-radius: 9px;
  background: var(--bg-1); border-left: 2px solid var(--accent-lo);
  margin-bottom: .6rem;
}
.loc__foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: .28rem;
  padding: .16rem .48rem; border-radius: 6px;
  font-size: .6875rem; font-weight: 620;
  background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line-soft);
}
.tag--year { font-family: var(--mono); font-feature-settings: 'tnum'; }
.tag--verified { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); }
.tag--approx  { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); background: color-mix(in srgb, var(--accent) 9%, transparent); }

.walk { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--fg-2); font-weight: 600; }

.maplink {
  display: inline-flex; align-items: center; gap: .32rem;
  font-size: .75rem; font-weight: 650; color: var(--accent);
  padding: .28rem .5rem; border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  transition: background .2s;
}
.maplink:hover { background: color-mix(in srgb, var(--accent) 11%, transparent); }

/* ---------- Empty / skeleton ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--fg-2); }
.empty__icon { font-size: 2rem; opacity: .35; margin-bottom: .6rem; }

.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shim 1.4s infinite; border-radius: 8px; }
@keyframes shim { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

/* ---------- Paywall / route builder ---------- */
.paywall {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--r-lg);
  background:
    radial-gradient(600px 200px at 50% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%),
    var(--bg-1);
  padding: 1.4rem 1.25rem;
  overflow: hidden;
}
.paywall__price { display: flex; align-items: baseline; gap: .4rem; margin: .6rem 0 1rem; }
.paywall__price b { font-size: 2.4rem; font-weight: 780; letter-spacing: -.04em; line-height: 1; }
.paywall ul { list-style: none; display: grid; gap: .45rem; margin-bottom: 1.15rem; }
.paywall li { display: flex; gap: .5rem; font-size: .875rem; color: var(--fg-1); }
.paywall li svg { flex: none; margin-top: .28rem; color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 400;
  transform: translate(-50%, 120%);
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  box-shadow: var(--shadow-3); font-size: .875rem; font-weight: 600;
  transition: transform .4s var(--ease);
  max-width: calc(100% - 2rem);
}
.toast.is-open { transform: translate(-50%, 0); }
.toast--err { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- Footer ---------- */
.ftr { border-top: 1px solid var(--line-soft); margin-top: 4rem; padding: 2rem 0 3rem; }
.ftr__in { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }
.ftr a { color: var(--fg-2); text-decoration: none; font-size: .8125rem; }
.ftr a:hover { color: var(--fg-1); }

/* ---------- Utility ---------- */
.stack   { display: grid; gap: .5rem; }
.row     { display: flex; align-items: center; gap: .5rem; }
.hidden  { display: none !important; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
