/* ==========================================================================
   The 7 GenAI Architectures - book portal
   Palette sampled directly from images/7-genai-architectures-front-cover.jpg.
   One theme, matching the printed object.
   ========================================================================== */

:root {
  --ground:   #F2EFE6;
  --ground-2: #E9E5D9;
  --ink:      #15161A;
  --ink-soft: #55534B;
  --rule:     #CFC9BA;
  --accent:   #D13B2D;

  --s0: #15161A;
  --s1: #6B3FA0;
  --s2: #2C3F9E;
  --s3: #1F7FD5;
  --s4: #2FA14A;
  --s5: #F0B324;
  --s6: #E8722C;
  --s7: #D13B2D;

  --page:    1120px;
  --measure: 68ch;
  --gap:     clamp(1.25rem, 4vw, 2.5rem);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gap);
}

/* ---------- type ---------- */

h1, h2, h3 { margin: 0; line-height: 1.08; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(2.6rem, 7.5vw, 4.6rem); letter-spacing: -0.03em; }
.h1-line { display: block; }
h2 { font-size: clamp(1.55rem, 3.4vw, 2.3rem); }
h3 { font-size: 1.125rem; letter-spacing: -0.01em; }
p  { margin: 0 0 1rem; }

.eyebrow {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-block;
}
.eyebrow i { font-style: normal; opacity: 0.45; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--ground-2);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.small { font-size: 0.9375rem; color: var(--ink-soft); }
.prose { max-width: var(--measure); }
.footnote { font-size: 0.875rem; color: var(--ink-soft); margin-top: 0.75rem; }

/* ---------- masthead ---------- */

.spectrum { display: flex; height: 10px; }
.spectrum i { flex: 1; }

.masthead { border-bottom: 1px solid var(--rule); }
.masthead__row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding-block: 0.9rem;
}
.masthead__right { text-align: right; }

/* ---------- sticky buy bar ---------- */

.buybar {
  position: fixed; inset-inline: 0; top: 0; z-index: 50;
  background: rgba(242, 239, 230, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  transform: translateY(-102%);
  transition: transform 0.25s ease;
}
body.is-scrolled .buybar { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .buybar { transition: none; } }

.buybar__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 0.55rem;
}
.buybar__title { font-weight: 700; letter-spacing: -0.02em; }
.buybar__links { display: flex; gap: 0.5rem; }
@media (max-width: 560px) { .buybar__title { display: none; } .buybar__row { justify-content: center; } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  gap: 0.1rem;
  padding: 0.7rem 1.2rem;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn span {
  font-family: var(--font-mono); font-size: 0.6rem; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.65;
}
.btn:hover { background: var(--ink); color: var(--ground); }
.btn--solid { background: var(--ink); color: var(--ground); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); }
.btn--sm { flex-direction: row; align-items: center; padding: 0.4rem 0.85rem; font-size: 0.875rem; }
.btn--invert { border-color: var(--ground); color: var(--ground); }
.btn--invert:hover { background: var(--ground); color: var(--ink); }
.btn--invert.btn--solid { background: var(--ground); color: var(--ink); }
.btn--invert.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--ground); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.buys { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.75rem 0 1.25rem; }
.buys--center { justify-content: center; margin-top: 2rem; }

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}
.hero__art img {
  border: 1px solid var(--rule);
  box-shadow: 0 18px 40px -20px rgba(21, 22, 26, 0.45);
}
.deck {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: var(--ink-soft);
  margin-top: 1.1rem;
  max-width: 34ch;
}
.thesis {
  margin: 1.75rem 0 0;
  padding-left: 1.1rem;
  border-left: 4px solid var(--accent);
  font-size: clamp(1rem, 1.8vw, 1.15rem);
  font-weight: 500;
  max-width: 46ch;
}
.hero__meta { margin-top: 0.5rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero__art { max-width: 300px; margin-inline: auto; }
  .deck, .thesis { max-width: none; }
}

/* ---------- bands ---------- */

