/* =========================================================
   Aquendium — visual identity v4
   Concept: Victorian conservatory at dusk × natural history library
   Mode: warm dark, lit-from-within
   Type: Fraunces (display) + Source Serif 4 (body)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600&display=swap');

:root {
  /* Surface — deep, warm, never blue-black */
  --color-bg: #131a16;            /* deep forest shadow */
  --color-bg-deep: #0c1210;       /* darker recessed zones */
  --color-surface: #1a2520;       /* raised surfaces, cards */
  --color-surface-warm: #1f2a23;  /* slightly warmer raised */
  --color-surface-edge: #2a3830;  /* hairline borders */
  --color-surface-edge-soft: #233029;

  /* Ink — warm bone-paper on dark, never cold white */
  --color-ink: #d8cdb6;            /* primary body text — aged paper */
  --color-ink-strong: #ebe2ce;     /* near-white for emphasis */
  --color-ink-soft: #a89a7d;       /* secondary text — soft sand */
  --color-ink-muted: #7a6f5a;      /* tertiary, captions */

  /* Brand & accents */
--color-primary: #6d8a6a;        /* moss / lichen green — readable on dark */
--color-primary-deep: #4a6347;
--color-water: #3a6b7a;          /* deep aquatic blue — water signal */
--color-water-soft: #5b8a9a;     /* lighter, for highlights */
--color-water-deep: #1f3a47;     /* very deep — for shadow/gradient */
--color-accent: #c08552;         /* brass / amber — lamplight */
--color-accent-soft: #d4a373;
--color-accent-deep: #8c5a30;

  /* Type */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Layout */
  --content-width: 720px;
  --content-width-wide: 960px;
  --radius: 2px;
  --radius-lg: 6px;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
  color: var(--color-ink);
  background: var(--color-bg);
  /* Subtle warm vignette + paper grain — gives the lit-from-within feel */
  background-image:
  radial-gradient(
    ellipse at 50% 0%,
    rgba(192, 133, 82, 0.07) 0%,
    transparent 50%
  ),
  radial-gradient(
    ellipse at 50% 100%,
    rgba(58, 107, 122, 0.10) 0%,
    transparent 50%
  ),
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'><g fill='none' stroke='%233a6b7a' stroke-width='0.5' opacity='0.11'><path d='M-20,40 Q40,25 100,40 T220,40 T340,40 T460,40'/><path d='M-20,60 Q50,42 120,60 T260,60 T400,60 T520,60'/><path d='M-20,80 Q45,62 110,80 T230,80 T350,80 T470,80'/><path d='M-20,100 Q55,82 130,100 T270,100 T410,100 T530,100'/><path d='M-20,120 Q40,102 100,120 T220,120 T340,120 T460,120'/><path d='M-20,140 Q50,122 120,140 T260,140 T400,140 T520,140'/><path d='M-20,160 Q45,142 110,160 T230,160 T350,160 T470,160'/><path d='M-20,180 Q55,162 130,180 T270,180 T410,180 T530,180'/><path d='M-20,200 Q40,182 100,200 T220,200 T340,200 T460,200'/><path d='M-20,220 Q50,202 120,220 T260,220 T400,220 T520,220'/><path d='M-20,240 Q45,222 110,240 T230,240 T350,240 T470,240'/><path d='M-20,260 Q55,242 130,260 T270,260 T410,260 T530,260'/><path d='M-20,280 Q40,262 100,280 T220,280 T340,280 T460,280'/><path d='M-20,300 Q50,282 120,300 T260,300 T400,300 T520,300'/><path d='M-20,320 Q45,302 110,320 T230,320 T350,320 T470,320'/><path d='M-20,340 Q55,322 130,340 T270,340 T410,340 T530,340'/><path d='M-20,360 Q40,342 100,360 T220,360 T340,360 T460,360'/></g></svg>"),
  radial-gradient(rgba(216, 205, 182, 0.012) 1px, transparent 1px);
background-size: auto, auto, 280px 280px, 4px 4px;
  background-attachment: fixed, fixed, fixed, fixed;
  min-height: 100vh;
}

/* =========================================================
   Typography
   ========================================================= */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-ink-strong);
  margin: 0;
  line-height: 1.15;
  font-weight: 500;
}

h1 {
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  color: var(--color-ink-strong);
}

h2 {
  font-size: 1.6rem;
  font-weight: 500;
  margin-top: var(--space-7);
  margin-bottom: var(--space-3);
  letter-spacing: -0.012em;
  color: var(--color-primary);
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
  color: var(--color-ink-strong);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
  display: block;
}

p {
  margin: 0 0 var(--space-4) 0;
}

