/* ─────────────────────────────────────────────────────────
   linuxperformancebook.com
   Marketing site for "Linux Performance" (BPB Publications, 2026)
   Tokens → base → layout → components → responsive

   Palette follows the book cover: white ground, near-black type,
   one crimson red carrying every accent. Light only, by design.
   ───────────────────────────────────────────────────────── */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:            #ffffff;
  --bg-alt:        #f7f7f8;
  --bg-elev:       #ffffff;
  --bg-sunken:     #ededf0;
  --bg-ink:        #111114;   /* black panels, as on the cover */

  --text:          #111114;
  --text-soft:     #4a4a52;
  --text-mute:     #6e6e78;
  --text-inv:      #ffffff;

  --border:        #e4e4e8;
  --border-strong: #cbcbd2;

  --accent:        #d01b3c;   /* crimson, the cover's red */
  --accent-hover:  #ae1531;
  --accent-soft:   #fdeaee;
  --accent-line:   #f3c4ce;

  --shadow-sm: 0 1px 2px rgba(17, 17, 20, .05), 0 1px 3px rgba(17, 17, 20, .04);
  --shadow-md: 0 4px 12px rgba(17, 17, 20, .06), 0 12px 32px rgba(17, 17, 20, .05);
  --shadow-lg: 0 18px 48px rgba(17, 17, 20, .11);
  --shadow-book: 0 26px 60px rgba(17, 17, 20, .24);

  --radius:    12px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --wrap: 1120px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  line-height: 1.15; margin: 0; letter-spacing: -0.025em;
  font-weight: 700; text-wrap: balance;
}
h1 { font-size: clamp(2.5rem, 6.2vw, 4.1rem); font-weight: 800; letter-spacing: -0.04em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 750; letter-spacing: -0.032em; }
h3 { font-size: 1.18rem; font-weight: 680; }
p  { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }
ul, ol { margin: 0 0 1rem; padding-left: 1.25rem; }
li { margin-bottom: .4rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: .7rem 1.1rem;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── Layout ─────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

.section { padding: clamp(4rem, 9vw, 7rem) 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }

.kicker {
  font-size: .76rem; font-weight: 750; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
  margin: 0 0 .7rem;
}
.section-sub {
  color: var(--text-soft); font-size: 1.1rem;
  max-width: 62ch; margin: .9rem 0 0;
}
.section-head { margin-bottom: 2.75rem; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.site-header.is-stuck { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }

.header-inner { display: flex; align-items: center; gap: 1rem; height: 66px; }

.brand {
  display: flex; align-items: center; gap: .6rem;
  color: var(--text); font-weight: 700; letter-spacing: -.025em;
  margin-right: auto; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 7px; background: var(--accent); color: #fff;
  font-size: .78rem; font-weight: 800; letter-spacing: .02em;
}
.brand-text { font-size: .97rem; }

.nav { display: flex; align-items: center; gap: 1.4rem; }
.nav a { color: var(--text-soft); font-size: .93rem; font-weight: 550; }
.nav a:hover { color: var(--text); text-decoration: none; }

.header-cta { display: flex; align-items: center; gap: .5rem; }

.nav-toggle {
  display: none; width: 38px; height: 38px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--bg-elev); color: var(--text); cursor: pointer;
  padding: 0; place-items: center;
}
.nav-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .78rem 1.35rem; border-radius: 9px;
  font-size: .96rem; font-weight: 650; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .14s ease, box-shadow .18s ease,
              background-color .18s ease, border-color .18s ease, color .18s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 5px 16px rgba(208, 27, 60, .26);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 9px 24px rgba(208, 27, 60, .32); }

/* Black button, for the second-tier action that still needs weight. */
.btn-ink { background: var(--bg-ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-ink:hover { background: #000; box-shadow: var(--shadow-md); }

.btn-ghost {
  background: var(--bg-elev); color: var(--text);
  border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: .52rem .95rem; font-size: .88rem; border-radius: 7px; }
.btn-lg { padding: .95rem 1.7rem; font-size: 1.02rem; }
.btn-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(3.5rem, 8vw, 6rem) 0 clamp(4rem, 8vw, 6.5rem);
  background: var(--bg);
}
/* A single crimson wash top-right, echoing the cover's corner swash. */
.hero::before {
  content: ""; position: absolute; top: -240px; right: -160px;
  width: 720px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, rgba(208, 27, 60, .10), rgba(208, 27, 60, 0) 68%);
  pointer-events: none; z-index: 0;
}
.hero > .wrap { position: relative; z-index: 1; }

.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: clamp(2.5rem, 6vw, 5rem); align-items: center;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .34rem .8rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .8rem; font-weight: 680; margin-bottom: 1.35rem;
  border: 1px solid var(--accent-line);
  letter-spacing: .01em;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.hero h1 .grad { color: var(--accent); }

.hero-sub {
  font-size: clamp(1.08rem, 2vw, 1.26rem); color: var(--text-soft);
  max-width: 56ch; margin: 1.3rem 0 0;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: .5rem .9rem;
  margin-top: 1.6rem; font-size: .875rem; color: var(--text-mute);
  align-items: center;
}
.hero-meta .sep { color: var(--accent); opacity: .55; }
.hero-note { margin-top: .9rem; font-size: .85rem; color: var(--text-mute); }

/* Book cover, given a little physical presence */
.cover-stage { perspective: 1600px; }
.cover {
  position: relative; display: block;
  transform: rotateY(-13deg) rotateX(3deg);
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2, .7, .3, 1);
  border-radius: 2px 8px 8px 2px;
  box-shadow: var(--shadow-book);
}
.cover:hover { transform: rotateY(-6deg) rotateX(1deg) translateY(-6px); }
.cover img { border-radius: 2px 8px 8px 2px; width: 100%; }
.cover::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 2px 8px 8px 2px;
  background: linear-gradient(97deg,
              rgba(255,255,255,.30) 0%, rgba(255,255,255,.04) 5%,
              rgba(255,255,255,0) 14%, rgba(0,0,0,.09) 100%);
  pointer-events: none;
}
.cover-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,.38), rgba(0,0,0,.08) 60%, rgba(255,255,255,.20));
  border-radius: 2px 0 0 2px;
}

