
/* =====================================================================
 * LAYOUT: tool-portal-dark
 *
 * Target shape: interactive platform whose primary value is a library of
 * tools plus a library of theory guides plus (optionally) playable
 * prototypes. Dark-mode-first because the audience is developers and
 * designers working in dark IDEs. The layout supports THREE page shapes:
 *
 *   1. Portal/index pages  — hero + grid cards for tools/guides/games
 *   2. Tool pages          — tool area dominates; supporting prose sits
 *                            below. Form controls are first-class.
 *   3. Article/guide pages — narrow reading column (720px), generous
 *                            line-height, table + code + callout support.
 *
 * Renderer contract (see brochure-formal for the same notes):
 *   - This template MUST NOT declare --section-* defaults; the renderer
 *     appends them after rendering based on palette luminance.
 *   - Renderer-managed surface section classes:
 *       .features-section, .services-section, .differentiators-section,
 *       .about-section, .faq-section
 *     These MUST be surface-coloured here.
 *   - Element rules use var(--section-*, var(--color-*)) so dark-section
 *     components override per container without restating rules.
 * ===================================================================== */

:root {
  /* ── Palette — dark-first fallbacks ── */
  --color-primary:        #e8a33d;
  --color-primary-hover:  #e8a33d;
  --color-primary-text:   #0b1016;
  --color-secondary:      #243044;
  --color-accent:         #e8a33d;
  --color-background:     #0b1016;
  --color-surface:        #111923;
  --color-surface-alt:    #111923;
  --color-text:           #e6edf5;
  --color-text-muted:     #8e9db0;
  --color-border:         #1f2a38;
  --color-card-bg:        #111923;
  --color-header-bg:      #0b1016;
  --color-header-text:    #e6edf5;
  --color-cta-bg:         #111923;
  --color-cta-text:       #e6edf5;
  --color-footer-bg:      #0b1016;
  --color-footer-text:    #e6edf5;
  --color-code-bg:        #0d0d0d;
  --color-callout-bg:     rgba(0,188,212,0.08);
  --color-callout-border: #00bcd4;

  /* ── Typography ── */
  --font-body:        Archivo, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-heading:     Archivo, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:        'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-size-base:   15px;
  --line-height-base: 1.65;

  /* ── Structure — tuned for dense utility feel ── */
  --container-max:    1200px;
  --container-pad-x:  1.25rem;
  --reading-max:      720px;
  --section-pad-y:    4rem;
  --section-pad-y-sm: 2.5rem;
  --radius:           0.25rem;
  --radius-sm:        2px;
  --radius-lg:        0.375rem;
  --shadow-sm:        0 1px 0 rgba(0,0,0,0.25);
  --shadow-md:        0 2px 4px rgba(0,0,0,0.35);
  --shadow-lg:        0 4px 16px rgba(0,0,0,0.5);
  --transition:       150ms ease;
  --card-pad:         1.5rem;
  --grid-gap:         1.5rem;

  /* Optional palette-driven heading override (same pattern as other layouts) */
  --section-heading: #e6edf5;
}

/* ── Base reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
code, pre, kbd, samp { font-family: var(--font-mono); }

/* ── Colour Inheritance Model ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--section-heading, var(--color-text));
  margin: 0 0 1rem;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 2.25rem; font-weight: 700; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p, li, blockquote { color: var(--section-text, inherit); margin: 0 0 1rem; }
a {
  color: var(--color-accent-ink, var(--color-accent));
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary); }

/* ── Layout primitives ── */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad-x);
  width: 100%;
}
.container--reading { max-width: var(--reading-max); }
.section { padding-block: var(--section-pad-y); }

/* ── Site header — low chrome, same background as body ── */
.site-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: 0.875rem var(--container-pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.logo {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-header-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.logo-img { max-height: 32px; width: auto; }
.main-nav ul {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.main-nav a {
  color: var(--color-header-text);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}
.main-nav a:hover,
.main-nav a.active { color: var(--color-accent); }
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-header-text);
}
.mobile-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  margin: 5px 0;
}

