/* ============ Who Is Heating the Planet? — broadsheet editorial ============ */

:root {
  --paper: #f7f1e5;
  --paper-deep: #efe6d2;
  --ink: #191410;
  --ink-soft: #4a4238;
  --rule: #d8ccb4;
  --perception: #a84a10;   /* ember — the story we tell */
  --perception-soft: #e6b596;
  --reality: #1e5f4a;      /* forest — what is measured */
  --reality-soft: #a3c4b4;
  --gold: #a87b2d;
  --dark: #0f1410;
  --dark-paper: #efe6d2;
  --serif: "Newsreader", Georgia, serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* stop mobile Chrome/Safari from inflating font sizes (breaks the centered
     masthead: the boosted title overflows and clips) */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.62;
  /* paper grain */
  background-image:
    radial-gradient(ellipse at top, rgba(255,255,255,.5), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

a { color: var(--reality); text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- masthead ---------- */

.masthead {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem 1.5rem 2rem;
  border-bottom: 3px double var(--rule);
}

.kicker {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
}

.masthead h1 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 0, "WONK" 0;
  font-weight: 600;
  font-size: clamp(2.5rem, 7.5vw, 5.2rem);
  line-height: 1.02;
  margin: 0 0 2rem;
  letter-spacing: -.01em;
}

.masthead h1 em { font-style: italic; color: var(--perception); }
.masthead h1 em.real { color: var(--reality); }
.masthead h1 .vs {
  font-family: var(--mono);
  font-size: .35em;
  vertical-align: .55em;
  font-style: normal;
  color: var(--ink-soft);
}

.standfirst {
  max-width: 38em;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  font-weight: 300;
  margin: 0 auto 1.4rem;
}

.byline {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--ink-soft);
  max-width: 46em;
  margin: 0 auto 2rem;
}

.legend-key { display: flex; gap: 1rem; justify-content: center; margin-bottom: 3rem; }
.key {
  font-family: var(--mono);
  font-size: .8rem;
  padding: .3rem .9rem;
  border-radius: 2rem;
  color: var(--paper);
}
.key--p { background: var(--perception); }
.key--r { background: var(--reality); }

.scroll-cue {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-soft);
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(8px); } }

/* ---------- prose sections ---------- */

.prose {
  max-width: 42em;
  margin: 0 auto;
  padding: 5rem 1.5rem 1rem;
}

.prose h2 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 0, "WONK" 1;
  font-weight: 720;
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.08;
  margin: 0 0 1.2rem;
}

.myth-no {
  display: block;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--perception);
  margin-bottom: .8rem;
}
.myth-no::after {
  content: "";
  display: block;
  width: 3.2rem;
  border-bottom: 3px solid var(--perception);
  margin-top: .5rem;
}

/* ---------- scrolly ---------- */

.scrolly {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 0 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  padding: clamp(1.25rem, 6vh, 2.5rem) 0 2.75rem;
  box-sizing: border-box;
  grid-column: 1;
  grid-row: 1;
}

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

.steps { grid-column: 2; grid-row: 1; padding-bottom: 100vh; }

.step {
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: .28;
  transition: opacity .4s;
}
.step.active { opacity: 1; }

.step p {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  box-shadow: 0 2px 14px rgba(25,20,16,.07);
  padding: 1.3rem 1.5rem;
  margin: 0;
  font-size: 1.08rem;
}

.step-kicker {
  font-family: var(--mono) !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  font-size: .78rem !important;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0 0 .5rem 0 !important;
}

/* ---------- solo charts & cards ---------- */

.chart-solo {
  max-width: 62em;
  margin: 2rem auto 3rem;
  padding: 0 1.5rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 1.2rem;
  max-width: 62em;
  margin: 2.5rem auto 4rem;
  padding: 0 1.5rem;
}

.belief-card {
  border: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,0));
  padding: 1.4rem 1.5rem 1.2rem;
  position: relative;
}
.belief-card::before {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 4px;
  background: var(--perception);
}
.belief-card.card--fact::before { background: var(--reality); }

.belief-card .big {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1;
  margin: 0 0 .5rem;
}
.belief-card.card--myth .big { color: var(--perception); }
.belief-card.card--fact .big { color: var(--reality); }
.belief-card p { margin: 0; font-size: 1rem; }
.belief-card .src {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-soft);
  margin-top: .8rem;
  display: block;
}

/* ---------- guess widget ---------- */

