/* ============================================================
   Rohit Mehta — v14 "Ember"
   Light and dark themes (auto, with a switch), and a sunrise glow at the end of every page. Newsreader for display,
   Hanken Grotesk for reading. An editorial layout: headings and
   notes live in a left margin, text sits in a narrow column, and
   images are allowed to run wide. One dark band, at the foot.
   ============================================================ */

:root {
  /* cool light-grey page, neutral ink */

  /* Sunrise: red to orange to amber */
  --accent: #E0372B;
  --grad: linear-gradient(90deg, #E5322D 0%, #F2682F 55%, #F7A24B 100%);
  --glow: rgba(242, 104, 47, 0.55);
  --glow-soft: rgba(242, 104, 47, 0.12);
  --glow-1: #E8302B;
  --glow-2: #F79A45;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", -apple-system, "Helvetica Neue", Arial, sans-serif;

  --wrap: 1120px;
  --margin-col: 220px;
  --text-col: 700px;
  --gutter: clamp(1.25rem, 5vw, 4rem);
}

/* ---------- Themes: light, dark, and auto (follows the system) ---------- */

:root {
  color-scheme: light;
  --paper: #FBFAF8;
  --paper-2: #F0EEEA;
  --ink: #111114;
  --body: #3D3D44;
  --muted: #6B6B73;
  --line: rgba(17, 17, 20, 0.13);
  --rule: #111114;
  --accent: #D93A22;
  --foot-ink: #111114;
  --colophon: rgba(17, 17, 20, 0.62);
  --shadow: 0 20px 50px -26px rgba(17, 17, 20, 0.35);
  --sun: radial-gradient(240% 100% at 50% 106%, #F9A55F 0%, #FB8C4C 10%, #FDA57A 24%, rgba(255, 205, 178, 0.8) 46%, rgba(255, 229, 213, 0.4) 72%, transparent 100%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #060607;
    --paper-2: #121214;
    --ink: #F6F3EF;
    --body: #C9C5BF;
    --muted: #A29E98;
    --line: rgba(255, 255, 255, 0.12);
    --rule: rgba(255, 255, 255, 0.38);
    --accent: #E0372B;
    --foot-ink: #FFFFFF;
    --colophon: rgba(255, 255, 255, 0.88);
    --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
    --sun: radial-gradient(240% 100% at 50% 106%, #F6B070 0%, #F58A3A 9%, #E8561C 19%, #B82004 31%, #6B1706 47%, rgba(34, 9, 4, 0.75) 68%, transparent 100%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #060607;
  --paper-2: #121214;
  --ink: #F6F3EF;
  --body: #C9C5BF;
  --muted: #A29E98;
  --line: rgba(255, 255, 255, 0.12);
  --rule: rgba(255, 255, 255, 0.38);
  --accent: #E0372B;
  --foot-ink: #FFFFFF;
  --colophon: rgba(255, 255, 255, 0.88);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --sun: radial-gradient(240% 100% at 50% 106%, #F6B070 0%, #F58A3A 9%, #E8561C 19%, #B82004 31%, #6B1706 47%, rgba(34, 9, 4, 0.75) 68%, transparent 100%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--paper); scroll-padding-top: 1.5rem; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--body);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; height: auto; }
::selection { background: var(--accent); color: #fff; }

.wrap { max-width: calc(var(--wrap) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Bar ---------- */

.bar { display: flex; align-items: baseline; justify-content: space-between; padding: 1.6rem 0 0; }
.brand { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); letter-spacing: -0.005em; }
.bar nav { display: flex; gap: 1.8rem; font-size: 0.9rem; }
.bar nav a { color: var(--muted); transition: color 0.2s ease; }
.bar nav a:hover { color: var(--ink); }
.bar nav a.say { color: var(--ink); border-bottom: 1px solid var(--accent); }
.back { font-size: 0.9rem; color: var(--muted); }
.back:hover { color: var(--ink); }

/* ---------- Intro (home) ---------- */

.intro { padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(3rem, 6vw, 5rem); }
.kicker { font-size: 0.9rem; color: var(--muted); }

.intro h1, .title h1 {
  margin-top: 1.1rem;
  max-width: 17.5em;
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(2.4rem, 3.4vw + 1rem, 3.5rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  color: var(--ink);
  font-variation-settings: "opsz" 72;
}

.intro h1 em, .title h1 em { font-style: italic; color: var(--accent); }

.intro-cols { margin-top: 2.4rem; display: grid; grid-template-columns: var(--margin-col) minmax(0, var(--text-col)); gap: 3rem; }
.intro-cols p { font-size: 1.15rem; line-height: 1.7; color: var(--body); }
.intro-cols p + p { margin-top: 1rem; }
.intro-cols .note { font-size: 0.875rem; line-height: 1.6; color: var(--muted); }

/* ---------- Editorial rows: margin heading + text column ---------- */

.sect { border-top: 1px solid var(--line); padding: 2.2rem 0 3.2rem; display: grid; grid-template-columns: var(--margin-col) minmax(0, 1fr); gap: 3rem; }
.sect > h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5625rem;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.008em;
}
.sect > h2 small { display: block; margin-top: 0.4rem; font-family: var(--sans); font-size: 0.8125rem; line-height: 1.6; color: var(--muted); letter-spacing: 0; }
.sect.sticky > h2 { position: sticky; top: 1.5rem; align-self: start; }

.text { max-width: var(--text-col); }
.text p + p { margin-top: 1.1rem; }
.text h3 { margin-top: 2.2rem; font-family: var(--serif); font-weight: 400; font-size: 1.375rem; line-height: 1.35; color: var(--ink); }
.text h3:first-child { margin-top: 0; }
.lead { font-family: var(--serif); font-size: 1.4rem; line-height: 1.5; color: var(--ink); font-weight: 350; letter-spacing: -0.005em; }

/* ---------- Work ledger ---------- */

.co { padding: 0; }
.co + .co { margin-top: 2.6rem; }

.co-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: 0.7rem; }
.co-head h3 { font-family: var(--serif); font-weight: 400; font-size: 1.5625rem; line-height: 1.3; color: var(--ink); }
.co-head span { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.ledger { counter-reset: r; border-top: 1px solid var(--rule); }

.item {
  counter-increment: r;
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.item::before { content: counter(r, decimal-leading-zero); font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.item .t { font-family: var(--serif); font-size: 1.4rem; line-height: 1.3; color: var(--ink); letter-spacing: -0.008em; transition: color 0.2s ease; }
.item .d { grid-column: 2; font-size: 0.9rem; line-height: 1.6; color: var(--muted); }
.item .arr { grid-row: 1; grid-column: 3; font-size: 0.85rem; color: var(--accent); opacity: 0; transform: translateX(-6px); transition: opacity 0.2s ease, transform 0.2s ease; }
a.item:hover .t { color: var(--accent); }
a.item:hover .arr { opacity: 1; transform: none; }
.item.soon .t, .item.soon::before { color: var(--muted); }

/* ---------- Experience ---------- */

.xp li { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.xp li:first-child { border-top: 1px solid var(--rule); }
.xp .y { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.xp .r { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); line-height: 1.4; }
.xp .r span { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); margin-left: 0.6rem; }

/* ---------- Case study: title, hero image, margin notes ---------- */

.title { padding: clamp(3rem, 7vw, 5.5rem) 0 0; }
.title .sub { margin-top: 1.4rem; max-width: 34em; font-family: var(--serif); font-size: 1.35rem; line-height: 1.5; color: var(--body); font-weight: 350; }
.title .tags { margin-top: 1.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.875rem; color: var(--muted); }

.hero-shot { margin-top: 3rem; }
.hero-shot img { width: 100%; border: 1px solid var(--line); background: #fff; }

.notes { display: grid; gap: 1.2rem; font-size: 0.875rem; line-height: 1.6; color: var(--muted); }
.notes b { display: block; font-weight: 600; font-size: 0.8125rem; color: var(--ink); line-height: 1.5; }
.sect.sticky > .notes { position: sticky; top: 1.5rem; align-self: start; }

.steps { margin-top: 1.4rem; counter-reset: s; border-top: 1px solid var(--rule); }
.steps li { counter-increment: s; display: grid; grid-template-columns: 3rem minmax(0, 1fr); padding: 1rem 0; border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(s); font-family: var(--serif); font-size: 1.7rem; line-height: 1.1; color: var(--accent); }

/* ---------- Figures ---------- */

figure.shot { margin-top: 3rem; }
figure.shot:first-of-type { margin-top: 0; }
figure.shot img { width: 100%; border: 1px solid var(--line); background: #fff; }
figure.shot figcaption { margin-top: 0.7rem; display: grid; grid-template-columns: 2.4rem minmax(0, var(--text-col)); font-size: 0.875rem; line-height: 1.6; color: var(--muted); }
figure.shot figcaption b { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--accent); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 3rem; }
.pair figure.shot { margin-top: 0; }
.pair figure.shot figcaption { grid-template-columns: 2.4rem 1fr; }

.wide { padding-bottom: 3rem; }
.wide > h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5625rem; line-height: 1.3; color: var(--ink); border-top: 1px solid var(--line); padding-top: 2.2rem; }
.wide > p.lead { margin-top: 0.8rem; max-width: 36em; }
.wide .figs { margin-top: 2.2rem; }

.takes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.take h3 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; line-height: 1.35; color: var(--ink); }
.take p { margin-top: 0.5rem; font-size: 0.94rem; line-height: 1.7; }
.take { padding-top: 1rem; border-top: 1px solid var(--rule); }

/* ---------- Next / previous ---------- */

.pn { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); }
.pn a { display: block; padding: 1.6rem 0 1.8rem; }
.pn a + a { padding-left: 2rem; border-left: 1px solid var(--line); text-align: right; padding-right: 0; padding-left: 0; }
.pn small { display: block; font-size: 0.8125rem; color: var(--muted); }
.pn b { display: block; margin-top: 0.2rem; font-family: var(--serif); font-weight: 400; font-size: 1.5rem; line-height: 1.3; color: var(--ink); transition: color 0.2s ease; }
.pn a:hover b { color: var(--accent); }

/* ---------- Foot (the one dark band) ---------- */

.foot { margin-top: 4rem; background: var(--paper); color: var(--ink); padding: clamp(3rem, 6vw, 5rem) 0 2.2rem; }
.foot .big { display: inline-block; font-family: var(--serif); font-weight: 350; font-size: clamp(2.2rem, 4.4vw + 0.5rem, 4.2rem); line-height: 1.1; letter-spacing: -0.02em; border-bottom: 1px solid rgba(237, 232, 220, 0.35); transition: border-color 0.2s ease, color 0.2s ease; }
.foot .big:hover { border-color: var(--accent); }
.foot .big { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 480px) { .foot .big { font-size: clamp(1.5rem, 6.4vw, 2.2rem); } }
.foot .cols { margin-top: 3rem; display: flex; flex-wrap: wrap; gap: 1.5rem 4rem; font-size: 0.9rem; color: var(--foot-ink); }
.foot .cols a:hover { opacity: 0.75; }
.foot .colophon { margin-top: 2.2rem; font-size: 0.78rem; color: var(--colophon); text-shadow: 0 1px 10px rgba(90, 20, 4, 0.35); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .intro-cols, .sect { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
  .sect.sticky > h2, .sect.sticky > .notes { position: static; }
  .pair, .takes { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .bar nav { gap: 1.1rem; }
  .xp li { grid-template-columns: 1fr; gap: 0.1rem; }
  .item { grid-template-columns: 2rem minmax(0, 1fr); }
  .item .arr { display: none; }
  .pn { grid-template-columns: 1fr; }
  .pn a + a { border-left: 0; border-top: 1px solid var(--line); text-align: left; }
}

.sect .takes { grid-template-columns: 1fr; gap: 1.4rem; max-width: var(--text-col); }
.sect .take { padding-top: 1rem; }

/* ============================================================
   Where the red shows up. The red itself (--accent, --grad,
   --glow) is defined with the other tokens at the top.
   ============================================================ */

/* ---- where the red shows up ---- */
body { overflow-x: clip; }
body::before { content: ""; position: fixed; z-index: 40; left: 0; right: 0; top: 0; height: 3px; background: var(--grad); }

.intro { position: relative; }

.intro h1 em, .title h1 em {
  font-style: italic; color: var(--accent);
  background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  padding: 0 0.08em; margin: 0 -0.08em;
}

.bar nav a.say { border-bottom: 0; background: var(--grad) left bottom / 100% 1px no-repeat; padding-bottom: 2px; }
.steps li::before { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.ledger, .xp li:first-child { border-top-color: var(--ink); }
.co-head h3 { position: relative; }

.foot { background: transparent; border-top: 0; padding-bottom: 4.5rem; }
.foot .big { border-bottom-color: var(--rule); }
.foot .big:hover { border-color: var(--accent); }

/* ---------- Components used by the converted case studies ---------- */

.figs-block { padding: 0.5rem 0 3.2rem; }
.figs-block figure.shot:first-child, .figs-block .pair:first-child { margin-top: 0; }
.figs-block + .sect { margin-top: 0; }

.pq { max-width: var(--text-col); font-family: var(--serif); font-weight: 350; font-style: italic; font-size: clamp(1.5rem, 1.4vw + 1rem, 2rem); line-height: 1.35; color: var(--ink); letter-spacing: -0.01em; padding-left: 1.4rem; border-left: 3px solid transparent; border-image: linear-gradient(180deg, #E5322D, #F7A24B) 1; }
.pq + .attrib { margin-top: 1rem; padding-left: 1.4rem; font-size: 0.9rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 2rem; max-width: var(--text-col); }
.stat { padding-top: 0.9rem; border-top: 1px solid var(--rule); }
.stat .v { font-family: var(--serif); font-weight: 350; font-size: clamp(1.7rem, 1.2vw + 1.2rem, 2.3rem); line-height: 1.1; letter-spacing: -0.02em; color: var(--ink); }
.stat .k { margin-top: 0.4rem; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.stats + .stats { margin-top: 2rem; }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr 1fr; } }

.text > .stats:first-child { margin-top: 0; }
.text p.lead + p { margin-top: 1.1rem; }
.text .steps { margin-top: 1.4rem; }
.hero-shot figcaption { margin-top: 0.7rem; font-size: 0.875rem; color: var(--muted); }

/* ============================================================
   Ember: the page glow. A fixed layer behind everything, black at
   the top, rising through deep red and orange to a pale hot edge
   at the bottom of the viewport.
   ============================================================ */

body { position: relative; }
body::after {
  content: ""; position: absolute; z-index: -1; left: 0; right: 0; bottom: 0; height: 640px; pointer-events: none;
  background: var(--sun);
}

/* ---------- Theme switch ---------- */

.bar-r { display: flex; align-items: baseline; gap: 1.6rem; }
.theme { appearance: none; background: none; border: 0; padding: 0; font: inherit; font-size: 0.9rem; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 0.45rem; transition: color 0.2s ease; }
.theme:hover { color: var(--ink); }
.theme .ico { width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 1.5px solid currentColor; flex: none; transform: translateY(1px); }
.theme[data-mode="auto"] .ico { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.theme[data-mode="dark"] .ico { background: currentColor; }
.theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* ---------- The glow, explained ---------- */

.sunrise-note { margin-top: 2.6rem; max-width: 34rem; font-size: 0.9rem; line-height: 1.65; color: var(--foot-ink); }
.sunrise-note b { display: block; margin-bottom: 0.2rem; font-family: var(--serif); font-weight: 400; font-size: 1.1rem; }
.sunrise-note .dv { font-family: "Noto Serif Devanagari", "Kohinoor Devanagari", "Devanagari Sangam MN", serif; }
.hero-shot img, figure.shot img { box-shadow: var(--shadow); }
.item .t, .pn b { text-shadow: none; }