/* ── Hero (component-coloured) ──
 * Tool-portal heroes are typically punchy statement typography, not
 * imagery-driven. Keep the layout minimal; the component supplies bg. */
.hero-section { padding-block: calc(var(--section-pad-y) * 1.25); }
.hero-section .container { text-align: center; max-width: 880px; }
.hero-section h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-bottom: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero-subtitle, .hero-section .lead {
  font-size: 1.15rem;
  color: var(--section-text-muted, var(--color-text-muted));
  margin: 0 auto 2rem;
  max-width: 640px;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Renderer-managed surface sections ──
 * Same contract as brochure-formal: these 5 classes MUST be surface-coloured.
 * The renderer will append --section-* defaults on top of this background. */
.features-section,
.services-section,
.differentiators-section,
.about-section,
.faq-section { background: var(--color-surface); }

/* ── Generic section grids — denser than brochure (3-col → 2 → 1) ── */
.features-grid,
.services-grid,
.differentiators-grid,
.tools-grid,
.guides-grid,
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--grid-gap);
  margin-top: 2rem;
}
.feature-card,
.service-card,
.differentiator-card,
.tool-card,
.guide-card,
.game-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--card-pad);
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.feature-card:hover,
.service-card:hover,
.differentiator-card:hover,
.tool-card:hover,
.guide-card:hover,
.game-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-alt);
}
.feature-icon,
.service-icon,
.tool-card__icon,
.guide-card__icon,
.game-card__icon {
  width: 32px;
  height: 32px;
  margin-bottom: 0.5rem;
  color: var(--color-accent);
}
.tool-card__title,
.guide-card__title,
.game-card__title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.tool-card__description,
.guide-card__excerpt,
.game-card__description {
  font-size: 0.9rem;
  color: var(--section-text-muted, var(--color-text-muted));
  margin: 0;
  flex: 1;
}

/* ── Tool page layout ──
 * The tool itself (form + output) dominates. Supporting prose sits below. */
.tool-section {
  padding-block: var(--section-pad-y);
  background: var(--color-background);
}
.tool-section .container { max-width: 960px; }
.tool-workspace {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 2.5rem;
}
.tool-workspace__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.tool-workspace__title { font-size: 1.25rem; margin: 0; }
.tool-workspace__meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.tool-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.tool-output {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-text);
  overflow-x: auto;
}
.tool-output__label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.tool-output__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
}

/* ── Article / guide page layout ──
 * Narrow reading column, generous line-height, supports code, tables,
 * callouts, and the Design Rule pattern from the content_direction. */
.article-section {
  padding-block: var(--section-pad-y);
}
.article-section .container { max-width: var(--reading-max); }
.article-body {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--color-text);
}
.article-body h2 {
  font-size: 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.article-body h3 { font-size: 1.15rem; margin-top: 2rem; }
.article-body p { margin-bottom: 1.25rem; }
.article-body ul, .article-body ol { margin: 0 0 1.25rem 1.5rem; }
.article-body li { margin-bottom: 0.4rem; }
.article-body blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
  font-style: italic;
}
.article-body code {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}
.article-body pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}
.article-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.article-body th, .article-body td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.article-body th {
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.article-body tbody td { color: var(--color-text-muted); }
.article-body td:first-child, .article-body th:first-child { padding-left: 0; }

/* Design Rule callout — the axiom pattern */
.design-rule {
  background: var(--color-callout-bg);
  border-left: 3px solid var(--color-callout-border);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.design-rule__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-callout-border);
  margin-bottom: 0.35rem;
}
.design-rule__body { color: var(--color-text); margin: 0; font-weight: 500; }

/* ── Forms (tool controls are first-class) ── */
.form-field { margin-bottom: 1rem; }
.form-field label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-background);
  color: var(--color-text);
  min-height: 40px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 30%, transparent);
}
.form-field--inline input { font-family: var(--font-mono); }

