/* ==========================================================================
   Tyfu — base: fonts, design tokens, reset, typography, utilities.
   Mobile-first throughout: base rules are for phones, min-width queries add
   tablet and desktop layout. No @layer, :has() or container queries, so older
   whiteboard browsers still get a working page.
   ========================================================================== */

/* Self-hosted (SIL Open Font License, see /fonts/LICENSE-*.txt) — no requests
   to Google from pupils' browsers. Latin-ext covers Welsh ŵ and ŷ. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Greens */
  --leaf: #3a7d44;          /* white text on it: 5.0:1 */
  --leaf-dark: #2b5e33;
  --leaf-light: #6aa86f;
  --leaf-wash: #eaf1e6;
  --soil: #6b4f36;

  /* Accent (links, highlight buttons). Darkened from #c1663f for contrast:
     5.0:1 on cream, white text on it 5.6:1. */
  --accent: #a3502f;
  --accent-dark: #8a4226;
  --accent-wash: #fbeee7;

  --water: #2f5c78;
  --water-wash: #e6eff5;
  --harvest: #d9a441;
  --harvest-ink: #8a6412;
  --harvest-wash: #fdf3de;
  --danger: #a33a2a;
  --danger-ink: #8d2f21;
  --danger-wash: #fbeae6;
  --danger-line: #e2b7ad;

  /* Neutrals */
  --cream: #f6f3ea;
  --paper: #fffdf8;
  --ink: #2c342c;
  --muted: #6f6659;          /* 5.1:1 on cream */
  --line: rgba(107, 98, 87, 0.18);
  --line-strong: rgba(107, 98, 87, 0.32);
  --field-border: #8c8274;   /* ≥ 3:1 against white, for inputs and tick boxes */

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(44, 52, 44, 0.05), 0 6px 20px rgba(44, 52, 44, 0.06);
  --shadow-lift: 0 2px 4px rgba(44, 52, 44, 0.07), 0 12px 32px rgba(44, 52, 44, 0.1);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gap: 1.25rem;
  --tap: 44px;               /* minimum comfortable touch target */
  --header-h: 56px;
  --tabbar-h: 60px;
}

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

/* The hidden attribute always wins over a component's display rule. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--cream);
  /* Faint organic texture so large cream areas don't read as flat grey.
     (No background-attachment: fixed — iOS ignores it and it janks scrolling.) */
  background-image:
    radial-gradient(circle at 12% 0, rgba(106, 168, 111, 0.1), transparent 420px),
    radial-gradient(circle at 88% 0, rgba(217, 164, 65, 0.1), transparent 380px);
  background-repeat: no-repeat;
}

img, svg { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--leaf-dark);
  margin: 0 0 0.5rem;
}
h1 { font-size: clamp(1.6rem, 1.25rem + 1.8vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.9vw, 1.65rem); }
h3 { font-size: 1.12rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-dark); }

code {
  font-size: 0.88em;
  background: rgba(107, 98, 87, 0.1);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}

/* ------------------------------------------------------- Accessibility -- */

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--leaf-dark);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 0.75rem; color: #fff; }

main:focus { outline: none; }

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

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

/* ------------------------------------------------------------ Utilities -- */

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.75rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.75rem; }
.mb-2 { margin-bottom: 1.5rem; }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.stack { display: grid; gap: 0.75rem; }
.stack-tight { display: grid; gap: 0.4rem; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.divider { height: 1px; background: var(--line); border: 0; margin: 1.5rem 0; }
.text-danger { color: var(--danger-ink); }
.nowrap { white-space: nowrap; }
