/* Hallmark · v2.0.0 · app screen · dark market atlas · signature: the map and ranking flash together on a rank reversal */
/* Critique: reserve amber for an active area and an actual change in rank. */
:root {
  color-scheme: dark;
  --ink: #0c1015;
  --panel: #10161d;
  --raised: #151e27;
  --selected: #272218;
  --map-water: #0d141b;
  --edge: #28343e;
  --edge-bright: #3c4b58;
  --text: #edf3f6;
  --muted: #a0b0bb;
  --up: #ff8a84;
  --down: #9ac7ff;
  --focus: #f4cf84;
  --spark: #ffe3ad;
  --spark-hot: #fba840;
  --map-halo: #111923;
  --missing: #29333c;
  --neutral: #485762;
  --up-1: #663e40;
  --up-2: #9b514e;
  --up-3: #c96a5d;
  --down-1: #344b6a;
  --down-2: #40648a;
  --down-3: #5080ac;
  --volume-1: #355650;
  --volume-2: #40796d;
  --volume-3: #519b85;
  --font-body: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --font-numeric: ui-monospace, "Cascadia Mono", "SFMono-Regular", monospace;
  --radius: 10px;
  --ease: cubic-bezier(.2, .75, .2, 1);
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  color: var(--text);
  background: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { color: var(--muted); background: var(--raised); cursor: default; }
button:not(:disabled):active { transform: translateY(1px); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: clip;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell { width: min(100% - 32px, 1328px); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--edge); }
.topbar-inner { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.03em;
}
.brand img { flex: none; }
.source-badge {
  border: 1px solid var(--edge);
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}
.source-badge[data-mode="demo"] { background: var(--selected); color: var(--focus); border-color: var(--selected); }

.intro { padding-block: 12px 16px; }
.breadcrumbs { display: flex; align-items: center; color: var(--muted); font-size: 13px; gap: 8px; }
.breadcrumbs [aria-current="location"] { color: var(--text); }
.crumb-divider { display: inline-block; color: var(--muted); margin-inline-end: 5px; }
.text-button { border: 0; background: transparent; padding: 0; min-height: 44px; }
.text-button:not(:disabled):hover { color: var(--focus); }
.intro-heading { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 16px; row-gap: 4px; }
.intro-heading h1 { min-width: 0; overflow-wrap: break-word; font-size: 29px; line-height: 1.25; font-weight: 740; letter-spacing: -.036em; }
.intro-heading p { color: var(--muted); font-size: 13px; white-space: nowrap; }

.market-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--panel); color: var(--text); min-width: 0; }
.panel-head { min-height: 63px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; }
.panel-head h2 { font-size: 17px; font-weight: 680; line-height: 1.2; }
.panel-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
  min-height: 44px;
  border: 1px solid var(--edge-bright);
  background: var(--raised);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.outline-button:not(:disabled):hover { border-color: var(--focus); }
.outline-button:disabled { color: var(--muted); background: var(--ink); cursor: default; }
.outline-button svg { fill: none; stroke: currentColor; stroke-width: 1.4; }
.map-count { color: var(--muted); white-space: nowrap; font-size: 12px; }

