/* ==========================================================================
   base.css — design tokens, font, reset, typography, forms, buttons.
   Shared by the public site (site.css) and the members area (admin.css).
   To re-theme, change the tokens in :root; everything else reads from them.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- Brand palette ---- */
  --navy-950: #050c1a;
  --navy-900: #071226;
  --navy-850: #0b1a35;
  --navy-800: #0f2245;
  --navy-700: #183262;
  --navy-600: #24457f;

  --emerald-50:  #ecfbf5;
  --emerald-100: #d2f5e7;
  --emerald-300: #6ee7c0;
  --emerald-400: #34d3a0;
  --emerald-500: #12b886;
  --emerald-600: #0b9a70;
  --emerald-700: #087a59;

  --gray-25:  #fcfcfd;
  --gray-50:  #f7f8fa;
  --gray-100: #eff2f6;
  --gray-200: #e3e7ee;
  --gray-300: #cdd4df;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #0f172a;

  /* ---- Semantic roles ---- */
  --ink:       var(--gray-900);
  --ink-soft:  var(--gray-700);
  --muted:     var(--gray-500);
  --line:      var(--gray-200);
  --line-strong: var(--gray-300);
  --bg:        #ffffff;
  --bg-alt:    var(--gray-50);
  --surface:   #ffffff;

  --primary:          var(--navy-900);   /* main buttons on light backgrounds */
  --primary-hover:    var(--navy-700);
  --primary-contrast: #ffffff;
  --accent:           var(--emerald-500); /* highlights, buttons on dark backgrounds */
  --accent-hover:     var(--emerald-400);
  --accent-contrast:  var(--navy-950);
  --accent-soft:      var(--emerald-50);
  --accent-text:      var(--emerald-700); /* accent colour that passes contrast on white */
  --link:             var(--emerald-700);

  --danger:     #c0362c;
  --danger-bg:  #fdeeec;
  --success:    #0b7a57;
  --success-bg: #e6f7ef;
  --focus:      #34d3a0;

  /* ---- Type ---- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  --text-xs: 0.78rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: clamp(1.75rem, 1.35rem + 1.3vw, 2.375rem);
  --text-3xl: clamp(2.35rem, 1.5rem + 3vw, 3.9rem);

  /* ---- Shape, depth, space ---- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / 0.08), 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow:    0 12px 32px -8px rgb(16 24 40 / 0.14), 0 4px 8px -4px rgb(16 24 40 / 0.06);
  --shadow-lg: 0 32px 64px -16px rgb(5 12 26 / 0.35);
  --container: 1200px;
  --container-narrow: 720px;
  --container-medium: 960px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:       #eef2f8;
    --ink-soft:  #c4cddb;
    --muted:     #8d9ab0;
    --line:      #1d2b45;
    --line-strong: #2a3b5c;
    --bg:        var(--navy-950);
    --bg-alt:    #08132a;
    --surface:   var(--navy-850);
    --primary:   var(--emerald-500);
    --primary-hover: var(--emerald-400);
    --primary-contrast: var(--navy-950);
    --accent-soft: #0d2a2a;
    --accent-text: var(--emerald-300);
    --link:      var(--emerald-300);
    --danger:    #f38b80;
    --danger-bg: #3a1714;
    --success:   #6ee7c0;
    --success-bg: #0d2a2a;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow:    0 12px 32px -8px rgb(0 0 0 / 0.55);
  }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-feature-settings: "cv11", "ss01", "ss03";
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, video { max-width: 100%; height: auto; display: block; }
audio { width: 100%; }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -0.022em; font-weight: 700; margin: 0 0 0.5em; color: var(--ink); }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); letter-spacing: -0.012em; }
p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }
::selection { background: var(--emerald-100); color: var(--navy-950); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---- Layout helpers ---- */
.container { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.container--medium { max-width: calc(var(--container-medium) + 2 * var(--gutter)); }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }
.eyebrow { font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 0.6rem; }
.eyebrow a { text-decoration: none; color: inherit; }
.lede { font-size: var(--text-lg); color: var(--ink-soft); max-width: 62ch; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 100; background: var(--surface); padding: 0.5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: 0.5rem; }

