/* =====================================================================
   GEOpetra design system — TERS theme (restrained)
   ---------------------------------------------------------------------
   Brand chrome (nav, wordmark, eyebrow, footer) carries the GEOpetra
   look. The "meat" of the app — analysis cards, tables, forms, results —
   keeps Bootstrap's clean default surfaces and uses the brand palette
   only as ACCENTS (primary buttons, links, active states, focus rings).

   Tokens mirror GEOpetra_website/DESIGN_SYSTEM.md — keep them in sync.
   This file is for the interactive app only; PDF/print templates are
   standalone and intentionally unaffected.
   ===================================================================== */

:root {
  /* ---- Brand tokens (source of truth: DESIGN_SYSTEM.md) ---- */
  /* Earth — primary neutral scale (warm stone/brown) */
  --color-earth-50:  #FAF7F2;
  --color-earth-100: #F2EBE0;
  --color-earth-200: #E2D3C0;
  --color-earth-300: #CBAF8A;
  --color-earth-400: #B08B62;
  --color-earth-500: #8C6D47;
  --color-earth-600: #6E5238;
  --color-earth-700: #52392A;
  --color-earth-800: #3A271D;
  --color-earth-900: #2C1E16;
  --color-earth-950: #1C1612;

  /* Terra — accent / CTA (rust / terracotta) */
  --color-terra-400: #D4754F;
  --color-terra-500: #C05A35;
  --color-terra-600: #A84828;

  /* Stone — supplementary neutral */
  --color-stone-light: #F5F0E8;
  --color-stone-mid:   #D9CEBC;
  --color-stone-dark:  #8A7D6E;

  /* ---- Accent-only Bootstrap retokenization ----
     Recolor just the "primary" channel (buttons, links, .text-primary,
     spinners, etc.) to terracotta. Surfaces, neutrals, borders, body
     text and radii keep Bootstrap's clean defaults. */
  --bs-primary: var(--color-terra-500);
  --bs-primary-rgb: 192, 90, 53;
  --bs-primary-text-emphasis: var(--color-terra-600);

  --bs-link-color: var(--color-terra-500);
  --bs-link-color-rgb: 192, 90, 53;
  --bs-link-hover-color: var(--color-terra-600);
  --bs-link-hover-color-rgb: 168, 72, 40;

  --bs-focus-ring-color: rgba(192, 90, 53, 0.25);

  /* Brand UI font (does not affect surface cleanliness). */
  --bs-body-font-family: "Geist", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bs-font-monospace: "Geist Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, "Liberation Mono", monospace;

  /* ---- Chart.js theme bridge (read by static/js/chart-theme.js) ----
     Chart.js can't see Bootstrap CSS vars directly (it draws to canvas),
     so chart-theme.js reads these via getComputedStyle and pushes them
     into Chart.defaults. Keep in sync with the dark-mode block below. */
  --geo-chart-grid: rgba(0, 0, 0, 0.1);
  --geo-chart-tick: rgba(33, 37, 41, 0.65);
  --geo-chart-label: var(--bs-body-color);
}

/* Clean, neutral content background — as before. */
body { background-color: #f8f9fa; }

/* =====================================================================
   Brand chrome — navigation (light, sticky, warm) + wordmark.
   ===================================================================== */
.app-navbar {
  background-color: rgba(250, 247, 242, 0.95);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-earth-200);
  min-height: 64px;
}
.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.35rem;
}
.app-navbar .navbar-brand .brand-geo { color: var(--color-terra-500); }
.app-navbar .navbar-brand .brand-petra { color: var(--color-earth-950); }
.app-navbar .nav-link {
  color: var(--color-earth-700);
  font-weight: 500;
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .nav-link.show {
  color: var(--color-terra-500);
}
.app-navbar .navbar-toggler { border-color: var(--color-earth-200); }

/* Eyebrow — signature uppercase, wide-tracked section label. */
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-earth-500);
  margin-bottom: 0.5rem;
}

/* Footer (PE disclaimer band) — warm, low-density chrome. */
.pe-disclaimer {
  font-size: 0.75rem;
  color: var(--color-earth-500);
  border-top: 1px solid var(--color-earth-200);
}