.map-panel { display: grid; grid-template-rows: auto 1fr auto; overflow: clip; }
.map-board {
  display: grid;
  position: relative;
  place-items: center;
  isolation: isolate;
  overflow: clip;
  min-height: 304px;
  background: var(--map-water);
  border-block: 1px solid var(--edge);
}
.map-board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(to right, var(--edge) 1px, transparent 1px), linear-gradient(to bottom, var(--edge) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
  opacity: .25;
}
.map-annotation {
  position: absolute;
  z-index: 1;
  top: 10px;
  left: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: calc(100% - 24px);
  padding: 4px 8px;
  border: 1px solid var(--focus);
  border-radius: 5px;
  background: var(--ink);
  font-size: 12px;
  pointer-events: none;
}
.map-annotation strong { font-family: var(--font-numeric); font-size: 13px; }
.map-graphic { width: 100%; padding: 24px 3% 4px; }
.map-graphic svg { width: 100%; height: 318px; display: block; overflow: visible; }
.map-graphic[data-scope="seoul"] svg { height: 280px; }
.map-loading { z-index: 2; position: absolute; inset: auto 12px 15px; text-align: center; background: var(--ink); padding: 8px; }
.map-shape { fill: var(--missing); stroke: var(--map-halo); stroke-width: 1.2; cursor: pointer; vector-effect: non-scaling-stroke; }
.map-shape:hover, .map-shape:focus-visible, .map-shape.is-selected { stroke: var(--focus); stroke-width: 2; }
.map-shape:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; stroke-dasharray: 3 2; }
.map-shape.map-flare { animation: map-flare 620ms var(--ease); }
.map-labels { pointer-events: none; }
.map-labels line { stroke: var(--muted); stroke-width: .8; vector-effect: non-scaling-stroke; }
.map-labels text {
  fill: var(--text);
  stroke: var(--map-halo);
  stroke-width: 3.1;
  stroke-linejoin: round;
  paint-order: stroke;
  font-size: 19px;
  font-weight: 720;
  dominant-baseline: middle;
}
[data-scope="seoul"] .map-labels text { font-size: 18px; }
.map-labels text.is-selected { fill: var(--focus); }

.tone-missing { --tone: var(--missing); }
.tone-neutral { --tone: var(--neutral); }
.tone-up-1 { --tone: var(--up-1); }
.tone-up-2 { --tone: var(--up-2); }
.tone-up-3 { --tone: var(--up-3); }
.tone-down-1 { --tone: var(--down-1); }
.tone-down-2 { --tone: var(--down-2); }
.tone-down-3 { --tone: var(--down-3); }
.tone-volume-1 { --tone: var(--volume-1); }
.tone-volume-2 { --tone: var(--volume-2); }
.tone-volume-3 { --tone: var(--volume-3); }
.map-shape { fill: var(--tone, var(--missing)); }
.map-footer { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 12px; color: var(--muted); }
.map-scope { font-size: 11px; white-space: nowrap; }
.legend, .legend-scale, .legend-missing { display: inline-flex; align-items: center; }
.legend { gap: 4px; font-size: 11px; }
.legend-scale { height: 6px; border-radius: 2px; overflow: clip; }
.legend-scale i, .legend-missing::before { width: 10px; height: 6px; background: var(--tone); }
.legend-missing { gap: 4px; margin-inline-start: 3px; }
.legend-missing::before { content: ""; background: var(--missing); border: 1px solid var(--edge-bright); }

.rank-panel { --rank-columns: 49px minmax(0, 1fr) 72px 58px; }
.rank-head { border-bottom: 1px solid var(--edge); min-height: 59px; }
.segments { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 7px; border: 1px solid var(--edge); flex: none; }
.segments button { border: none; background: transparent; color: var(--muted); padding: 0 8px; min-height: 44px; font-size: 12px; border-radius: 4px; }
.segments button[aria-pressed="true"] { color: var(--text); background: var(--raised); box-shadow: inset 0 -2px var(--focus); }
.segments button:hover { color: var(--text); }
.table-head, .rank-row { display: grid; align-items: center; grid-template-columns: var(--rank-columns); gap: 4px; padding-inline: 12px; }
.table-head { min-height: 34px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--edge); }
.table-head > :nth-child(n+3) { text-align: end; }
.rank-list { margin: 0; padding: 0; list-style: none; }
.rank-item { border-bottom: 1px solid var(--edge); }
.rank-row {
  min-height: 46px;
  width: 100%;
  position: relative;
  isolation: isolate;
  border: 0;
  background: transparent;
  text-align: start;
}
.rank-row[aria-pressed="true"] { background: var(--selected); box-shadow: inset 2px 0 var(--focus); }
.rank-row:hover { background: var(--raised); }
.rank-row:focus-visible { outline-offset: -3px; }
.rank-place, .rank-value { font-family: var(--font-numeric); }
.rank-place { display: flex; align-items: center; gap: 4px; font-weight: 650; }
.rank-delta { color: var(--focus); font-size: 9px; white-space: nowrap; }
.rank-name { min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-chevron { display: inline-block; margin-inline-start: 4px; color: var(--focus); }
.rank-value { text-align: end; white-space: nowrap; font-size: 12px; }
.positive { color: var(--up); }
.negative { color: var(--down); }
.muted { color: var(--muted); }
.show-all { display: block; padding-inline: 12px; color: var(--focus); font-size: 13px; }
.rank-note { padding: 8px 12px 12px; color: var(--muted); font-size: 12px; }
.rank-flare::before { content: ""; position: absolute; inset: 1px 0; z-index: -1; border: 1px solid var(--focus); opacity: .22; animation: row-flare 680ms var(--ease); pointer-events: none; }
.rank-flare-first::before { opacity: .43; }
.sparks { pointer-events: none; position: absolute; z-index: 2; inset: 1px auto auto 13px; }
.spark-ray {
  position: absolute;
  width: var(--trail);
  height: 1.5px;
  border-radius: 1px;
  background: var(--spark);
  box-shadow: 0 0 4px var(--spark-hot);
  opacity: 0;
  animation: spark-flight 650ms var(--ease);
}
@keyframes spark-flight {
  0% { opacity: .98; transform: translate(0, 0) rotate(var(--angle)) scaleX(.38); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--angle)) scaleX(.72); }
}
@keyframes row-flare {
  0% { opacity: 1; box-shadow: 0 0 14px var(--spark-hot), inset 0 0 13px var(--spark-hot); }
  100% { box-shadow: 0 0 0 transparent; }
}
@keyframes map-flare {
  0%, 23% { stroke: var(--spark); filter: drop-shadow(0 0 4px var(--spark-hot)); }
  100% { filter: none; }
}