#guess-widget {
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  padding: 1.6rem 1.8rem;
  margin: 2rem 0 1rem;
}
#guess-widget .gw-row { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
#guess-widget input[type=range] {
  flex: 1;
  accent-color: var(--perception);
  height: 2rem;
}
#guess-widget .gw-value {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.4rem;
  min-width: 3.2ch;
  text-align: right;
  color: var(--perception);
}
#guess-widget button {
  font-family: var(--mono);
  font-size: .85rem;
  letter-spacing: .08em;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: .7rem 1.3rem;
  cursor: pointer;
}
#guess-widget button:hover { background: var(--perception); }
#guess-widget .gw-result { margin-top: 1rem; font-size: 1.05rem; display: none; }
#guess-widget.revealed .gw-result { display: block; }

/* ---------- dark section ---------- */

.dark {
  background: var(--dark);
  color: var(--dark-paper);
  margin-top: 5rem;
  padding: 4rem 0 5rem;
}
.prose--dark { color: var(--dark-paper); }
.prose--dark h2 { color: var(--dark-paper); }
.chart--dark {
  max-width: 62em;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* ---------- controls, tooltip, chart text ---------- */

.chart-toggle {
  display: inline-flex;
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: .8rem;
  margin-bottom: 1rem;
}
.chart-toggle button {
  font: inherit;
  border: none;
  background: none;
  color: var(--ink);
  padding: .5rem 1.1rem;
  cursor: pointer;
}
.chart-toggle button.on { background: var(--ink); color: var(--paper); }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: .74rem;
  padding: .5rem .7rem;
  max-width: 240px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 50;
}

svg text { font-family: var(--mono); fill: var(--ink); }
svg .axis text { font-size: .68rem; fill: var(--ink-soft); }
svg .axis line, svg .axis path { stroke: var(--rule); }
svg .anno { font-size: .7rem; }
svg .chart-title { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }

