/* Field Notes (Fern & Clay palette with a Graphite dark mode, Botanical type): shared tokens, theme toggle and theme transition for index.html and birds.html.
   To change fonts site-wide, edit the --f-* tokens here and the Google Fonts <link> in each page. */

:root {
  --bg: #f4f2ed;
  --surface: #fbfaf7;
  --fg: #22201c;
  --muted: #5c574f;
  --faint: #837c73;
  --line: #ddd9d0;
  --accent: #3d6a3e;
  --accent-soft: #e4eadd;
  --wing: #a5553a;
  --contour: #dbd7cd;
  --plate: #ffffff;
  --plate-dim: 1;
  --shadow: rgba(45, 38, 28, 0.4);
  --glass: rgba(251, 250, 247, 0.86);

  --f-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --f-body: 'Commissioner', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Fragment Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --f-note: var(--f-mono);     /* dates and years; can be a script face */
  --body-scale: 1;             /* optical size correction for the body face */
  --note-scale: 1;             /* bump to ~1.4 for a handwritten --f-note */
  --display-scale: 1;          /* size of the name in the hero */
  --display-weight: 400;
  --display-tracking: -0.025em;
  --display-em: italic;        /* style of the accented surname; 'normal' for faces without italics */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2e2d2a;
    --surface: #373532;
    --fg: #e0dbd2;
    --muted: #b4ada1;
    --faint: #948d82;
    --line: #47443e;
    --accent: #a2c695;
    --accent-soft: #363e30;
    --wing: #df937b;
    --contour: #3b3833;
    --plate: #ebe8e2;
    --plate-dim: 0.95;
    --shadow: rgba(0, 0, 0, 0.3);
    --glass: rgba(55, 53, 50, 0.86);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #2e2d2a;
  --surface: #373532;
  --fg: #e0dbd2;
  --muted: #b4ada1;
  --faint: #948d82;
  --line: #47443e;
  --accent: #a2c695;
  --accent-soft: #363e30;
  --wing: #df937b;
  --contour: #3b3833;
  --plate: #ebe8e2;
  --plate-dim: 0.95;
  --shadow: rgba(0, 0, 0, 0.3);
  --glass: rgba(55, 53, 50, 0.86);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--accent); }

/* ---------- Theme toggle (sun/moon) ---------- */
.theme-toggle {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; grid-area: 1 / 1; transition: transform 0.6s cubic-bezier(.2,.7,.2,1), opacity 0.4s ease; }
.theme-toggle .moon { opacity: 0; transform: rotate(-70deg) scale(0.6); }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 0; transform: rotate(70deg) scale(0.6); }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { opacity: 0; transform: rotate(70deg) scale(0.6); }
  :root:not([data-theme="light"]) .theme-toggle .moon { opacity: 1; transform: none; }
}

/* ---------- Theme change ----------
   Preferred path: a View Transition. The old theme stays fully opaque underneath
   while the new theme fades in over it, so there is no washed-out midpoint where
   both are half transparent. Fallback: every color eases together. */
::view-transition-old(root) {
  animation: none;
}
::view-transition-new(root) {
  animation: theme-fade-in 0.6s cubic-bezier(.4, 0, .2, 1) both;
  mix-blend-mode: normal;
}
@keyframes theme-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.theme-fading,
.theme-fading *,
.theme-fading *::before,
.theme-fading *::after {
  transition: background-color 0.5s cubic-bezier(.4, 0, .2, 1), color 0.5s cubic-bezier(.4, 0, .2, 1),
              border-color 0.5s cubic-bezier(.4, 0, .2, 1), fill 0.5s cubic-bezier(.4, 0, .2, 1),
              stroke 0.5s cubic-bezier(.4, 0, .2, 1), box-shadow 0.5s cubic-bezier(.4, 0, .2, 1) !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}