a {
  color: var(--color-accent-soft);
  text-decoration: underline;
  text-decoration-color: var(--color-surface-edge);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

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

strong {
  font-weight: 600;
  color: var(--color-ink-strong);
}

em {
  font-style: italic;
  color: var(--color-ink-soft);
}

small {
  font-size: 0.85rem;
  color: var(--color-ink-muted);
}

hr {
  border: none;
  border-top: 1px solid var(--color-surface-edge);
  margin: var(--space-7) 0;
}

main h1 + p {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  font-weight: 400;
  color: var(--color-ink-soft);
  line-height: 1.55;
  margin-bottom: var(--space-7);
  letter-spacing: -0.005em;
}

/* =========================================================
   Layout
   ========================================================= */
.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* =========================================================
   Header — wordmark with custom botanical SVG
   ========================================================= */
.site-header {
  background: transparent;
  padding: var(--space-6) 0 var(--space-5) 0;
  border-bottom: 1px solid var(--color-surface-edge);
  margin-bottom: var(--space-8);
  position: relative;
}

.site-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--color-surface-edge-soft);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-5);
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--color-ink-strong);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-variation-settings: 'opsz' 144;
}

.site-title:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.site-title:hover .site-mark {
  fill: var(--color-accent);
}

.site-mark {
  width: 1.3em;
  height: 1.3em;
  fill: var(--color-primary);
  transition: fill 0.3s ease;
  flex-shrink: 0;
}

.site-header nav {
  display: flex;
  gap: var(--space-6);
}

.site-header nav a {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--color-accent);
}

/* =========================================================
   Main content
   ========================================================= */
main.container {
  padding-bottom: var(--space-9);
}

main p {
  font-size: 1.05rem;
}

ul {
  padding-left: 1.25rem;
  margin: 0 0 var(--space-4) 0;
}

li {
  margin-bottom: var(--space-2);
}

li::marker {
  color: var(--color-accent);
}

/* =========================================================
   Species index — editorial directory
   ========================================================= */
.species-index {
  list-style: none;
  padding: 0;
  margin: var(--space-6) 0;
  border-top: 1px solid var(--color-primary-deep);
  border-bottom: 1px solid var(--color-primary-deep);
}

.species-index li {
  border-bottom: 1px solid var(--color-surface-edge);
  margin: 0;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  transition: background 0.2s ease;
}

.species-index li:last-child {
  border-bottom: none;
}

.species-index li:hover {
  background: var(--color-surface);
}

.species-index li::marker {
  content: none;
}

.species-index a {
  text-decoration: none;
  color: var(--color-ink);
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.species-index a:hover {
  color: var(--color-accent);
}

.species-index .common-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-ink-strong);
}

.species-index .scientific-name {
  font-style: italic;
  color: var(--color-water-soft);
  font-size: 0.95rem;
}

.species-index .meta {
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  margin-top: var(--space-9);
  padding: var(--space-6) 0;
  border-top: 1px solid var(--color-surface-edge);
  color: var(--color-ink-muted);
  font-size: 0.9rem;
  position: relative;
}

.site-footer::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 1px;
  background: var(--color-surface-edge-soft);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.site-footer p {
  margin: 0;
}

.site-footer small {
  font-style: italic;
}

/* =========================================================
   Selection
   ========================================================= */
::selection {
  background: var(--color-water-deep);
  color: var(--color-ink-strong);
}

/* =========================================================
   Table of contents
   ========================================================= */
.toc {
  margin: var(--space-7) 0 var(--space-6) 0;
  padding: var(--space-5) var(--space-6);
  background: var(--color-surface);
  border-left: 2px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.toc-label {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-3) 0;
}

.toc ol {
  margin: 0;
  padding-left: var(--space-5);
  font-family: var(--font-body);
}

.toc li {
  margin-bottom: var(--space-2);
  font-size: 0.98rem;
  line-height: 1.4;
}

.toc li::marker {
  color: var(--color-ink-muted);
  font-variant-numeric: tabular-nums;
}

.toc a {
  color: var(--color-ink);
  text-decoration: none;
  transition: color 0.2s ease;
}

.toc a:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-underline-offset: 3px;
}

/* Improve anchor jump positioning — leave breathing room above target heading */
:target {
  scroll-margin-top: var(--space-6);
}

/* =========================================================
   Responsive
   ========================================================= */
/* =========================================================
   Back-to-top button
   ========================================================= */
.back-to-top {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-warm);
  color: var(--color-ink);
  border: 1px solid var(--color-surface-edge);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease, color 0.2s ease;
  z-index: 100;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--color-surface);
  color: var(--color-accent);
  border-color: var(--color-accent);
  text-decoration: none;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.back-to-top svg {
  flex-shrink: 0;
}   
@media (max-width: 640px) {
  html {
    font-size: 16px;
  }
  h1 {
    font-size: 2.2rem;
  }
  h2 {
    font-size: 1.4rem;
  }
  main h1 + p {
    font-size: 1.1rem;
  }
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .site-header nav {
    gap: var(--space-4);
  }
  .species-index a {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
  .species-index li {
    flex-direction: column;
    align-items: flex-start;
  }
  .back-to-top {
    bottom: var(--space-4);
    right: var(--space-4);
    padding: var(--space-2) var(--space-3);
    font-size: 0.72rem;
  }
}