/* ---- Logo ---- */
.logo-mark { width: 2rem; height: 2rem; flex: none; display: block; }
.logo-mark__bg { fill: var(--emerald-500); }
.logo-mark__peak { stroke: var(--navy-900); }
.logo-mark__node { fill: var(--navy-900); }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; color: inherit; }
.brand__name { font-weight: 700; letter-spacing: -0.015em; font-size: 1.05rem; }

/* ---- Buttons ---- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.62rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  font: inherit; font-weight: 600; font-size: 0.94rem; line-height: 1.2; letter-spacing: -0.005em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.button:hover { border-color: var(--gray-400); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button--primary { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.button--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button--accent { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); box-shadow: 0 8px 24px -8px rgb(18 184 134 / 0.6); }
.button--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button--on-dark { background: rgb(255 255 255 / 0.06); color: #fff; border-color: rgb(255 255 255 / 0.18); box-shadow: none; }
.button--on-dark:hover { background: rgb(255 255 255 / 0.12); border-color: rgb(255 255 255 / 0.32); }
.button--ghost { background: transparent; box-shadow: none; }
.button--danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; box-shadow: none; }
.button--danger:hover { border-color: var(--danger); }
.button--lg { padding: 0.85rem 1.4rem; font-size: 1rem; }
.button--small { padding: 0.36rem 0.7rem; font-size: var(--text-sm); }
.button--block { width: 100%; }

.link-button {
  background: none; border: 0; padding: 0; font: inherit; color: var(--link);
  cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em;
}
.link-button--danger { color: var(--danger); }

/* ---- Forms ---- */
.field { display: grid; gap: 0.4rem; margin-bottom: 1.1rem; }
.field-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
label, legend { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.optional { font-weight: 400; color: var(--muted); font-size: var(--text-sm); }
input:not([type="checkbox"]):not([type="file"]), select, textarea {
  width: 100%; padding: 0.62rem 0.8rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--emerald-500); box-shadow: 0 0 0 4px rgb(18 184 134 / 0.16); }
textarea { resize: vertical; line-height: 1.55; }
input[type="file"] { font: inherit; font-size: var(--text-sm); }
input[type="checkbox"] { accent-color: var(--emerald-600); width: 1rem; height: 1rem; }
.hint { margin: 0; font-size: var(--text-sm); color: var(--muted); }
.hint code { background: var(--bg-alt); border: 1px solid var(--line); padding: 0.05em 0.35em; border-radius: 5px; }
.field__error { margin: 0; font-size: var(--text-sm); color: var(--danger); font-weight: 600; }
.checkbox { display: flex; align-items: center; gap: 0.55rem; font-weight: 500; margin-bottom: 1rem; }

/* ---- Alerts & flash ---- */
.alert { padding: 0.85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.flash { padding: 0.8rem 0; font-weight: 600; font-size: 0.95rem; }
.flash--success { background: var(--success-bg); color: var(--success); }
.flash--error { background: var(--danger-bg); color: var(--danger); }
.flash__inner { width: 100%; max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.6rem; border-radius: 999px; font-size: 0.74rem; font-weight: 650; }
.badge--published { background: var(--success-bg); color: var(--success); }
.badge--published::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--draft { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--line); }

