/* =========================
   Spire — Core Theme (Black • Sand • Brown)
   ========================= */

/* Reset & base */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { font-size: 16px; }
body {
  margin: 0;
  color-scheme: light dark;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

/* Theme tokens */
:root {
  /* Brand palette */
  --black:    #0b0b0b;
  --sand:     #d8c3a5;  /* light brown/sandy */
  --cocoa:    #5c3a21;  /* dark brown */
  --espresso: #1f1511;  /* deeper brown */
  --cream:    #f2ede6;  /* warm light text */

  /* Mapped UI vars */
  --bg:        var(--black);
  --bg-soft:   #111111;
  --card:      var(--espresso);
  --text:      var(--cream);
  --muted:     #cbb79f;
  --brand:     var(--sand);
  --brand-2:   #8b5e3c;
  --accent:    #c7a27a;
  --ring:      rgba(200, 170, 130, .45);
  --shadow:    0 12px 30px rgba(0,0,0,.45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:      #ffffff;
    --bg-soft: #faf8f6;
    --card:    #ffffff;
    --text:    #1b130f;
    --muted:   #6d5a49;
    --shadow:  0 10px 30px rgba(27,19,15,.08);
  }
}

/* Layout helpers */
.sf-body { background: var(--bg); color: var(--text); }
.sf-container { width: min(1100px, 92vw); margin-inline: auto; }

/* =========================
   Header / Navigation
   ========================= */
.sf-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in oklab, var(--text) 10%, transparent);
}
.sf-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; gap: 12px;
}
.sf-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.sf-logo { height: 34px; width: auto; }
.sf-brand-text { font-weight: 700; letter-spacing: .3px; }

.sf-burger {
  display: none; background: transparent;
  border: 1px solid color-mix(in oklab, var(--text) 18%, transparent);
  border-radius: 10px; padding: 8px; cursor: pointer;
}
.sf-burger-bar { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; }

.sf-nav { display: flex; }
.sf-nav-list { display: flex; gap: 18px; list-style: none; padding: 0; margin: 0; align-items: center; }
.sf-nav-list a { color: var(--text); text-decoration: none; opacity: .9; }
.sf-nav-list a:hover { opacity: 1; text-decoration: underline; }
.sf-linklike { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.sf-divider { width: 1px; height: 18px; background: color-mix(in oklab, var(--text) 18%, transparent); margin-inline: 6px; }
.sf-subtle { color: var(--muted); }

@media (max-width: 900px) {
  .sf-burger { display: block; }
  .sf-nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: var(--bg-soft);
    border-bottom: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  }
  .sf-nav.open { display: block; }
  .sf-nav-list { flex-direction: column; align-items: flex-start; padding: 14px 20px; gap: 10px; }
}

/* =========================
   Hero
   ========================= */
.sf-hero { position: relative; overflow: hidden; }
.sf-hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 480px at 20% -10%, color-mix(in oklab, var(--sand) 55%, transparent), transparent 60%),
    radial-gradient(900px 520px at 110% 10%, color-mix(in oklab, var(--cocoa) 45%, transparent), transparent 60%),
    linear-gradient(to bottom, var(--bg-soft), var(--bg));
  filter: blur(6px) saturate(110%);
  animation: sfGlow 18s ease-in-out infinite alternate;
}
@keyframes sfGlow {
  0%   { filter: hue-rotate(0deg)  blur(6px) saturate(108%); }
  100% { filter: hue-rotate(-6deg) blur(8px) saturate(120%); }
}
@media (prefers-reduced-motion: reduce) { .sf-hero-bg { animation: none; } }

.sf-hero-inner { position: relative; z-index: 1; padding: clamp(48px, 12vw, 110px) 0; text-align: center; }
.sf-hero-title { font-size: clamp(28px, 5vw, 54px); line-height: 1.05; margin: 0 0 10px; letter-spacing: .3px; }
.sf-gradient-text {
  background: linear-gradient(90deg, var(--sand), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.sf-hero-subtitle { color: var(--muted); font-size: clamp(16px, 2.2vw, 20px); margin: 0 auto 22px; max-width: 820px; }

/* =========================
   Buttons
   ========================= */
.sf-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.sf-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: 12px; border: 1px solid transparent;
  text-decoration: none; font-weight: 600; box-shadow: var(--shadow);
  transition: transform .08s ease, filter .12s ease;
}
.sf-btn:active { transform: translateY(1px); }
.sf-btn-primary {
  background: linear-gradient(90deg, var(--sand), var(--accent) 45%, var(--cocoa));
  color: #0b0b0b;  /* switch to #fff if you prefer */
  border: 1px solid color-mix(in oklab, var(--cocoa) 35%, transparent);
}
.sf-btn-primary:hover { filter: brightness(1.05); }
.sf-btn-ghost {
  background: transparent;
  border-color: color-mix(in oklab, var(--sand) 35%, transparent);
  color: var(--sand);
}

/* =========================
   Sections / Cards
   ========================= */
.sf-section { padding: clamp(28px, 6vw, 64px) 0; }
.sf-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px){ .sf-cards { grid-template-columns: 1fr; } }
.sf-card {
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--sand) 18%, transparent);
  border-radius: 16px; padding: 18px; box-shadow: var(--shadow);
}
.sf-card h3 { margin: 0 0 8px; }

