/* ==========================================================================
   TProM Team — foundation
   Tokens, reset, typography, buttons, utilities.

   Design intent — "the instrument".
   The site is set in deep space: a near-black indigo ground, a live star
   field, and one violet-to-rose-to-gold aurora gradient that every accent is
   cut from. Colour is spent on light (rims, sparks, glows), never on flat
   fills behind text, so the only bright thing on a screen is either the work
   itself or a piece of the instrument reacting to the visitor.
   ========================================================================== */

:root {
  /* ── Ground: deep space, not neutral black ──────────────────────────── */
  --void: #05040e;
  --void-2: #080614;
  --ink: #05040e;           /* legacy alias — kept so older rules still read */
  --ink-raise: #0a0818;
  --ink-panel: #100c22;
  --ink-line: #1b1533;

  /* ── Foreground: a white with violet in it ──────────────────────────── */
  --paper: #f3f0ff;
  --paper-80: rgba(243, 240, 255, 0.8);
  --paper-64: rgba(243, 240, 255, 0.64);
  --paper-48: rgba(243, 240, 255, 0.48);
  --paper-32: rgba(243, 240, 255, 0.32);
  --paper-16: rgba(243, 240, 255, 0.16);
  --paper-08: rgba(243, 240, 255, 0.08);

  /* The quietest tint that still clears WCAG AA (4.5:1) for body-size text
     on the void ground. Below this, hairlines and ornament only. */
  --paper-muted: rgba(243, 240, 255, 0.54);

  /* ── Brand ──────────────────────────────────────────────────────────── */
  --violet: #b25bf0;
  --violet-bright: #d9b8ff;
  --violet-deep: #6d3ad4;
  --violet-veil: rgba(178, 91, 240, 0.14);

  /* Nebula accents. Rose and gold appear only inside gradients, sparks and
     star glyphs — never as a flat fill behind text. */
  --rose: #ff6fd8;
  --gold: #ffd79a;
  --aurora: linear-gradient(100deg, var(--violet-deep) 0%, var(--violet) 34%, var(--rose) 68%, var(--gold) 100%);
  --aurora-soft: linear-gradient(100deg, rgba(109, 58, 212, 0.9), rgba(178, 91, 240, 0.9) 40%, rgba(255, 111, 216, 0.75) 72%, rgba(255, 215, 154, 0.6));

  /* Hairlines carry a violet cast so nothing on the page is pure grey. */
  --line: rgba(170, 140, 255, 0.16);
  --line-soft: rgba(170, 140, 255, 0.09);

  /* Per-project accent. Overwritten inline on each showcase from projects.js
     so nested elements can reference one variable name. */
  --accent: var(--violet);
  --accent-soft: var(--violet-bright);

  /* ── Type ───────────────────────────────────────────────────────────── */
  --font-sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;

  --fs-display-xl: clamp(2.45rem, 5.1vw, 5.6rem);
  --fs-display-lg: clamp(2rem, 4.3vw, 4.5rem);
  --fs-display-md: clamp(1.5rem, 2.5vw, 2.5rem);
  --fs-display-sm: clamp(1.25rem, 1.7vw, 1.65rem);
  --fs-lead: clamp(1.02rem, 1.25vw, 1.28rem);
  --fs-body: clamp(0.95rem, 1.02vw, 1.03rem);
  --fs-meta: clamp(0.7rem, 0.78vw, 0.775rem);

  /* ── Rhythm ─────────────────────────────────────────────────────────── */
  --shell: 1560px;
  --gutter: clamp(1.15rem, 4vw, 4.5rem);
  --section-y: clamp(5.5rem, 11vw, 11.5rem);
  --measure: 62ch;

  --radius: 4px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* ── Motion ─────────────────────────────────────────────────────────── */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  /* Overshoots slightly, then settles — the house easing for anything that
     travels: the comet, the gate, the aperture. */
  --ease-orbit: cubic-bezier(0.16, 1.02, 0.24, 1);
  --dur-fast: 0.28s;
  --dur: 0.55s;
  --dur-slow: 0.9s;

  --nav-h: 88px;
  --nav-h-min: 64px;
  color-scheme: dark;
}

@media (max-width: 900px) {
  :root {
    --nav-h: 72px;
    --nav-h-min: 58px;
  }
}

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

