/* Chai Five Press. Tokens and components follow Website/DESIGN.md. */

:root {
  --ink: #1c2433;
  --ink-soft: #4d586b;
  --paper: #fffaf0;
  --surface: #ffffff;
  --line: #e6dfcf;
  --primary: #345aaa;
  --primary-dark: #27468a;
  --accent: #ffe14d;

  --font-display: "Fredoka", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-sm: 14px;
  --text-base: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-3xl: clamp(34px, 5vw, 48px);
  --text-4xl: clamp(40px, 7vw, 68px);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --shadow-lift: 0 14px 30px rgba(28, 36, 51, .18);
  --shadow-soft: 0 2px 8px rgba(28, 36, 51, .08);

  --content: 1120px;
  --section-y: var(--space-9);
  color-scheme: light;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 28px;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
cite { font-style: italic; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
p { margin: 0; }
p, li, dd { max-width: 62ch; }

.wrap { width: 100%; max-width: calc(var(--content) + 2 * 20px); margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 800; text-decoration: none;
}
.skip:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Buttons, links, pills */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 var(--space-5);
  border-radius: var(--radius-pill); border: 2px solid var(--primary);
  font: 800 var(--text-base)/1.2 var(--font-body);
  text-decoration: none; text-align: center;
  transition: background-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); }
.btn-secondary:hover { background: #eef2fb; }

.quiet { color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.quiet:hover { text-decoration-thickness: 3px; }

.pill {
  display: inline-block; background: var(--accent); color: var(--ink);
  font: 800 var(--text-sm)/20px var(--font-body); letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 14px; border-radius: var(--radius-pill);
}

/* A printed page lying on the table */
.sheet {
  background: var(--surface); border-radius: 4px; box-shadow: var(--shadow-lift);
}

/* Header */
.site-header { padding: var(--space-4) 0; border-bottom: 1px solid var(--line); background: var(--paper); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-6); }
.wordmark {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font: 700 26px/1 var(--font-display); color: var(--ink); text-decoration: none;
}
.badge { width: 44px; height: 44px; flex: none; }
.site-header nav ul, .site-footer nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.site-header nav a {
  display: inline-block; padding: 10px 2px; color: var(--ink); font-weight: 800; text-decoration: none;
  border-bottom: 3px solid transparent;
}
.site-header nav a:hover { border-bottom-color: var(--accent); }

/* Sections */
section { padding: var(--section-y) 0; }
h1 { font-size: var(--text-4xl); line-height: 1.05; font-weight: 700; }
h2 { font-size: var(--text-3xl); line-height: 1.1; }
.lead { font-size: var(--text-lg); line-height: 30px; color: var(--ink-soft); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); align-items: center; }

/* Hero */
.hero { padding-top: var(--space-8); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: var(--space-7); align-items: center; }
.hero-copy { display: grid; gap: var(--space-5); justify-items: start; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }

.hero-art { position: relative; aspect-ratio: 1 / 0.92; width: 100%; max-width: 540px; justify-self: end; }
.hero-art img { position: absolute; }
.hero-sheet { width: 56%; left: 2%; top: 0; transform: rotate(-7deg); }
.cover { box-shadow: var(--shadow-lift); border-radius: 3px; }
.c-spin { width: 30%; left: 4%; top: 42%; transform: rotate(-9deg); z-index: 1; }
.c-myoh { width: 42%; left: 57%; top: 30%; transform: rotate(8deg); z-index: 1; }
.c-eight { width: 46%; left: 27%; top: 22%; transform: rotate(1deg); z-index: 2; }

/* Free pages */
.free { background: var(--surface); border-block: 1px solid var(--line); }
.free-copy { display: grid; gap: var(--space-5); justify-items: start; }
.free-copy p { color: var(--ink-soft); }
.facts { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); font-weight: 600; }
.facts li { padding-left: 28px; position: relative; }
.facts li::before {
  content: ""; position: absolute; left: 4px; top: 9px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink);
}
.free-art { position: relative; aspect-ratio: 1.1 / 1; }
.free-art .sheet { position: absolute; width: 44%; }
.free-art .s1 { left: 0; top: 10%; transform: rotate(-8deg); }
.free-art .s2 { left: 20%; top: 0; transform: rotate(-2deg); }
.free-art .s3 { left: 38%; top: 14%; transform: rotate(5deg); }
.free-art .s4 { left: 55%; top: 4%; transform: rotate(10deg); }

