/* ==========================================================================
   base.css — tokens, reset and the band model for every ordinary page.

   The design is tavela.se's (from 2026-12-05, when tavela.se moved in under
   /skola/): chalkboard green with a terracotta accent on warm off-white,
   rounded corners, full-width bands, Inter for UI and headings, Charis SIL
   for running prose. Light theme only. See AGENTS.md, "Design".

   css/tokens.css is the OLD dark-panel-grid file. Only the skill trees and
   the small apps that load nothing else still use it; ordinary pages load
   this file instead and never both.

   NO other stylesheet may hardcode a hex value or a font stack. If a value
   is missing, add a token here.
   ========================================================================== */

:root {
  /* ---- Grounds ---------------------------------------------------------- */
  --paper:         #FAF8F4;   /* default page ground — warm off-white */
  --paper-2:       #F1EDE6;   /* alternate band, warm sand */
  --surface:       #FFFFFF;   /* cards, panels, header */

  /* ---- Ink -------------------------------------------------------------- */
  --ink:           #18211E;   /* primary text, and the footer ground */
  --ink-2:         #47504C;   /* secondary text — 7.1:1 on --primary-tint */
  --ink-3:         #626A66;   /* muted: captions, metadata — 5.3:1 on --paper */
  --ink-inverse:   #FAF8F4;   /* text on --ink and --primary bands */
  --rule:          rgba(24, 33, 30, 0.12);
  --rule-strong:   rgba(24, 33, 30, 0.24);
  --rule-inverse:  rgba(250, 248, 244, 0.28);

  /* ---- Primary: chalkboard green ---------------------------------------- */
  --primary:        #1E4D43;  /* hero, buttons, links — 9.6:1 on white */
  --primary-strong: #153A32;  /* hover/active */
  --primary-tint:   #E6EFEB;  /* page headers, the quotes band */
  --scrim-strong:   rgba(30, 77, 67, 0.92);   /* --primary over the hero photo */
  --scrim-mid:      rgba(30, 77, 67, 0.6);
  --scrim-weak:     rgba(30, 77, 67, 0.1);

  /* ---- Accent: terracotta ----------------------------------------------- */
  --accent:         #B4492A;  /* eyebrows and small marks — 5.0:1 on --paper */
  --accent-soft:    #F4B79A;  /* the accent on --primary — 5.5:1 */
  --accent-tint:    #F7E6DC;  /* chip fill */

  /* ---- Status ----------------------------------------------------------- */
  --success: #16A34A;
  --warning: #B45309;
  --danger:  #C2341F;

  /* ---- Shape ------------------------------------------------------------ */
  --radius:      14px;        /* photos, cards, panels */
  --radius-sm:   8px;         /* buttons */
  --radius-pill: 999px;       /* chips */
  --shadow:      0 18px 40px -18px rgba(24, 33, 30, 0.35);

  /* ---- Type ------------------------------------------------------------- */
  --font-sans:  "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-serif: "Charis SIL", "Source Serif 4", Georgia, serif;

  --step-xs:  0.875rem;                                       /* 14px — captions, metadata */
  --step-s:   1rem;                                           /* 16px — UI, labels */
  --step-m:   clamp(1.0625rem, 0.5vw + 0.95rem, 1.1875rem);   /* 17→19px — body prose */
  --step-l:   clamp(1.375rem, 1vw + 1.1rem, 1.75rem);         /* 22→28px — h3 */
  --step-xl:  clamp(1.75rem, 2vw + 1.25rem, 2.5rem);          /* 28→40px — h2 */
  --step-2xl: clamp(2.25rem, 4.5vw + 1rem, 3.75rem);          /* 36→60px — h1 */
  --step-3xl: clamp(2.75rem, 7vw + 0.5rem, 5.5rem);           /* 44→88px — hero only */

  /* ---- Spacing and measures -------------------------------------------- */
  --gutter:        clamp(1.25rem, 5vw, 4rem);   /* 20px phone → 64px desktop */
  --space-band:    clamp(3rem, 8vw, 7rem);      /* vertical padding of a band */
  --space-band-lg: clamp(4.5rem, 12vw, 10rem);
  --measure-prose: 68ch;
  --measure-wide:  1200px;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4rem;

  /* ---- Old names --------------------------------------------------------
     The page-specific <style> blocks (the apps, the master's guidelines,
     the 404 page) were written against the dark-panel-grid tokens. These
     map those names onto the palette above so they keep working. Don't use
     them in new CSS. */
  --bg:            var(--paper);
  --surface-hover: var(--paper-2);
  --border:        var(--rule);
  --border-strong: var(--rule-strong);
  --text:          var(--ink);
  --text-muted:    var(--ink-3);
  --accent-grad:   linear-gradient(135deg, var(--accent-soft), var(--accent-tint)); /* dark text sits on it */
}

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

