/* ForgeAndPray foundation: design tokens plus the few components every page shares
   (buttons, page/admin headers, notices, badges, focus ring). Loaded by _Layout before
   site.css or public-home.css, so both page stylesheets build on the same system.
   Page files may tweak these per context, but should not re-declare them. */

:root {
  /* Colors */
  --bg: #0f172a;
  --panel: #111c31;
  --panel-soft: #17233a;
  --surface: rgba(17, 28, 49, 0.82);        /* default card/panel fill */
  --surface-strong: rgba(17, 28, 49, 0.95);
  --surface-hover: rgba(255, 255, 255, 0.04);
  --text: #f8fafc;
  --text-soft: #cbd5e1;                      /* body copy on cards, form labels */
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(148, 163, 184, 0.5);
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-rgb: 56, 189, 248;
  --on-accent: #082f49;
  --danger: #f87171;
  --danger-rgb: 248, 113, 113;
  --success: #4ade80;
  --success-rgb: 74, 222, 128;
  --warning: #fbbf24;                        /* amber: in review, scheduled, needs attention */
  --warning-rgb: 251, 191, 36;
  --gold: #c8a95a;                           /* gold: highlight, selected, unsaved changes */
  --gold-rgb: 200, 169, 90;
  --live: #f97316;                           /* orange: acts on the live site/game right away */
  --live-rgb: 249, 115, 22;

  /* Older names some rules still use; kept as aliases so they resolve instead of failing silently */
  --fg: var(--text);
  --border: var(--line);
  --forge-gold: var(--warning);

  /* Shape and depth */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow: 0 18px 60px rgba(2, 6, 23, 0.28);
  --focus-ring: 0 0 0 3px rgba(var(--accent-rgb), 0.45);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Type scale */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-size-xs: 0.72rem;
  --font-size-sm: 0.82rem;
  --font-size-md: 0.9rem;
  --font-size-title: clamp(1.9rem, 5vw, 3rem);
  --font-size-title-sm: 1.8rem;

  /* Container widths */
  --w-narrow: 440px;   /* auth cards */
  --w-form: 700px;     /* settings */
  --w-text: 820px;     /* long text, single forms */
  --w-content: 1120px; /* admin, landing, inner pages */
  --w-page: 1160px;    /* footer/info pages with side rail */
  --w-wide: 1340px;    /* wide admin editors */

  /* Shared framework (Rekcuz.Shared.Web base.css, e.g. on /forge-control/branding) defaults
     to a light theme; point its semantic tokens at ours so ui-* components stay dark. */
  --ui-color-canvas: var(--bg);
  --ui-color-surface: var(--surface);
  --ui-color-surface-muted: var(--panel-soft);
  --ui-color-text: var(--text);
  --ui-color-text-muted: var(--muted);
  --ui-color-border: var(--line);
  --ui-color-accent: var(--accent);
  --ui-color-accent-strong: var(--accent-strong);
  --ui-color-on-accent: var(--on-accent);
  --ui-color-success-bg: rgba(var(--success-rgb), 0.12);
  --ui-color-success-border: rgba(var(--success-rgb), 0.3);
  --ui-color-success-text: var(--success);
  --ui-color-warning-bg: rgba(var(--warning-rgb), 0.12);
  --ui-color-warning-border: rgba(var(--warning-rgb), 0.3);
  --ui-color-warning-text: var(--warning);
  --ui-color-danger-bg: rgba(var(--danger-rgb), 0.12);
  --ui-color-danger-border: rgba(var(--danger-rgb), 0.3);
  --ui-color-danger-text: var(--danger);
  --ui-color-info-bg: rgba(var(--accent-rgb), 0.12);
  --ui-color-info-border: rgba(var(--accent-rgb), 0.3);
  --ui-color-info-text: var(--accent);
  --ui-font-family: var(--font-sans);
}

/* ── Focus ────────────────────────────────────────────────────────────────
   One visible ring for keyboard users; components with their own ring keep it. */
