/*
   Vienna's Housing Paradox:
   Editorial scrollytelling. Display: Archivo · Body: Source Serif 4 ·
   Data/UI: IBM Plex Mono. Colour semantics: green = protected housing,
   red = market-rate, gold = neutral chrome.
*/

:root {
  --ink: #1a1c22;
  --ink-soft: #3a3d45;
  --paper: #fbfaf7;
  --paper-2: #f3efe6;
  --panel: #ffffff;
  --protected: #138a72;
  --protected-soft: #9fd4c6;
  --market: #d23b2c;
  --market-soft: #f0b2aa;
  --accent: #b8893b;
  --muted: #6b6f76;
  --line: #ded7c9;

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 19px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display { font-family: var(--display); font-weight: 800; letter-spacing: -0.01em; line-height: 1.04; }
.mono { font-family: var(--mono); }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* a thin progress bar pinned to the top */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 60; transition: width 0.1s linear;
}

/* persistent source ribbon (credibility always one tap away) */
#ribbon {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em;
  color: var(--muted); background: rgba(251, 250, 247, 0.92);
  border-top: 1px solid var(--line); backdrop-filter: blur(4px);
  padding: 6px 16px; display: flex; gap: 14px; align-items: center;
  transform: translateY(110%); transition: transform 0.3s ease;
}
#ribbon.show { transform: translateY(0); }
#ribbon .src-label { color: var(--ink); font-weight: 600; }
#ribbon a { color: var(--accent); }

