/* ============================================================================
   ouRGeo — shared design system
   ----------------------------------------------------------------------------
   Shell components — the frame, header/nav, mobile drawer, footer, buttons,
   forms, avatars, geo-sections — shared by every page on the site.

   Colour lives in assets/css/tokens.css, which every page links BEFORE this
   file. There is no token block here any more: there used to be one, copied
   into the inline <style> of each marketing page, and keeping five of them in
   step was a standing invitation to drift. Add a colour there, not here.
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; overflow-x: hidden; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 78% -8%, rgb(var(--accent-rgb) / 0.12), transparent 60%),
    radial-gradient(900px 600px at 12% 108%, rgb(var(--aqua-rgb) / 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 46%, var(--bg-0) 100%);
  -webkit-font-smoothing: antialiased;
  padding: 16px;
}

/* ── Dimmed topographic + mountain-ridge backdrop (CSS/SVG only) ── */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    repeating-radial-gradient(circle at 82% -6%, rgb(var(--water-rgb) / 0.05) 0 1px, transparent 1px 52px),
    repeating-radial-gradient(circle at 14% 112%, rgb(var(--aqua-rgb) / 0.045) 0 1px, transparent 1px 64px),
    linear-gradient(rgb(var(--water-rgb) / 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgb(var(--water-rgb) / 0.028) 1px, transparent 1px);
  background-size: auto, auto, 64px 64px, 64px 64px;
  opacity: 0.85;
}