/* Books */
.section-head { display: grid; gap: var(--space-2); margin-bottom: var(--space-7); }
.section-head p { color: var(--ink-soft); font-size: var(--text-lg); }
.shelf-title { font-size: var(--text-2xl); line-height: 38px; margin: 0 0 var(--space-5); }
.book-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6) var(--space-5); }
.book-grid + .shelf-title { margin-top: var(--space-8); }

.book { display: flex; flex-direction: column; gap: var(--space-2); }
.shelf {
  background: var(--shelf); border-radius: var(--radius-md);
  aspect-ratio: 1 / 1.1; display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-3);
}
.shelf img { width: auto; max-width: 74%; max-height: 82%; box-shadow: var(--shadow-lift); border-radius: 3px; }
.book h4 { font-size: var(--text-xl); line-height: 30px; }
.meta { color: var(--ink-soft); font-size: var(--text-sm); line-height: 20px; font-weight: 700; }
.line { color: var(--ink); }
.buy { margin-top: auto; padding-top: var(--space-3); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }

.promo {
  background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius-md);
  padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start;
  align-self: start;
}
.promo-title { font: 600 var(--text-xl)/30px var(--font-display); }
.promo p:not(.pill):not(.promo-title) { color: var(--ink-soft); }

/* Details */
.details { background: var(--surface); border-block: 1px solid var(--line); }
.split-reverse .details-art { order: 2; }
.details-copy { display: grid; gap: var(--space-6); }
.detail-list { margin: 0; display: grid; gap: var(--space-5); }
.detail-list div { padding-left: var(--space-5); border-left: 4px solid var(--accent); }
.detail-list dt { font: 600 var(--text-xl)/32px var(--font-display); }
.detail-list dd { margin: var(--space-1) 0 0; color: var(--ink-soft); }
.details-art .sheet, .teachers-art .sheet { width: 72%; margin: 0 auto; }
.details-art .sheet { transform: rotate(3deg); }
.teachers-art .sheet { transform: rotate(-3deg); }

/* Teachers */
.teachers-copy { display: grid; gap: var(--space-5); }
.teachers-copy p { color: var(--ink-soft); }
.teachers-copy .quiet { overflow-wrap: anywhere; }

/* Footer */
.site-footer { background: var(--ink); color: var(--paper); padding: var(--space-8) 0 var(--space-7); }
.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: var(--space-5) var(--space-7); align-items: start; }
.wordmark-footer { color: var(--paper); margin-bottom: var(--space-2); }
.site-footer nav a { color: var(--paper); font-weight: 700; }
.site-footer nav a:hover { text-decoration-thickness: 3px; }
.site-footer :focus-visible { outline-color: var(--accent); }
.fine { grid-column: 1 / -1; max-width: none; font-size: var(--text-sm); line-height: 20px; color: #c9cfda; padding-top: var(--space-5); border-top: 1px solid #3a4457; }

/* 404 */
.missing { min-height: 100vh; display: grid; align-items: center; text-align: center; padding: var(--space-8) 0; }
.missing .wrap { display: grid; gap: var(--space-5); justify-items: center; }
.badge-big { width: 88px; height: 88px; }

/* Tablet */
@media (max-width: 960px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid, .split { grid-template-columns: 1fr; }
  .hero-art { justify-self: center; max-width: 480px; }
  .free-art, .details-art, .teachers-art, .split-reverse .details-art { order: 2; }
  .free-art { max-width: 560px; width: 100%; justify-self: center; }
  .details-art, .teachers-art { max-width: 420px; width: 100%; justify-self: center; }
}

/* Phone */
@media (max-width: 600px) {
  :root { --section-y: var(--space-8); }
  .hero { padding-top: var(--space-7); }
  .header-inner { justify-content: flex-start; }
  .wordmark { font-size: 23px; }
  .badge { width: 40px; height: 40px; }
  .actions .btn { width: 100%; }
  .book-grid { grid-template-columns: 1fr; gap: var(--space-7); }
  .shelf { aspect-ratio: 1 / 0.95; }
  .shelf img { max-height: 84%; }
  .free-copy .btn { width: 100%; }
  .footer-inner { grid-template-columns: 1fr; }
}
