/* ==========================================================================
   THE CEILING TRAP — a visual essay on rent control
   Typography after Edward Tufte; palette after Sanzo Wada,
   "A Dictionary of Color Combinations" (1933).
   ========================================================================== */

:root {
  /* Wada-inspired palette */
  --paper:      #f5efe1;  /* warm ivory */
  --paper-deep: #ece0c8;  /* aged paper */
  --ink:        #2b251c;  /* sepia-black ink */
  --ink-soft:   #55492f;
  --muted:      #82755f;
  --line:       #cfc2a6;

  --peacock:    #22585e;  /* peacock green  — demand, tenants  */
  --ochre:      #ac7d2c;  /* mustard ochre  — supply, landlords */
  --vermilion:  #b6432c;  /* vermilion      — the ceiling       */
  --rose:       #c08e79;  /* hermosa clay */
  --night:      #23312f;  /* deep spruce, dark panels */
  --night-ink:  #e9e0cb;

  --serif: "Newsreader", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --measure: 660px;
  --gutter: 320px;      /* sidenote column */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.62;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(182, 67, 44, 0.22); }

/* ------------------------------------------------------------------ */
/* Progress bar & top nav                                              */
/* ------------------------------------------------------------------ */

#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--vermilion); z-index: 60;
  transition: width 60ms linear;
}

.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 28px 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  transform: translateY(0);
  transition: transform .35s ease;
}
.site-nav.hidden { transform: translateY(-110%); }
.site-nav .wordmark {
  font-style: italic; letter-spacing: .02em; text-decoration: none;
  color: var(--ink); font-size: 16px;
}
.site-nav .wordmark b { font-style: normal; color: var(--vermilion); }
.site-nav ul { display: flex; gap: 22px; list-style: none; margin: 0; padding: 0; }
.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover { color: var(--vermilion); }
@media (max-width: 760px) { .site-nav ul { display: none; } }

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */

.hero {
  min-height: 96vh;
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
  padding: 110px 24px 46vh;
  border-bottom: 1px solid var(--line);
}
.hero-inner { width: 100%; max-width: 980px; margin: 0 auto; position: relative; z-index: 2; }
.hero .kicker {
  text-transform: uppercase; letter-spacing: .28em; font-size: 13px;
  color: var(--vermilion); margin: 0 0 18px;
}
.hero h1 {
  font-size: clamp(44px, 7.2vw, 88px);
  line-height: 1.02; font-weight: 500; letter-spacing: -0.015em;
  margin: 0 0 26px;
}
.hero h1 em { font-style: italic; color: var(--peacock); }
.hero .dek {
  font-size: clamp(19px, 2.1vw, 24px); line-height: 1.55;
  max-width: 720px; color: var(--ink-soft); margin: 0 0 34px;
}
.hero .byline { font-size: 15px; color: var(--muted); font-style: italic; }
.hero-photo {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 1;
  height: 44vh; min-height: 260px; margin: 0; overflow: hidden;
}
.hero-photo img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 72%;
  display: block; border: 0;
  filter: sepia(.26) contrast(1.02);
}
.hero-photo::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, var(--paper) 0%, rgba(245, 239, 225, 0) 45%);
}
.hero-photo figcaption {
  position: absolute; right: 12px; bottom: 10px; z-index: 2;
  font-size: 12.5px; font-style: italic; line-height: 1.4;
  color: #f0e9d8; background: rgba(35, 49, 47, .72);
  padding: 4px 10px; max-width: 480px; text-align: right;
}
.hero-photo figcaption a { color: #f0e9d8; }
.scroll-cue {
  position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%);
  z-index: 3; color: #f0e9d8; font-size: 13px; letter-spacing: .2em;
  text-transform: uppercase; text-decoration: none;
  text-shadow: 0 1px 4px rgba(20, 18, 14, .85);
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translate(-50%,0);} 50% { transform: translate(-50%,7px);} }

/* ------------------------------------------------------------------ */
/* Article layout with Tufte sidenotes                                 */
/* ------------------------------------------------------------------ */

.article {
  max-width: calc(var(--measure) + var(--gutter) + 96px);
  margin: 0 auto;
  padding: 0 24px;
}
@media (min-width: 1140px) {
  .article { padding-right: calc(var(--gutter) + 48px); position: relative; }
}

section.chapter { padding: 60px 0 24px; }

.chapter-no {
  font-size: 14px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--vermilion); margin: 0 0 10px;
}
.chapter h2 {
  font-size: clamp(32px, 4.2vw, 48px); line-height: 1.1;
  font-weight: 500; margin: 0 0 8px; letter-spacing: -0.01em;
  max-width: 760px;
}
.chapter .subhead {
  font-size: 22px; font-style: italic; color: var(--muted);
  margin: 0 0 30px; max-width: var(--measure);
}
.chapter h3 {
  font-size: 26px; font-weight: 500; margin: 56px 0 12px;
  max-width: var(--measure);
}

