/* Shared Foresight UI styles: the public web shell, the PWA share page, the Chrome
   extension (vendored copy) and the Verify views. This is the Foresight design
   system (palette: docs/FORESIGHT_COLOR_SYSTEM.md): white paper and near-black ink, one gold hue as a hint taken from
   the F mark (underlines, a thin edge on the primary button, section dots, focus),
   square corners, IBM Plex Sans body text, IBM Plex
   Mono micro-labels and Playfair Display headlines. Tokens mirror GST_THEME in
   frontend/data.js. Fonts come from the web pages' <link>; the extension has no
   network fonts and falls back to system faces. */

:root {
  color-scheme: light;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* neutral */
  --bg: #ffffff; --surface: #f6f6f6; --surface-2: #ececec;
  --border: #e3e3e3; --border-strong: #c6c6c6; --rule: rgba(0, 0, 0, 0.09);
  --text: #0a0a0a; --text-2: #3a3a3a; --text-3: #595959;
  /* brand gold: identity / quiet ornament / readable ink; --accent is the themed alias (docs/FORESIGHT_COLOR_SYSTEM.md) */
  --gold: #c9ba6c; --gold-muted: #968746; --gold-ink: #756625;
  --accent: var(--gold-ink);
  /* semantic status */
  --status-success: #35642a; --status-warning: #80531b; --status-danger: #9a3a1a;
  --dot-field-color: var(--border-strong); --dot-field-opacity: 0.18;
  --shadow-pill: 0 7px 20px rgba(23, 25, 29, 0.10);
  --shadow-menu: 0 8px 24px rgba(23, 25, 29, 0.16);

  --type-micro: 10px; --type-meta: 11px; --type-control: 12px; --type-body-sm: 14px; --type-body: 16px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --content-narrow: 740px; --content-analytical: 960px;
  --motion-ui: 170ms; --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-gst-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a; --surface: #121212; --surface-2: #1c1c1c;
  --border: #262626; --border-strong: #3a3a3a; --rule: rgba(255, 255, 255, 0.07);
  --text: #fafafa; --text-2: #c9c9c9; --text-3: #a3a3a3;
  --accent: var(--gold);
  --status-success: #72a364; --status-warning: #d29a46; --status-danger: #d36548;
  --dot-field-color: var(--border-strong); --dot-field-opacity: 0.22;
  --shadow-pill: 0 7px 22px rgba(0, 0, 0, 0.20);
  --shadow-menu: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* No explicit choice (extension, or a page without the theme script): follow the OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-gst-theme]) {
    color-scheme: dark;
    --bg: #0a0a0a; --surface: #121212; --surface-2: #1c1c1c;
    --border: #262626; --border-strong: #3a3a3a; --rule: rgba(255, 255, 255, 0.07);
    --text: #fafafa; --text-2: #c9c9c9; --text-3: #a3a3a3;
    --accent: var(--gold);
    --status-success: #72a364; --status-warning: #d29a46; --status-danger: #d36548;
    --dot-field-color: var(--border-strong); --dot-field-opacity: 0.22;
    --shadow-pill: 0 7px 22px rgba(0, 0, 0, 0.20);
    --shadow-menu: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 300 14px/1.6 var(--font-sans);
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); }

main { padding: 16px; display: grid; gap: 16px; }

/* Type */
h1 { font: 400 28px/1.15 var(--font-serif); margin: 0; color: var(--text); }

/* Section label: mono, uppercase, wide-tracked, with the accent signal dot. */
h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font: 400 var(--type-meta)/1.3 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
}
section > h2::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 52%, transparent);
  flex-shrink: 0;
}

h3 { margin: 12px 0 4px; font: 500 var(--type-body-sm)/1.4 var(--font-sans); color: var(--text); }
p { margin: 0 0 8px; color: var(--text-2); }
strong { font-weight: 500; color: var(--text); }
code { font-family: var(--font-mono); font-size: 0.92em; }

section { display: grid; gap: 8px; }
.rule { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; width: 100%; }

/* Controls */
textarea, input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: 400 var(--type-body-sm)/1.5 var(--font-sans);
  resize: vertical;
}

textarea::placeholder, input::placeholder { color: var(--text-3); }

textarea:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button.primary, button.secondary, button.link {
  font: 500 var(--type-control)/1.2 var(--font-mono);
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 0;
  transition: background-color var(--motion-ui) ease, border-color var(--motion-ui) ease, color var(--motion-ui) ease, opacity var(--motion-ui) ease;
}

button.primary {
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  /* the one gold hint on a primary action: a thin edge along the bottom */
  box-shadow: inset 0 -2px 0 var(--accent);
  padding: 10px 16px;
  text-transform: uppercase;
}
button.primary:hover:not(:disabled) { opacity: 0.88; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
  padding: 10px 16px;
  text-transform: uppercase;
}
button.secondary:hover:not(:disabled) { border-color: var(--text); color: var(--text); }
button.secondary:disabled { opacity: 0.5; cursor: not-allowed; }

button.link {
  border: 0;
  background: none;
  color: var(--text);
  padding: 0;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

a { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.muted { color: var(--text-3); font-size: var(--type-meta); }

/* Verify and Ask results */
.quote {
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid var(--gold-muted);
  background: var(--surface);
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.status { font: 600 18px/1.2 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; }
.status[data-status="confirmed"] { color: var(--status-success); }
.status[data-status="partly_true"], .status[data-status="superseded"] { color: var(--status-warning); }
.status[data-status="contradicted"] { color: var(--status-danger); }
.status[data-status="not_notified"], .status[data-status="unverified"] { color: var(--text-2); }

.caution {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--status-warning) 45%, transparent);
  background: color-mix(in srgb, var(--status-warning) 10%, var(--bg));
  font-size: 13px;
  color: var(--text-2);
}
.caution strong { color: var(--status-warning); }

.outlook {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  display: grid;
  gap: 4px;
}
.outlook .figure { font: 500 28px/1.1 var(--font-mono); color: var(--text); }

ol.evidence, ul.plain { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
ul.plain { list-style: none; padding-left: 0; }
ol.evidence li { padding-left: 4px; }

.code {
  font: 600 24px/1.2 var(--font-mono);
  letter-spacing: 0.14em;
  text-align: center;
  padding: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

/* The pairing code with its Copy button beside it. */
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row .code { flex: 1; min-width: 0; }

.answer ul { margin: 0 0 8px; padding-left: 20px; }
.notice { padding: 10px 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); }
form { display: grid; gap: 8px; }
main > button.link, .stack > button.link { justify-self: start; }
.stack { display: grid; gap: 16px; }

@media (prefers-reduced-motion: reduce) {
  button.primary, button.secondary, button.link { transition: none; }
}
