/* ==========================================================================
   Jotato — main stylesheet
   Single file by design: one request, no render-blocking chain.
   Sections: 1 fonts · 2 tokens · 3 reset · 4 typography · 5 primitives
   ========================================================================== */

/* 1 — FONTS ---------------------------------------------------------------
   Self-hosted latin subsets. Variable axes declared as ranges: never add a
   separate @font-face per weight, that just re-downloads the same file.
   unicode-range is set explicitly so adding a CJK face later costs latin
   visitors nothing.
   ------------------------------------------------------------------------ */

@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('../fonts/woff2/Jost-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'IM Fell English';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/woff2/IMFellEnglish-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/woff2/Caveat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2 — TOKENS -------------------------------------------------------------- */

:root {
  /* Brand palette — light. Carried over from the Jotato brand set. */
  --ground: #FDF8F2;
  --paper: #FFFCF4;
  --paper-2: #FBF4E9;
  --ink: #1A1A1A;
  --ink-soft: #6B5B49;
  --ink-faint: #9A8A76;
  --accent: #C97B3A;
  --accent-soft: #F0DCC4;
  --fry: #F0A93A;
  --carton: #D14A2E;
  --live: #6AA86A;
  --rule: #E4D9C7;
  --rule-strong: #D3C4AC;
  --blue: #1D5FD7;
  --shadow: 0 14px 34px rgba(90, 62, 32, .10);
  --shadow-sm: 0 4px 14px rgba(90, 62, 32, .07);
  --grain: .035;

  /* Type roles */
  --font-display: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --font-ui: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Caveat', 'Bradley Hand', cursive;

  /* Fluid type scale — clamp() so no layout shift between breakpoints and
     no container is sized to the pixel width of one specific language. */
  --step--1: clamp(.83rem, .8rem + .15vw, .92rem);
  --step-0: clamp(1rem, .96rem + .2vw, 1.12rem);
  --step-1: clamp(1.2rem, 1.12rem + .4vw, 1.45rem);
  --step-2: clamp(1.5rem, 1.35rem + .75vw, 2rem);
  --step-3: clamp(1.9rem, 1.6rem + 1.5vw, 2.9rem);
  --step-4: clamp(2.4rem, 1.85rem + 2.75vw, 4.2rem);

  /* Spacing + layout */
  --space-2xs: .25rem;
  --space-xs: .5rem;
  --space-s: .75rem;
  --space-m: 1.25rem;
  --space-l: 2rem;
  --space-xl: 3.25rem;
  --space-2xl: 5rem;
  --space-3xl: 7.5rem;
  --measure: 62ch;
  --wrap: 1140px;
  --radius: 14px;
  --radius-sm: 8px;
}

/* Dark: system preference, unless the user explicitly chose light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #17130F;
    --paper: #201B15;
    --paper-2: #26201A;
    --ink: #F2E9DB;
    --ink-soft: #BCAB94;
    --ink-faint: #8B7B67;
    --accent: #E3A063;
    --accent-soft: #4A3521;
    --fry: #EFB055;
    --carton: #E0664A;
    --live: #7FBE7F;
    --rule: #372E25;
    --rule-strong: #4A3E32;
    --blue: #7BA7F0;
    --shadow: 0 14px 34px rgba(0, 0, 0, .45);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);
    --grain: .05;
  }
}

/* Dark: explicit choice wins in both directions. */
:root[data-theme="dark"] {
  --ground: #17130F;
  --paper: #201B15;
  --paper-2: #26201A;
  --ink: #F2E9DB;
  --ink-soft: #BCAB94;
  --ink-faint: #8B7B67;
  --accent: #E3A063;
  --accent-soft: #4A3521;
  --fry: #EFB055;
  --carton: #E0664A;
  --live: #7FBE7F;
  --rule: #372E25;
  --rule-strong: #4A3E32;
  --blue: #7BA7F0;
  --shadow: 0 14px 34px rgba(0, 0, 0, .45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .35);
  --grain: .05;
}

/* 3 — RESET --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Intrinsic sizing so images never cause CLS. Every <img> in the markup
   also carries explicit width/height attributes. */
img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

/* 4 — TYPOGRAPHY ---------------------------------------------------------- */

h1, h2, h3, h4 {
  margin: 0 0 var(--space-s);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -.01em;
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); font-family: var(--font-ui); font-weight: 500; }
h4 { font-size: var(--step-1); font-family: var(--font-ui); font-weight: 500; }

p {
  margin: 0 0 var(--space-m);
  max-width: var(--measure);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: .18em;
}

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

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

/* Handwritten margin notes / counters. Text lives in HTML, never in
   CSS content — pseudo-element text cannot be translated. */
.note {
  font-family: var(--font-hand);
  font-size: var(--step-1);
  color: var(--ink-soft);
  line-height: 1.3;
}

.lede {
  font-size: var(--step-1);
  color: var(--ink-soft);
  font-weight: 300;
}

.eyebrow {
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* 5 — PRIMITIVES ---------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 2.5rem);
}

.section { padding-block: var(--space-3xl); }

/* Skip link — keyboard users land past the nav. */
.skip {
  position: absolute;
  left: var(--space-m);
  top: -100%;
  z-index: 100;
  padding: var(--space-xs) var(--space-m);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.skip:focus { top: var(--space-m); }

/* Visually hidden but read by screen readers and parsed by crawlers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-s) var(--space-l);
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: var(--step-0);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.btn--primary {
  background: var(--accent);
  color: #FFFCF4;
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}

.btn--ghost:hover { border-color: var(--accent); }

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--space-l);
  box-shadow: var(--shadow-sm);
}

/* Wide content (tables, code, diagrams) scrolls inside itself so the page
   body never scrolls horizontally. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