/* ── Stat strip ─────────────────────────────────────────── */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.stat { background: var(--bg-elev); padding: 1.4rem 1.2rem; text-align: center; }
.stat dt { font-size: .76rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: .09em; font-weight: 650; }
.stat dd { margin: .35rem 0 0; font-size: 1.65rem; font-weight: 800; letter-spacing: -.035em; color: var(--accent); }

/* ── Cards / grids ──────────────────────────────────────── */
.grid { display: grid; gap: 1.25rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card h3 { margin-bottom: .55rem; }
.card p { color: var(--text-soft); font-size: .96rem; margin: 0; }

.card-icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 1rem;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line);
}
.card-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ── Learn list ─────────────────────────────────────────── */
.learn-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .85rem; }
.learn-list li {
  display: flex; gap: .8rem; align-items: flex-start;
  margin: 0; color: var(--text-soft);
}
.learn-list svg {
  flex-shrink: 0; width: 21px; height: 21px; margin-top: .18rem;
  fill: none; stroke: var(--accent); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── Chapters (table of contents) ───────────────────────── */
.toc {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: .7rem; counter-reset: ch; padding: 0;
}
.toc li {
  list-style: none; margin: 0;
  display: flex; gap: .9rem; align-items: baseline;
  padding: .85rem 1rem;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.toc li:hover { border-color: var(--accent); transform: translateX(2px); box-shadow: var(--shadow-sm); }
.toc li::before {
  counter-increment: ch; content: counter(ch, decimal-leading-zero);
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  color: var(--accent); flex-shrink: 0;
}

/* ── Buy / retailer grid ────────────────────────────────── */
.buy-lead {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem; margin-bottom: 2.5rem;
}
.buy-primary {
  position: relative;
  background: var(--bg-elev); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 1.75rem;
  box-shadow: 0 10px 30px rgba(208, 27, 60, .13);
}
.buy-primary .flag {
  position: absolute; top: -11px; left: 1.5rem;
  background: var(--accent); color: #fff;
  font-size: .69rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase;
  padding: .24rem .7rem; border-radius: 999px;
}
.buy-primary h3, .buy-card h3 { font-size: 1.15rem; margin-bottom: .4rem; }
.buy-primary p, .buy-card p { color: var(--text-soft); font-size: .93rem; margin: 0 0 1.15rem; }
.buy-card {
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}
.buy-formats { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.15rem; }
.tag {
  font-size: .75rem; font-weight: 640; padding: .2rem .6rem;
  border-radius: 999px; background: var(--bg-sunken);
  color: var(--text-soft); border: 1px solid var(--border);
}
.tag-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

/* Store links */
.stores {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: .6rem; padding: 0; margin: 0; list-style: none;
}
.stores li { margin: 0; }
.store {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem .95rem; border-radius: var(--radius-sm);
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text); font-size: .93rem; font-weight: 580;
  transition: border-color .16s ease, background-color .16s ease,
              transform .16s ease, box-shadow .16s ease;
  height: 100%;
}
.store:hover {
  text-decoration: none; border-color: var(--accent);
  background: var(--accent-soft); transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.store .flagmark { width: 26px; flex-shrink: 0; text-align: center; font-size: 1.05rem; line-height: 1; }
.store .store-name { flex: 1; min-width: 0; }
.store .store-sub { display: block; font-size: .76rem; color: var(--text-mute); font-weight: 450; }
.store .arrow { width: 14px; height: 14px; flex-shrink: 0; opacity: .35; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.store:hover .arrow { opacity: 1; color: var(--accent); }

.store-group { margin-bottom: 2.25rem; }
.store-group:last-child { margin-bottom: 0; }
.store-group h3 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-mute); margin-bottom: .9rem; font-weight: 720;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}

/* ── Author ─────────────────────────────────────────────── */
.author {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: clamp(2rem, 5vw, 3.5rem); align-items: center;
}
.author-portrait {
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--bg-elev); padding: 2rem; text-align: center;
  box-shadow: var(--shadow-md);
}
.author-initials {
  width: 90px; height: 90px; margin: 0 auto 1.1rem;
  border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-ink); color: #fff;
  font-size: 1.95rem; font-weight: 800; letter-spacing: -.03em;
  border: 3px solid var(--accent);
}
.author-portrait h3 { font-size: 1.25rem; }
.author-portrait .role { color: var(--text-mute); font-size: .9rem; margin-top: .3rem; }
.author-creds {
  list-style: none; padding: 0; margin: 1.3rem 0 0; text-align: left;
  display: grid; gap: .5rem; font-size: .89rem; color: var(--text-soft);
}
.author-creds li { display: flex; gap: .55rem; margin: 0; }
.author-creds li::before { content: "▸"; color: var(--accent); flex-shrink: 0; }