html {
  background: var(--ink);
  scroll-behavior: smooth;
  /* Anchors clear the fixed header instead of hiding beneath it. */
  scroll-padding-top: calc(var(--nav-h) + 1.5rem);
  -webkit-text-size-adjust: 100%;
  /* Frames in the 3D scenes deliberately overhang the grid, and perspective
     magnifies them outward. Clip at the root so neither edge can ever create a
     horizontal scrollbar — in LTR or RTL, where the overflow lands on the
     opposite side. `clip` rather than `hidden` on purpose: it does not create a
     scroll container, so the sticky process rail keeps working. */
  overflow-x: hidden;
  /* A phone will still rubber-band sideways even when there is nothing to
     scroll to — the page slides under the thumb and springs back, which
     reads as the whole site being draggable. This stops the bounce and any
     chaining to the browser's own horizontal gestures. */
  overscroll-behavior-x: none;
}
@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--paper);
  background: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1, 'liga' 1, 'cv11' 1;
  /* NEVER `overflow-x: hidden` here. That makes body a scroll container that
     never scrolls, and every position:sticky descendant silently stops
     pinning — which is exactly what happened to the process rail. The `clip`
     in the @supports block above is a different thing: it clips without
     creating a scroll container, so sticky survives, and mobile Safari
     honours it where a clip on the root alone can still be panned.

     Only vertical gestures and pinch-zoom. Nothing on this site scrolls
     sideways, so there is no horizontal pan to preserve — if a horizontal
     scroller is ever added, it needs `touch-action: auto` on itself AND this
     rule relaxed, because ancestors intersect with descendants here. */
  touch-action: pan-y pinch-zoom;
}

/* Arabic uses its own family at every level. The Latin display serif has no
   Arabic glyphs, so headings switch to a weighted sans rather than falling
   back to an unrelated system serif. */
html[lang='ar'] body {
  font-family: var(--font-ar);
  line-height: 1.75;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
}

/* Nothing on this site is a file to be taken away. A press-and-hold on Vael is
   meant to take hold of him and a press-and-hold on any other film or picture
   is meant to do nothing at all, but a browser answers both with the same
   menu — save, copy, download the video. Safari reads the callout; Chrome and
   Android need the menu itself refused, which js/main.js does. Scoped to media
   on purpose: text stays selectable, and every link and control keeps the menu
   a visitor expects to find on it. */
img,
video {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

::selection {
  background: var(--violet);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--violet-bright);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Scrollbar — thin, unobtrusive, matches the ground. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-line) var(--ink);
}
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: var(--ink);
}
::-webkit-scrollbar-thumb {
  background: #24242d;
  border-radius: 99px;
  border: 2px solid var(--ink);
}
::-webkit-scrollbar-thumb:hover {
  background: #33333f;
}

/* ── Typography ───────────────────────────────────────────────────────── */

.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.display em {
  font-style: italic;
  /* Optical: the italic serif reads slightly small next to the roman. */
  font-size: 1.02em;
}

html[lang='ar'] .display {
  font-family: var(--font-ar);
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: 0;
}
html[lang='ar'] .display em {
  font-style: normal;
  font-weight: 700;
  font-size: 1em;
  color: var(--accent-soft);
}

.display-xl {
  font-size: var(--fs-display-xl);
}
.display-lg {
  font-size: var(--fs-display-lg);
}
.display-md {
  font-size: var(--fs-display-md);
  line-height: 1.06;
}
.display-sm {
  font-size: var(--fs-display-sm);
  line-height: 1.2;
}

/* German compounds are long; keep them from overflowing narrow columns. */
html[lang='de'] .display {
  hyphens: auto;
}

.lead {
  font-size: var(--fs-lead);
  line-height: 1.62;
  color: var(--paper-64);
  max-width: var(--measure);
  font-weight: 350;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-48);
  font-family: var(--font-sans);
}

/* Arabic does not have upper case; tracking out lowercase Arabic damages
   legibility, so the eyebrow keeps natural casing and spacing. */
html[lang='ar'] .eyebrow {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
}