.dark svg text { fill: var(--dark-paper); }
.dark svg .axis text { fill: #9a8f7d; }
.dark svg .axis line, .dark svg .axis path { stroke: #3a322a; }

/* ---------- close & footer ---------- */

.close-list li { margin-bottom: 1rem; }
.fin {
  font-family: var(--display);
  font-weight: 550;
  font-size: 1.35rem;
  line-height: 1.45;
  border-top: 3px double var(--rule);
  padding-top: 1.6rem;
  margin-top: 2.4rem;
}
.essay-trail {
  margin-top: 2rem;
  font-size: .9rem;
  color: var(--ink-soft);
  line-height: 1.7;
}
.essay-trail p { margin: 0; }
.essay-trail a { color: var(--ink-soft); text-underline-offset: 3px; }
.essay-trail a:hover { color: var(--ink); }
.essay-trail--before-sources {
  margin: 0 0 1.25rem;
  padding: 0;
  max-width: none;
}

.methodology {
  border-top: 3px double var(--rule);
  margin-top: 5rem;
  padding: 2.5rem 1.5rem 4rem;
  max-width: 46em;
  margin-left: auto;
  margin-right: auto;
  font-size: .88rem;
  color: var(--ink-soft);
}
.methodology h3 { font-family: var(--display); color: var(--ink); }
#sources { position: relative; z-index: 1; background: var(--paper); }
#sources-list { font-family: var(--mono); font-size: .74rem; line-height: 2; }
.series-nav {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin: .5rem 0 1.5rem;
}
.series-nav a { color: var(--ink); text-decoration: none; }
.series-nav a:hover { text-decoration: underline; }
.series-nav .series-here { color: var(--ink-soft); font-style: italic; }

/* ---------- mobile ---------- */

@media (max-width: 820px) {
  .scrolly { grid-template-columns: 1fr; }
  /* Compact pinned graphic: fixed height, always fully visible. Steps read
     in the clear zone below it — never overlaid, never clipped mid-read. */
  .sticky {
    height: 38vh; height: 38svh;
    align-self: start;
    grid-column: 1;
    z-index: 1;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: .6rem 0 .4rem;
  }
  .steps { grid-column: 1; }
  /* Bottom-anchor step content: when the scroller activates a step (its
     center at viewport center), the content sits below the graphic. */
  /* Full-viewport steps with content anchored just above the fold: when the
     scroller centers a step (making it active), its card sits in the clear
     zone below the pinned graphic. Shorter boxes push the card top under the
     opaque panel at that resting position. Card must still fit the zone
     (100svh - 38svh panel), hence the tighter card padding and grid. */
  .step {
    min-height: 100vh; min-height: 100svh;
    justify-content: flex-end;
    padding-bottom: 1.25rem;
  }
  .step p { font-size: 1rem; padding: 1rem 1.15rem; }
  .comp-label { flex: 1 1 auto; }
}

/* very narrow screens (small phones, accessibility zoom): let the title shrink
   below its desktop minimum so it never overflows the viewport */
@media (max-width: 480px) {
  .masthead h1 { font-size: clamp(1.6rem, 11.5vw, 2.5rem); }
}

/* back link to the Notes & Tones home (added when folded into the blog) */
.site-back {
  font-family: "IBM Plex Mono", monospace;
  font-size: .8rem;
  letter-spacing: .04em;
  padding: .9rem clamp(1.2rem, 5vw, 2.4rem);
  border-bottom: 1px solid #d8ccb4;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .3rem 1.5rem;
}
.site-back a { color: #1e5f4a; text-decoration: none; }
.site-back a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* sources definition list generated from quantities.json */
.sources-list dt { font-weight: 600; margin-top: .9rem; }
.sources-list dd { margin: .1rem 0 0 0; font-size: .95rem; color: var(--ink-soft); }

/* sources methodology note */
.sources-note {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--ink-soft);
  margin-top: 1.5rem;
  line-height: 1.6;
}

/* ===== Aviation-specific additions ===== */

/* Calendar SVG sizing. The beat-2 view is much taller than the year grid
   (habit blocks below), so cap height and let preserveAspectRatio fit it. */
.calendar-svg {
  display: block;
  width: min(480px, 88vw);
  height: auto;
  max-height: calc(100svh - 8rem);
  flex-shrink: 0;
}

/* Calendar SVG cells — every square is one budget-day */
.calendar-svg rect              { fill: var(--rule); transition: fill 0.05s; }
.calendar-svg rect.consumed     { fill: var(--perception); }
.calendar-svg rect.comp-a       { fill: var(--reality); }    /* driving  */
.calendar-svg rect.comp-b       { fill: var(--gold); }       /* beef     */
.calendar-svg rect.comp-c       { fill: var(--ink-soft); }   /* heating  */
.calendar-svg rect.habit-hidden { fill: transparent; }       /* beat 2 only */
.calendar-svg rect.ice          { fill: #dce9ef; }           /* beat 4: sea ice   */
.calendar-svg rect.melted       { fill: #16324a; }           /* beat 4: open water */
/* the scroll-driven ice reveal should feel gradual, not a flicker */
.calendar-svg rect.ice, .calendar-svg rect.melted { transition: fill .35s; }

.cal-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0.5rem 0 0;
  min-height: 1.4em;
}

/* Haul toggle */
.haul-toggle {
  display: flex;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.haul-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}

.haul-btn.active {
  border-color: var(--perception);
  background: var(--paper-deep);
}

.haul-example {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.days-readout {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--perception);
  margin: 0.5rem 0 0;
}

/* Comparison strip */
.comparison-strip {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comp-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.comp-swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.comp-swatch-flight { background: var(--perception); }
.comp-swatch-a { background: var(--reality); }
.comp-swatch-b { background: var(--gold); }
.comp-swatch-c { background: var(--ink-soft); }

.comp-label { flex: 0 0 9.5rem; color: var(--ink-soft); }
.comp-days { color: var(--perception); font-weight: 600; }

/* 100-person grid */
.person-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin: 1rem 0;
}

.person-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--reality-soft);
}

.person-cell.flew {
  background: var(--perception);
}

.person-cell.super-flier {
  background: var(--perception);
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

/* Mobile: calendar scales to fit the fixed-height sticky panel. The tall
   beat-2 view (year + habit blocks) letterboxes down via preserveAspectRatio. */
@media (max-width: 820px) {
  .calendar-svg {
    width: min(320px, 88vw);
    height: auto;
    max-height: calc(38svh - 3rem);
  }
  .cal-label { font-size: .72rem; margin-top: .3rem; }
  /* Keep each card shorter than the clear zone below the pinned panel.
     (Must live after the base rules above — same specificity.) */
  .step p { font-size: .95rem; line-height: 1.5; padding: .9rem 1.1rem; }
  .haul-toggle { margin: .75rem 0; }
  .haul-btn { padding: .6rem .9rem; }
  .person-grid { max-width: 170px; margin: .75rem 0 0; }
}

/* Short phones: shrink the pinned panel further so every step card still fits
   the clear zone beneath it. MUST come after the max-width:820px block above:
   both set .calendar-svg max-height at equal specificity, so on a short phone
   (matching both queries) source order decides and this tighter cap must win. */
@media (max-width: 820px) and (max-height: 700px) {
  .sticky { height: 34vh; height: 34svh; }
  .calendar-svg { max-height: calc(34svh - 3rem); }
}

@media (max-width: 500px) {
  .haul-toggle {
    flex-direction: column;
  }
  .comp-label {
    flex: 0 0 7rem;
  }
}

/* read-next: curated related essays with one-line summaries */
.read-next { margin-bottom: 2.2rem; }
.read-next p {
  font-size: .92rem;
  color: var(--ink-soft);
  margin: .5rem 0;
  line-height: 1.55;
}
.read-next a { font-weight: 600; }