.band { padding-block: clamp(3rem, 7vw, 5rem); }
.band--dark { background: var(--ink); color: var(--ground); }
.band--dark .eyebrow { color: rgba(242, 239, 230, 0.6); }
.band--dark a { color: var(--s5); }
.band--close { background: var(--ink); color: var(--ground); text-align: center; }
.band--close .prose { max-width: 56ch; margin-inline: auto; }
.band--stat { background: var(--ground-2); border-block: 1px solid var(--rule); }

.lede { font-size: clamp(1.35rem, 3vw, 1.9rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.pull {
  font-size: clamp(1.1rem, 2.2vw, 1.4rem); font-weight: 500; font-style: italic;
  border-left: 4px solid var(--accent); padding-left: 1.1rem; margin-block: 1.5rem;
}
.band--close .pull, .closer { font-weight: 700; }
.closer { font-size: 1.15rem; }

/* ---------- sections ---------- */

.section { padding-block: clamp(3rem, 7vw, 5rem); }
.section__head { max-width: 62ch; margin-bottom: 2.25rem; }
.section__head h2 { margin-top: 0.65rem; }
.section__sub { color: var(--ink-soft); margin-top: 0.9rem; }

/* ---------- the ladder ---------- */

.expand {
  margin-top: 1.25rem;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 2px;
  padding: 0.5rem 0.9rem; cursor: pointer;
}
.expand:hover { color: var(--ink); border-color: var(--ink); }

.ladder { list-style: none; margin: 0; padding: 0; }

.rung { margin-bottom: 0.5rem; }
/* the staircase: each rung steps in, capped so the top rung never crushes */
.rung[data-i="1"] { margin-left: 1.2%; }
.rung[data-i="2"] { margin-left: 2.4%; }
.rung[data-i="3"] { margin-left: 3.6%; }
.rung[data-i="4"] { margin-left: 4.8%; }
.rung[data-i="5"] { margin-left: 6.0%; }
.rung[data-i="6"] { margin-left: 7.2%; }
.rung[data-i="7"] { margin-left: 8.4%; }
@media (max-width: 640px) { .rung[data-i] { margin-left: 0; } }

.rung details {
  border: 1px solid var(--rule);
  border-left: 6px solid var(--c);
  background: #F7F5EF;
}
.rung details[open] { background: #FBFAF6; }

.rung summary {
  display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap;
  padding: 0.95rem 1.1rem;
  cursor: pointer;
  list-style: none;
}
.rung summary::-webkit-details-marker { display: none; }
.rung summary::marker { content: ""; }
.rung summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem;
  color: var(--ink-soft);
}
.rung details[open] summary::after { content: "\2212"; }
.rung summary:hover { background: rgba(21, 22, 26, 0.03); }

.rung__lv {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--c);
  min-width: 4.6rem;
}
.rung__nm { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; }
.rung__cost {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.rung__cost b { color: var(--ink); }
.rung__cost i { font-style: normal; opacity: 0.45; }

.rung__body { padding: 0 1.1rem 1.25rem; border-top: 1px solid var(--rule); }
.rung__body dl { margin: 1.1rem 0 0; display: grid; gap: 0.35rem; }
.rung__body dt {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
  margin-top: 0.85rem;
}
.rung__body dt:first-child { margin-top: 0; }
.rung__body dd { margin: 0; max-width: var(--measure); }
.rung__body code { background: var(--ground-2); }
.risk, .note {
  margin: 1.15rem 0 0; padding-top: 0.85rem; border-top: 1px dashed var(--rule);
  font-size: 0.9375rem; color: var(--ink-soft);
}
.risk .eyebrow { margin-right: 0.6rem; }
.note { border-top-style: dotted; font-style: italic; }

/* ---------- stat ---------- */

.stat { display: grid; grid-template-columns: auto 1fr; gap: clamp(1.5rem, 5vw, 3.5rem); align-items: center; }
.stat__fig { text-align: center; }
.stat__n {
  display: block;
  font-size: clamp(3rem, 9vw, 5rem); font-weight: 700; line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--s6);
}
.stat__txt { max-width: var(--measure); }
.stat__txt p:last-child { margin-bottom: 0; }
@media (max-width: 700px) { .stat { grid-template-columns: 1fr; text-align: left; } .stat__fig { text-align: left; } }

/* ---------- cards ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.card {
  border: 1px solid var(--rule); border-top: 4px solid var(--accent);
  padding: 1.4rem; background: #F7F5EF;
}
.card h3 { margin: 0.6rem 0 0.75rem; }
.card p:last-child { margin-bottom: 0; }

/* ---------- procedure table ---------- */

.tablewrap { overflow-x: auto; }
.proc { width: 100%; border-collapse: collapse; font-size: 0.9375rem; min-width: 480px; }
.proc th, .proc td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule); }
.proc thead th {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 2px solid var(--ink);
}
.proc td:first-child { font-family: var(--font-mono); color: var(--ink-soft); width: 2.5rem; }
.proc td:last-child { white-space: nowrap; font-weight: 500; }
.proc tbody tr:hover { background: var(--ground-2); }

