/* Klynetic Books website. Every colour, font and size is a token from
   theme/theme.yml (tokens.css); never hard-code one here (DES-01 D-05). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--size-base);
  line-height: var(--line-height);
  background: var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
[data-mode] { color: var(--ink); }
section[data-mode], header[data-mode], footer[data-mode] { background-color: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand-cyan); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.18; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: var(--size-h1); }
h2 { font-size: var(--size-h2); }
h3 { font-size: var(--size-h3); }
p { margin: 0 0 1em; }
.wrap { width: min(100% - 2 * var(--gutter), var(--page-width)); margin-inline: auto; }
.narrow { max-width: 40rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--surface); padding: .6rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; }
.muted { color: var(--ink-muted); }
.small { font-size: var(--size-small); }
.kicker, .label, .pill, .btn, .site-nav, .chip, .status-note {
  font-family: var(--font-label); letter-spacing: .08em; text-transform: uppercase;
}
.kicker { color: var(--accent); font-size: .85rem; font-weight: 500; margin-bottom: .6rem; }

/* The jigsaw: drawn by the build from the mode's colours. */
.jigsaw { background-image: var(--jigsaw); }

/* Open flags in draft builds (DES-01 D-10). */
mark.flag {
  background: var(--flag-bg); color: var(--flag-ink); border-radius: 4px; padding: .05em .35em;
  font: 600 .8rem/1.4 var(--font-label); letter-spacing: .02em; text-transform: none;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.draft-banner {
  background: var(--flag-bg); color: var(--flag-ink); text-align: center;
  font: 500 .85rem/1.4 var(--font-label); padding: .45rem var(--gutter);
}
.draft-banner code { font-size: .8rem; }

/* ---------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--rule);
  transition: box-shadow var(--motion);
}
.site-header.is-scrolled { box-shadow: var(--shadow); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.2rem; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.brand-piece {
  width: 30px; height: 30px; fill: var(--accent);
  transition: transform var(--motion);
}
.brand:hover .brand-piece { transform: rotate(90deg); }
.site-nav ul { list-style: none; display: flex; gap: .3rem; margin: 0; padding: 0; }
.site-nav a, .nav-soon { display: block; padding: .5rem .8rem; color: var(--ink); text-decoration: none; font-size: .95rem; border-radius: var(--radius-small); }
.site-nav a:hover { background: var(--surface-alt); }
.site-nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-soon { color: var(--ink-muted); }
.nav-soon small { font-size: .65rem; border: 1px solid var(--rule); border-radius: 99px; padding: .05rem .4rem; margin-left: .2rem; }
.nav-toggle { display: none; }

@media (max-width: 52rem) {
  .nav-toggle {
    display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border: 1px solid var(--rule);
    border-radius: var(--radius-small); background: transparent; color: var(--ink); cursor: pointer;
  }
  .bars, .bars::before, .bars::after { display: block; width: 20px; height: 2px; background: currentColor; position: relative; transition: transform var(--motion), opacity var(--motion); }
  .bars::before, .bars::after { content: ""; position: absolute; left: 0; }
  .bars::before { top: -6px; } .bars::after { top: 6px; }
  .nav-toggle[aria-expanded="true"] .bars { background: transparent; }
  .nav-toggle[aria-expanded="true"] .bars::before { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .bars::after { transform: translateY(-6px) rotate(-45deg); }
  .js .site-nav {
    position: absolute; inset: 100% 0 auto 0; background: var(--bg); border-bottom: 1px solid var(--rule);
    max-height: 0; overflow: hidden; transition: max-height var(--motion);
  }
  .js .site-nav.is-open { max-height: 24rem; }
  .site-nav ul { flex-direction: column; padding: .5rem var(--gutter) 1rem; }
  html:not(.js) .header-inner { flex-wrap: wrap; }
  html:not(.js) .nav-toggle { display: none; }
  html:not(.js) .site-nav ul { flex-direction: row; flex-wrap: wrap; padding: 0 0 .6rem; }
}

/* ---------------------------------------------------------- buttons, pills */
.btn {
  display: inline-flex; align-items: center; gap: .5rem; padding: .8rem 1.3rem; border-radius: 99px;
  font-size: .9rem; font-weight: 500; text-decoration: none; border: 2px solid transparent; cursor: pointer;
  transition: transform var(--motion), box-shadow var(--motion), background var(--motion);
}
.btn small { font-size: .7rem; opacity: .8; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-ghost { border-color: currentColor; color: var(--ink); background: transparent; }
.btn-ghost:hover { background: var(--surface-alt); }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.6rem; }
.pill {
  display: inline-block; font-size: .72rem; font-weight: 500; padding: .25rem .7rem; border-radius: 99px;
  background: var(--surface-alt); color: var(--ink); border: 1px solid var(--rule);
}
.pill.status-published { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.status-note { font-size: .8rem; color: var(--ink-muted); margin-left: .4rem; }

/* ---------------------------------------------------------- sections */
.section { padding-block: clamp(3rem, 2rem + 4vw, 6rem); }
.section-head { margin-bottom: 2rem; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(1.3rem, 1rem + 1.5vw, 2.2rem); box-shadow: var(--shadow); }
.prose { max-width: var(--measure); }
.prose h2 { margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.prose blockquote { margin: 1.5em 0; padding-left: 1.2em; border-left: 3px solid var(--accent); font-family: var(--font-display); font-style: italic; }
.lede { font-size: 1.2rem; color: var(--ink-muted); max-width: 46rem; }

/* ---------------------------------------------------------- hero (home) */
.hero { padding-block: clamp(3rem, 2rem + 6vw, 7rem); overflow: hidden; position: relative; }
.hero::after { /* a pool of light on the table, as on the Office Politics cover */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 70% 50%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
              radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0, 0, 0, .45));
}
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(2rem, 4vw, 4rem); align-items: center; }
.hero h1 { max-width: 18ch; }
.hero-covers { position: relative; aspect-ratio: 1 / 1; max-width: 32rem; width: 100%; justify-self: center; perspective: 1200px; }
.hero-portrait { justify-self: center; max-width: 30rem; width: 100%; }
.hero-portrait img { width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow-cover); }
.hero-cover { position: absolute; width: 46%; transition: transform var(--motion), z-index 0s; }
.hero-cover img, .cover img { border-radius: 4px 8px 8px 4px; box-shadow: var(--shadow-cover); }
.hc-1 { left: 6%; top: 4%; transform: rotate(-8deg); z-index: 3; }
.hc-2 { left: 46%; top: 0; transform: rotate(6deg); z-index: 4; }
.hc-3 { left: 14%; top: 46%; transform: rotate(4deg); z-index: 2; }
.hc-4 { left: 50%; top: 44%; transform: rotate(-5deg); z-index: 1; }
.hero-cover:hover { transform: rotate(0) scale(1.06); z-index: 9; }
@media (max-width: 52rem) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-covers { max-width: 24rem; }
}

