/*
  render-the-quest.css — "The Quest" (SKIN-G04) Render layer
  token map aligned to BU-CORE-UIUX-001 §4.1, 2026-07-03
  ===========================================================================
  Fires when data-theme="the-quest". ARENA/GAMIFIED category (student-facing
  only per BUP-UI-THEME-001 Rule 2). Phase 2 target per catalog.

  SOURCING CLASS: [AUTHORED PROPOSAL -- pending owner approval; no source
  values existed]. BUP-UI-SKIN-002 SKIN-G04 (lines 67-72) describes this
  skin only in prose: "Rich greens, earth tones, and forest palette...
  dark with organic warmth. Lush. Adventurous." No hex values exist. This
  file authors a forest-green accent over a warm dark-brown/green canvas.

  Contrast check (WCAG AA, BUP-UI-SKIN-001 L-9): text-primary #f2ede0 on
  canvas #0e1409 = ~17.3:1. text-secondary #b9c79e on canvas = ~11.9:1 --
  passes 4.5:1 minimum.
  ===========================================================================
*/

:root[data-theme="the-quest"] {
  --theme-bg-canvas: #0e1409;
  --theme-bg-surface: rgba(200, 220, 170, 0.05);
  --theme-bg-frosted: var(--theme-bg-surface); /* alias — dialect has no distinct frosted-fill token; §4.1 requires this name, value derived from bg-surface */
  --theme-bg-card: rgba(200, 220, 170, 0.08);
  --theme-x-bg-sunken: #0e1409;
  --theme-border-inactive: rgba(200, 220, 170, 0.14);
  --theme-border-active: #4c7a2e;

  --theme-text-main: #f2ede0;
  --theme-x-text-secondary: #b9c79e;
  --theme-text-muted: #8a9a72;
  --theme-x-text-inverse: #0e1409;
  --theme-x-text-disabled: #566349;

  --theme-accent-primary: #4c7a2e;
  --theme-accent-secondary: var(--theme-accent-primary); /* alias — no distinct secondary accent hue exists in sources; §4.1 requires this name */
  --theme-x-accent-hover: #6ba33f;
  --theme-x-accent-active: #3a5f22;
  --theme-x-accent-disabled: rgba(76, 122, 46, 0.4);
  --theme-x-accent-text: #f2ede0;
  --theme-x-focus-ring: #6ba33f;

  --theme-state-healthy: #6ba33f;
  --theme-state-warning: #c9a04a;
  --theme-state-error: #b8503a;
  --theme-x-state-info: #4c7a2e;

  --theme-x-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --theme-x-elevation-2: 0 15px 35px rgba(0, 0, 0, 0.3);
  --theme-x-elevation-3: 0 0 20px rgba(76, 122, 46, 0.5);
  --theme-accent-glow: 0 0 20px rgba(76, 122, 46, 0.5); /* derived — same glow value as --theme-x-elevation-3 (measured/authored glow shadow); §4.1 requires this name */
  --theme-accent-glow-secondary: 0 0 20px rgba(76, 122, 46, 0.5); /* derived — no distinct secondary glow exists in sources; aliased to primary glow value */
  --theme-x-glass-tint: rgba(200, 220, 170, 0.05);
  --theme-backdrop-blur: 20px;

  --theme-x-font-family-base: var(--structure-font-family);
  --theme-x-font-size-sm: 0.875rem;
  --theme-x-font-size-base: 1rem;
  --theme-x-font-size-lg: 1.25rem;
  --theme-x-font-size-xl: 1.75rem;
  --theme-x-line-height-base: 1.5;
  --theme-x-space-unit: 0.5rem;
}

/* Structural selector list mirrors render-greyscale-skeleton.css / render-fight-night.css
   1:1 (R-S7-10 / D-S07-FW-01: structure never forks per skin — value-only skin). */
:root[data-theme="the-quest"] body {
  background-color: var(--theme-bg-canvas);
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] a {
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] h1,
:root[data-theme="the-quest"] h2,
:root[data-theme="the-quest"] h3,
:root[data-theme="the-quest"] h4,
:root[data-theme="the-quest"] h5,
:root[data-theme="the-quest"] h6 {
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] p,
:root[data-theme="the-quest"] li {
  color: var(--theme-x-text-secondary);
}

