/* The case study "How I Built Realm Weather" (/how-i-built-realm-weather/): design H3.1 (PO decisions 116.8–116.11, 144.5).
 * Builds on base.css (tokens, type, buttons) and home.css (the home's top bar and footer).
 * A long-form reading page: one comfortable measure (about 66 characters), a sticky contents rail on wide
 * windows, figures that widen past the text column, and the five decisions set as numbered plates. */

.cs-page { --cs-measure: 680px; --cs-bleed: 280px; }
html { scroll-padding-top: 88px; }

/* ---------- Top bar: the way back home ---------- */
.bar__home { gap: 8px; padding: 0 14px 0 10px; }
.bar__home .icon { width: 18px; height: 18px; }

/* ---------- Hero: a chapter opening over the Realm Weather storm art (116.10), darkened for AA text ---------- */
.cs-hero {
  position: relative; isolation: isolate; overflow: hidden; border-bottom: 1px solid var(--sh-line);
  background:
    radial-gradient(720px 480px at 84% 30%, rgba(142, 27, 36, .28), transparent 68%),
    radial-gradient(520px 360px at 12% 100%, rgba(196, 201, 208, .05), transparent 70%),
    linear-gradient(180deg, #0E0E11, #0B0B0D);
}
.cs-hero::before { /* engraved rings, echoing the seal */
  content: ""; position: absolute; z-index: -1; right: -180px; top: 50%; width: 760px; aspect-ratio: 1; margin-top: -380px; border-radius: 50%; pointer-events: none;
  background: repeating-radial-gradient(circle, transparent 0 44px, rgba(196, 201, 208, .06) 44px 45px);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
}
.cs-hero__rain { /* fine slanted rain streaks over steel: static, drawn in CSS */
  position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .8;
  background:
    repeating-linear-gradient(104deg, transparent 0 22px, rgba(196, 201, 208, .045) 22px 23px, transparent 23px 61px),
    repeating-linear-gradient(104deg, transparent 0 37px, rgba(196, 201, 208, .03) 37px 38px, transparent 38px 89px);
  -webkit-mask: linear-gradient(90deg, transparent 30%, #000 75%); mask: linear-gradient(90deg, transparent 30%, #000 75%);
}
/* The cleared storm-hero art (the same web image as the home banner), set to the right and faded into the dark
 * on its left and bottom edges, then dimmed, so the title, lead and byline stay at AA or better. Static: no motion. */
.cs-hero__art { position: absolute; z-index: -2; top: 0; right: 0; bottom: 0; width: 56%; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, rgba(0, 0, 0, .6) 18%, #000 40%), linear-gradient(0deg, transparent 0, #000 28%);
  mask-image: linear-gradient(90deg, transparent 0, rgba(0, 0, 0, .6) 18%, #000 40%), linear-gradient(0deg, transparent 0, #000 28%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.cs-hero__art img { width: 100%; height: 100%; object-fit: cover; object-position: 28% 30%; }
.cs-hero__art::after { /* the dimming veil: deepest under the text, lightest at the far right */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(11, 11, 13, .8) 0%, rgba(11, 11, 13, .55) 35%, rgba(11, 11, 13, .42) 100%),
    linear-gradient(180deg, rgba(11, 11, 13, .3), transparent 35%);
}
.cs-hero:has(.cs-hero__art)::before { display: none; } /* the drawn rings give way to the art */
.cs-hero__title, .cs-hero__lead, .cs-hero__by, .cs-hero__eyebrow { text-shadow: 0 1px 2px rgba(0, 0, 0, .7), 0 0 24px rgba(0, 0, 0, .55); }
.cs-hero__in { width: min(1280px, 100% - 64px); margin: 0 auto; padding: clamp(48px, 7vw, 104px) 0 clamp(44px, 6vw, 88px); }
.cs-hero__eyebrow { color: var(--sh-red-text); letter-spacing: .3em; font-weight: 700; }
.cs-hero__title { margin-top: 16px; max-width: 16ch; font-size: clamp(2.4rem, 1.2rem + 4vw, 4.75rem); line-height: 1.04; letter-spacing: .03em; }
.cs-hero__lead { margin-top: 26px; max-width: 62ch; font-size: clamp(1.125rem, 1rem + .45vw, 1.375rem); line-height: 1.6; color: var(--sh-text); }
.cs-hero__by { display: flex; align-items: center; gap: 12px; margin-top: 28px; font-family: var(--sh-font-display); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .875rem; color: var(--sh-steel); }
.cs-hero__by img { width: 36px; height: 36px; }

/* ---------- Layout: contents rail + reading column (+ room for wide figures) ---------- */
.cs-layout {
  width: min(1280px, 100% - 64px); margin: 0 auto; padding-top: 56px;
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 64px; align-items: start;
}
.cs { display: grid; grid-template-columns: minmax(0, var(--cs-measure)) minmax(0, var(--cs-bleed)); column-gap: 48px; }
.cs-sec { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-content: start; scroll-margin-top: 88px; }
.cs-sec > * { grid-column: 1; }
.cs-sec > .cs-fig { grid-column: 1 / -1; }
.cs-sec + .cs-sec { margin-top: 72px; padding-top: 56px; border-top: 1px solid var(--sh-line); position: relative; }
.cs-sec + .cs-sec::before { /* the seal's lozenge on every section rule */
  content: ""; position: absolute; left: 0; top: -4px; width: 7px; height: 7px; transform: rotate(45deg); background: var(--sh-red); box-shadow: 0 0 0 1px var(--sh-line-steel);
}

/* Reading type */
.cs-h { font-size: clamp(1.75rem, 1.3rem + 1.3vw, 2.5rem); letter-spacing: .04em; margin-bottom: 22px; }
.cs-sec > p, .hard > p { font-size: 1.125rem; line-height: 1.72; color: var(--sh-text); }
.cs-sec > p + p { margin-top: 1.1em; }
.cs strong { font-weight: 700; color: #FFF; }

/* Contents rail (wide windows) */
.toc { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto; padding-bottom: 16px; }
.toc__h { margin-bottom: 14px; }
.toc__list { display: grid; border-left: 1px solid var(--sh-line); }
.toc__list a {
  display: flex; align-items: center; gap: 8px; min-height: var(--sh-tap); padding: 6px 0 6px 16px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--sh-text-2); text-decoration: none; line-height: 1.3; font-size: .9688rem;
  transition: color 140ms var(--sh-ease), border-color 140ms var(--sh-ease);
}
.toc__list a:hover { color: #FFF; border-left-color: var(--sh-red-text); }
.toc__sub { display: grid; margin: 0 0 6px 16px; }
.toc__sub a { padding-left: 12px; font-size: .875rem; color: var(--sh-muted); border-left: 0; min-height: 36px; }
.toc__sub li a { min-height: var(--sh-tap); }
.toc__sub span { flex: none; width: 2.2em; font-family: var(--sh-font-display); font-weight: 700; color: var(--sh-red-text); font-size: .8125rem; }

/* Contents for narrow windows: a plain disclosure, no script */
.toc-m { display: none; }

/* ---------- My role: the ledger (as on the home page) ---------- */
.cs-ledger { margin-top: 26px; }
.cs-ledger .ledger__item { font-size: 1.0625rem; line-height: 1.62; color: var(--sh-text-2); padding: 16px 0 16px 26px; }
.cs-ledger .ledger__item::before { top: 27px; }
.cs-ledger .ledger__co { font-family: var(--sh-font-body); font-weight: 700; letter-spacing: 0; color: #FFF; }

/* ---------- Figures ---------- */
.cs-fig { margin-top: 40px; }
.cs-fig figcaption { margin-top: 12px; max-width: var(--cs-measure); font-size: .9375rem; line-height: 1.5; color: var(--sh-muted); width: max-content; max-width: min(100%, var(--cs-measure)); }
.shot { position: relative; border: 1px solid var(--sh-line-steel); border-radius: 6px; overflow: hidden; background: #0B0B0D; box-shadow: var(--sh-e3); }
.shot::after { content: ""; position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); pointer-events: none; }
.shot img { width: 100%; height: auto; }

/* The drawn diagram: the team around the product owner, and the order of authority */
.diagram {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1px; overflow: hidden;
  border: 1px solid var(--sh-line); border-radius: 6px; background: var(--sh-line); box-shadow: var(--sh-e2);
}
.diagram > div { padding: 28px 28px 30px; background: var(--sh-brushed); }
.diagram__h { font-family: var(--sh-font-display); font-weight: 500; font-size: .8125rem; letter-spacing: .22em; text-transform: uppercase; color: var(--sh-steel); line-height: 1.3; }

.team__tree { position: relative; display: grid; justify-items: center; margin-top: 22px; }
.team__node {
  position: relative; display: inline-grid; justify-items: center; gap: 2px; padding: 10px 16px; min-width: 140px; text-align: center;
  border: 1px solid var(--sh-line-ui); border-radius: 4px; background: linear-gradient(180deg, #202027, #16161B); box-shadow: var(--sh-bevel);
  font-weight: 600; font-size: .9688rem; line-height: 1.25; color: var(--sh-text);
}
.team__node small { font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sh-red-text); }
.team__node--po { border-color: #B8414A; background: linear-gradient(180deg, var(--sh-red-bright), var(--sh-red) 55%, var(--sh-red-deep)); color: #FFF; padding: 12px 22px; }
.team__me { font-family: var(--sh-font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: .08em; }
.team__node--orch { margin-top: 26px; }
.team__node--po::after, .team__node--orch::after { /* the trunk */
  content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 26px; background: var(--sh-line-steel);
}
.team__roles { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 26px; padding-top: 0; }
.team__roles::before { /* the branch rail */
  content: ""; position: absolute; left: 12.5%; right: 12.5%; top: -13px; height: 1px; background: var(--sh-line-steel);
}
.team__role { position: relative; display: grid; }
.team__role::before { content: ""; position: absolute; left: 50%; top: -13px; width: 1px; height: 13px; background: var(--sh-line-steel); }
.team__role .team__node { min-width: 0; padding: 10px 8px; font-size: .9375rem; }
.team__agents { margin-top: 12px; width: 100%; padding-top: 8px; border-top: 1px dashed var(--sh-line-steel); text-align: center; font-size: .875rem; color: var(--sh-muted); line-height: 1.4; }

.auth__steps { display: grid; gap: 8px; margin-top: 22px; }
.auth__step {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px 8px 8px;
  border: 1px solid var(--sh-line); border-radius: 4px; background: rgba(11, 11, 13, .5); font-weight: 600; font-size: .9688rem; line-height: 1.3;
}
.auth__step:nth-child(2) { margin-left: 16px; } .auth__step:nth-child(3) { margin-left: 32px; } .auth__step:nth-child(4) { margin-left: 48px; }
.auth__step:first-child { border-color: var(--sh-line-ui); }
.auth__n { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--sh-line-ui); font-family: var(--sh-font-body); font-weight: 700; font-size: .875rem; color: var(--sh-steel); }
.auth__step:first-child .auth__n { background: var(--sh-red); border-color: #B8414A; color: #FFF; }
.auth__note { margin-top: 16px; font-size: .9375rem; line-height: 1.5; color: var(--sh-text-2); font-style: italic; }

/* ---------- Decisions that shaped it: five numbered plates ---------- */
.decisions { display: grid; gap: 14px; counter-reset: none; }
.decision {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 20px; align-items: start; scroll-margin-top: 88px;
  padding: 22px 26px 24px 20px; border: 1px solid var(--sh-line); border-radius: 6px; background: var(--sh-brushed); box-shadow: var(--sh-e2);
}
.decision::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(196, 201, 208, .07); border-radius: 3px; pointer-events: none; }
.decision__n {
  grid-row: 1 / span 2; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--sh-line-ui); box-shadow: 0 0 0 4px rgba(11, 11, 13, .6), 0 0 0 5px var(--sh-line);
  font-family: var(--sh-font-display); font-weight: 700; font-size: 1.0625rem; letter-spacing: .02em; color: var(--sh-text);
  background: radial-gradient(circle at 50% 35%, #2A2A32, #141418);
}
.decision__h { font-family: var(--sh-font-display); font-weight: 700; font-size: clamp(1.1875rem, 1.05rem + .4vw, 1.375rem); line-height: 1.25; letter-spacing: .03em; color: #FFF; padding-top: 3px; }
.cs .decision__p { margin-top: 8px; font-size: 1.0625rem; line-height: 1.66; color: var(--sh-text-2); }
.cs .decision__p strong { color: var(--sh-text); }

/* ---------- The hard parts ---------- */
.hard + .hard { margin-top: 36px; }
.hard__h { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-family: var(--sh-font-display); font-weight: 700; font-size: clamp(1.1875rem, 1.05rem + .4vw, 1.375rem); line-height: 1.25; letter-spacing: .03em; color: #FFF; }
.hard__h .icon { width: 40px; height: 40px; padding: 8px; border: 1px solid var(--sh-line-ui); border-radius: 50%; color: var(--sh-steel); stroke-width: 1.4; background: radial-gradient(circle at 50% 35%, #24242B, #141418); }

/* ---------- What it does ---------- */
.cs-sec > .does { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.does__item {
  position: relative; padding: 16px 18px 16px 40px; border: 1px solid var(--sh-line); border-radius: 6px; background: rgba(19, 19, 23, .7);
  font-size: 1.0313rem; line-height: 1.58; color: var(--sh-text-2);
}
.does__item::before { content: ""; position: absolute; left: 18px; top: 25px; width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid var(--sh-red-text); }
.does__item strong { display: block; margin-bottom: 2px; font-family: var(--sh-font-display); font-weight: 700; letter-spacing: .04em; font-size: 1rem; color: #FFF; }

/* ---------- Results: the lesson as a plate ---------- */
.cs-sec > p.lesson {
  margin-top: 28px; padding: 24px 28px; border: 1px solid var(--sh-line); border-left: 3px solid var(--sh-red); border-radius: 0 6px 6px 0;
  background: radial-gradient(420px 200px at 0% 0%, rgba(142, 27, 36, .18), transparent 70%), var(--sh-brushed);
  font-size: clamp(1.125rem, 1.02rem + .35vw, 1.3125rem); line-height: 1.62; font-style: italic;
}

/* ---------- The end: connect ---------- */
.cs-end { margin-top: 96px; border-block: 1px solid var(--sh-line); background: radial-gradient(560px 300px at 50% 0%, rgba(142, 27, 36, .2), transparent 70%), var(--sh-brushed); }
.cs-end__in { width: min(760px, 100% - 48px); margin: 0 auto; padding: 56px 0 60px; display: grid; justify-items: center; gap: 18px; text-align: center; }
.cs-end__seal { width: 96px; height: 96px; filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .8)); }
.cs-end__name { font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.6rem); letter-spacing: .05em; }
.cs-end__ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 8px; }

/* ---------- Narrower windows ---------- */
@media (max-width: 1279px) {
  .cs { grid-template-columns: minmax(0, var(--cs-measure)) minmax(0, 1fr); column-gap: 32px; }
}
@media (max-width: 1099px) {
  .cs-layout { display: block; width: min(var(--cs-measure), 100% - 64px); padding-top: 28px; }
  .toc { display: none; }
  .cs { display: block; }
  .cs-sec { display: block; }
  .toc-m { display: block; width: min(var(--cs-measure), 100% - 64px); margin: 28px auto 0; border: 1px solid var(--sh-line); border-radius: 6px; background: var(--sh-brushed); }
  .toc-m summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 18px; cursor: pointer; list-style: none;
    font-family: var(--sh-font-display); font-weight: 700; font-size: .8125rem; letter-spacing: .2em; text-transform: uppercase; color: var(--sh-steel);
  }
  .toc-m summary::-webkit-details-marker { display: none; }
  .toc-m summary .icon { width: 18px; height: 18px; transform: rotate(90deg); transition: transform 140ms var(--sh-ease); }
  .toc-m[open] summary .icon { transform: rotate(-90deg); }
  .toc-m .toc__list { margin: 0 18px 14px; }
}
@media (max-width: 900px) {
  .diagram { grid-template-columns: 1fr; }
}
/* Tablets: the text runs wider than the art's fade, so the art narrows and the veil deepens under the lead. */
@media (min-width: 761px) and (max-width: 1099px) {
  .cs-hero__art { width: 50%; }
  .cs-hero__art::after { background: linear-gradient(90deg, rgba(11, 11, 13, .9) 0%, rgba(11, 11, 13, .74) 50%, rgba(11, 11, 13, .5) 100%), linear-gradient(180deg, rgba(11, 11, 13, .3), transparent 35%); }
}
@media (max-width: 760px) {
  .cs-page { scroll-padding-top: 72px; }
  .bar__home { padding: 0 12px 0 8px; }
  .cs-hero__in { width: calc(100% - 32px); }
  .cs-hero::before { width: 480px; margin-top: -240px; right: -260px; }
  /* Phones: the art becomes a band across the top (the figure and the lightning), fading into the dark behind the title. */
  .cs-hero__art { left: 0; width: 100%; bottom: auto; height: 300px;
    -webkit-mask-image: linear-gradient(180deg, #000 40%, transparent 100%); mask-image: linear-gradient(180deg, #000 40%, transparent 100%); }
  .cs-hero__art img { object-position: 25% 15%; }
  .cs-hero__art::after { background: linear-gradient(180deg, rgba(11, 11, 13, .25) 0%, rgba(11, 11, 13, .4) 40%, rgba(11, 11, 13, .86) 62%, rgba(11, 11, 13, .96) 100%); }
  .cs-hero { background: radial-gradient(420px 320px at 92% 88%, rgba(142, 27, 36, .22), transparent 70%), linear-gradient(180deg, #0E0E11, #0B0B0D); }
  .cs-hero__in { padding-top: 196px; }
  .cs-layout, .toc-m { width: calc(100% - 32px); }
  .cs-sec { scroll-margin-top: 72px; }
  .cs-sec + .cs-sec { margin-top: 52px; padding-top: 40px; }
  .cs-sec > p, .hard > p { font-size: 1.0625rem; line-height: 1.68; }
  .decision { grid-template-columns: 1fr; padding: 18px 18px 20px; }
  .decision__n { grid-row: auto; width: 40px; height: 40px; font-size: .9375rem; margin-bottom: 12px; }
  .cs-sec > .does { grid-template-columns: 1fr; }
  .diagram > div { padding: 22px 16px 24px; }
  .team__roles { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .team__roles::before { left: 25%; right: 25%; }
  .team__role:nth-child(n+3)::before { display: none; }
  .auth__step:nth-child(2) { margin-left: 10px; } .auth__step:nth-child(3) { margin-left: 20px; } .auth__step:nth-child(4) { margin-left: 30px; }
  .cs-sec > p.lesson { padding: 20px 18px; }
  .cs-end { margin-top: 64px; }
  .cs-end__in { padding: 44px 0 48px; }
  .cs-end__ctas, .cs-end__ctas .btn { width: 100%; }
}
/* Phones: the same screens, captured on a phone, in a slim steel frame (art direction via <picture>). */
@media (max-width: 600px) {
  .cs-fig--shot .shot { width: min(300px, 86%); margin-inline: auto; border-radius: 26px; border: 1px solid var(--sh-line-ui); padding: 7px; background: linear-gradient(180deg, #23232A, #121216); }
  .cs-fig--shot .shot::after { border-radius: 26px; }
  .cs-fig--shot .shot img { border-radius: 19px; }
  .cs-fig--shot figcaption { margin-inline: auto; text-align: center; width: auto; }
}

/* ---------- The fan-content notices at the foot (decision 145.8): small print, the app's words ---------- */
.foot__notices { display: grid; gap: 8px; max-width: 64ch; margin-top: 6px; }