.replay-panel, .chart-panel { margin-block-start: 12px; }
.chart-panel { padding: 12px; }
.chart-panel .chart-ranges > button { min-width: 44px; min-height: 44px; }
.replay-head { min-height: 57px; }
.replay-controls { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 4px 12px 12px; }
.play-button { width: 44px; height: 44px; border: 0; border-radius: 6px; display: grid; place-items: center; background: var(--focus); color: var(--ink); }
.play-button svg { fill: currentColor; }
.replay-timeline { min-width: 0; }
.replay-timeline input { display: block; width: 100%; margin: 0; height: 30px; accent-color: var(--focus); cursor: pointer; }
.range-dates { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.replay-controls output { font-family: var(--font-numeric); font-size: 11px; align-self: start; padding-block-start: 10px; color: var(--focus); }
.market-footer { display: grid; gap: 8px; padding: 16px 0 28px; font-size: 12px; color: var(--muted); }
.source-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.source-links a { text-decoration: underline; text-underline-offset: 3px; }
.notice { border: 1px solid var(--edge); padding: 12px; margin-block: 12px; }

@media (min-width: 800px) {
  .shell { width: min(100% - 72px, 1328px); }
  .topbar-inner { min-height: 62px; }
  .intro { padding-block: 16px 24px; }
  .intro-heading h1 { font-size: 39px; }
  .intro-heading p { font-size: 14px; }
  .market-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .panel-head { padding-inline: 16px; min-height: 65px; }
  .panel-head h2 { font-size: 19px; }
  .map-graphic { padding: 16px 4% 8px; }
  .map-graphic svg, .map-graphic[data-scope="seoul"] svg { height: 445px; }
  .map-annotation { top: 16px; left: 16px; padding: 8px; font-size: 14px; }
  .map-annotation strong { font-size: 15px; }
  .map-footer { min-height: 42px; padding-inline: 16px; }
  .legend { gap: 8px; font-size: 12px; }
  .legend-scale i { width: 17px; }
  .rank-panel { --rank-columns: 58px minmax(0, 1fr) 76px 65px; }
  .table-head, .rank-row { padding-inline: 16px; gap: 8px; }
  .rank-row { min-height: 48px; }
  .rank-value { font-size: 13px; }
  .rank-note, .show-all { padding-inline: 16px; }
  .replay-panel, .chart-panel { margin-block-start: 16px; }
  .chart-panel { padding: 16px; }
  .replay-controls { padding-inline: 16px; }
  .replay-controls output { font-size: 13px; }
}

@media (min-width: 1120px) {
  .rank-panel { --rank-columns: 67px minmax(0, 1fr) 89px 75px; }
  .rank-row, .table-head { padding-inline: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .rank-flare::before, .spark-ray, .map-shape.map-flare { animation: none; }
}