/* ── Quote / pull ───────────────────────────────────────── */
.pull {
  border-left: 3px solid var(--accent);
  padding: .3rem 0 .3rem 1.4rem; margin: 2.5rem 0 0;
  font-size: 1.15rem; color: var(--text); font-style: italic;
}

/* ── FAQ ────────────────────────────────────────────────── */
.faq { display: grid; gap: .7rem; max-width: 820px; margin: 0 auto; }
.faq details {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.faq details[open] { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.faq summary {
  cursor: pointer; padding: 1.05rem 1.3rem;
  font-weight: 640; font-size: 1rem; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex-shrink: 0; width: 10px; height: 10px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s ease;
}
.faq details[open] summary::after { transform: rotate(225deg) translate(-3px, -3px); }
.faq .faq-body { padding: 0 1.3rem 1.2rem; color: var(--text-soft); font-size: .96rem; }

/* ── Final CTA ──────────────────────────────────────────── */
.cta-final {
  background: var(--bg-ink); color: var(--text-inv);
  border-block: 0; text-align: center;
}
.cta-final .wrap { max-width: 760px; }
.cta-final h2 { color: #fff; }
.cta-final .kicker { color: #ff6b85; }
.cta-final .section-sub { color: rgba(255, 255, 255, .74); }
.cta-final .hero-actions { justify-content: center; }
.cta-final .hero-note { color: rgba(255, 255, 255, .6); }
.cta-final .hero-note a { color: #ff8ba0; }
.cta-final .btn-ghost {
  background: transparent; color: #fff; border-color: rgba(255, 255, 255, .34);
  box-shadow: none;
}
.cta-final .btn-ghost:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, .08); }

/* ── Sticky mobile buy bar ──────────────────────────────── */
.buybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: none; align-items: center; gap: .75rem;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 2px solid var(--accent);
  transform: translateY(110%); transition: transform .28s ease;
}
.buybar.is-on { transform: translateY(0); }
.buybar-txt { flex: 1; min-width: 0; font-size: .84rem; line-height: 1.3; }
.buybar-txt strong { display: block; font-size: .92rem; }
.buybar-txt span { color: var(--text-mute); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  padding: 3rem 0 2.5rem; border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: .9rem; color: var(--text-mute);
}
.footer-top {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  justify-content: space-between; align-items: flex-start;
  margin-bottom: 2rem;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.footer-links a { color: var(--text-soft); }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; flex-wrap: wrap; gap: .8rem 1.5rem;
  justify-content: space-between; align-items: center;
  padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.disclosure { font-size: .82rem; color: var(--text-mute); max-width: 60ch; }

/* ── Reveal-on-scroll ───────────────────────────────────────
   Gated on .reveal-ready, which main.js sets only once it is
   running and has an observer attached. If main.js never loads,
   nothing is ever hidden. A marketing page must not be able to
   render blank because one script 404'd. */
.reveal-ready .reveal { opacity: 0; transform: translateY(16px); }
.reveal-ready .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
  .reveal-ready .reveal { opacity: 1; transform: none; }
  .cover, .cover:hover { transform: none; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; text-align: left; }
  .cover-stage { max-width: 290px; margin: 0 auto; order: -1; }
  .cover { transform: none; }
  .author { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .nav-toggle { display: grid; }
  .nav {
    position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg-elev); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: .5rem 1.5rem 1rem;
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: .75rem 0; border-bottom: 1px solid var(--border); font-size: 1rem; }
  .nav a:last-child { border-bottom: 0; }
  .header-cta .btn { display: none; }
  .buybar { display: flex; }
  body { padding-bottom: 4.5rem; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .stats { grid-template-columns: 1fr; }
  .hero-actions .btn { width: 100%; }
  .toc { grid-template-columns: 1fr; }
  .brand-text { display: none; }
}

@media print {
  .site-header, .buybar, .hero::before { display: none; }
  body { color: #000; background: #fff; }
  .cta-final { background: #fff; color: #000; }
  .cta-final h2 { color: #000; }
}