/* HERO / HOOK */
.hook {
  position: relative; min-height: 100vh; background: #0e0f13; color: #f4f1ea;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; padding: 0 24px;
}
.hook__skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 38vh; display: block; }
.hook__inner { max-width: var(--maxw); margin: 0 auto; width: 100%; position: relative; z-index: 2; }
.hook .eyebrow {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 22px;
}
.hook h1 { font-size: clamp(44px, 9vw, 118px); margin: 0; color: #fff; }
.hook h1 .turn { display: block; color: var(--market); }
.hook__sub {
  font-size: clamp(18px, 2.4vw, 25px); max-width: 30ch; margin: 26px 0 0;
  color: #cfcabb;
}
.hook__cue {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 3; font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em;
  text-transform: uppercase; color: #cfcabb; text-align: center;
}
.hook__cue .arrow { display: block; margin: 8px auto 0; width: 18px; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) { .hook__cue .arrow { animation: none; } }

/* SECTION INTRO BANDS */
.band { max-width: 760px; margin: 0 auto; padding: 80px 24px 24px; }
.band .kicker {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.band h2 { font-size: clamp(30px, 5vw, 52px); margin: 0 0 18px; }
.band p { color: var(--ink-soft); font-size: 20px; }

/* SCROLLY SCENES */
.scene { position: relative; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.scene__inner { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 40px; align-items: start; }
.scene__graphic {
  position: sticky; top: 0; height: 92vh; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
}
.viz { width: 100%; }
.viz figcaption {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  margin-top: 10px; text-align: left; line-height: 1.5;
}
.scene__steps { padding: 6vh 0 12vh; }
.step {
  min-height: 64vh; display: flex; flex-direction: column; justify-content: center;
}
.step__card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 22px 24px; border-radius: 4px; box-shadow: 0 8px 30px rgba(26, 28, 34, 0.06);
  transition: opacity 0.3s ease, transform 0.3s ease; opacity: 0.45;
}
.step.is-active .step__card { opacity: 1; transform: translateY(-2px); }
.step__card h3 { font-size: 24px; margin: 0 0 8px; }
.step__card p { margin: 0; font-size: 18px; color: var(--ink-soft); }
.step__card .lead { font-weight: 700; color: var(--ink); }
.tag {
  display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 3px; margin-bottom: 10px; text-transform: uppercase;
}
.tag.protected { background: var(--protected-soft); color: #0a4a3c; }
.tag.market { background: var(--market-soft); color: #7a160c; }

/* chart primitives shared across scenes */
.axis path, .axis line { stroke: var(--line); }
.axis text { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.gridline line { stroke: #e7e1d4; stroke-dasharray: 2 3; }
.gridline path { stroke: none; }
.bar-label { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.chart-title { font-family: var(--display); font-weight: 800; font-size: 19px; fill: var(--ink); }
.chart-sub { font-family: var(--mono); font-size: 12px; fill: var(--muted); }
.annot { font-family: var(--mono); font-size: 12.5px; fill: var(--ink); }
.annot-em { font-family: var(--display); font-weight: 800; }

/* TOOLTIP  */
.tooltip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 260px;
  background: var(--ink); color: #f4f1ea; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.5; padding: 9px 11px; border-radius: 5px; box-shadow: 0 6px 22px rgba(0,0,0,0.28);
  transition: opacity 0.12s ease;
}
.tooltip b { color: #fff; }
.tooltip .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* MAP SCENE */
.map-wrap { position: relative; width: 100%; }
.district { stroke: #fff; stroke-width: 0.8; cursor: pointer; transition: stroke-width 0.1s; }
.district:hover, .district.sel { stroke: var(--ink); stroke-width: 2; }
.district.dim { opacity: 0.25; }
.gb-dot { fill: var(--accent); fill-opacity: 0.5; stroke: var(--accent); stroke-width: 0.8; pointer-events: none; }
.map-legend text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.map-panel {
  position: absolute; top: 0; right: 0; width: 210px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 14px; box-shadow: 0 8px 30px rgba(26,28,34,0.1);
}
.map-panel .pname { font-family: var(--display); font-weight: 800; font-size: 18px; margin-bottom: 10px; }
.map-panel .row { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 12.5px; padding: 4px 0; border-top: 1px solid var(--paper-2); }
.map-panel .row:first-of-type { border-top: none; }
.map-panel .row .k { color: var(--muted); }
.map-panel .row .v { color: var(--ink); font-weight: 600; }
.map-panel .hint { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* FUNNEL SCENE*/
.funnel-stage { cursor: pointer; }
.funnel-band { transition: opacity 0.4s ease; }
.funnel-band.off { opacity: 0.12; }
.funnel-label { font-family: var(--display); font-weight: 700; font-size: 14px; fill: #fff; }
.funnel-pct { font-family: var(--mono); font-size: 12px; fill: #fff; }
.funnel-drop { font-family: var(--mono); font-size: 12px; fill: var(--market); }

/*  CALCULATOR SCENE */
.calc {
  max-width: 980px; margin: 0 auto 120px; padding: 0 24px;
  display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 38px; align-items: start;
}
.calc__controls { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.calc__controls h3 { font-size: 22px; margin: 0 0 18px; }
.ctrl { margin-bottom: 22px; }
.ctrl label { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 13px; color: var(--ink); margin-bottom: 8px; }
.ctrl label .val { color: var(--accent); font-weight: 700; font-size: 15px; }
.ctrl input[type="range"] { width: 100%; accent-color: var(--accent); }
.segbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.segbtns button {
  font-family: var(--mono); font-size: 13px; padding: 9px 14px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-soft); border-radius: 6px; cursor: pointer; transition: all 0.12s;
}
.segbtns button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.toggle-row .tg {
  font-family: var(--mono); font-size: 12.5px; padding: 8px 14px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-soft); border-radius: 999px; cursor: pointer; transition: all 0.12s;
}
.toggle-row .tg:hover { border-color: var(--ink-soft); }
.toggle-row .tg.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.city-bar, .bar { cursor: default; }
.calc__result { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.verdict { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; margin-bottom: 6px; }
.verdict.no { color: var(--market); }
.verdict.yes { color: var(--protected); }
.verdict-sub { color: var(--ink-soft); font-size: 16px; margin-bottom: 22px; }
.path-row { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 13.5px; padding: 9px 0; border-top: 1px solid var(--paper-2); }
.path-row .k { color: var(--muted); }
.path-row .v { color: var(--ink); font-weight: 600; text-align: right; }
.path-row .v.market { color: var(--market); }
.path-row .v.protected { color: var(--protected); }
.burden-wrap { margin-top: 18px; }
.burden-bar { height: 26px; border-radius: 4px; background: var(--paper-2); overflow: hidden; position: relative; }
.burden-fill { height: 100%; width: 0; background: var(--market); transition: width 0.5s ease, background 0.5s ease; }
.burden-cap { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.calc__compare { margin-top: 16px; }
.calc__compare button { font-family: var(--mono); font-size: 13px; padding: 9px 14px; border: 1px solid var(--accent); background: transparent; color: var(--accent); border-radius: 6px; cursor: pointer; }
.calc__compare .copied { color: var(--protected); font-family: var(--mono); font-size: 12px; margin-left: 10px; }

/* CLOSING */
.closing { background: #0e0f13; color: #e9e5da; padding: 110px 24px 90px; margin-top: 60px; }
.closing__inner { max-width: 760px; margin: 0 auto; }
.closing h2 { color: #fff; font-size: clamp(28px, 5vw, 46px); margin: 0 0 18px; }
.closing p { color: #cfcabb; }
.closing .sources { margin-top: 34px; border-top: 1px solid #2a2c33; padding-top: 22px; }
.closing .sources h4 { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--accent); margin: 0 0 14px; }
.closing .sources li { font-family: var(--mono); font-size: 13px; color: #b9b4a7; margin-bottom: 12px; list-style: none; }
.closing .sources ul { padding: 0; margin: 0; }
.closing .sources a { color: #e9e5da; }
.closing .note { font-family: var(--mono); font-size: 12px; color: #8d8a80; margin-top: 26px; line-height: 1.6; }

/* RESPONSIVE */
@media (max-width: 820px) {
  body { font-size: 17px; }
  .scene__inner { grid-template-columns: 1fr; gap: 0; }
  .scene__graphic { position: sticky; top: 0; height: 56vh; padding-top: 8px; background: linear-gradient(var(--paper), var(--paper) 86%, transparent); z-index: 1; }
  .scene__steps { padding: 2vh 0 16vh; position: relative; z-index: 2; }
  .step { min-height: 58vh; }
  .map-panel { position: relative; width: 100%; margin-top: 12px; }
  .calc { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 520px) {
  .band { padding-top: 60px; }
  .hook h1 { font-size: 13vw; }
}