/* ---------- six columns ---------- */

/* six items, so a fixed 3 x 2 rather than auto-fit - auto-fit orphans the last
   one on its own row at most desktop widths */
.cols {
  list-style: none; margin: 0 0 1.75rem; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem;
}
@media (max-width: 760px) { .cols { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .cols { grid-template-columns: 1fr; } }
.cols li {
  border: 1px solid var(--rule); border-left: 3px solid var(--s3);
  padding: 0.65rem 0.9rem;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  background: #F7F5EF;
}

/* ---------- readers ---------- */

.readers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; margin-top: 1.5rem; }
.readers h3 { margin-bottom: 0.6rem; }
.readers p { color: rgba(242, 239, 230, 0.78); margin-bottom: 0; }
.readers__note {
  margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid rgba(242, 239, 230, 0.2);
  max-width: var(--measure); color: rgba(242, 239, 230, 0.78);
}

/* ---------- contents ---------- */

.toc { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; }
.toc__part ol { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.toc__part li { padding: 0.4rem 0; border-bottom: 1px solid var(--rule); font-size: 0.9375rem; }
.toc__part b {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-soft);
  margin-right: 0.55rem;
}
.appendices { margin-top: 2.25rem; padding-top: 1.5rem; border-top: 2px solid var(--ink); }
.appendices ul {
  list-style: none; margin: 0.75rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.5rem;
}
.appendices li { font-size: 0.9375rem; }
.appendices b { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); margin-right: 0.55rem; }

/* ---------- code box ---------- */

.codebox {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(1.5rem, 4vw, 3rem); align-items: center;
  border: 1px solid var(--rule); background: #F7F5EF; padding: clamp(1.5rem, 4vw, 2.5rem);
}
.codebox h2 { margin: 0.6rem 0 1rem; }
.codebox__code {
  margin: 0; padding: 1.25rem;
  background: var(--ink); color: var(--ground);
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.7;
  border-radius: 2px;
  /* wrap rather than scroll - the clone URL is longer than the column, and a
     clipped command reads as a broken page */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* the inline `code` chip style must not apply inside the dark block */
.codebox__code code {
  background: none; color: inherit; padding: 0; font-size: inherit;
}
.codebox .btn { margin-top: 0.5rem; font-size: 0.875rem; }

/* ---------- author ---------- */

.author { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2.5rem; }
.author h2 { margin: 0.6rem 0 0.9rem; }
.errata { border-left: 3px solid var(--rule); padding-left: 1.5rem; }
@media (max-width: 640px) { .errata { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 1.5rem; } }

/* ---------- footer ---------- */

.foot { border-top: 1px solid var(--rule); padding-block: 1.5rem; }
.foot__row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.foot a { color: var(--ink-soft); }

/* ---------- reveal (progressive: visible by default) ---------- */

.section, .band { opacity: 1; }
body.js-reveal .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease, transform 0.5s ease; }
body.js-reveal .reveal.is-in { opacity: 1; transform: none; }