/* ---- Rendered Markdown ---- */
.prose { font-size: 1.075rem; line-height: 1.75; color: var(--ink-soft); }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.65rem; margin: 2.4rem 0 0.8rem; color: var(--ink); }
.prose h3 { font-size: 1.25rem; margin: 1.9rem 0 0.6rem; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.25em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--accent-text); }
.prose strong { color: var(--ink); font-weight: 650; }
.prose img { border-radius: var(--radius); margin: 1.75rem 0; }
.prose blockquote { margin: 2rem 0; padding: 0.25rem 0 0.25rem 1.4rem; border-left: 3px solid var(--accent); color: var(--ink); font-size: 1.2rem; line-height: 1.6; font-weight: 500; letter-spacing: -0.01em; }
.prose blockquote p { margin: 0; }
.prose pre { background: var(--navy-900); color: #e6edf7; padding: 1.1rem 1.2rem; border-radius: var(--radius-sm); overflow-x: auto; }
.prose :not(pre) > code { background: var(--bg-alt); border: 1px solid var(--line); padding: 0.1em 0.35em; border-radius: 5px; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.75rem 0; font-size: 0.95rem; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; display: table; }
.prose th { background: var(--bg-alt); color: var(--ink); font-weight: 650; font-size: var(--text-sm); }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 0.65rem 0.85rem; text-align: left; }
.prose tr:last-child td { border-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

/* ---- Media ---- */
.media--image, .media--video { width: 100%; border-radius: var(--radius); }
.media--file { display: inline-flex; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- Review workflow (shared by admin and members pages) ---- */
.alert--info { background: var(--bg-alt); color: var(--text); border-color: var(--line); }
.badge--pending { background: #fff4e0; color: #9a5b00; border: 1px solid #f3d8a6; }
.badge--pending::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.textarea--mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92rem; }
.review-note { margin: 0 0 1.25rem; padding: 1rem 1.15rem; border-radius: var(--radius-sm); background: #fff4e0; border: 1px solid #f3d8a6; color: #5c3a00; }
.review-note__label { margin: 0 0 0.3rem; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.review-note__text { margin: 0 0 0.4rem; white-space: pre-line; }
.review-note .hint { color: inherit; opacity: 0.8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge--pending,
  :root:not([data-theme="light"]) .review-note { background: #3a2a0c; border-color: #6b4a12; color: #f7d9a0; }
}
.tag { display: inline-flex; align-items: center; gap: 0.35rem; width: fit-content; margin: 0 0 0.6rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; }
.tag--members { background: var(--success-bg); color: var(--success); }
.tag--members::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 2px; border: 1.5px solid currentColor; }

/* ---- Image picker (post editors) ---- */
.image-picker { margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.image-picker > summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; cursor: pointer; font-weight: 600; }
.image-picker > summary::marker { color: var(--muted); }
.image-picker__count { padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--line); font-size: var(--text-xs); color: var(--muted); }
.image-picker > .hint { padding: 0 1rem; }
.image-picker__grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); padding: 0.75rem 1rem 1rem; max-height: 460px; overflow-y: auto; }
.image-picker__item { margin: 0; display: grid; gap: 0.35rem; align-content: start; padding: 0.4rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.image-picker__item:has(input:checked) { border-color: var(--emerald-500); box-shadow: 0 0 0 3px rgb(18 184 134 / 0.18); }
.image-picker__item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--bg-alt); }
.image-picker__item figcaption { display: grid; gap: 0.1rem; font-size: var(--text-xs); line-height: 1.35; }
.image-picker__alt { color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.image-picker__source { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-picker__actions { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: var(--text-xs); }
.image-picker__use { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.image-picker__item--none { display: flex; align-items: center; gap: 0.5rem; font-size: var(--text-sm); color: var(--muted); cursor: pointer; }
.image-picker input[type="radio"] { appearance: auto; width: auto; height: auto; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; accent-color: var(--emerald-500); }
.image-picker label.image-picker__use, .image-picker label.image-picker__item--none { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-size: var(--text-xs); font-weight: 600; color: var(--text); }
.image-picker label.image-picker__item--none { grid-column: 1 / -1; padding: 0.55rem 0.75rem; font-size: var(--text-sm); font-weight: 500; color: var(--muted); }
.image-picker .link-button { font-size: var(--text-xs); }