/* =====================================================================
   Accents only — applied over Bootstrap's clean defaults.
   ===================================================================== */

/* Primary call-to-action → terracotta. */
.btn-primary {
  --bs-btn-bg: var(--color-terra-500);
  --bs-btn-border-color: var(--color-terra-500);
  --bs-btn-hover-bg: var(--color-terra-600);
  --bs-btn-hover-border-color: var(--color-terra-600);
  --bs-btn-active-bg: var(--color-terra-600);
  --bs-btn-active-border-color: var(--color-terra-600);
  --bs-btn-disabled-bg: var(--color-terra-500);
  --bs-btn-disabled-border-color: var(--color-terra-500);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--color-terra-500);
  --bs-btn-border-color: var(--color-terra-500);
  --bs-btn-hover-bg: var(--color-terra-500);
  --bs-btn-hover-border-color: var(--color-terra-500);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--color-terra-600);
  --bs-btn-active-border-color: var(--color-terra-600);
  --bs-btn-active-color: #fff;
}
.btn-link {
  --bs-btn-color: var(--color-terra-500);
  --bs-btn-hover-color: var(--color-terra-600);
}

/* Accent text/icons → terracotta. */
.text-primary { color: var(--color-terra-500) !important; }

/* Focus ring → terracotta (over otherwise-default inputs). */
.form-control:focus,
.form-select:focus {
  border-color: var(--color-terra-400);
  box-shadow: 0 0 0 0.2rem rgba(192, 90, 53, 0.18);
}

/* Active selections pick up the accent. */
.list-group { --bs-list-group-active-bg: var(--color-terra-500);
  --bs-list-group-active-border-color: var(--color-terra-500); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--color-terra-500); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--color-terra-500); }
.nav-tabs { --bs-nav-tabs-link-active-color: var(--color-terra-600); }
.nav-tabs .nav-link:hover { color: var(--color-terra-500); }
.progress-bar { background-color: var(--color-terra-500); }

/* Favorite-pinned card highlight → terracotta, not yellow. */
.card.border-warning { border-color: var(--color-terra-500) !important; }

/* Product cards — warm border, soft hover lift (DESIGN_SYSTEM §5 Cards). */
.product-card {
  border-color: var(--color-earth-200);
  transition: box-shadow 0.15s ease-in-out;
}
.product-card:hover { box-shadow: 0 12px 32px rgba(58, 39, 29, 0.10); }
.product-card .card-footer {
  background-color: transparent;
  border-top: 1px solid var(--color-earth-100);
}

/* Product-card icon tile: 48px rounded earth-100 tile, terra stroke icon
   (DESIGN_SYSTEM §5 "Cards"). Used on the product picker. */
.product-icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 0.75rem;
  background-color: var(--color-earth-100);
  color: var(--color-terra-500);
  font-size: 1.5rem;
  line-height: 1;
}

/* The limitation/assumption callout uses the accent rule. */
.limitation-warning { border-left: 4px solid var(--color-terra-500); }

/* =====================================================================
   Auth / entrance pages (sign in, sign up, password reset, MFA challenge)
   — full brand treatment: petoskey-tile background, hex badge logo,
   centered white card.
   ===================================================================== */
body.auth-body {
  background-color: var(--color-earth-50);
  background-image: url("../brand/bg-petoskey-tile-subtle.a3cb98aa8f0c.svg");
  background-size: 420px auto;
}
.auth-shell { max-width: 430px; padding: 1.5rem 0 3rem; }
.auth-logo {
  width: 110px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(58, 39, 29, 0.18));
}
.auth-card {
  background: #fff;
  border: 1px solid var(--color-earth-200);
  border-radius: 1rem;
  box-shadow: 0 12px 32px rgba(58, 39, 29, 0.10);
}
/* allauth form action rows: inline buttons on manage pages, full-width
   stacked buttons inside the entrance card. */
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.auth-card .auth-actions { display: grid; }

/* allauth renders widgets without Bootstrap classes; style bare inputs
   inside allauth forms to match .form-control. */