p, ul.prose, ol.prose, blockquote { max-width: var(--measure); }
p { margin: 0 0 1.25em; }
a { color: var(--peacock); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { color: var(--vermilion); }

.dropcap::first-letter {
  float: left; font-size: 4.6em; line-height: .82; padding: 6px 10px 0 0;
  color: var(--vermilion); font-weight: 500;
}

/* Sidenotes */
.sn-ref {
  vertical-align: super; font-size: .68em; color: var(--vermilion);
  font-weight: 600; padding-left: 1px;
}
.sidenote {
  font-size: 15px; line-height: 1.5; color: var(--ink-soft);
}
.sidenote .sn-no { color: var(--vermilion); font-weight: 600; }
@media (min-width: 1140px) {
  .sidenote {
    float: right; clear: right;
    width: var(--gutter);
    margin-right: calc(-1 * var(--gutter) - 48px);
    margin-top: 4px; margin-bottom: 18px;
  }
}
@media (max-width: 1139px) {
  .sidenote {
    display: block; margin: 18px 0; padding: 12px 16px;
    border-left: 3px solid var(--line); background: var(--paper-deep);
  }
}

/* Pull quotes */
blockquote.pull {
  margin: 54px 0; padding: 0 0 0 28px;
  border-left: 4px solid var(--vermilion);
  font-size: clamp(24px, 2.8vw, 31px); line-height: 1.35; font-style: italic;
  color: var(--ink);
}
blockquote.pull footer {
  font-size: 16px; font-style: normal; color: var(--muted); margin-top: 14px;
}

/* Key stat callouts */
.statline {
  display: flex; flex-wrap: wrap; gap: 34px; margin: 46px 0;
  padding: 26px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line);
  max-width: 760px;
}
.statline .stat { flex: 1 1 140px; }
.statline .stat b {
  display: block; font-size: clamp(34px, 3.6vw, 46px); font-weight: 500;
  line-height: 1; margin-bottom: 8px; color: var(--peacock);
}
.statline .stat.bad b { color: var(--vermilion); }
.statline .stat span { font-size: 15px; color: var(--ink-soft); line-height: 1.4; display: block; }

/* ------------------------------------------------------------------ */
/* Figures — Tufte style                                               */
/* ------------------------------------------------------------------ */

figure { margin: 48px 0; max-width: 820px; }
figure.wide { max-width: 100%; }
figure svg { width: 100%; height: auto; display: block; }
figcaption {
  font-size: 15px; line-height: 1.5; color: var(--ink-soft);
  margin-top: 12px; max-width: var(--measure);
}
figcaption b { font-style: normal; }
figure img {
  max-width: 100%; height: auto; display: block;
  border: 1px solid var(--line);
}

/* chart text */
.chart text {
  font-family: var(--serif); fill: var(--ink-soft);
}
.chart .axis-label { font-size: 13px; fill: var(--muted); }
.chart .direct-label { font-size: 14.5px; }
.chart .num { font-size: 13px; }
.chart .annot { font-size: 13.5px; font-style: italic; fill: var(--ink-soft); }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { stroke: var(--muted); stroke-width: 1; }

/* animated draw-in for chart marks */
.chart [data-draw] { transition: none; }
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s ease, transform .8s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ */
/* Interactive ceiling widget                                          */
/* ------------------------------------------------------------------ */

.widget {
  margin: 52px 0; padding: 28px 28px 22px;
  background: #fbf7ec;
  border: 1px solid var(--line);
  box-shadow: 4px 4px 0 var(--paper-deep);
  max-width: 860px;
}
.widget h4 { margin: 0 0 4px; font-size: 21px; font-weight: 600; }
.widget .hint { font-size: 15px; color: var(--muted); font-style: italic; margin: 0 0 14px; }
.widget-readout {
  display: flex; flex-wrap: wrap; gap: 26px; margin-top: 10px;
  font-size: 15px; color: var(--ink-soft);
}
.widget-readout div b { display: block; font-size: 26px; font-weight: 600; line-height: 1.15; }
.widget-readout .r-rent b { color: var(--vermilion); }
.widget-readout .r-supplied b { color: var(--ochre); }
.widget-readout .r-demanded b { color: var(--peacock); }
.widget-readout .r-short b { color: var(--vermilion); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; margin: 18px 0 4px;
  background: linear-gradient(to right, var(--vermilion), var(--line));
  outline: none; border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--vermilion); border: 3px solid var(--paper);
  box-shadow: 0 1px 4px rgba(43,37,28,.4); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--vermilion); border: 3px solid var(--paper);
  box-shadow: 0 1px 4px rgba(43,37,28,.4); cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Full-bleed dark story panels                                        */