.ridge {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: -1;
  width: 100%; height: 46vh; min-height: 260px;
  opacity: 0.5; pointer-events: none;
  mask-image: linear-gradient(to top, #000 30%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, #000 30%, transparent 100%);
}

.frame {
  width: 100%; max-width: 1040px; margin: 0 auto;
  border-radius: var(--radius); padding: 22px;
  background: rgb(var(--bg1-rgb) / 0.72);
  backdrop-filter: blur(9px);
  border: 1px solid rgb(var(--water-rgb) / 0.10);
  box-shadow: 0 8px 46px rgb(var(--shadow-rgb) / 0.75);
}
.frame.narrow { max-width: 560px; }

/* ── Header / Nav ─────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  flex-wrap: wrap; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .badge {
  width: 50px; height: 50px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--aqua));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--on-accent); font-size: 18px;
  box-shadow: 0 0 22px rgb(var(--water-rgb) / 0.35);
}
.brand .name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  color: var(--text-strong); letter-spacing: 0.03em;
}
.brand .name .r { color: var(--aqua); }
.brand .sub { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }

nav { display: flex; gap: 8px; align-items: center; }
nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 8px 14px; border-radius: 8px; transition: color 0.2s, background 0.2s;
}
nav a:hover { color: var(--aqua); background: rgb(var(--aqua-rgb) / 0.06); }
nav a.active { color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--aqua)); }

/* Which half of the auth chrome is on screen.
 *
 * Both halves are in the markup, and these two rules only ever HIDE — never
 * restore a display value. That is deliberate: nav a.nav-auth below is an
 * inline-flex pill, .mobile-nav a is something else again, and a rule that had
 * to switch one back on would have to know which. Hiding the wrong half leaves
 * the right half with whatever display it was always going to have.
 *
 * The state is stamped on <html> by the first-paint guard in each page's
 * <head>, from the identity remembered in local storage, so the correct half is
 * painted before any script is fetched. auth.js re-stamps it once the session
 * is known. With no stamp at all — JavaScript off, or storage blocked — the
 * :not() branch matches and a visitor correctly sees "Sign in".
 */
html:not([data-auth-state="in"]) [data-auth="in"] { display: none; }
html[data-auth-state="in"] [data-auth="out"] { display: none; }

/* Auth entry in the nav — an outlined pill so it reads as an action, not a page. */
nav a.nav-auth {
  border: 1px solid rgb(var(--aqua-rgb) / 0.45); color: var(--aqua);
  display: inline-flex; align-items: center; gap: 8px;
}
nav a.nav-auth:hover { background: rgb(var(--aqua-rgb) / 0.10); }
nav a.nav-auth .avatar { width: 22px; height: 22px; font-size: 10px; }
/* Hold the avatar's box open before there is an avatar in it. The wrapper is an
 * empty span until auth.js fills it, and an empty span is 0px wide — so the
 * pill used to widen by 22px plus its gap the moment the profile landed, which
 * is a nudge to everything beside it in the nav. Same size as .avatar above. */
nav a.nav-auth [data-auth-avatar] {
  display: inline-flex; flex: none; width: 22px; height: 22px;
}
/* Long display names must not push the nav onto a second row. */
nav a.nav-auth .who { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-toggle { display: none; background: none; border: none; color: var(--aqua); font-size: 28px; cursor: pointer; }
.mobile-nav {
  position: fixed; top: 0; right: -280px; width: 250px; height: 100%;
  background: rgb(var(--bg1-rgb) / 0.97); backdrop-filter: blur(8px);
  box-shadow: -2px 0 14px rgb(var(--shadow-rgb) / 0.6); transition: right 0.3s ease;
  padding: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.mobile-nav a {
  color: var(--muted); font-weight: 600; text-decoration: none; font-size: 1.05rem;
  padding: 10px 8px; border-radius: 8px;
}
.mobile-nav a:hover, .mobile-nav a.active { color: var(--aqua); background: rgb(var(--aqua-rgb) / 0.06); }
.mobile-nav.open { right: 0; }
.overlay { display: none; position: fixed; inset: 0; background: rgb(var(--shadow-rgb) / 0.5); z-index: 9998; }
.overlay.active { display: block; }

/* Elements toggled by auth.js once the session is known. Using [hidden] keeps
   the pre-JS render free of flicker in either direction. */
[hidden] { display: none !important; }

/* ── Page headings ────────────────────────────────────────────────────── */
.page-head { text-align: center; padding: 10px 8px 22px; border-bottom: 1px solid rgb(var(--water-rgb) / 0.14); margin-bottom: 22px; }
.page-head h1 {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--text-strong); letter-spacing: 0.03em; text-shadow: 0 0 22px rgb(var(--water-rgb) / 0.35);
  margin-bottom: 10px;
}
.page-head p { color: var(--muted); max-width: 640px; margin: 0 auto; line-height: 1.65; font-size: 0.98rem; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; cursor: pointer; border: none;
  font-family: var(--font-display); font-size: 0.8rem;
  letter-spacing: var(--display-tracking); text-transform: var(--display-transform);
  padding: 12px 22px; border-radius: calc(var(--radius) * 0.62);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
.btn-primary { color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--aqua)); box-shadow: 0 0 20px rgb(var(--water-rgb) / 0.3); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 28px rgb(var(--water-rgb) / 0.5); }
.btn-ghost { color: var(--aqua); background: none; border: 1px solid rgb(var(--aqua-rgb) / 0.5); }
.btn-ghost:hover { background: rgb(var(--aqua-rgb) / 0.08); transform: translateY(-2px); }
.btn-danger { color: var(--danger); background: none; border: 1px solid rgb(var(--danger-rgb) / 0.45); }
.btn-danger:hover { background: rgb(var(--danger-rgb) / 0.10); }
.btn-sm { padding: 8px 14px; font-size: 0.7rem; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Panels ───────────────────────────────────────────────────────────── */
.geo-section {
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, rgb(var(--water-rgb) / 0.04) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgb(var(--water-rgb) / 0.04) 39px 40px),
    var(--map-deep);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 22px;
  border: 1px solid rgb(var(--water-rgb) / 0.16); box-shadow: inset 0 0 60px rgb(var(--water-rgb) / 0.05);
  position: relative;
}
.geo-section::before, .geo-section::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 1px solid rgb(var(--water-rgb) / 0.5);
}
.geo-section::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.geo-section::after  { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }
.geo-section h2 {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--water);
  letter-spacing: var(--display-tracking); text-transform: var(--display-transform); margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.geo-section h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgb(var(--water-rgb) / 0.4), transparent); }
.geo-section p { font-size: 1rem; color: var(--text); line-height: 1.75; margin-bottom: 12px; }
.geo-section p:last-child { margin-bottom: 0; }

