/* ============ 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;
  display: flex;
  align-items: center;
  grid-column: 1;
  grid-row: 1;
}

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

.steps { grid-column: 2; grid-row: 1; }

.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-list { font-family: var(--mono); font-size: .74rem; line-height: 2; }

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

@media (max-width: 820px) {
  .scrolly { grid-template-columns: 1fr; }
  .sticky { position: sticky; top: 0; height: auto; align-self: start; grid-column: 1;
            z-index: 1; background: var(--paper); align-items: flex-start;
            padding: .5rem 0 .75rem; }
  .steps { grid-column: 1; }
  .step { min-height: 70vh; }
  .step p { font-size: 1rem; }
}

/* 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; }

/* ---------- footprint controls ---------- */

.ctl { margin-top: 1rem; }
.ctl .chart-toggle { margin-bottom: .8rem; background: var(--paper); flex-wrap: wrap; }
.ctl .gw-row { display: flex; align-items: center; gap: 1rem; }
.ctl input[type=range] { flex: 1; accent-color: var(--perception); height: 2rem; }
.ctl-value {
  font-family: var(--mono);
  font-size: .8rem;
  min-width: 7ch;
  color: var(--perception);
  font-weight: 600;
}

.stepper { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.stepper-label { font-family: var(--mono); font-size: .74rem; flex: 1; }
.stepper button {
  font-family: var(--mono);
  font-size: 1rem;
  width: 2rem; height: 2rem;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
}
.stepper button:hover { background: var(--perception); }
.stepper-value {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  min-width: 2ch;
  text-align: center;
}

#share-btn {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .06em;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: .6rem 1.1rem;
  cursor: pointer;
}
#share-btn:hover { background: var(--reality); }
#share-done { font-family: var(--mono); font-size: .72rem; color: var(--ink-soft); margin-left: .6rem; word-break: break-all; }

/* ---------- city picker ---------- */

.city-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  max-width: 34em;
  margin: 0 auto 2.2rem;
}
.city-picker button {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .04em;
  padding: .55rem 1rem;
  background: none;
  border: 1px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
}
.city-picker button:hover { background: var(--perception); border-color: var(--perception); color: var(--paper); }
.city-picker button.on { background: var(--ink); color: var(--paper); }