/* ------------------------------------------------------------------ */

.panel {
  background: var(--night); color: var(--night-ink);
  margin: 60px 0; padding: 64px 24px;
}
.panel-inner { max-width: 980px; margin: 0 auto; }
.panel .kicker {
  text-transform: uppercase; letter-spacing: .28em; font-size: 13px;
  color: var(--rose); margin: 0 0 14px;
}
.panel h3 {
  font-size: clamp(30px, 4vw, 44px); font-weight: 500; line-height: 1.12;
  margin: 0 0 18px; max-width: 780px;
}
.panel p { color: #cfc6ad; max-width: 700px; }
.panel a { color: #dfd4b4; }
.panel blockquote.pull { border-color: var(--rose); color: var(--night-ink); }
.panel blockquote.pull footer { color: #a99f86; }
.panel .statline { border-top-color: var(--night-ink); border-bottom-color: #3d4c49; }
.panel .statline .stat b { color: #d8b45a; }
.panel .statline .stat.bad b { color: #d97a5f; }
.panel .statline .stat span { color: #b3ab93; }
.panel figcaption { color: #a99f86; }
.panel .chart text { fill: #cfc6ad; }
.panel .chart .axis, .panel .chart .tick { stroke: #7d8a83; }

.video-frame {
  position: relative; width: 100%; max-width: 820px;
  aspect-ratio: 16 / 9; margin: 36px 0 10px;
  border: 1px solid #3d4c49; background: #000;
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* two-column inside panels */
.panel-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: start; }
@media (max-width: 860px) { .panel-cols { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* Cards for the five effects                                          */
/* ------------------------------------------------------------------ */

.effects {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px; margin: 44px 0; max-width: 860px;
  counter-reset: effect;
}
.effect {
  border: 1px solid var(--line); background: #fbf7ec;
  padding: 20px 20px 16px; position: relative;
}
.effect::before {
  counter-increment: effect; content: counter(effect);
  position: absolute; top: -14px; left: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--vermilion); color: var(--paper);
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.effect b { display: block; font-size: 18px; margin: 6px 0 6px; }
.effect p { font-size: 15px; line-height: 1.5; color: var(--ink-soft); margin: 0; }

/* ------------------------------------------------------------------ */
/* Photo layouts                                                       */
/* ------------------------------------------------------------------ */

.photo-pair { display: grid; grid-template-columns: 320px 1fr; gap: 36px; align-items: start; margin: 48px 0; max-width: 860px; }
@media (max-width: 760px) { .photo-pair { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* Design-rules list                                                   */
/* ------------------------------------------------------------------ */

ol.rules { list-style: none; counter-reset: rule; margin: 40px 0; padding: 0; max-width: 720px; }
ol.rules li {
  counter-increment: rule; position: relative;
  padding: 20px 0 20px 74px; border-top: 1px solid var(--line);
}
ol.rules li:last-child { border-bottom: 1px solid var(--line); }
ol.rules li::before {
  content: counter(rule, decimal-leading-zero);
  position: absolute; left: 0; top: 18px;
  font-size: 30px; color: var(--vermilion); font-style: italic;
}
ol.rules li b { font-size: 20px; }
ol.rules li p { margin: 6px 0 0; font-size: 16.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------------ */
/* Sources & colophon                                                  */
/* ------------------------------------------------------------------ */

.sources { padding: 56px 0 32px; border-top: 1px solid var(--ink); margin-top: 56px; }
.sources h2 { font-size: 30px; font-weight: 500; }
.sources ul { list-style: none; padding: 0; max-width: 820px; }
.sources li {
  font-size: 16px; line-height: 1.55; color: var(--ink-soft);
  padding: 10px 0; border-bottom: 1px solid var(--paper-deep);
}
.sources li b { color: var(--ink); font-weight: 600; }

.colophon {
  padding: 60px 24px 80px; text-align: center;
  font-size: 15px; color: var(--muted); font-style: italic;
}
.colophon .swatches { display: flex; justify-content: center; gap: 6px; margin: 0 auto 18px; }
.colophon .swatches span { width: 34px; height: 18px; display: inline-block; border: 1px solid rgba(43,37,28,.25); }

/* misc */
hr.sep {
  border: 0; height: 1px; background: var(--line);
  margin: 48px auto 0; max-width: 240px; position: relative;
}
.smallcaps { font-variant: small-caps; letter-spacing: .06em; }

@media (max-width: 600px) {
  body { font-size: 18px; }
  section.chapter { padding: 44px 0 18px; }
  .statline { gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; opacity: 1; transform: none; }
  .scroll-cue { animation: none; }
  html { scroll-behavior: auto; }
}