.allauth-fields input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="hidden"]),
.allauth-fields select,
.allauth-fields textarea {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.allauth-fields input:not([type="checkbox"]):not([type="radio"]):focus,
.allauth-fields select:focus,
.allauth-fields textarea:focus {
  border-color: var(--color-terra-400);
  box-shadow: 0 0 0 0.2rem rgba(192, 90, 53, 0.18);
  outline: 0;
}
/* Native checkboxes/radios pick up the brand accent. */
input[type="checkbox"],
input[type="radio"] { accent-color: var(--color-terra-500); }
/* Bootstrap hardcodes blue for checked .form-check-input — rebrand it. */
.form-check-input:checked {
  background-color: var(--color-terra-500);
  border-color: var(--color-terra-500);
}
.form-check-input:focus {
  border-color: var(--color-terra-400);
  box-shadow: 0 0 0 0.2rem rgba(192, 90, 53, 0.18);
}

/* Account settings nav — shared across Profile / Plan / Email /
   Password / Two-Factor (partials/account_nav.html). */
.account-nav { font-size: 0.9rem; }
.account-nav .nav-link {
  color: var(--color-earth-700);
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  white-space: nowrap;
}
.account-nav .nav-link:hover { color: var(--color-terra-500); }
.account-nav .nav-link.active { color: #fff; }

/* Manage-card header h1s come from allauth's h1 element (h4-sized). */
.account-manage-card h1 { color: var(--color-earth-950); }
.account-panel .card-header { background-color: var(--color-earth-100); }

/* =====================================================================
   Dark mode (Bootstrap 5.3 native theming via [data-bs-theme="dark"]).
   ---------------------------------------------------------------------
   Bootstrap re-themes most component surfaces (cards, forms, dropdowns,
   tables, .bg-body, etc.) automatically once the attribute is set on
   <html> — see static/js/theme-toggle.js / templates/base.html. This
   block only overrides the custom, hand-rolled rules above that Bootstrap
   doesn't touch, plus bumps the accent a step lighter for AA contrast on
   dark surfaces.
   ===================================================================== */
[data-bs-theme="dark"] {
  /* Accent bump: promote terra-400 into the terra-500 "primary" slot and
     terra-500 into the terra-600 "hover/active" slot. Every rule above
     that reads var(--color-terra-500)/var(--color-terra-600) (buttons,
     links, focus rings, list-group/dropdown/nav-pills active states,
     progress bars, the favorite-card border, product-icon-tile, the
     limitation-warning rule, checked checkboxes/radios) picks this up
     automatically — no need to restate each selector. */
  --color-terra-500: #D4754F; /* was --color-terra-400 */
  --color-terra-600: #C05A35; /* was --color-terra-500 */

  --bs-primary-rgb: 212, 117, 79;
  --bs-link-color-rgb: 212, 117, 79;
  --bs-link-hover-color-rgb: 192, 90, 53;
  --bs-focus-ring-color: rgba(212, 117, 79, 0.35);

  /* Chart.js bridge (see :root above / static/js/chart-theme.js). */
  --geo-chart-grid: rgba(255, 255, 255, 0.14);
  --geo-chart-tick: rgba(233, 227, 219, 0.65);
  --geo-chart-label: var(--bs-body-color);
}

/* Content background — Bootstrap's own dark body bg, replacing the
   hardcoded light-mode `#f8f9fa` set on `body` above. */
[data-bs-theme="dark"] body { background-color: var(--bs-body-bg); }

/* Nav chrome — the warm cream navbar becomes a warm-dark (earth-950-ish)
   bar; the wordmark's earth-950 half needs to flip light to stay legible. */
[data-bs-theme="dark"] .app-navbar {
  background-color: rgba(28, 22, 18, 0.92);
  border-bottom-color: var(--color-earth-800);
}
[data-bs-theme="dark"] .app-navbar .navbar-brand .brand-petra { color: var(--color-earth-100); }
[data-bs-theme="dark"] .app-navbar .nav-link { color: var(--color-earth-200); }
[data-bs-theme="dark"] .app-navbar .nav-link:hover,
[data-bs-theme="dark"] .app-navbar .nav-link:focus,
[data-bs-theme="dark"] .app-navbar .nav-link.show { color: var(--color-terra-500); }
[data-bs-theme="dark"] .app-navbar .navbar-toggler { border-color: var(--color-earth-700); }
[data-bs-theme="dark"] .eyebrow { color: var(--color-earth-400); }

/* Footer disclaimer band — lighten the muted text/border a step so it
   still reads on a dark page. */
[data-bs-theme="dark"] .pe-disclaimer {
  color: var(--color-earth-400);
  border-top-color: var(--color-earth-800);
}

/* Focus rings — the two hardcoded rgba(terra-500,...) box-shadows above
   don't reference the terra-500 var, so restate them with the bumped rgb. */
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .allauth-fields input:not([type="checkbox"]):not([type="radio"]):focus,
[data-bs-theme="dark"] .allauth-fields select:focus,
[data-bs-theme="dark"] .allauth-fields textarea:focus,
[data-bs-theme="dark"] .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(212, 117, 79, 0.3);
}

/* Product picker cards. */
[data-bs-theme="dark"] .product-card { border-color: var(--color-earth-700); }
[data-bs-theme="dark"] .product-card:hover { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55); }
[data-bs-theme="dark"] .product-card .card-footer { border-top-color: var(--color-earth-800); }
[data-bs-theme="dark"] .product-icon-tile { background-color: var(--color-earth-800); }