/* =========================
   Stats (bigger, sand, subtle 3D)
   ========================= */
.sf-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: center; align-items: center; }
@media (max-width: 900px){ .sf-stats-grid { grid-template-columns: 1fr; } }

.sf-stat { text-align: center; perspective: 1000px; }

.sf-stat-number {
  /* ~20% smaller than the previous giant size */
  font-size: clamp(52px, 8vw, 112px);
  line-height: .88;
  font-weight: 900;
  letter-spacing: .02em;
  display: inline-block;
  font-variant-numeric: tabular-nums;

  /* Ensure sand color even if gradient clipping isn't supported */
  color: var(--sand);

  /* Gradient fill (applied when supported) */
  background: linear-gradient(
    180deg,
    var(--sand) 0%,
    #f3e8da 28%,
    var(--sand) 55%,
    #b98b62 100%
  );
  -webkit-background-clip: text; background-clip: text;

  /* Gentle 3D/extrusion that doesn't overpower the fill */
  text-shadow:
    0 1px 0 rgba(31,21,17,.85),
    0 3px 6px rgba(0,0,0,.35);

  -webkit-text-stroke: 0.3px rgba(31,21,17,.25);
}

/* Only make the text transparent if clipping is supported to avoid "blackish" look */
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .sf-stat-number {
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

.sf-stat-label { margin-top: 8px; font-size: clamp(12px, 1.6vw, 16px); color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .sf-stat-number { transition: transform .18s ease, filter .18s ease; }
  .sf-stat:hover .sf-stat-number { transform: translateY(-2px); filter: brightness(1.05); }
}

/* =========================
   Panel
   ========================= */
.sf-panel { background: linear-gradient(180deg, var(--bg-soft), transparent); }
.sf-panel-inner {
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--sand) 18%, transparent);
  border-radius: 16px; padding: 22px; text-align: center; box-shadow: var(--shadow);
}

/* =========================
   Footer
   ========================= */
.sf-footer { border-top: 1px solid color-mix(in oklab, var(--sand) 16%, transparent); margin-top: 30px; }
.sf-footer-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; gap: 12px; }
.sf-footer-nav { display: flex; gap: 14px; }
.sf-footer-nav a { color: var(--muted); text-decoration: none; }
.sf-footer-nav a:hover { color: var(--text); text-decoration: underline; }

/* =========================
   Flash messages
   ========================= */
#flashes { margin: 14px 0; display: grid; gap: 8px; }
.flash {
  padding: 10px 12px; border-radius: 12px;
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--text) 15%, transparent);
}
.flash-pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }

/* =========================
   Generic utilities
   ========================= */
.container { max-width: 960px; margin: 2rem auto; padding: 0 1rem; } /* legacy pages */
.centered-images { text-align: center; }
.centered-images img { margin: 0 .5rem; vertical-align: middle; }

/* --- Mobile readability for hero headline --- */

/* 1) Always give the gradient text a tiny outline so it never washes out */
.sf-gradient-text {
  -webkit-text-stroke: 0.5px rgba(0,0,0,.25);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}

/* 2) On small screens, add a dark scrim behind the hero content */
@media (max-width: 720px) {
  .sf-hero {
    position: relative;
  }
  .sf-hero::after {
    content: "";
    position: absolute; inset: 0;
    /* gentle top-to-bottom fade so the headline area gets contrast */
    background: linear-gradient(
      180deg,
      rgba(0,0,0,.45) 0%,
      rgba(0,0,0,.30) 40%,
      rgba(0,0,0,0) 100%
    );
    pointer-events: none;
    z-index: 0;
  }
  .sf-hero-inner { position: relative; z-index: 1; }
}