/* ---------------------------------------------------------- bookshelf */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); gap: clamp(1rem, 2vw, 1.8rem); }
.book-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: transform var(--motion), box-shadow var(--motion);
}
.book-card:hover { transform: translateY(-6px); }
.book-card[hidden] { display: none; }
.book-card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.book-card .cover { padding: 1.6rem 1.6rem .4rem; background: var(--jigsaw) center / 90px, var(--bg); perspective: 900px; }
.book-card .cover img { margin-inline: auto; max-height: 22rem; width: auto; }
.book-card-body { padding: 1.1rem 1.3rem 1.4rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.book-card h3 { margin: .2rem 0 0; }
.book-card .subtitle { color: var(--ink-muted); font-size: .92rem; margin: 0; }
.book-card .summary { font-size: .95rem; margin: 0; }
.book-card .more { margin-top: auto; color: var(--accent); font: 500 .82rem var(--font-label); letter-spacing: .08em; text-transform: uppercase; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.8rem; }
.chip { font-size: .8rem; padding: .5rem 1rem; border-radius: 99px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------------------------------------------------------- page and book heroes */
.page-hero { padding-block: clamp(3rem, 2rem + 5vw, 6rem); }
.page-hero.tall { padding-block: clamp(5rem, 4rem + 8vw, 10rem); }
.page-hero .lede p:last-child { margin-bottom: 0; }
.book-hero { padding-block: clamp(2.5rem, 2rem + 5vw, 6rem); position: relative; overflow: hidden; }
.book-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 30% 50%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 55%);
}
.book-hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 24rem) 1fr; gap: clamp(2rem, 5vw, 5rem); align-items: center; }
.cover-large { perspective: 1200px; }
.cover-large img { width: 100%; }
.book-hero .subtitle { font-family: var(--font-display); font-style: italic; font-size: 1.25rem; color: var(--ink-muted); }
.book-hero .tagline { max-width: 42rem; }
.byline { font: 500 .9rem var(--font-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); }
.buy { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-top: 1.4rem; }
.buy-amazon { display: inline-flex; align-items: stretch; gap: .4rem; }
.market select {
  height: 100%; border-radius: 99px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  padding: 0 .8rem; font: 500 .8rem var(--font-label);
}
@media (max-width: 46rem) {
  .book-hero-inner { grid-template-columns: 1fr; }
  .cover-large { max-width: 18rem; margin-inline: auto; }
}
.book-body { display: grid; grid-template-columns: 1fr 18rem; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.details dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; font-size: .95rem; }
.details dt { color: var(--ink-muted); font: 500 .78rem/1.9 var(--font-label); letter-spacing: .08em; text-transform: uppercase; }
.details dd { margin: 0; }
.downloads { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; }
@media (max-width: 52rem) { .book-body { grid-template-columns: 1fr; } }

.page-grid.has-aside { display: grid; grid-template-columns: 16rem 1fr; gap: 3rem; align-items: start; }
.portrait img { border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 46rem) { .page-grid.has-aside { grid-template-columns: 1fr; } .portrait { max-width: 14rem; } }