/* The old reset, kept: the apps' own styles count on zero default margins. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-s);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

img, picture, video, canvas, svg { max-width: 100%; }
:where(.bands) :is(img, picture, video, canvas, svg) { display: block; }

a { color: inherit; text-decoration: none; }

/* A link inside running text is coloured AND underlined, never colour
   alone. Classed links (buttons, cards, tiles) style themselves. */
:where(p, li, dd, td, th, blockquote, figcaption, .prose) a:not([class]) {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color 150ms ease;
}
:where(p, li, dd, td, th, blockquote, figcaption, .prose) a:not([class]):hover { color: var(--primary-strong); }

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

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: var(--ink-inverse);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 100;
  transition: top 0.2s;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   main. Ordinary pages (CV, projects, the apps) keep one centred column with
   panels in it; their header becomes a full-width band (see content.css).
   Pages built from bands — the front page, /talks/, /skola/ — say so with
   <main class="bands"> and get the whole width.
   -------------------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-band);
}
main > section { margin: var(--space-5) 0; }

main.bands { max-width: none; padding: 0; }
main.bands > section { margin: 0; }

/* --------------------------------------------------------------------------
   The band model. A band's background always reaches both screen edges; the
   gutter lives inside, on .band__inner. width:100%, not 100vw (100vw
   includes the scrollbar and scrolls sideways).
   -------------------------------------------------------------------------- */

.band {
  width: 100%;
  padding-block: var(--space-band);
  background: var(--paper);
}

.band__inner {
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.band__inner--prose { max-width: var(--measure-prose); }

.band--alt     { background: var(--paper-2); }
.band--tint    { background: var(--primary-tint); }
.band--primary { background: var(--primary); color: var(--ink-inverse); }
.band--dark    { background: var(--ink);     color: var(--ink-inverse); }
.band--lg      { padding-block: var(--space-band-lg); }

/* --------------------------------------------------------------------------
   Typography inside bands. Scoped to .bands because the reset above zeroes
   every margin and the apps rely on that.
   -------------------------------------------------------------------------- */

:where(.bands) :is(h1, h2, h3, h4) {
  font-family: var(--font-sans);
  font-weight: 600;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
:where(.bands) h1 { font-size: var(--step-2xl); line-height: 1.05; letter-spacing: -0.02em; }
:where(.bands) h2 { font-size: var(--step-xl);  line-height: 1.15; letter-spacing: -0.01em; }
:where(.bands) h3 { font-size: var(--step-l);   line-height: 1.25; }
:where(.bands) h4 { font-size: var(--step-s);   line-height: 1.4; }

:where(.bands) p { margin: 0 0 var(--space-3); }
:where(.bands) :is(p, h1, h2, h3):last-child { margin-bottom: 0; }

/* In a band every link is coloured and underlined, like tavela.se's. */
:where(.bands) a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  transition: color 150ms ease;
}
:where(.bands) a:hover { color: var(--primary-strong); }
:where(.band--dark, .band--primary) a,
:where(.band--dark, .band--primary) a:not([class]) { color: var(--ink-inverse); }
.band--dark :focus-visible,
.band--primary :focus-visible { outline-color: var(--ink-inverse); }

/* Running prose: serif, comfortable measure. */
.prose {
  font-family: var(--font-serif);
  font-size: var(--step-m);
  line-height: 1.65;
  max-width: var(--measure-prose);
}
.prose ul, .prose ol { padding-left: 1.25em; margin: 0 0 var(--space-3); }
.prose li { margin-bottom: var(--space-1); }
.prose h2 { margin-top: var(--space-5); }
.prose h2:first-child { margin-top: 0; }
.prose .note { font-size: var(--step-s); color: var(--ink-3); }
.prose .lede-p { font-size: var(--step-l); line-height: 1.45; }

.lede {
  font-family: var(--font-serif);
  font-size: var(--step-l);
  line-height: 1.45;
  max-width: 46ch;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--step-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--space-2);
}
.band--dark .eyebrow,
.band--primary .eyebrow { color: var(--accent-soft); }