:where(a, button, summary, [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────
   .btn + one tone (primary | secondary | ghost | outline | danger) + optional size (sm | full).
   .action-btn is the compact table/toolbar button; it is the same system at the small size. */
.btn,
.action-btn {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: var(--space-2);
  justify-content: center;
  padding: 11px 18px;
  text-decoration: none;
  transition: background-color 0.14s, border-color 0.14s, color 0.14s;
}

.btn:hover,
.action-btn:hover {
  text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-strong);
  color: #f0f9ff;
}

.btn--secondary {
  background: rgba(148, 163, 184, 0.08);
  border-color: var(--line);
  color: var(--text);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn--secondary:hover,
.btn--ghost:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn--outline {
  background: transparent;
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent);
}

.btn--outline:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--danger {
  background: rgba(var(--danger-rgb), 0.12);
  border-color: rgba(var(--danger-rgb), 0.35);
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(var(--danger-rgb), 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.btn--full {
  width: 100%;
}

.btn--sm,
.action-btn {
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  padding: 5px 10px;
}

/* Compact buttons: quiet outline by default, coloured by intent */
.action-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 600;
}

.action-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.action-btn--danger {
  border-color: rgba(var(--danger-rgb), 0.3);
  color: var(--danger);
}

.action-btn--danger:hover {
  background: rgba(var(--danger-rgb), 0.08);
  border-color: var(--danger);
  color: var(--danger);
}

.action-btn--live {
  border-color: rgba(var(--live-rgb), 0.42);
  color: #fdba74;
}

.action-btn--live:hover {
  background: rgba(var(--live-rgb), 0.1);
  border-color: var(--live);
  color: #fed7aa;
}

.action-btn--disabled,
.action-btn--disabled:hover {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  opacity: 0.45;
  pointer-events: none;
}

.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Page headers ─────────────────────────────────────────────────────────
   Public/settings: .page-header > .page-eyebrow + .page-title + .page-subtitle (+ .page-actions).
   Admin: .admin-header > .admin-eyebrow + h1 + p (+ .admin-header__actions). Same type scale. */
.page-header {
  margin-bottom: var(--space-7);
  max-width: 680px;
}

.page-header--center {
  max-width: 100%;
  text-align: center;
}

/* Narrow pages (settings) get a smaller title and less air below it */
.page-header--compact {
  margin-bottom: 0;
  max-width: none;
}

.page-eyebrow,
.admin-eyebrow {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 0 0 var(--space-3);
  text-transform: uppercase;
}

.page-title,
.admin-header h1 {
  font-size: var(--font-size-title);
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0 0 var(--space-4);
}

.page-header--compact .page-title {
  font-size: var(--font-size-title-sm);
  margin-bottom: var(--space-1);
}

/* The eyebrow is excluded: the old `.admin-header p` rule out-ranked it and turned it grey. */
.page-subtitle,
.admin-header p:not(.admin-eyebrow) {
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

.page-subtitle {
  font-size: 1.05rem;
}

.admin-header p:not(.admin-eyebrow) {
  max-width: 720px;
}

.admin-header p:not(.admin-eyebrow) + p {
  margin-top: var(--space-2);
}

.page-actions,
.admin-header__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.admin-header {
  margin-bottom: 28px;
}

.admin-header__actions {
  margin-top: var(--space-4);
}

/* ── Notices ──────────────────────────────────────────────────────────────
   .alert--success|danger|warning|info. The admin spellings (.admin-notice--ok|err|warn,
   .admin-alert--success|danger) share the same rules so older markup keeps working. */
.alert,
.admin-notice,
.admin-alert {
  --notice-rgb: var(--accent-rgb);
  background: rgba(var(--notice-rgb), 0.12);
  border: 1px solid rgba(var(--notice-rgb), 0.3);
  border-left: 4px solid rgb(var(--notice-rgb));
  border-radius: var(--radius);
  color: var(--text);
  line-height: 1.5;
  margin-bottom: var(--space-4);
  padding: var(--space-3) 14px;
}

.alert--success,
.admin-notice--ok,
.admin-alert--success {
  --notice-rgb: var(--success-rgb);
}

.alert--danger,
.admin-notice--err,
.admin-alert--danger {
  --notice-rgb: var(--danger-rgb);
}

.alert--warning,
.admin-notice--warn {
  --notice-rgb: var(--warning-rgb);
}

.alert pre {
  margin: 0;
  white-space: pre-wrap;
}

/* ── Badges ───────────────────────────────────────────────────────────────
   One pill for state labels: .tag--*, .status-badge--*, .game-admin__state--*. */
.tag,
.status-badge,
.game-admin__state {
  --badge-rgb: 148, 163, 184;
  background: rgba(var(--badge-rgb), 0.14);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: rgb(var(--badge-rgb));
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.5;
  padding: 2px 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--blue,
.status-badge--blue,
.game-admin__state--Draft {
  --badge-rgb: var(--accent-rgb);
}

.tag--green,
.status-badge--pub,
.status-badge--published,
.game-admin__state--Published {
  --badge-rgb: var(--success-rgb);
}

.tag--amber,
.status-badge--scheduled,
.game-admin__state--InReview,
.game-admin__state--Scheduled {
  --badge-rgb: var(--warning-rgb);
}

.tag--red,
.status-badge--archived,
.game-admin__state--ScheduleFailed {
  --badge-rgb: var(--danger-rgb);
}

.status-badge--blue {
  border-color: rgba(var(--badge-rgb), 0.3);
}

/* ── Brand in the top bar ────────────────────────────────────────────────
   Logo plus name; .site-nav in front so it beats the plain .nav-brand rules in site.css/public-home.css. */
.site-nav .nav-brand {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  gap: var(--space-2);
}

.nav-brand__logo {
  display: block;
  height: 28px;
  object-fit: contain;
  width: 28px;
}

/* ── Phones ──────────────────────────────────────────────────────────────
   Loaded on every page (home included), so the mobile safety net lives here.
   `body` in front so these beat the plain per-page rules in site.css/public-home.css. */

/* full-bleed glows (.landing::before at 100vw) count the classic scrollbar; decoration never scrolls the page sideways.
   On html, not body: Chrome does not hand a body clip on to the viewport. */
html {
  overflow-x: clip;
}

@media (max-width: 640px) {
  /* long German compounds ("Datenschutzerklärung") hyphenate instead of overflowing */
  body :is(h1, h2, h3) {
    hyphens: auto;
    overflow-wrap: break-word;
  }

  /* tap targets: at least 44px tall on phones */
  body .btn,
  body .form-input,
  body .admin-search__input {
    min-height: 44px;
  }

  body .nav-toggle {
    min-height: 44px;
    min-width: 44px;
  }

  body :is(.pub-filter-btn, .news-filter-btn, .news-card__more) {
    align-items: center;
    display: inline-flex;
    min-height: 44px;
  }

  /* site.css already makes these boxed flex rows; the home footer's plain links get the same height */
  body .footer-link {
    min-height: 44px;
  }

  body .landing-inline-link {
    align-items: center;
    min-height: 44px;
  }

  /* plain checkboxes (filters, partner flags): the whole label row is the target */
  body label:has(> input[type="checkbox"]:not([class])) {
    align-items: center;
    display: inline-flex;
    gap: 8px;
    min-height: 44px;
  }

  body input[type="checkbox"]:not([class]) {
    flex: none;
    height: 20px;
    margin: 0;
    width: 20px;
  }

  /* unstyled disclosure rows ("Delete game data") */
  body summary:not([class]) {
    box-sizing: border-box;
    min-height: 44px;
    padding-block: 12px;
  }

  /* show/hide fills the right end of the 44px password field instead of floating inside it */
  body .pw-field__toggle {
    border-width: 0 0 0 1px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    bottom: 0;
    right: 0;
    top: 0;
    transform: none;
  }

  /* shared UI kit (branding forms) and plain search/file inputs */
  body .ui-button,
  body .ui-field__control,
  body input:is([type="search"], [type="file"]),
  body .site-nav .nav-brand {
    min-height: 44px;
  }

  /* compact table/toolbar buttons too: a phone has no mouse precision either way */
  body .action-btn {
    min-height: 44px;
  }

  /* contact desk: its own sheets use .contact-desk--queue scoping, so these go through .contact-desk to win */
  body .contact-desk :is(.contact-desk__brand, .contact-desk__tab, .contact-desk__exit) {
    align-items: center;
    display: flex;
    min-height: 44px;
  }

  body .contact-desk :is(.contact-desk__category, .contact-desk__stage, .contact-workload__stage,
    button, select, input:not([type="checkbox"], [type="radio"], [type="hidden"])) {
    min-height: 44px;
  }
}
