/*
  Atlas Dinosaures — styles
  - Design tokens (light/dark)
  - Layout: container, grid, rows
  - Components: buttons, chips, cards, tabs, panel, modal
  - Charts (SVG) and timeline visuals
  - Accessibility: focus, contrast, reduced motion
*/

/* Design tokens */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;

  --shadow-s: 0 1px 2px hsl(220 40% 2% / 0.06), 0 1px 1px hsl(220 40% 2% / 0.05);
  --shadow-m: 0 4px 10px hsl(220 40% 2% / 0.10), 0 2px 4px hsl(220 40% 2% / 0.08);
  --shadow-l: 0 16px 40px hsl(220 40% 2% / 0.18), 0 6px 12px hsl(220 40% 2% / 0.12);

  --space-2xs: 4px;
  --space-xs: 8px;
  --space-s: 12px;
  --space-m: 16px;
  --space-l: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 72px;

  /* Light palette */
  --bg: hsl(220 20% 98%);
  --bg-elev: hsl(220 20% 99%);
  --bg-soft: hsl(220 24% 96%);
  --text: hsl(220 30% 15%);
  --muted: hsl(220 10% 40%);
  --border: hsl(220 18% 88%);
  --primary: hsl(260 80% 57%);
  --primary-ink: #fff;
  --accent: hsl(200 90% 45%);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: hsl(220 28% 7%);
    --bg-elev: hsl(220 30% 10%);
    --bg-soft: hsl(220 26% 12%);
    --text: hsl(220 20% 94%);
    --muted: hsl(220 10% 70%);
    --border: hsl(220 16% 22%);
    --primary: hsl(270 90% 68%);
    --primary-ink: #0b0614;
    --accent: hsl(200 90% 60%);
  }
}

html[data-theme="dark"] {
  --bg: hsl(220 28% 7%);
  --bg-elev: hsl(220 30% 10%);
  --bg-soft: hsl(220 26% 12%);
  --text: hsl(220 20% 94%);
  --muted: hsl(220 10% 70%);
  --border: hsl(220 16% 22%);
  --primary: hsl(270 90% 68%);
  --primary-ink: #0b0614;
  --accent: hsl(200 90% 60%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus { left: 16px; top: 16px; width: auto; height: auto; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius-s); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-l); }
.row { display: flex; gap: var(--space-m); }
.row.center { align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.gap-s { gap: var(--space-s); }
.row.gap-l { gap: var(--space-xl); }
.flex { flex: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-l);
}

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--bg), var(--bg-elev) 60%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.2) blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.main-nav a { color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.main-nav a:hover, .main-nav a:focus { background: var(--bg-soft); outline: none; }
.header-actions { display: inline-flex; gap: var(--space-s); }

.hero { position: relative; padding: var(--space-3xl) 0; overflow: clip; }
.hero .baseline { color: var(--muted); max-width: 60ch; }
.hero-cta { display: flex; gap: var(--space-m); margin-top: var(--space-l); }
.hero-bg { position: absolute; inset: 0; z-index: -1; opacity: .9; }

.section-header { margin: var(--space-2xl) 0 var(--space-l); }
.section-header h2 { margin: 0 0 8px; }
.muted { color: var(--muted); }

.filters { display: grid; gap: var(--space-m); margin-bottom: var(--space-l); }
.filters input, .filters select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev); color: inherit; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg-soft); border-radius: 999px; border: 1px dashed var(--border); font-size: 12px; }
.chip button { background: transparent; border: 0; cursor: pointer; color: inherit; }

.card { grid-column: span 4; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-s); overflow: hidden; display: flex; flex-direction: column; }
.card:hover { box-shadow: var(--shadow-m); transform: translateY(-1px); transition: transform 160ms ease, box-shadow 160ms ease; }
.card .cover { height: 120px; background: linear-gradient(135deg, hsl(220 70% 55% / .2), hsl(280 70% 60% / .2)); display: grid; place-items: center; }
.card .body { padding: var(--space-m); display: grid; gap: 6px; }
.card .title { font-weight: 700; }
.card .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.card .actions { display: flex; gap: var(--space-s); padding: var(--space-m); padding-top: 0; }

@media (max-width: 920px) { .card { grid-column: span 6; } }
@media (max-width: 640px) { .card { grid-column: span 12; } }

.btn { appearance: none; border: 1px solid var(--border); background: var(--bg-elev); color: inherit; padding: 8px 12px; border-radius: 10px; cursor: pointer; box-shadow: var(--shadow-s); }
.btn:hover { filter: brightness(1.02); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: color-mix(in oklab, var(--primary), black 8%); }
.btn.ghost { background: transparent; }

.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-m); box-shadow: var(--shadow-s); overflow: clip; }
.panel-body { padding: var(--space-l); }

.control { display: grid; gap: 6px; margin-bottom: var(--space-m); }
label { font-weight: 600; }
input[type="range"] { width: 260px; }

.chart { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-m); min-height: 240px; box-shadow: var(--shadow-s); padding: var(--space-s); }
.chart-card { flex: 1 1 320px; display: grid; gap: var(--space-s); }

.tabs { display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); }
.tabs [role="tab"] { background: transparent; border: 0; padding: 10px 12px; cursor: pointer; border-radius: 10px 10px 0 0; }
.tabs [role="tab"][aria-selected="true"] { background: var(--bg-elev); border: 1px solid var(--border); border-bottom-color: transparent; }
.tabpanes article { padding: var(--space-l); background: var(--bg-elev); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-m) var(--radius-m); min-height: 220px; }

dialog { width: min(720px, 96vw); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 0; background: var(--bg-elev); color: inherit; box-shadow: var(--shadow-l); }
dialog::backdrop { backdrop-filter: blur(2px) brightness(.8); }
dialog header { padding: var(--space-m); border-bottom: 1px solid var(--border); }
dialog #speciesContent { padding: var(--space-l); display: grid; gap: var(--space-m); }

.code { font-family: var(--font-mono); font-size: 13px; background: var(--bg-soft); padding: var(--space-m); border-radius: var(--radius-s); border: 1px dashed var(--border); overflow: auto; }

.site-footer { border-top: 1px solid var(--border); padding: var(--space-l) 0; margin-top: var(--space-2xl); color: var(--muted); }
.noscript { margin: var(--space-l); background: #fee; color: #900; padding: var(--space-m); border: 1px solid #fbb; border-radius: 8px; }

/* Focus ring */
:where(a, button, input, select, [role="tab"]) {
  outline: none;
}
:where(a, button, input, select, [role="tab"]):focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), white 20%);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* Utilities */
.sr-only { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