/* ── Buttons — flat, tool-specific verb framing ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  min-height: 40px;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
}
.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  color: var(--color-primary-text);
}
.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.btn-secondary:hover {
  background: var(--color-accent);
  color: var(--color-primary-text);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface); }
.btn-large { padding: 0.875rem 1.75rem; font-size: 0.95rem; }

/* ── FAQ ── */
.faq-section .container { max-width: var(--reading-max); }
.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--color-text-muted); font-size: 1.25rem; }
.faq-item[open] summary::after { content: "−"; color: var(--color-accent); }
.faq-item p {
  padding-top: 0.625rem;
  color: var(--section-text-muted, var(--color-text-muted));
}

/* ── About / Contact (component-coloured) ── */
.about-section .container { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: start; }
.contact-section .container { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }

/* ── Site footer — even darker than body for visual separation ── */
.site-footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding-top: 3rem;
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}
.footer-container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: 0 var(--container-pad-x);
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}
.site-footer h3, .site-footer h4 { color: var(--color-text); font-size: 0.95rem; }
.site-footer a { color: var(--color-footer-text); }
.site-footer a:hover { color: var(--color-accent); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.footer-bottom {
  margin-top: 2.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .footer-container { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .section { padding-block: var(--section-pad-y-sm); }
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.375rem; }
  .about-section .container,
  .contact-section .container,
  .footer-container { grid-template-columns: 1fr; }
  .main-nav { display: none; }
  .main-nav.is-open { display: block; }
  .mobile-menu-toggle { display: inline-flex; flex-direction: column; justify-content: center; align-items: center; }
  .tool-workspace__header { flex-direction: column; align-items: flex-start; }
}

/* ── Accessibility ── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* C5-PROSE-LINK (owner ruling 2026-09-14): a link in running copy needs a cue that is not colour. Unclassed links only - component links carry classes and keep their own styling. */
:where(main) :is(p, li, dd, blockquote) a:not([class]){text-decoration:underline;text-underline-offset:2px}


/* === Component-specific styles === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.6s ease forwards; }

/* ── Renderer-enforced section defaults ── */
/* Text/heading colours are picked from the site palette by contrast ratio. */
/* Themes MUST NOT declare --section-* defaults; the renderer owns this. */

body {
  --section-text: #e6edf5;
  --section-text-muted: rgba(230,237,245,0.75);
  --section-heading: #e6edf5;
  --section-surface: rgba(255,255,255,0.05);
  --section-border: rgba(255,255,255,0.2);
}

.differentiators-section,
.features-section,
.faq-section,
.services-section,
.about-section {
  --section-text: #e6edf5;
  --section-text-muted: rgba(230,237,245,0.75);
  --section-heading: #e6edf5;
  --section-surface: rgba(255,255,255,0.05);
  --section-border: rgba(255,255,255,0.2);
}


/* renderer-enforced compatibility aliases (component vocabulary bridge) */
:root {
  --border-radius: var(--radius, 8px);
  --shadow: var(--shadow-md, 0 2px 12px rgba(0, 0, 0, 0.15));
  --spacing-section: var(--section-pad-y, 4rem);
  --container-max-width: var(--container-max, 1200px);
  --primary-color: var(--color-primary);
  --secondary-color: var(--color-secondary);
  --accent-color: var(--color-accent);
  --color-heading: var(--color-text);
  --color-white: #ffffff;
  --color-error: #d64545;
  --hero-ink: var(--color-text);
}


/* renderer-owned legible-ink companions. Opt in with
   var(--color-primary-ink, var(--color-primary)) — never bare, so a
   stylesheet rendered before this block renders byte-identically. */
:root {
  --color-primary-ink: #e8a33d;
  --color-accent-ink: #e8a33d;
  --color-accent-text: #253e5c;
  --color-cta-bg-ink: #111923;
}