:root[data-theme="the-quest"] .bu-panel {
  background-color: var(--theme-bg-surface);
  border: 1px solid var(--theme-border-inactive);
  border-top: 2px solid var(--theme-border-active);
  border-bottom: 2px solid var(--theme-border-active);
  box-shadow: var(--theme-x-elevation-2);
  backdrop-filter: blur(var(--theme-backdrop-blur));
  -webkit-backdrop-filter: blur(var(--theme-backdrop-blur));
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-rail {
  background-color: rgba(14, 20, 9, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--theme-border-inactive);
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-soffit {
  border-top: 1px solid var(--theme-border-inactive);
  color: var(--theme-text-muted);
  font-size: var(--structure-text-sm, 0.875rem);
}

:root[data-theme="the-quest"] .bu-soffit a {
  color: var(--theme-text-muted);
}

:root[data-theme="the-quest"] .bu-soffit a:hover {
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-brick {
  color: var(--theme-x-text-secondary);
}

:root[data-theme="the-quest"] .bu-badge-tag {
  background-color: var(--theme-bg-card);
  border: 1px solid var(--theme-border-active);
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-control {
  background-color: var(--theme-bg-surface);
  border-color: var(--theme-border-active);
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-control:hover {
  background-color: var(--theme-x-accent-hover);
  color: var(--theme-x-text-inverse);
}

:root[data-theme="the-quest"] .bu-control:focus-visible {
  outline: 2px solid var(--theme-x-focus-ring);
  outline-offset: 2px;
}

:root[data-theme="the-quest"] .bu-btn {
  background-color: rgba(200, 220, 170, 0.1);
  border-top: 2px solid var(--theme-border-active);
  border-bottom: 2px solid var(--theme-border-active);
  border-left-color: transparent;
  border-right-color: transparent;
  color: var(--theme-x-accent-text);
}

:root[data-theme="the-quest"] .bu-btn:hover {
  background-color: rgba(200, 220, 170, 0.16);
  border-top-color: var(--theme-x-accent-hover);
  border-bottom-color: var(--theme-x-accent-hover);
}

:root[data-theme="the-quest"] .bu-btn:disabled {
  background-color: rgba(200, 220, 170, 0.04);
  border-top-color: var(--theme-x-accent-disabled);
  border-bottom-color: var(--theme-x-accent-disabled);
  color: var(--theme-x-text-disabled);
}

:root[data-theme="the-quest"] .bu-btn-secondary {
  background-color: transparent;
  border-color: var(--theme-border-active);
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-btn-secondary:hover {
  border-color: var(--theme-x-accent-hover);
  color: var(--theme-x-accent-hover);
}

/* PG-035 demo skin switcher active-selection state (D-S07-SKIN-02 switcher UI). */
:root[data-theme="the-quest"] .bu-btn-secondary.is-active {
  background-color: var(--theme-accent-primary);
  border-color: var(--theme-accent-primary);
  color: var(--theme-x-accent-text);
}

:root[data-theme="the-quest"] .bu-btn:focus-visible,
:root[data-theme="the-quest"] .bu-btn-secondary:focus-visible {
  outline: 2px solid var(--theme-x-focus-ring);
  outline-offset: 2px;
}

:root[data-theme="the-quest"] .bu-gate {
  background-color: var(--theme-x-glass-tint);
  backdrop-filter: blur(var(--theme-backdrop-blur));
}

/* Brand lockup accent: the "UP" half of BELT|UP carries the accent hue, the
   rest inherits .bu-nav-brand's text colour. Uniform across every skin per
   D-S07-SKIN-02 (no partial-skin fallthrough) — added 2026-08-21 when an audit
   found this styled in only 2 of 20 skins. Uses the standard accent token, NOT
   the lighter hover tone. */
:root[data-theme="the-quest"] .bu-nav-brand span {
  color: var(--theme-accent-primary);
}

/* --- Footer band -----------------------------------------------------------
   Ported 2026-08-21 to close a partial-skin fallthrough: this family was
   coloured in only 1 of 20 Public skins, so the footer rendered untinted and
   dividerless in every other skin (D-S07-SKIN-02). Token-for-token identical to
   render-greyscale-skeleton.css — no new values invented; each token resolves
   to this skin's own palette. */
:root[data-theme="the-quest"] .bu-footer {
  border-top: 2px solid var(--theme-border-inactive);
  background-color: var(--theme-bg-surface);
}

:root[data-theme="the-quest"] .bu-footer-heading {
  color: var(--theme-text-main);
}

:root[data-theme="the-quest"] .bu-footer-copyright {
  border-top: 1px solid var(--theme-border-inactive);
  color: var(--theme-text-muted);
}

:root[data-theme="the-quest"] .bu-footer-lab-link {
  color: var(--theme-text-muted);
}

:root[data-theme="the-quest"] .bu-link-stealth {
  color: var(--theme-text-muted);
}

:root[data-theme="the-quest"] .bu-link-stealth:hover {
  color: var(--theme-text-main);
}

/* ==== #234 CONSTRUCTION FAMILY BEGIN ==== (CRYSTAL GATE, family 5 of 8) ====
   Skin "the-quest" belongs to the CRYSTAL GATE construction family. Colour variants of one
   family share this construction and differ only in the variables above. */
/* family variables: derived from this skin's own palette; contrast pairs verified >= 4.5:1 (fill/ink), >= 3:1 (edge, focus) against the canvas */
:root[data-theme="the-quest"] {
  --fam-edge: #6ba33f;
  --fam-hi: #9fd46a;
  --fam-hov: #9fd46a;
  --fam-fill: #6ba33f;
  --fam-ink: #0e1409;
  --fam-deep: #26401a;
  --fam-focus: #9fd46a;
  --fam-glow: color-mix(in srgb, #6ba33f 55%, transparent);
  --theme-state-healthy: #6ca441; /* AA repair (>= 4.7:1 on canvas, surface and card), hue kept semantic */
  --theme-state-error: #cc8171; /* AA repair (>= 4.7:1 on canvas, surface and card), hue kept semantic */
}

/* ===========================================================================
   CONSTRUCTION FAMILY 5 of 8 — CRYSTAL GATE  [#234 / R-0823-01 / R-0823-02]
   Reference: six-terminals.html 02 "Crystal Gate -- faceted, emissive";
   ar-crystal-forms.html. Reuses the student crystal-gate chamfer construction.
   Frame strategy: a faceted slab -- two opposite corners cut (clip-path), a
   crisp outline and an inner offset hairline drawn as inset shadows on
   pseudo-elements that carry the same clip; two diagonal light shards inside.
   Light source: emissive from inside (inset glow + text glow). The outer halo
   is deliberately absent: clip-path would cut it (clip order: filter, then
   clip), so the light stays inside the crystal.
   Palette discipline: deep green/earth gradient, one emissive hue.
   Type: semibold, wide-tracked uppercase headings with a soft glow.
   NOTE: no backdrop-filter on any clipped element (the #228 paint-outside bug).
   [PILLAR-1: Gestalt -- the cut corners create a strong silhouette; the
   student crystal-gate is the validated precedent for this construction.]
   =========================================================================== */
:root[data-theme="the-quest"] body {
  background-image:
    linear-gradient(115deg, color-mix(in srgb, var(--fam-edge) 7%, transparent) 0 22%, transparent 22% 100%),
    linear-gradient(250deg, color-mix(in srgb, var(--fam-deep) 40%, transparent) 0 18%, transparent 18% 100%);
  background-repeat: no-repeat;
}
:root[data-theme="the-quest"] .bu-panel {
  border: 0;
  border-radius: 0;
  isolation: isolate;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background-color: var(--theme-bg-canvas);
  background-image:
    linear-gradient(112deg, color-mix(in srgb, var(--fam-edge) 12%, transparent), transparent 38%),
    linear-gradient(248deg, color-mix(in srgb, var(--fam-edge) 8%, transparent), transparent 34%),
    linear-gradient(var(--theme-bg-surface), var(--theme-bg-surface));
  box-shadow: inset 0 0 38px -16px var(--fam-edge);
}
:root[data-theme="the-quest"] .bu-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  box-shadow: inset 0 0 0 1px var(--fam-edge);
}
:root[data-theme="the-quest"] .bu-panel::after {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fam-edge) 30%, transparent);
}
:root[data-theme="the-quest"] .bu-panel > .bu-reveal:first-child {
  background: linear-gradient(90deg, var(--fam-edge), color-mix(in srgb, var(--fam-edge) 8%, transparent)) left bottom / 100% 1px no-repeat;
  padding-bottom: 0.6rem;
}
:root[data-theme="the-quest"] h1, :root[data-theme="the-quest"] h2, :root[data-theme="the-quest"] h3 { font-weight: 600; overflow-wrap: break-word; }
:root[data-theme="the-quest"] .bu-panel h2, :root[data-theme="the-quest"] .bu-panel h3, :root[data-theme="the-quest"] .bu-panel-title, :root[data-theme="the-quest"] .bu-panel-headline {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 12px color-mix(in srgb, var(--fam-edge) 70%, transparent);
}
:root[data-theme="the-quest"] .bu-panel-sublabel, :root[data-theme="the-quest"] .bu-badge-tag, :root[data-theme="the-quest"] .bu-metric-label, :root[data-theme="the-quest"] .bu-panel-footnote {
  font-family: var(--structure-font-family-mono);
  letter-spacing: 0.16em;
  font-size: var(--structure-text-xs, 0.75rem);
  color: var(--fam-hi);
}
:root[data-theme="the-quest"] .bu-badge-tag { background: color-mix(in srgb, var(--fam-edge) 12%, transparent); border: 1px solid var(--fam-edge); border-radius: 0; padding: 0.25rem 0.6rem; }
:root[data-theme="the-quest"] .bu-rail {
  border-bottom: 1px solid var(--fam-edge);
  background-image: linear-gradient(100deg, color-mix(in srgb, var(--fam-edge) 14%, transparent), transparent 40%);
}
:root[data-theme="the-quest"] .bu-nav-links a:hover, :root[data-theme="the-quest"] .bu-nav-links a.active { color: var(--fam-hi); text-shadow: 0 0 10px var(--fam-glow); text-decoration: none; }
/* faceted buttons: two cut corners, focus ring drawn INSIDE the clip */
:root[data-theme="the-quest"] .bu-btn {
  background: var(--fam-fill);
  border: 0;
  border-radius: 0;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  color: var(--fam-ink);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: none;
}
:root[data-theme="the-quest"] .bu-btn:hover { background: var(--fam-hov); color: var(--fam-ink); }
:root[data-theme="the-quest"] .bu-btn:focus-visible, :root[data-theme="the-quest"] .bu-btn-secondary:focus-visible { outline-offset: -5px; outline-color: var(--fam-focus); }
:root[data-theme="the-quest"] .bu-btn-secondary {
  background: transparent;
  border: 0;
  border-radius: 0;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  box-shadow: inset 0 0 0 1px var(--fam-edge);
  color: var(--fam-hi);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
:root[data-theme="the-quest"] .bu-btn-secondary:hover { background: color-mix(in srgb, var(--fam-edge) 18%, transparent); color: var(--fam-hi); box-shadow: inset 0 0 0 1px var(--fam-hi); }
:root[data-theme="the-quest"] .bu-btn-secondary.is-active { background: var(--fam-fill); color: var(--fam-ink); }
:root[data-theme="the-quest"] .bu-control, :root[data-theme="the-quest"] .bu-field input[type="text"], :root[data-theme="the-quest"] .bu-field input[type="email"], :root[data-theme="the-quest"] .bu-field input[type="tel"],
:root[data-theme="the-quest"] .bu-field input[type="password"], :root[data-theme="the-quest"] .bu-field input[type="number"], :root[data-theme="the-quest"] .bu-field select, :root[data-theme="the-quest"] .bu-field textarea,
:root[data-theme="the-quest"] input.bu-input, :root[data-theme="the-quest"] select.bu-input, :root[data-theme="the-quest"] textarea.bu-input {
  background: color-mix(in srgb, var(--theme-bg-canvas) 80%, var(--theme-bg-card));
  border: 1px solid var(--fam-edge);
  border-radius: 0;
  color: var(--theme-text-main);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--fam-edge) 14%, transparent);
}
:root[data-theme="the-quest"] .bu-control:hover, :root[data-theme="the-quest"] .bu-field input:hover, :root[data-theme="the-quest"] .bu-field select:hover, :root[data-theme="the-quest"] .bu-field textarea:hover { border-color: var(--fam-hi); color: var(--theme-text-main); background: color-mix(in srgb, var(--theme-bg-canvas) 80%, var(--theme-bg-card)); }
:root[data-theme="the-quest"] .bu-table th, :root[data-theme="the-quest"] .bu-table td { border-bottom: 1px solid color-mix(in srgb, var(--fam-edge) 28%, transparent); }
:root[data-theme="the-quest"] .bu-table th { text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; }

/* --- shared floors every family honours (state tokens, focus, option list) --- */
:root[data-theme="the-quest"] .bu-field select option,
:root[data-theme="the-quest"] select.bu-input option {
  background-color: var(--theme-bg-canvas);
  color: var(--theme-text-main);
}
:root[data-theme="the-quest"] .bu-btn:focus-visible,
:root[data-theme="the-quest"] .bu-btn-secondary:focus-visible,
:root[data-theme="the-quest"] .bu-control:focus-visible,
:root[data-theme="the-quest"] .bu-field input:focus-visible,
:root[data-theme="the-quest"] .bu-field select:focus-visible,
:root[data-theme="the-quest"] .bu-field textarea:focus-visible,
:root[data-theme="the-quest"] .bu-input:focus-visible,
:root[data-theme="the-quest"] .bu-nav-links a:focus-visible,
:root[data-theme="the-quest"] .bu-tab-btn:focus-visible {
  outline: 2px solid var(--fam-focus);
  outline-offset: 2px;
}
:root[data-theme="the-quest"] .bu-btn:disabled,
:root[data-theme="the-quest"] .bu-btn-secondary:disabled {
  background: transparent;
  border-color: var(--theme-x-accent-disabled);
  color: var(--theme-x-text-disabled);
  box-shadow: none;
  filter: none;
}
:root[data-theme="the-quest"] .bu-status-dot.is-healthy { background: var(--theme-state-healthy); }
:root[data-theme="the-quest"] .bu-status-dot.is-warning,
:root[data-theme="the-quest"] .bu-status-dot.is-alert { background: var(--theme-state-warning); }
:root[data-theme="the-quest"] .bu-status-dot.is-error { background: var(--theme-state-error); }
:root[data-theme="the-quest"] .bu-field-error { color: var(--theme-state-error); }
/* --- overlay / scroll-container panels (Admin drawers, slide-outs, the report widget) ---
   A family frame is drawn on pseudo-elements and a plate that would scroll away with the
   content, and some panel margins would leave a closed drawer peeking in. Overlay panels
   therefore get a solid attached fill, one plain outline, no pseudo frame, no clip. */
:root[data-theme="the-quest"] .bu-drawer, :root[data-theme="the-quest"] .bu-slideout-content, :root[data-theme="the-quest"] .bu-report-widget-panel {
  clip-path: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background-color: var(--theme-bg-canvas);
  background-image: linear-gradient(var(--theme-bg-surface), var(--theme-bg-surface));
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: 0 0;
  border: 1px solid var(--fam-edge);
  box-shadow: none;
  isolation: auto;
}
:root[data-theme="the-quest"] .bu-drawer::before, :root[data-theme="the-quest"] .bu-drawer::after,
:root[data-theme="the-quest"] .bu-slideout-content::before, :root[data-theme="the-quest"] .bu-slideout-content::after,
:root[data-theme="the-quest"] .bu-report-widget-panel::before, :root[data-theme="the-quest"] .bu-report-widget-panel::after { content: none; }

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="the-quest"] .bu-btn, :root[data-theme="the-quest"] .bu-btn-secondary { transition: none; transform: none; }
}
:root[data-reduced-motion="true"][data-theme="the-quest"] .bu-btn,
:root[data-reduced-motion="true"][data-theme="the-quest"] .bu-btn-secondary { transition: none; transform: none; }
/* ==== #234 CONSTRUCTION FAMILY END ==== */
