/* ============================================================
   HYPERTALE — Base: reset, typography, layout scaffolding
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

/* Author stylesheets always beat the UA stylesheet, so any component that
   also declares `display` on the same element (e.g. `.tools { display:flex }`)
   silently defeats `el.hidden = true`. Force it back to authoritative. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--bg-650) transparent;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-900);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Deep base gradient behind the canvas FX layer */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(var(--purple-rgb), 0.14), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(var(--green-rgb), 0.1), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, rgba(var(--purple-rgb), 0.1), transparent 60%),
    var(--bg-900);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

/* Default size for every inline icon emitted by lib/icons.js `icon()`.
   Sized in `em` so an icon always matches the text it sits beside. Declared here,
   in the first stylesheet, so any later `.parent svg { … }` rule overrides it —
   which is how every existing component keeps its own icon sizing. */
.ui-ico {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.16em;
}

/* Belt and braces: an icon sitting directly in a heading, paragraph, label or
   table cell gets sized even if it somehow lacks the class above. Specificity
   (0,0,2) — beats the bare `svg` reset, still loses to every `.parent svg` rule. */
h1 > svg, h2 > svg, h3 > svg, h4 > svg,
p > svg, label > svg, summary > svg, td > svg, th > svg, li > svg {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.16em;
}

a { color: var(--green); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--green-bright); }

button, input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }

p { color: var(--text-soft); }

::selection { background: rgba(var(--green-rgb), 0.28); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--bg-650), var(--bg-700));
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(var(--green-deep), var(--purple-deep)); background-clip: padding-box; }

/* ---- Layout primitives ---- */
main { flex: 1 0 auto; position: relative; z-index: var(--z-base); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.wrap-wide { width: 100%; max-width: var(--wrap-wide); margin-inline: auto; padding-inline: var(--gutter); }

.section { padding-block: clamp(48px, 8vw, 96px); position: relative; }
.section-tight { padding-block: clamp(28px, 5vw, 52px); }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.wrap-flex { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.mt-a { margin-top: auto; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
}
.eyebrow::before {
  content: '';
  width: 22px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--green), transparent);
}

.section-head { margin-bottom: clamp(24px, 4vw, 40px); }
.section-head h2 { margin-top: 10px; }
.section-head .sub { color: var(--text-dim); max-width: 60ch; margin-top: 8px; }

.text-dim { color: var(--text-dim); }
.text-soft { color: var(--text-soft); }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }
.muted { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

@media (max-width: 860px) { .hide-md { display: none !important; } }
@media (max-width: 560px) { .hide-sm { display: none !important; } }