/* Auth / entrance pages — keep the brand petoskey-tile treatment but on a
   dark ground; let the card match the page's dark body surface so the
   allauth inputs (which already key off var(--bs-body-bg)) blend in.
   The tile SVG itself is opaque cream, so a near-opaque dark wash is
   layered over it — the pattern stays as a faint texture instead of a
   full-brightness light background behind the dark card. */
[data-bs-theme="dark"] body.auth-body {
  background-color: var(--color-earth-900);
  background-image:
    linear-gradient(rgba(28, 22, 18, 0.92), rgba(28, 22, 18, 0.92)),
    url("../brand/bg-petoskey-tile-subtle.a3cb98aa8f0c.svg");
  background-size: auto, 420px auto;
}
[data-bs-theme="dark"] .auth-card {
  background: var(--bs-body-bg);
  border-color: var(--color-earth-700);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* Account settings nav / manage card. */
[data-bs-theme="dark"] .account-nav .nav-link { color: var(--color-earth-300); }
[data-bs-theme="dark"] .account-manage-card h1 { color: var(--color-earth-100); }
[data-bs-theme="dark"] .account-panel .card-header { background-color: var(--color-earth-800); }

/* Table header bands — Bootstrap's .table-light hardcodes literal light
   values into the table CSS vars (it is "light" by definition, not
   theme-aware), so every `<thead class="table-light">` across the products
   would keep a light band on a dark page. Remap it to the dark theme's
   tertiary surface. */
[data-bs-theme="dark"] .table-light {
  --bs-table-bg: var(--bs-tertiary-bg);
  --bs-table-color: var(--bs-body-color);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-striped-bg: var(--bs-tertiary-bg);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: var(--bs-secondary-bg);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: var(--bs-secondary-bg);
  --bs-table-hover-color: var(--bs-body-color);
  color: var(--bs-table-color);
  border-color: var(--bs-table-border-color);
}

/* =====================================================================
   Drawings stay paper — server-rendered SVG previews and canvas editors
   are engineering drawings, not app chrome; they keep a white background
   in both themes so line colors chosen by preview.py / the drawing JS
   stay legible and print-consistent. `.drawing-paper` is offered for new
   preview containers; the two containers below can't take a shared class
   without touching preview.py / drawing JS, so they're targeted directly.
   ===================================================================== */
.drawing-paper {
  background: #fff;
  border-radius: var(--bs-border-radius, 0.375rem);
}
/* TERS analysis_detail.html elevation/plan canvas — the drawing JS only
   clearRect()s (transparent), it never paints a background fill. */
#viz-canvas { background: #fff; }
/* mse_wall cross-section preview: preview.py already inlines
   `style="...background:#fff"` on the <svg> itself, so the drawing stays
   paper; only the surrounding card chrome needs the dark-mode retone,
   which Bootstrap already handles natively for `.card`. */
/* slope_engine's #section-svg / .slope-svg-preview (templates/slope/
   analysis_edit.html) hardcode their own light background colors inline
   in that template's <style> block (not CSS vars), so they already stay
   paper-toned in dark mode with no change needed here. */
