@font-face { font-family: 'Inter'; src: url('../fonts/inter-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f7f7f5; --surface: #ffffff; --surface-2: #efefec;
  --ink: #16181b; --ink-2: #4a4f56; --ink-3: #7b8189; --line: #e3e3df;
  --accent: #f26b1d; --accent-ink: #ffffff; --accent-soft: #fde9dc; --ok: #1f9d55; --warn: #b7791f; --focus: #1b6ef3;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 10px 30px rgb(0 0 0 / .06);
  --nav-h: 60px; --gutter: 16px; --content-max: 680px;
  --font: 'Inter', 'Plex Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #1a1c1f; --surface-2: #23262a;
    --ink: #f2f2f0; --ink-2: #b9bdc3; --ink-3: #8a9098; --line: #2d3035;
    --accent-soft: #3a2416;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #1a1c1f; --surface-2: #23262a;
  --ink: #f2f2f0; --ink-2: #b9bdc3; --ink-3: #8a9098; --line: #2d3035;
  --accent-soft: #3a2416; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
  color-scheme: dark;
}
[lang="ar"] { --font: 'Plex Arabic', 'Inter', system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--font); -webkit-font-smoothing: antialiased; overflow-x: clip; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 16px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

.topbar { position: sticky; top: 0; z-index: 20; height: var(--nav-h); display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; white-space: nowrap; font-size: 14px; }
.nav a[aria-current="true"] { background: var(--ink); color: var(--bg); }
.topbar-actions { display: flex; gap: 8px; }

.pill, .btn, .tab { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn { font-size: 15px; padding: 10px 18px; }
.pill-accent, .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tab input { position: absolute; opacity: 0; pointer-events: none; }
.tab[aria-selected="true"], .tab[aria-pressed="true"], .tab:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-row, .hero-cta, .tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.content { padding: 0 clamp(16px, 4vw, 56px) 96px; min-width: 0; }
.stage-wrap { position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h));
  background: radial-gradient(ellipse at 50% 42%, var(--surface) 0%, var(--bg) 72%); overflow: hidden; }
#stage { width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
.stage-box { position: relative; width: 100%; height: 100%; }

.section { max-width: var(--content-max); padding: 80px 0 24px; }
.hero { min-height: calc(100vh - var(--nav-h)); display: flex; flex-direction: column; justify-content: center; padding-top: 32px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 13px; font-weight: 600; color: var(--accent); margin: 0 0 12px; }
h1 { font-size: clamp(34px, 5vw, 58px); line-height: 1.06; letter-spacing: -.025em; margin: 0 0 18px; }
h2 { font-size: clamp(28px, 3.6vw, 42px); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 12px; }
h3 { font-size: 21px; line-height: 1.3; margin: 0 0 8px; }
[lang="ar"] .eyebrow { text-transform: none; letter-spacing: 0; }
[lang="ar"] h1, [lang="ar"] h2 { letter-spacing: 0; line-height: 1.3; }
.lede { font-size: 19px; color: var(--ink-2); margin: 0 0 8px; }
.note { font-size: 13px; color: var(--ink-3); }
.disclaimer { font-size: 14px; background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin: 20px 0;
  box-shadow: var(--shadow); transition: transform .35s ease, box-shadow .35s ease; }
@media (hover: hover) { .card:hover { transform: perspective(900px) translateY(-2px) rotateX(1deg); } }
.prose p, .prose li { color: var(--ink-2); }
.prose p { margin: 0 0 12px; }
.prose strong { color: var(--ink); }
[data-term] { border-bottom: 1px dotted var(--ink-3); cursor: help; }

.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 32px 0 8px; }
.hero-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.hero-stats dt { font-size: 13px; color: var(--ink-3); }
.hero-stats dd { margin: 0; font-size: 20px; font-weight: 700; }

.controls { display: grid; gap: 14px; margin: 16px 0; }
.control { display: grid; grid-template-columns: 150px minmax(0, 1fr) 56px; align-items: center; gap: 12px; }
.control output { font-variant-numeric: tabular-nums; text-align: end; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.rpm-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 8px 0 16px; }
.rpm-bar { display: grid; gap: 6px; text-align: center; font-size: 12px; color: var(--ink-2); }
.rpm-bar .track { height: 90px; background: var(--surface-2); border-radius: 8px; position: relative; overflow: hidden; }
.rpm-bar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--accent); }
.rpm-bar output { font-variant-numeric: tabular-nums; color: var(--ink); }
.readout { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 8px 0; }

.spec-table { width: 100%; border-collapse: collapse; font-size: 15px; table-layout: fixed; }
.spec-table th { width: 42%; }
.spec-table th, .spec-table td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec-table th { text-align: start; font-weight: 400; color: var(--ink-2); padding-inline-end: 16px; }
.spec-table td { text-align: end; font-weight: 600; overflow-wrap: anywhere; }

.focal-frame { overflow: hidden; border-radius: var(--radius-sm); aspect-ratio: 16 / 9; background: var(--surface-2); }
.focal-frame img { width: 100%; height: 100%; object-fit: cover; }
.box-figure { position: relative; }
.box-hotspot { position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer; font: 700 12px/1 var(--font); }
.box-hotspot[aria-pressed="true"] { outline: 3px solid var(--ink); }
.box-list { columns: 2; padding-inline-start: 20px; color: var(--ink-2); }
.focal-frame { position: relative; }
.fov-box { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 2px solid rgb(255 255 255 / .6);
  border-radius: 4px; pointer-events: none; transition: border-color .3s, box-shadow .3s; }
