/* ================================================================
   TOKENS — Light mode (default)
   ================================================================ */
:root {
  --bg: #f0f7f9;
  --surface: #ffffff;
  --text: #0c1a24;
  --muted: #4a6878;
  --accent: #0e7490;
  --accent-strong: #0a5a6f;
  --accent-warm: #d97706;
  --border: #b8d4dc;
  --focus: #b00020;
  --hero-from: #e8f4f7;
  --hero-to: #f7f0e6;
  --tag-bg: #e0f2f7;
  --tag-border: #7ecde4;
  --tag-text: #0a5a6f;
  --blockquote-bg: #e8f4f7;
  --card-hover-bg: #f5fbfd;
  --code-bg: #0f172a;
  --code-text: #f9fafb;
  --max-width: 72rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
}

/* ================================================================
   TOKENS — Dark mode (system preference, not overridden by user)
   ================================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080f17;
    --surface: #0f1a24;
    --text: #e8f3f7;
    --muted: #7fa8b8;
    --accent: #22d3ee;
    --accent-strong: #67e8f9;
    --accent-warm: #fbbf24;
    --border: #1e3345;
    --focus: #f87171;
    --hero-from: #0f1a24;
    --hero-to: #0d1e2a;
    --tag-bg: #0d2a36;
    --tag-border: #164e63;
    --tag-text: #67e8f9;
    --blockquote-bg: #0d2233;
    --card-hover-bg: #111e2a;
    --code-bg: #020b12;
    --code-text: #f9fafb;
  }
}

/* ================================================================
   TOKENS — Dark mode (user toggled via button)
   ================================================================ */
[data-theme="dark"] {
  --bg: #080f17;
  --surface: #0f1a24;
  --text: #e8f3f7;
  --muted: #7fa8b8;
  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-warm: #fbbf24;
  --border: #1e3345;
  --focus: #f87171;
  --hero-from: #0f1a24;
  --hero-to: #0d1e2a;
  --tag-bg: #0d2a36;
  --tag-border: #164e63;
  --tag-text: #67e8f9;
  --blockquote-bg: #0d2233;
  --card-hover-bg: #111e2a;
  --code-bg: #020b12;
  --code-text: #f9fafb;
}

/* ================================================================
   BASE
   ================================================================ */
* {
  box-sizing: border-box;
}

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

body {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.12em;
}

a:hover,
a:focus-visible {
  color: var(--accent-strong);
}

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

/* ================================================================
   SKIP LINK
   ================================================================ */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--text);
  color: var(--surface);
  padding: var(--space-1) var(--space-2);
  z-index: 9999;
}

.skip-link:focus {
  left: var(--space-1);
}

/* ================================================================
   LAYOUT
   ================================================================ */
.container {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

/* ================================================================
   HEADER
   ================================================================ */
.site-header {
  border-bottom: 3px solid var(--accent);
  background: var(--surface);
}

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

.logo {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
}

.logo:hover,
.logo:focus-visible {
  color: var(--accent-strong);
}

/* ================================================================
   NAVIGATION
   ================================================================ */
.nav-list {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--space-2);
}

.nav-list a {
  font-weight: 600;
  text-decoration: none;
  padding-bottom: 0.15rem;
  border-bottom: 2px solid transparent;
}

.nav-list a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

/* ================================================================
   DARK MODE TOGGLE
   ================================================================ */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem 0.65rem;
  line-height: 1;
  display: flex;
  align-items: center;
  width: auto;
  font-weight: 400;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: var(--tag-bg);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ================================================================
   MAIN
   ================================================================ */
main {
  padding: var(--space-4) 0;
}

section,
article,
.card,
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: var(--space-3);
}

/* ================================================================
   HERO
   ================================================================ */
.hero {
  margin-bottom: var(--space-4);
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
  border-left: 4px solid var(--accent);
}

.hero h1 {
  margin-top: 0;
  line-height: 1.2;
}

/* ================================================================
   GRID
   ================================================================ */
.grid {
  display: grid;
  gap: var(--space-3);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

/* Crisis/dashboard cards — amber left-border accent */
.grid-3 article {
  border-left: 4px solid var(--accent-warm);
}

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.25;
}

p,
ul,
ol,
dd {
  margin-top: 0;
}

.meta {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ================================================================
   TAGS
   ================================================================ */
.tag {
  display: inline-block;
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  color: var(--tag-text);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ================================================================
   RESOURCE & POST LISTS
   ================================================================ */
.resource-list,
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.resource-list li,
.post-list li {
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 0.5rem;
  padding: var(--space-2);
  background: var(--surface);
}

.resource-list li:hover,
.post-list li:hover {
  border-left-color: var(--accent);
  background: var(--card-hover-bg);
}

/* ================================================================
   FILTER LINKS
   ================================================================ */
.filter-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.filter-links a {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  text-decoration: none;
}

.filter-links a:hover {
  border-color: var(--accent);
  background: var(--tag-bg);
}

/* ================================================================
   BLOCKQUOTE
   ================================================================ */
blockquote {
  margin: 0;
  padding: var(--space-2);
  border-left: 0.3rem solid var(--accent);
  border-radius: 0 0.5rem 0.5rem 0;
  background: var(--blockquote-bg);
}

/* ================================================================
   CODE
   ================================================================ */
pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: var(--space-2);
  border-radius: 0.5rem;
  overflow-x: auto;
}

code {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  font-size: 0.9em;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ================================================================
   FORM
   ================================================================ */
form {
  display: grid;
  gap: var(--space-2);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  font: inherit;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

textarea {
  min-height: 10rem;
  resize: vertical;
}

button {
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  font: inherit;
  padding: 0.65rem 0.75rem;
  width: auto;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button:hover,
button:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
  margin-top: var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer .container {
  padding: var(--space-2) 0;
  color: var(--muted);
}

/* ================================================================
   MOTION SAFETY — wrap transitions
   ================================================================ */
@media (prefers-reduced-motion: no-preference) {
  .nav-list a {
    transition: border-bottom-color 0.15s ease, color 0.15s ease;
  }

  .resource-list li,
  .post-list li {
    transition: border-left-color 0.15s ease, background 0.15s ease;
  }

  .filter-links a,
  .theme-toggle {
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 40rem) {
  .site-header .container {
    align-items: flex-start;
  }
}
