/* gipity-theme.css — the canonical Gipity brand + polish layer for Water.css apps.
   SINGLE SOURCE OF TRUTH: registry/_shared/css/gipity-theme.css.
   The per-template copies are synced by scripts/sync-registry.ts — DON'T edit a
   copy; edit the source and re-run `npx tsx scripts/sync-registry.ts`.

   How it works: the page forces dark (Water's dark.css build) and this file maps
   the Gipity brand onto Water.css's OWN variables, so every plain element (links,
   buttons, inputs, tables…) is on-brand with zero per-element CSS. The
   --background-body / --text-main / --links / etc. names below are Water.css's;
   loaded after water.css, they recolor the whole classless page. App-specific and
   agent-added styles belong in the template's own styles.css (loaded after this).
   To rebrand the accent, change --primary in one place. */
:root {
  color-scheme: dark;
  accent-color: var(--primary); /* native checkboxes, radios, range, progress */

  /* Gipity brand palette — ONE knob: every amber below derives from --primary. */
  --primary: #fea60b;
  --primary-hover: color-mix(in srgb, var(--primary) 82%, white);
  /* Label color on --primary surfaces (buttons). Dark, NOT --text-bright: white
     on the amber is ~2:1 (fails WCAG AA); dark is 8.9:1 here and 5.4:1 on the
     blue theme. The light theme's deep amber flips it to white. If you rebrand
     --primary to a DARK accent, set this light too. */
  --button-text: #1a1a1a;

  /* Surface colors (custom components + Water's panels/inputs/code) */
  --surface: #202020;
  --surface-alt: #191919;
  --text-muted: #a8a29e;

  /* Map the brand onto Water.css's variables (left = Water's name) */
  --background-body: #0d0d0d;           /* page background (Gipity black) */
  --background: var(--surface);         /* inputs, code, table stripe */
  --background-alt: var(--surface-alt);
  --text-main: #e6e6f0;                 /* body text (Gipity cream) */
  --text-bright: #fffeff;               /* headings (buttons use --button-text) */
  --links: var(--primary);              /* links */
  --focus: color-mix(in srgb, var(--primary) 60%, transparent); /* focus ring */
  --border: #333333;
  --button-base: var(--primary);        /* buttons → amber */
  --button-hover: var(--primary-hover);
  --form-text: #e6e6f0;
  --form-placeholder: #6f6f78;
  --selection: color-mix(in srgb, var(--primary) 40%, transparent); /* text selection */
  --code: color-mix(in srgb, var(--primary) 55%, white); /* inline / preformatted code */
  --scrollbar-thumb: #333333;
  --scrollbar-thumb-hover: #444444;

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;

  /* Type-size scale (the Gipity "5 sizes only" convention). Use these for
     font-size; don't invent new sizes. Note --text-xs/sm/base/lg/xl are SIZES,
     while --text-main/--text-bright/--text-muted above are COLORS. */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.75rem;    /* 28px */

  /* Shape */
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── Themes ────────────────────────────────────────────────────────────────
   :root above is the default (dark). Set data-theme="light" | "blue" on <html>
   to switch — the palettes below override only the color tokens (Water's own
   vars + the brand). An app can hardcode <html data-theme="light">, or use the
   SDK: Gipity.setTheme('light') flips + persists it (with a pre-paint snippet in
   the template head there's no flash), and Gipity.theme({primary:'#…'}) sets a
   custom brand accent on top of any theme. Structure (spacing/type/radius) is
   shared, so it lives only in :root. */
:root[data-theme="light"] {
  color-scheme: light;
  /* Light sibling of the brand amber: bright amber is ~1.9:1 as text on a
     near-white page, so links/code fail. This deep amber is 5.0:1 as text on
     --background-body and 5.3:1 under the white --button-text. The focus ring,
     selection and accent-color re-derive from it via :root's color-mix(). */
  --primary: #9e5c00;
  --primary-hover: color-mix(in srgb, var(--primary) 85%, black);
  --button-text: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f1efea;
  --text-muted: #6b6660;
  --background-body: #faf9f7;
  --text-main: #1c1a17;
  --text-bright: #14110e;
  --border: #e4e0d8;
  --form-text: #1c1a17;
  --form-placeholder: #9a948c;
  --code: color-mix(in srgb, var(--primary) 80%, black);
  --scrollbar-thumb: #cfc9be;
  --scrollbar-thumb-hover: #b8b1a4;
}

:root[data-theme="blue"] {
  color-scheme: dark;
  accent-color: #4c8dff;
  --primary: #4c8dff;
  --primary-hover: #6ba1ff;
  --surface: #131a2e;
  --surface-alt: #0f1626;
  --text-muted: #9aa6c0;
  --background-body: #0a0f1e;
  --text-main: #e6ebf5;
  --text-bright: #ffffff;
  --focus: rgba(76, 141, 255, 0.6);
  --border: #263151;
  --form-text: #e6ebf5;
  --form-placeholder: #667092;
  --selection: rgba(76, 141, 255, 0.4);
  --code: #9ec5ff;
  --scrollbar-thumb: #263151;
  --scrollbar-thumb-hover: #35426a;
}

/* Make the HTML `hidden` attribute always win. Author CSS beats the UA's
   `[hidden] { display: none }`, so a rule like `#overlay { display: flex }` on a
   hidden-toggled element silently breaks `el.hidden = true` — stuck fullscreen
   overlays, "loading…" placeholders that never clear. This guard makes any
   `display:` rule safe to write on elements toggled via the hidden attribute. */
[hidden] { display: none !important; }

/* Brand the two native elements Water's vars + accent-color don't reach. */
mark {
  background-color: color-mix(in srgb, var(--primary) 55%, white); /* pale Gipity amber highlighter */
  color: #1a1a1a; /* dark text for contrast on the highlight */
}
meter::-webkit-meter-bar {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
meter::-webkit-meter-optimum-value,
meter::-webkit-meter-suboptimum-value,
meter::-webkit-meter-even-less-good-value {
  background: var(--primary);
}
meter::-moz-meter-bar {
  background: var(--primary);
}

/* Modern polish: unified radius + smooth interactions. Pure cosmetic token
   tweaks on Water's native elements - no layout change. */
button, input, select, textarea {
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
/* Form fields fill their container. Water sizes a textarea to its box
   (`textarea:not([cols]) { width: 100% }`) but gives `input`/`select` no width at
   all, so they fall back to the UA's ~20-character intrinsic width while still
   being `display: block` — a plain form renders a stubby subject field stacked
   above a full-width body box. Match them so plain semantic markup lays out right
   with no per-element CSS. `size=` (like Water's `cols=`) is the opt-out for a
   deliberately short field, and :where() keeps specificity at 0,0,1 so any app
   rule wins. Water's 6px margin-right would overflow a 100%-wide field, so it's
   zeroed here for the same reason Water zeroes it on textarea. */
input:where(:not([type='checkbox'], [type='radio'], [type='range'], [type='color'],
                 [type='submit'], [type='button'], [type='reset'], [type='image'], [size])),
select:where(:not([size])) {
  width: 100%;
  box-sizing: border-box;
  margin-right: 0;
}
/* Pill buttons — the standard Gipity button shape (matches the gipity.ai
   login page and the Sign-in-with-Gipity pages). Extra horizontal padding so
   labels don't crowd the rounded ends. */
button, input[type="submit"], input[type="button"], input[type="reset"] {
  font-weight: 600;
  border-radius: 999px;
  padding-left: 18px;
  padding-right: 18px;
  /* Water's dark build puts near-white text on the button, which is ~1.9:1
     against the amber --button-base — an out-of-the-box WCAG AA failure on
     every template. Pair the accent with the dark label color instead. */
  color: var(--button-text);
}
/* Water's dark build HARDCODES button:hover to near-black (#040a0f) instead of
   honoring its own --button-hover variable, so the amber rebrand above vanishes on
   hover (buttons flip amber -> black). Re-assert the brand hover so it applies. */
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
  background: var(--button-hover);
}
pre {
  border-radius: var(--radius);
}
code, kbd {
  border-radius: 5px;
}
/* Pill-shaped gauges. Styling a progress pseudo-element opts out of
   accent-color, so the amber fill must be re-asserted here. */
progress, meter {
  border-radius: 999px;
}
progress::-webkit-progress-bar {
  background: var(--surface-alt);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: var(--primary);
}
meter::-webkit-meter-bar, meter::-webkit-meter-optimum-value {
  border-radius: 999px;
}
/* Range sliders. Water's dark.css paints the track with --background (#202020)
   and the thumb with --border (#333) — both near-black on the #0d0d0d page, so
   the control reads as invisible and (being explicitly styled) never picks up the
   amber accent-color either. Re-assert a visible track + a Gipity-amber thumb,
   same reason progress/meter above must re-declare their fill. */
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px; /* center the 18px thumb on the 6px track */
  background: var(--primary);
  border: 2px solid var(--background-body);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--primary-hover);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  background: var(--primary);
  border-radius: 999px;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border: 2px solid var(--background-body);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:focus::-moz-range-thumb {
  background: var(--primary-hover);
}
h1, h2 {
  letter-spacing: -0.02em; /* subtle modern tightening on large headings */
}
/* Wrap short text evenly: headings, figure/table captions and the opening
   lede of a section balance their lines (no long line + one stub word). Body
   copy only avoids a lone last word - balancing long paragraphs reads oddly.
   Opt a short blurb or card title in with class="balance". */
h1, h2, h3, h4, h5, h6, caption, figcaption, legend, summary,
:is(h1, h2, header) + p, .balance {
  text-wrap: balance;
}
p, li, dd, blockquote {
  text-wrap: pretty;
}