.eyebrow::before {
  content: '';
  inline-size: 5px;
  block-size: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.eyebrow--plain::before {
  display: none;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* ── Layout helpers ───────────────────────────────────────────────────── */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  /* The gutter, or the notch — whichever is wider. On a phone held sideways
     the safe area is the larger of the two and text would otherwise run
     under the camera housing. */
  padding-inline:
    max(var(--gutter), env(safe-area-inset-left))
    max(var(--gutter), env(safe-area-inset-right));
}

.section {
  position: relative;
  padding-block: var(--section-y);
}

.section-head {
  display: grid;
  gap: clamp(1rem, 1.6vw, 1.5rem);
  max-width: 46rem;
  margin-bottom: clamp(3rem, 6vw, 6rem);
}

/* A hairline that draws itself as the section arrives. */
.rule {
  position: relative;
  block-size: 1px;
  background: var(--ink-line);
  overflow: hidden;
}
.rule::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 100%;
  background: linear-gradient(90deg, var(--accent), transparent);
  transform: scaleX(0);
  /* transform-origin has no logical keywords, so the flip is explicit. */
  transform-origin: left center;
  transition: transform 1.1s var(--ease);
}
html[dir='rtl'] .rule::after {
  background: linear-gradient(270deg, var(--accent), transparent);
  transform-origin: right center;
}
.rule.is-in::after {
  transform: scaleX(1);
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 200;
  padding: 0.7rem 1.1rem;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  transform: translateY(-160%);
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  --btn-py: 0.95rem;
  --btn-px: 1.6rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: var(--btn-py) var(--btn-px);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  line-height: 1;
  border-radius: 999px;
  white-space: nowrap;
  isolation: isolate;
  overflow: hidden;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

html[lang='ar'] .btn {
  font-family: var(--font-ar);
  font-weight: 500;
}

.btn__label {
  position: relative;
  z-index: 2;
}

/* Arrow points along the reading direction in both scripts. */
.btn__arrow {
  position: relative;
  z-index: 2;
  transition: transform var(--dur-fast) var(--ease);
}
html[dir='rtl'] .btn__arrow {
  transform: scaleX(-1);
}

.btn--solid {
  background: var(--paper);
  color: var(--ink);
}
.btn--solid::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(100deg, var(--violet-bright), var(--violet));
  transform: translateY(101%);
  transition: transform var(--dur) var(--ease);
}
.btn--solid:hover {
  color: #fff;
}
.btn--solid:hover::before {
  transform: translateY(0);
}
.btn--solid:hover .btn__arrow {
  transform: translateX(3px);
}
html[dir='rtl'] .btn--solid:hover .btn__arrow {
  transform: scaleX(-1) translateX(3px);
}

.btn--ghost {
  border: 1px solid var(--paper-16);
  color: var(--paper);
}
.btn--ghost:hover {
  border-color: var(--paper-48);
}
.btn--ghost:hover .btn__arrow {
  transform: translateX(3px);
}
html[dir='rtl'] .btn--ghost:hover .btn__arrow {
  transform: scaleX(-1) translateX(3px);
}

.btn--sm {
  --btn-py: 0.68rem;
  --btn-px: 1.15rem;
  font-size: 0.82rem;
}

.btn--lg {
  --btn-py: 1.1rem;
  --btn-px: 2rem;
  font-size: 0.95rem;
}

.btn:active {
  transform: scale(0.985);
}

/* A quiet text link that reveals its own underline. */
.link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--paper);
  padding-block-end: 3px;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size var(--dur) var(--ease), color var(--dur-fast) var(--ease);
}
html[dir='rtl'] .link {
  background-position: 100% 100%;
}
.link:hover {
  background-size: 100% 1px;
}
.link__arrow {
  transition: transform var(--dur-fast) var(--ease);
}
html[dir='rtl'] .link__arrow {
  transform: scaleX(-1);
}
.link:hover .link__arrow {
  transform: translateX(4px);
}
html[dir='rtl'] .link:hover .link__arrow {
  transform: scaleX(-1) translateX(4px);
}

/* ── Ambient ground ───────────────────────────────────────────────────── */

/* Fine grain. One tiny inline SVG, fixed, no blur, no repaint cost. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.032;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (pointer: coarse) {
  .grain {
    display: none;
  }
}

/* Reading progress hairline. */
.progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  inline-size: 100%;
  block-size: 2px;
  z-index: 120;
  transform: scaleX(0);
  /* Grows from the edge the page starts at: left, or right in Arabic. */
  transform-origin: left center;
  background: linear-gradient(90deg, var(--violet-deep), var(--violet), var(--violet-bright));
  will-change: transform;
}
html[dir='rtl'] .progress {
  transform-origin: right center;
  background: linear-gradient(270deg, var(--violet-deep), var(--violet), var(--violet-bright));
}