.geo-callout {
  background: rgb(var(--aqua-rgb) / 0.06); border-left: 3px solid var(--aqua); border-radius: 0 8px 8px 0;
  padding: 14px 18px; margin: 6px 0; color: var(--text-strong); font-size: 0.95rem; line-height: 1.7;
}
.mono { font-family: var(--font-mono); font-size: 0.9em; color: var(--aqua); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-family: var(--font-display); font-size: 0.7rem;
  letter-spacing: var(--display-tracking); text-transform: var(--display-transform);
  color: var(--water); margin-bottom: 7px;
}
.field .hint { font-size: 0.8rem; color: var(--muted); margin-top: 6px; line-height: 1.5; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  width: 100%; font-family: inherit; font-size: 0.95rem; color: var(--text);
  background: rgb(var(--bg0-rgb) / 0.75); border: 1px solid rgb(var(--water-rgb) / 0.22);
  border-radius: 9px; padding: 11px 13px; transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { resize: vertical; min-height: 150px; line-height: 1.65; }
textarea.code { font-family: var(--font-mono); font-size: 0.9rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--water); box-shadow: 0 0 0 3px rgb(var(--water-rgb) / 0.14);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--water) 50%), linear-gradient(135deg, var(--water) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* ── Status / flash messages ──────────────────────────────────────────── */
.msg {
  border-radius: 9px; padding: 11px 14px; font-size: 0.9rem; line-height: 1.6;
  margin-bottom: 16px; border: 1px solid transparent;
}
.msg-error { color: var(--danger); background: rgb(var(--danger-rgb) / 0.10); border-color: rgb(var(--danger-rgb) / 0.35); }
.msg-ok    { color: var(--ok); background: rgb(var(--aqua-rgb) / 0.09); border-color: rgb(var(--aqua-rgb) / 0.35); }
.msg-info  { color: var(--water); background: rgb(var(--water-rgb) / 0.09);  border-color: rgb(var(--water-rgb) / 0.30); }

/* ── Avatars ──────────────────────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--aqua));
  object-fit: cover; overflow: hidden; text-transform: uppercase;
}
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }

/* ── Loading / empty states ───────────────────────────────────────────── */
.state {
  text-align: center; color: var(--muted); padding: 40px 20px;
  font-size: 0.95rem; line-height: 1.7;
}
.state strong { display: block; font-family: var(--font-display); color: var(--water); font-size: 0.95rem; margin-bottom: 8px; letter-spacing: 0.04em; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 14px; border-radius: 50%;
  border: 2px solid rgb(var(--water-rgb) / 0.2); border-top-color: var(--water);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ───────────────────────────────────────────────────────────── */
footer { margin-top: 22px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.7; }
footer a { color: var(--aqua); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  nav { display: none !important; }
  .menu-toggle { display: block; }
  .frame { padding: 16px; }
}
@media (min-width: 901px) { .mobile-nav { display: none !important; } .overlay { display: none !important; } }
@media (max-width: 620px) {
  body { padding: 8px; }
  .page-head h1 { font-size: 1.6rem; }
  .geo-section { padding: 22px 18px; }
}

/* ── Theme picker ──────────────────────────────────────────────────────────
   The cards carry .theme-<slug> from themes.css, so each one paints itself in
   its own palette. Everything below therefore uses tokens and nothing else —
   a literal here would be the one part of a card that ignored its theme. */
.theme-menu { position: relative; display: inline-flex; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; cursor: pointer;
  color: var(--muted); background: none;
  border: 1px solid rgb(var(--water-rgb) / 0.22);
  border-radius: calc(var(--radius) * 0.55);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.theme-toggle:hover { color: var(--aqua); border-color: rgb(var(--aqua-rgb) / 0.45); background: rgb(var(--aqua-rgb) / 0.06); }
.theme-toggle[aria-expanded="true"] { color: var(--aqua); border-color: rgb(var(--aqua-rgb) / 0.55); }

.theme-pop {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  width: min(94vw, 560px); max-height: min(70vh, 560px); overflow-y: auto;
  padding: 14px; border-radius: var(--radius);
  background: rgb(var(--bg1-rgb) / 0.97);
  backdrop-filter: blur(10px);
  border: 1px solid rgb(var(--water-rgb) / 0.22);
  box-shadow: 0 14px 44px rgb(var(--shadow-rgb) / 0.55);
}

.theme-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.theme-card {
  display: flex; flex-direction: column; gap: 7px; text-align: left;
  padding: 12px; cursor: pointer;
  /* Painted from the card's OWN theme tokens. */
  background: var(--bg-0);
  color: var(--text);
  border: 1px solid var(--map-line);
  border-radius: var(--radius);
  transition: transform 0.15s, box-shadow 0.15s;
}
.theme-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgb(var(--shadow-rgb) / 0.4); }
.theme-card[data-current] { outline: 2px solid var(--aqua); outline-offset: 2px; }
.theme-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.theme-name {
  font-family: var(--font-display); font-size: 0.84rem; font-weight: 700;
  letter-spacing: var(--display-tracking); text-transform: var(--display-transform);
  color: var(--text-strong);
}
.theme-scheme { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.theme-swatch { display: flex; gap: 5px; }
.theme-swatch i { width: 100%; height: 9px; border-radius: 2px; }
.theme-blurb { font-size: 0.72rem; line-height: 1.5; color: var(--muted); }

@media (max-width: 720px) {
  .theme-pop { position: fixed; right: 8px; left: 8px; width: auto; top: 64px; }
}