/* 3) On small screens, use a darker gradient for the word “Great” */
@media (max-width: 720px) {
  .sf-gradient-text {
    /* cocoa -> mid sand -> sand for stronger contrast on light BG */
    background: linear-gradient(90deg, var(--cocoa), 3f2718 50%, #a06e47);
    -webkit-background-clip: text;
    background-clip: text;

    /* a touch more edge to fight bright backgrounds */
    -webkit-text-stroke: 0.6px rgba(0,0,0,.55);
    text-shadow:
      0 1px 2px rgba(0,0,0,.35),
      0 2px 6px rgba(0,0,0,.25);
  }

  /* Slightly tighten the title on mobile for balance */
  .sf-hero-title { letter-spacing: .02em; }
}

/* 4) If the user requests higher contrast, force the darker blend everywhere */
@media (prefers-contrast: more) {
  .sf-gradient-text {
    background: linear-gradient(90deg, var(--cocoa), #a06e47 50%, var(--sand));
    -webkit-text-stroke: 0.6px rgba(0,0,0,.6);
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

/* --- Mobile CTA contrast fix --- */
@media (max-width: 720px) {
  /* Make primary CTA dark with light text */
  .sf-cta-row .sf-btn-primary {
    background: linear-gradient(90deg, var(--cocoa), #3f2718);
    color: var(--cream);
    border-color: color-mix(in oklab, var(--cream) 18%, var(--cocoa));
    text-shadow: 0 1px 1px rgba(0,0,0,.45);
    box-shadow: 0 6px 18px rgba(0,0,0,.55);
  }

  /* Ghost button: add a translucent dark backdrop + lighter border */
  .sf-cta-row .sf-btn-ghost {
    background: rgba(0,0,0,.28);
    border-color: color-mix(in oklab, var(--cream) 60%, var(--cocoa));
    color: var(--cream);
    /* if you want a little polish and your CSP allows it: */
    backdrop-filter: blur(3px);
  }

  /* Optionally add a soft chip behind the whole CTA row for readability */
  .sf-cta-row {
    background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(0,0,0,.18));
    padding: 8px 10px;
    border-radius: 14px;
  }
}

/* High-contrast users: always use dark primary */
@media (prefers-contrast: more) {
  .sf-btn-primary {
    background: #5c3a21; /* cocoa */
    color: #fff;
    border-color: #3f2718;
    text-shadow: 0 1px 1px rgba(0,0,0,.5);
  }
}

/* Keyboard focus: visible, accessible ring */
.sf-btn:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

/* =========================
   Auth / Login Styles (Dark, High-Contrast)
   ========================= */
.sf-auth {
  min-height: 72vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--bg-soft), transparent);
}

.sf-auth-card {
  width: min(440px, 92vw);
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--sand) 18%, transparent);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.sf-auth-title {
  margin: 0 0 6px;
  font-size: clamp(20px, 3.6vw, 28px);
}

.sf-auth-sub {
  margin: 0 0 14px;
  color: var(--muted);
}

.sf-field { margin: 12px 0; }

.sf-label {
  display: block;
  font-weight: 600;
  margin: 0 0 6px;
}

.sf-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in oklab, var(--bg) 70%, var(--card)); /* deep, not white */
  border: 1px solid color-mix(in oklab, var(--sand) 18%, transparent);
  color: var(--text);
  outline: none;
}

.sf-input::placeholder {
  color: color-mix(in oklab, var(--text) 60%, transparent);
}

/* Focus ring (keyboard visible) */
.sf-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Autofill fix (keeps dark background on Chrome) */
.sf-input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-in-out 0s; /* suppress flash */
  box-shadow: 0 0 0px 1000px color-mix(in oklab, var(--bg) 70%, var(--card)) inset;
}

/* Error state helpers (use if you render field.errors) */
.sf-input.is-invalid {
  border-color: #e56;
  box-shadow: 0 0 0 3px rgba(229, 86, 86, .25);
}
.sf-error { color: #ffb4b4; font-size: .9rem; margin-top: 6px; }

.sf-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.sf-checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); }

.sf-btn-block { width: 100%; }

/* Mobile: stack actions and keep contrast strong */
@media (max-width: 720px) {
  .sf-actions { flex-direction: column; align-items: stretch; gap: 12px; }
}

/* Optional: a slightly darker backdrop specifically when the page is very light */
@media (max-width: 720px) {
  .sf-auth { background: linear-gradient(180deg, rgba(0,0,0,.18), transparent); }
}

/* Password visibility control */
.sf-input-wrap { position: relative; }
.sf-input-wrap .sf-input { padding-right: 44px; } /* space for the button */

.sf-eye {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted);
  border-radius: 8px; cursor: pointer;
}
.sf-eye:hover { color: var(--text); }
.sf-eye:focus-visible { outline: 2px solid var(--cream); outline-offset: 2px; }

.sf-eye svg { width: 20px; height: 20px; display: block; }
.sf-eye .eye-slash { display: none; }
.sf-eye[aria-pressed="true"] .eye-slash { display: block; }
.sf-eye[aria-pressed="true"] .eye-pupil { opacity: .85; }
.sf-eye[aria-pressed="true"] { color: var(--sand); }

