@import url('/assets/brand.css');

/* ── Design variables: spacing, type, colour for BOTH themes ─────────────────── */
:root {
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --t-xs: 0.78rem; --t-sm: 0.9rem; --t-md: 1rem; --t-lg: 1.25rem; --t-xl: 1.6rem; --t-2xl: 2.2rem; --t-hero: clamp(3rem, 7vw, 4.6rem);
  --radius: 14px; --radius-sm: 8px;
  --font-body: var(--brand-font-body);
  --font-head: var(--brand-font-heading);
  --gold: var(--brand-primary);
  --rust: var(--brand-accent);
  --sand: var(--brand-background);
  /* dark theme (default — bold & direct) */
  --bg: #15120f; --bg-2: #1c1815; --surface: #221d19; --surface-2: #2b241f; --border: #3d342c;
  --text: #f2ece2; --muted: #c9beae; --on-gold: #1a1410; --on-rust: #f7f1e8;
  /* lighter tints of the brand gold/rust so TEXT clears AA on dark; fills keep the exact brand hue */
  --gold-text: color-mix(in srgb, var(--brand-primary) 78%, #fff); --rust-text: color-mix(in srgb, var(--brand-accent) 55%, #fff);
  --ok: #7fd39a; --warn: #f0c060; --bad: #ff9b85; --info: #8fc4ff;
  --ok-bg: #173323; --warn-bg: #3a2d10; --bad-bg: #3b1d16; --info-bg: #1b2b3d;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: var(--brand-background); --bg-2: #efeae0; --surface: #f8f5ee; --surface-2: #ffffff; --border: #cfc6b6;
  --text: var(--brand-text); --muted: #5f5754; --on-gold: #1a1410; --on-rust: #fbf6ee;
  --gold-text: color-mix(in srgb, var(--brand-primary) 62%, #000); --rust-text: var(--brand-accent);
  --ok: #1f6b3a; --warn: #7a5212; --bad: #9a2f14; --info: #1f4e8a;
  --ok-bg: #d9efe0; --warn-bg: #f4e6c9; --bad-bg: #f6d9d1; --info-bg: #dbe7f6;
  --shadow: 0 10px 30px rgba(60,40,20,.12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-body); font-size: var(--t-md); line-height: 1.55; color: var(--text); background: var(--bg); min-height: 100vh; overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--gold-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.1; margin: 0 0 var(--s-3); letter-spacing: -0.01em; }
h1 { font-size: var(--t-2xl); } h2 { font-size: var(--t-xl); } h3 { font-size: var(--t-lg); } h4 { font-size: var(--t-md); }
p { margin: 0 0 var(--s-3); }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: var(--t-xs); color: var(--gold-text); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.icon { width: 24px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; flex: none; }
.icon.lg { width: 36px; height: 24px; }

.price, .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.price { font-weight: 700; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.wrap { width: min(1180px, 100% - 2 * var(--s-4)); margin: 0 auto; }
.section { padding: var(--s-7) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); }
.grid { display: grid; gap: var(--s-4); }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.stack > * + * { margin-top: var(--s-3); }
.split { grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.between { justify-content: space-between; }

/* ── Header / nav ───────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 64px; }
.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--text); font-family: var(--font-head); font-weight: 700; }
.brand img { height: 40px; width: auto; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: var(--s-1); align-items: center; }
.nav a, .nav button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s-3); border-radius: var(--radius-sm); color: var(--text); font-weight: 600; font-size: var(--t-sm); border: 0; background: none; font-family: inherit; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--gold-text); background: var(--surface); }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; flex-direction: column; align-items: stretch; background: var(--bg-2); border-bottom: 1px solid var(--border); padding: var(--s-3); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a, .nav button { justify-content: flex-start; min-height: 48px; }
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 var(--s-5); border-radius: 999px; font-weight: 700; font-family: inherit; font-size: var(--t-sm); cursor: pointer; border: 2px solid transparent; transition: transform .12s ease, filter .12s ease; text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--gold); color: var(--on-gold); }
.btn-accent { background: var(--rust); color: var(--on-rust); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 40px; padding: 0 var(--s-4); font-size: var(--t-xs); }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

/* ── Panels, badges ─────────────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3); height: 100%; }
.panel.tight { padding: var(--s-4); }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: var(--s-3); }
.panel-head h3 { margin: 0; }
.panel-price { margin-left: auto; text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 700; letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gold { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); color: var(--gold-text); }
.badge-neutral { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-4) var(--s-5); }
.kpi .v { font-family: var(--font-head); font-size: clamp(1.3rem, 4.5vw, var(--t-2xl)); font-weight: 700; line-height: 1; margin: var(--s-2) 0; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { color: var(--muted); font-size: var(--t-sm); }
.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--rust), var(--gold)); }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

/* ── Hero ───────────────────────────────────────────────────────────────────── */
.hero { position: relative; min-height: min(84vh, 760px); display: flex; align-items: center; background-image: url('/assets/hero-generated.webp'); background-size: cover; background-position: center; color: #f7f1e8; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,8,6,.55) 0%, rgba(10,8,6,.72) 60%, rgba(21,18,15,.96) 100%); }
.hero .wrap { position: relative; padding: var(--s-8) 0 var(--s-7); }
.hero h1 { font-size: var(--t-hero); line-height: 1.02; margin: var(--s-3) 0 var(--s-4); max-width: 14ch; color: #f7f1e8; text-wrap: balance; }
.hero p.lead { font-size: var(--t-lg); max-width: 56ch; color: #eadfcf; }
.hero .eyebrow { color: #f0c060; }
.hero .cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-5); }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-3); margin-top: var(--s-6); }
.hero-stats div { border-left: 3px solid var(--gold); padding-left: var(--s-3); }
.hero-stats b { display: block; font-family: var(--font-head); font-size: var(--t-xl); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hero-stats span { color: #d9cdbb; font-size: var(--t-sm); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: var(--t-sm); }
.field .hint { color: var(--muted); font-size: var(--t-xs); }
.field .err { color: var(--bad); font-size: var(--t-xs); min-height: 1em; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 44px; padding: 10px 12px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.form-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.error-summary { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-sm); padding: var(--s-3) var(--s-4); }
.notice { background: var(--info-bg); color: var(--info); border-radius: var(--radius-sm); padding: var(--s-3) var(--s-4); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.choice { display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.choice label { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; background: var(--surface-2); }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice input:checked + span { color: var(--gold-text); }
.choice label:has(input:checked) { border-color: var(--gold); }
.choice label:has(input:focus-visible) { outline: 3px solid var(--gold); }

/* ── Steps ──────────────────────────────────────────────────────────────────── */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; counter-reset: step; }
.steps li { list-style: none; font-size: var(--t-xs); color: var(--muted); border-top: 4px solid var(--border); padding-top: 6px; }
.steps li.done { border-color: var(--gold); color: var(--text); }
.steps li.active { border-color: var(--rust); color: var(--text); font-weight: 700; }
.steps ol, ol.steps { padding: 0; margin: 0; }
@media (max-width: 520px) { .steps li span { display: none; } }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); min-width: 560px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface-2); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; }
th[aria-sort="ascending"]::after { content: " \2191"; } th[aria-sort="descending"]::after { content: " \2193"; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
.table-tools { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding: var(--s-3); border-bottom: 1px solid var(--border); }
.table-tools input { max-width: 260px; }
.pager { display: flex; gap: var(--s-2); align-items: center; justify-content: flex-end; padding: var(--s-3); font-size: var(--t-sm); }

/* ── States ─────────────────────────────────────────────────────────────────── */
.skeleton { display: grid; gap: 10px; }
.skeleton span { display: block; height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty, .error-state { text-align: center; padding: var(--s-6) var(--s-4); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.error-state { color: var(--bad); border-color: var(--bad); }

/* ── Toast & dialog ─────────────────────────────────────────────────────────── */
.toast-host { position: fixed; bottom: var(--s-4); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(480px, calc(100% - 32px)); }
.toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-left: 5px solid var(--gold); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); font-size: var(--t-sm); display: flex; justify-content: space-between; gap: 12px; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.toast button { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; min-width: 44px; min-height: 32px; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-5); width: min(560px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.55); }

/* ── Map ────────────────────────────────────────────────────────────────────── */
.map-shell { position: relative; background: #1a2417; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.map-shell svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.map-legend { display: flex; flex-wrap: wrap; gap: var(--s-3); font-size: var(--t-xs); color: var(--muted); padding: var(--s-3); }
.map-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -3px; margin-right: 6px; border: 1px solid rgba(255,255,255,.4); }
.map-controls { position: absolute; top: var(--s-3); right: var(--s-3); display: grid; gap: 6px; }
.map-controls button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255,255,255,.35); background: rgba(20,16,12,.8); color: #f7f1e8; font-weight: 700; cursor: pointer; }
.parcel-shape { fill-opacity: .28; stroke-width: 2; cursor: pointer; transition: fill-opacity .12s; }
.parcel-shape:hover, .parcel-shape.selected { fill-opacity: .5; stroke-width: 3; }
.parcel-available { fill: #7fd39a; stroke: #7fd39a; }
.parcel-protected { fill: var(--gold); stroke: var(--gold); }
.parcel-restoration { fill: #8fc4ff; stroke: #8fc4ff; }
.heat-cell { fill: #ff5a1f; pointer-events: none; }
.sighting-dot { fill: #fff3d6; stroke: #a63d11; stroke-width: 1; pointer-events: none; }
.map-label { font-family: var(--font-body); font-size: 11px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 3px; pointer-events: none; }

/* ── Lion cards / media ─────────────────────────────────────────────────────── */
.media { aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.media img { width: 100%; height: 100%; object-fit: cover; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 var(--s-4) var(--s-5); }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); }
.timeline time { display: block; color: var(--muted); font-size: var(--t-xs); }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
footer.site { border-top: 1px solid var(--border); background: var(--bg-2); padding: var(--s-7) 0 var(--s-6); margin-top: var(--s-7); color: var(--muted); font-size: var(--t-sm); }
footer.site h4 { color: var(--text); }
footer.site a { color: var(--text); }
.trust { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ── Admin shell ────────────────────────────────────────────────────────────── */
.admin { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-4); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 var(--s-3); border-radius: var(--radius-sm); color: var(--text); font-weight: 600; font-size: var(--t-sm); }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: var(--surface); color: var(--gold-text); border-left: 3px solid var(--gold); }
.admin-main { padding: var(--s-5); min-width: 0; }
.admin-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-3); margin-bottom: var(--s-5); }
.admin-top h1 { margin: 0; font-size: var(--t-xl); }
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { display: flex; flex-wrap: wrap; width: 100%; }
}
.chart { width: 100%; height: auto; }
.chart .bar { fill: var(--gold); }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font-body); }
.evidence-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.evidence-grid figure { margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.evidence-grid img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.evidence-grid figcaption { padding: 8px; font-size: var(--t-xs); color: var(--muted); }
.theme-toggle { display: inline-flex; align-items: center; gap: 8px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