/* ---------------------------------------------------------- reviews */
.carousel { position: relative; }
.carousel-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(100%, 34rem); gap: 1.4rem;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 1rem; scrollbar-width: thin;
}
.carousel-slide { scroll-snap-align: start; display: flex; }
.review {
  margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 2rem; display: flex; flex-direction: column; gap: 1rem; width: 100%; position: relative;
}
.review::before { content: "\201C"; position: absolute; top: -.2rem; left: 1.2rem; font: 700 5rem/1 var(--font-display); color: var(--accent); opacity: .5; }
.review blockquote { margin: 0; font-family: var(--font-display); font-size: 1.08rem; font-style: italic; }
.review blockquote p:last-child { margin-bottom: 0; }
.review figcaption { display: flex; flex-direction: column; font-size: .9rem; margin-top: auto; }
.review figcaption span, .review cite { color: var(--ink-muted); font-style: normal; }
.review figcaption a { margin-top: .3rem; font: 500 .78rem var(--font-label); letter-spacing: .08em; text-transform: uppercase; }
.stars { margin: 0; color: var(--accent); letter-spacing: .15em; }
.stars .off { opacity: .25; }
.carousel-controls { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; }
.carousel-controls button {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink); cursor: pointer; font-size: 1.1rem;
}
.carousel-dots { display: flex; gap: .4rem; margin-left: .4rem; }
.carousel-dots button { width: .7rem; height: .7rem; padding: 0; border-radius: 50%; background: var(--rule); border: 0; }
.carousel-dots button[aria-current="true"] { background: var(--accent); }

/* ---------------------------------------------------------- community, sign-up, forms */
.community-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1.6rem; }
.signup { padding-block: clamp(3rem, 2rem + 4vw, 5rem); border-top: 1px solid var(--rule); }
.signup-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; }
.signup-form { display: flex; flex-wrap: wrap; gap: .6rem; }
.signup-form p { flex-basis: 100%; margin: .3rem 0 0; }
.signup-form input { flex: 1 1 14rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius-small); padding: .8rem 1rem;
}
.signup-form input { border-radius: 99px; padding-inline: 1.2rem; }
.contact-form { display: grid; gap: 1rem; }
.contact-form label { display: grid; gap: .35rem; font: 500 .85rem var(--font-label); letter-spacing: .06em; text-transform: uppercase; }
.contact-form button { justify-self: start; }
@media (max-width: 46rem) { .signup-inner { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--rule); padding-top: 3rem; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
.footer-inner ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.footer-inner a { color: var(--ink); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }
.footer-name { font: 700 1.2rem var(--font-display); }
.label { font-size: .8rem; color: var(--ink-muted); }
.footer-base { border-top: 1px solid var(--rule); margin-top: 2.5rem; padding-block: 1.2rem; font-size: .85rem; }
.footer-base p { margin: 0; }
@media (max-width: 46rem) { .footer-inner { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- motion (enhancement only) */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 700ms ease, transform 700ms ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
.tilt img { transition: transform 200ms ease-out; transform-style: preserve-3d; will-change: transform; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
@media print {
  .site-header, .signup, .draft-banner, .carousel-controls { display: none; }
  .jigsaw { background: none; }
}

/* A book's parts list (book.yml `parts:`) */
.parts { counter-reset: part; list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: .6rem; }
.parts li { counter-increment: part; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: var(--radius-small); padding: .7rem 1rem; margin: 0; font-weight: 500; }
.parts li::before { content: counter(part) ". "; color: var(--accent); font-family: var(--font-label); }

/* Home: the areas the series puts structure on (index.md `areas:`) */
.areas-wrap { margin-top: 2.5rem; }
.areas-title { font-size: var(--size-h3); }
.areas { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; }
.area a {
  display: flex; flex-direction: column; gap: .45rem; height: 100%; padding: 1.4rem 1.3rem 1.3rem;
  background: var(--surface); color: var(--ink); text-decoration: none; border: 1px solid var(--rule);
  border-top: 4px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform var(--motion);
}
.area a:hover { transform: translateY(-4px); }
.area .kicker { margin: 0; }
.area strong { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.3; }
.area-text { font-size: .93rem; color: var(--ink-muted); }
.area .pill { margin-top: auto; align-self: flex-start; }

/* Review headline, and long reviews clamped until expanded (main.js) */
.review-title { margin: 0; font: 700 1.05rem/1.35 var(--font-display); }
.review figcaption cite a { color: inherit; }
.js .review blockquote.long:not(.is-open) { max-height: 13.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.review-more { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: 500 .8rem var(--font-label); letter-spacing: .08em; text-transform: uppercase; }

/* Bookshelf groups (site.yml book_groups) */
.shelf-group + .shelf-group { margin-top: clamp(2.5rem, 2rem + 2vw, 4rem); }
.shelf-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1.2rem; margin-bottom: 1.2rem; padding-bottom: .8rem; border-bottom: 1px solid var(--rule); }
.shelf-group-head h3 { margin: 0; font-size: var(--size-h3); }
.shelf-group-head p { margin: 0; font-size: .95rem; }
.shelf-group .shelf { grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); }
.shelf-group .book-card .cover { padding: 1.2rem 1.2rem .3rem; }
