/* ============================================================
   Phyla Technologies, shared design system
   "The Naturalist's Press" — see DESIGN.md for the prose spec.
   Every page links this file. Page-specific styles live inline
   in each page's <style> block; anything that must stay
   consistent across pages belongs here.
   ============================================================ */

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* === Tokens, the Specimen Palette === */
:root {
  --parchment:        oklch(95.5% 0.012 80);
  --parchment-pale:   oklch(97.2% 0.008 80);
  --parchment-mid:    oklch(92% 0.014 78);
  --parchment-deep:   oklch(88% 0.018 75);

  --ink:              oklch(22% 0.02 70);
  --ink-soft:         oklch(35% 0.025 70);
  --ink-hairline:     oklch(35% 0.025 70 / 0.18);
  --ink-hairline-strong: oklch(35% 0.025 70 / 0.32);

  --tannin:           oklch(42% 0.10 55);
  --tannin-deep:      oklch(32% 0.09 55);

  --moss:             oklch(50% 0.08 140);
  --moss-deep:        oklch(38% 0.08 140);

  --ochre:            oklch(62% 0.12 70);

  --focus:            oklch(42% 0.10 55);

  /* Type system, "Field Data": Familjen Grotesk = logo only; Schibsted Grotesk = voice
     (headlines, body, UI); Space Mono = data (eyebrows, labels, numbers, IDs, buttons).
     Loaded as variable fonts so the font-variation-settings "wght" throughout keeps working. */
  --f-wordmark: 'Familjen Grotesk', system-ui, -apple-system, sans-serif;
  --f-voice:    'Schibsted Grotesk', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  --f-data:     'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: var(--f-voice); /* alias: existing var(--sans) usages now render in the voice face */

  --measure-narrow: 52ch;
  --measure: 65ch;
  --measure-wide: 75ch;

  --view-transition-duration: 280ms;
}

/* === Page transitions === */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: page-fade-out 220ms cubic-bezier(0.5, 0, 0.75, 0); }
::view-transition-new(root) { animation: page-fade-in 280ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes page-fade-out { to { opacity: 0; } }
@keyframes page-fade-in { from { opacity: 0; } }

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

body {
  font-family: var(--sans);
  font-feature-settings: "ss01", "ss02", "kern";
  font-variation-settings: "wdth" 100, "wght" 400;
  background: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
  overflow-x: hidden;
}

::selection { background: var(--tannin); color: var(--parchment); }

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

/* Skip link (visually hidden until focused) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--parchment);
  z-index: 100;
  border-radius: 2px;
}

/* === Type === */
.display {
  font-family: var(--sans);
  font-weight: 700;
  font-variation-settings: "wght" 700;
  font-size: clamp(2.75rem, 7vw, 5rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.display em {
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "wght" 500;
  color: var(--tannin);
}

.headline {
  font-weight: 600;
  font-variation-settings: "wght" 600;
  font-size: clamp(1.75rem, 3.2vw, 2.625rem);
  line-height: 1.15;
  letter-spacing: -0.018em;
  color: var(--ink);
}
.headline em {
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "wght" 500;
  color: var(--tannin);
}

.title {
  font-weight: 600;
  font-variation-settings: "wght" 600;
  font-size: 1.0625rem;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.body {
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: var(--measure);
}
.body-narrow { max-width: var(--measure-narrow); }
.body-large {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: var(--measure);
}

.label {
  font-family: var(--f-data);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.latin {
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "wght" 400;
}

/* === Layout primitives === */
.wrap {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.75rem);
}
.wrap-narrow {
  max-width: 880px;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.75rem);
}
.hairline {
  height: 1px;
  background: var(--ink-hairline);
  width: 100%;
}

/* === Header === */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--parchment);
  border-bottom: 1px solid var(--ink-hairline);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: clamp(0.6rem, 1.2vw, 0.95rem);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  line-height: 1;
}
/* Inline logo lockup (mark + wordmark), so the page's Familjen renders the wordmark.
   ~3x the original 40px on desktop for presence; scales down on narrow screens. */
.wordmark-svg {
  display: block;
  height: clamp(52px, 9vw, 120px);
  width: auto;
}
nav.primary {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: baseline;
}
nav.primary a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-variation-settings: "wdth" 100, "wght" 500;
  transition: color 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
nav.primary a:hover { color: var(--ink); }
nav.primary a.active,
nav.primary a[aria-current="page"] {
  color: var(--ink);
  font-variation-settings: "wdth" 100, "wght" 600;
}
nav.primary a.cta {
  color: var(--tannin);
  font-variation-settings: "wdth" 100, "wght" 600;
}
nav.primary a.cta:hover { color: var(--tannin-deep); }

/* === Section rhythm === */
section + section { padding-top: clamp(4.5rem, 9vw, 8rem); }
section { padding-bottom: clamp(4.5rem, 9vw, 8rem); }
.section-head { margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-head .label { margin-bottom: 0.875rem; display: block; }
.section-head h2 { max-width: 22ch; }
.section-head p { margin-top: 1.25rem; max-width: var(--measure); }

/* === Shared controls === */
/* Solid tannin button (contact submit, closing CTAs) */
.btn-primary {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--tannin);
  color: var(--parchment-pale);
  padding: 0.85rem 1.6rem;
  font-family: var(--f-data);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--tannin);
  border-radius: 0;
  text-decoration: none;
  transition: background 180ms ease-out, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.btn-primary:hover { background: var(--tannin-deep); border-color: var(--tannin-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.65; cursor: not-allowed; }

/* Underlined tannin text link with a nudging arrow. Mono, per the data/label system. */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.25rem;
  color: var(--tannin);
  text-decoration: none;
  font-family: var(--f-data);
  font-weight: 700;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--tannin);
  transition: color 180ms ease-out, border-color 180ms ease-out, gap 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.link-arrow:hover { color: var(--tannin-deep); border-color: var(--tannin-deep); gap: 0.75rem; }
.link-arrow .arrow { display: inline-block; line-height: 1; }

/* === Footer === */
footer.site-footer {
  border-top: 1px solid var(--ink-hairline);
  padding-block: 2.25rem 2.75rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.7fr) auto;
  gap: 2.5rem;
  align-items: baseline;
}
.footer-etymology {
  max-width: 60ch;
  line-height: 1.6;
}
.footer-etymology em { color: var(--tannin); font-style: italic; font-variation-settings: "wdth" 95, "wght" 500; }
.footer-meta { font-variant-numeric: tabular-nums; }
.footer-links { display: flex; gap: 1.75rem; justify-content: flex-end; }
.footer-links a {
  text-decoration: none;
  transition: color 180ms ease-out;
}
.footer-links a:hover { color: var(--ink); }

/* === Shared responsive (header, footer, section heads) === */
@media (max-width: 640px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .footer-links { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; gap: 0.85rem 1rem; }
  nav.primary {
    flex-wrap: wrap;
    gap: 0.5rem 1.1rem;
    justify-content: flex-start;
  }
  nav.primary a { white-space: nowrap; font-size: 0.875rem; }
}

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