.fov-box span { position: absolute; top: 4px; inset-inline-start: 6px; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .6); }
.fov-box.is-active { border-color: var(--accent); box-shadow: 0 0 0 9999px rgb(0 0 0 / .35); }
.box-list li.is-active { color: var(--accent); font-weight: 600; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gallery figure { margin: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.figure { margin: 16px 0 0; }
.diagram { width: 100%; height: auto; display: block; }
.diagram .d-body rect { fill: var(--ink-3); }
.diagram .d-prop circle { fill: var(--surface-2); stroke: var(--line); }
.diagram .d-arrow { stroke: var(--ink); stroke-width: 3; fill: none; }
.diagram .d-accent { stroke: var(--accent); }
.diagram .d-muted { stroke: var(--ink-3); }
.diagram .d-links line { stroke: var(--line); stroke-width: 2; }
.diagram .d-chip rect { fill: var(--surface); stroke: var(--line); }
.diagram .d-core { fill: var(--ink); }
.diagram text { fill: var(--ink-2); font: 600 14px var(--font); }
.diagram .d-core-text { fill: var(--bg); }

.hotspots { position: absolute; inset: 0; pointer-events: none; }
.hotspot { position: absolute; pointer-events: auto; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; background: var(--accent); cursor: pointer; padding: 0;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent); }
.hotspot[hidden] { display: none; }
.part-card { position: absolute; inset-inline-start: 16px; bottom: 16px; max-width: min(360px, calc(100% - 32px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.part-card h4 { margin: 0 0 6px; font-size: 17px; }
.part-card p { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }

.stick-pair { display: flex; justify-content: space-between; gap: 24px; margin: 16px 0; }
.stick-col { display: grid; justify-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); text-align: center; }
.stick { width: 132px; height: 132px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); position: relative;
  touch-action: none; user-select: none; -webkit-user-select: none; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: var(--ink); box-shadow: var(--shadow); }
.sim-hud { position: absolute; top: 16px; inset-inline-end: 16px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.checklist { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 3px; }
.calc { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
.calc label { display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); }
select, .search { font: inherit; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.table-wrap { overflow-x: auto; }
.rules-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.rules-table th, .rules-table td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rules-table thead th { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; margin-inline-start: 4px; }
.badge-unverified { background: var(--accent-soft); color: var(--warn); }

.search { width: 100%; margin: 12px 0 4px; }
.glossary-list { display: grid; gap: 4px; margin: 16px 0; }
.glossary-list dt { font-weight: 700; margin-top: 12px; }
.glossary-list dt .alt { font-weight: 400; color: var(--ink-3); margin-inline-start: 8px; }
.glossary-list dd { margin: 0; color: var(--ink-2); }
.glossary-list :target { background: var(--accent-soft); border-radius: 6px; }
.term-tip { position: absolute; z-index: 40; max-width: 300px; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 1.5;
  padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow); pointer-events: none; }

.footer { border-top: 1px solid var(--line); padding: 32px clamp(16px, 4vw, 56px); color: var(--ink-3); font-size: 14px; }
.sources { font-size: 13px; }

.fallback-gallery { display: none; }
.no-webgl .stage-box, .no-webgl .requires-webgl { display: none; }
.no-webgl .fallback-gallery { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; gap: 16px; padding: 24px; }
.fallback-gallery img { flex: 0 0 100%; object-fit: contain; scroll-snap-align: center; }
.no-webgl-only { display: none; }
.no-webgl .no-webgl-only { display: block; }

.presenter { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.presenter[hidden] { display: none; }
.presenter-slide { padding: 7vh 5vw 14vh; overflow: auto; font-size: clamp(19px, 1.5vw, 26px); }
.presenter-slide .card { box-shadow: none; border: 0; background: transparent; padding: 0; margin: 0; transform: none; }
.presenter-slide h1, .presenter-slide h3 { font-size: 2.1em; line-height: 1.15; }
.presenter-stage { position: relative; min-height: 0; }
.presenter-stage .stage-box { position: absolute; inset: 0; }
.presenter-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px; box-shadow: var(--shadow); }
.presenter-bar output { font-variant-numeric: tabular-nums; padding: 0 8px; }

@media (max-width: 860px) {
  :root { --nav-h: 56px; }
  .topbar { padding: 0 var(--gutter); gap: 8px; }
  .brand { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage-wrap { order: -1; top: var(--nav-h); height: 42vh; height: 42dvh; z-index: 5; border-bottom: 1px solid var(--line); }
  .content { padding: 0 var(--gutter) 64px; }
  .hero { min-height: auto; padding-top: 32px; }
  .section { padding-top: 48px; }
  .control { grid-template-columns: minmax(0, 1fr) 56px; }
  .control label { grid-column: 1 / -1; }
  .stick { width: 120px; height: 120px; }
  .box-list { columns: 1; }
  .presenter { grid-template-columns: minmax(0, 1fr); grid-template-rows: 42vh minmax(0, 1fr); }
  .presenter-stage { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
