/* ═══════════════════════════════════════════════════════════════════
   AMIRSEPEHR TIMAJCHI — INFRASTRUCTURE PORTFOLIO
   Design system · True dark · glassmorphism · data-dense
   ═══════════════════════════════════════════════════════════════════ */

:root{
  /* ── surfaces ── */
  --bg:        #000000;
  --onyx:      #050507;
  --slate:     #0a0b0e;
  --slate-2:   #0e1015;
  --surface:   rgba(255,255,255,0.022);
  --surface-2: rgba(255,255,255,0.035);

  /* ── lines ── */
  --line:      rgba(255,255,255,0.08);
  --line-soft: rgba(255,255,255,0.05);
  --line-hard: rgba(255,255,255,0.14);

  /* ── ink ── */
  --ink:       #f4f6f8;
  --ink-2:     #b6bcc6;
  --ink-3:     #6e7682;
  --ink-4:     #444b56;

  /* ── accents ── */
  --accent:     #00ff66;   /* terminal green */
  --accent-dim: #00a843;
  --blue:       #0077ff;   /* cyber blue */
  --blue-dim:   #0a5fc4;

  /* ── type ── */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace;

  /* ── motion ── */
  --ease: cubic-bezier(.16,1,.3,1);
  --ease-2: cubic-bezier(.65,.05,.36,1);

  --maxw: 1340px;
  --pad: clamp(20px, 5vw, 72px);
}

/* ── reset ── */
*,*::before,*::after{ box-sizing:border-box; margin:0; padding:0; }
html{ -webkit-text-size-adjust:100%; scroll-behavior:smooth; }
@media (prefers-reduced-motion: reduce){ html{ scroll-behavior:auto; } *{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; } }

body{
  font-family:var(--sans);
  background:var(--bg);
  color:var(--ink);
  line-height:1.5;
  letter-spacing:-0.01em;
  font-feature-settings:"ss01","cv01","cv11";
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  overflow-x:hidden;
  cursor:none;
}
@media (hover:none){ body{ cursor:auto; } }

img,svg{ display:block; max-width:100%; }
a{ color:inherit; text-decoration:none; }
ul{ list-style:none; }
em{ font-style:normal; color:var(--ink); }
::selection{ background:var(--accent); color:#000; }

.mono{ font-family:var(--mono); font-feature-settings:normal; letter-spacing:0; }
.dim{ color:var(--ink-3); }
.bracket{ color:var(--accent); }

.container{ width:100%; max-width:var(--maxw); margin-inline:auto; padding-inline:var(--pad); }

/* ── shared status dot ── */
.dot{ width:7px; height:7px; border-radius:50%; background:var(--ink-3); display:inline-block; flex:none; }
.dot--live{
  background:var(--accent);
  box-shadow:0 0 0 0 rgba(0,255,102,.6);
  animation:pulse 2.4s var(--ease) infinite;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(0,255,102,.55); }
  70%{ box-shadow:0 0 0 7px rgba(0,255,102,0); }
  100%{ box-shadow:0 0 0 0 rgba(0,255,102,0); }
}

/* ═══════════════════════ BOOT / PRELOADER ═══════════════════════ */
.boot{
  position:fixed; inset:0; z-index:9000;
  background:var(--bg);
  display:grid; place-items:center;
  transition:opacity .7s var(--ease), visibility .7s;
}
.boot.is-done{ opacity:0; visibility:hidden; pointer-events:none; }
.boot__inner{ width:min(440px,82vw); }
.boot__brand{ display:flex; align-items:center; gap:10px; font-family:var(--mono); font-size:13px; letter-spacing:.08em; margin-bottom:22px; }
.boot__mark{ color:var(--accent); font-weight:700; }
.boot__sep{ color:var(--ink-4); }
.boot__sys{ color:var(--ink-2); }
.boot__log{ font-family:var(--mono); font-size:11.5px; line-height:1.9; color:var(--ink-3); min-height:118px; margin-bottom:18px; }
.boot__log b{ color:var(--accent); font-weight:500; }
.boot__bar{ height:2px; background:var(--line); border-radius:2px; overflow:hidden; }
.boot__fill{ display:block; height:100%; width:0; background:linear-gradient(90deg,var(--accent-dim),var(--accent)); box-shadow:0 0 12px var(--accent); transition:width .25s var(--ease); }
.boot__pct{ font-family:var(--mono); font-size:11px; color:var(--ink-2); margin-top:10px; text-align:right; }
.boot__dim{ color:var(--ink-4); }

/* ═══════════════════════ CURSOR ═══════════════════════ */
.cursor{ position:fixed; top:0; left:0; z-index:9500; pointer-events:none; mix-blend-mode:difference; }
.cursor__dot{ position:fixed; width:6px; height:6px; border-radius:50%; background:#fff; transform:translate(-50%,-50%); }
.cursor__ring{
  position:fixed; width:34px; height:34px; border-radius:50%;
  border:1px solid rgba(255,255,255,.6); transform:translate(-50%,-50%);
  transition:width .28s var(--ease), height .28s var(--ease), border-color .28s, background .28s;
}
.cursor.is-link .cursor__ring{ width:54px; height:54px; background:rgba(255,255,255,.08); }
.cursor.is-cell .cursor__ring{ width:74px; height:74px; border-color:rgba(255,255,255,.35); }
.cursor.is-down .cursor__ring{ width:24px; height:24px; }
@media (hover:none){ .cursor{ display:none; } }

/* ═══════════════════════ FX OVERLAYS ═══════════════════════ */
.fx-grain{
  position:fixed; inset:0; z-index:8000; pointer-events:none; opacity:.035;
  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='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size:140px 140px;
}
.fx-vignette{ position:fixed; inset:0; z-index:7990; pointer-events:none; background:radial-gradient(120% 100% at 50% 0%, transparent 55%, rgba(0,0,0,.55) 100%); }

/* ═══════════════════════ PROGRESS RAIL ═══════════════════════ */
.progress{ position:fixed; top:0; left:0; right:0; height:2px; z-index:1200; background:transparent; }
.progress__bar{ display:block; height:100%; width:0; background:linear-gradient(90deg,var(--blue),var(--accent)); box-shadow:0 0 10px var(--accent); }

/* ═══════════════════════ NAV ═══════════════════════ */
.nav{
  position:fixed; top:0; left:0; right:0; z-index:1100;
  display:flex; align-items:center; justify-content:space-between;
  padding:18px var(--pad);
  transition:background .4s var(--ease), border-color .4s, padding .4s var(--ease);
  border-bottom:1px solid transparent;
}
.nav.is-stuck{
  background:rgba(5,5,7,.6);
  backdrop-filter:blur(18px) saturate(140%);
  -webkit-backdrop-filter:blur(18px) saturate(140%);
  border-bottom-color:var(--line);
  padding-block:13px;
}
.nav__brand{ display:flex; align-items:center; gap:12px; }
.nav__monogram{
  font-family:var(--mono); font-weight:700; font-size:14px; color:#000;
  background:var(--accent); width:30px; height:30px; display:grid; place-items:center;
  border-radius:7px; box-shadow:0 0 18px rgba(0,255,102,.35); flex:none;
}
.nav__name{ display:flex; flex-direction:column; line-height:1.1; }
.nav__name-main{ font-size:12.5px; font-weight:700; letter-spacing:.02em; }
.nav__name-sub{ font-family:var(--mono); font-size:9.5px; color:var(--ink-3); letter-spacing:.12em; margin-top:2px; }

.nav__links{ display:flex; gap:30px; }
.nav__links a{ font-size:13px; font-weight:500; color:var(--ink-2); display:flex; align-items:center; gap:7px; transition:color .25s; position:relative; }
.nav__links a::after{ content:""; position:absolute; left:0; bottom:-6px; height:1px; width:0; background:var(--accent); transition:width .3s var(--ease); }
.nav__links a:hover{ color:var(--ink); }
.nav__links a:hover::after{ width:100%; }
.nav__idx{ font-family:var(--mono); font-size:9.5px; color:var(--accent); }

.nav__right{ display:flex; align-items:center; gap:14px; }
.nav__status{ display:flex; align-items:center; gap:8px; font-family:var(--mono); font-size:10.5px; letter-spacing:.1em; color:var(--ink-2); padding:7px 12px; border:1px solid var(--line); border-radius:999px; background:var(--surface); }

/* language toggle */
.lang{ display:inline-flex; align-items:center; gap:7px; font-family:var(--mono); font-size:12px; letter-spacing:.04em; }
.lang__btn{ background:none; border:none; color:var(--ink-3); cursor:none; font:inherit; padding:4px 2px; transition:color .25s; line-height:1; }
.lang__btn:hover{ color:var(--ink); }
.lang__btn.is-active{ color:var(--accent); }
.lang__sep{ color:var(--ink-4); }
@media (hover:none){ .lang__btn{ cursor:pointer; } }

@media (max-width:900px){ .nav__links{ display:none; } }
@media (max-width:560px){ .nav__name-main{ font-size:11px; } .nav__status-txt{ display:none; } .nav__right{ gap:10px; } }

/* ═══════════════════════ HERO ═══════════════════════ */
.hero{ position:relative; min-height:100svh; display:flex; flex-direction:column; overflow:hidden; padding:clamp(118px,15vh,168px) 0 96px; }
.hero__canvas{ position:absolute; inset:0; width:100%; height:100%; z-index:0; }
.hero__scrim{ position:absolute; inset:0; z-index:1; pointer-events:none;
  background:
    radial-gradient(80% 60% at 50% 42%, transparent 40%, rgba(0,0,0,.55) 100%),
    linear-gradient(180deg, rgba(0,0,0,.45) 0%, transparent 22%, transparent 70%, rgba(0,0,0,.9) 100%);
}
/* lift in-flow hero content above the canvas/scrim without clobbering
   the absolutely-positioned .hero__top (which is also a .container) */
.hero__core, .hero__stats{ position:relative; z-index:2; }

.hero__top{ position:absolute; top:96px; left:0; right:0; display:flex; justify-content:space-between; align-items:flex-start; font-size:12px; color:var(--ink-2); z-index:2; }
.hero__loc{ display:flex; gap:8px; align-items:center; letter-spacing:.04em; }
.hero__slash{ color:var(--ink-4); }
.hero__clock{ font-size:12px; letter-spacing:.12em; color:var(--ink); padding:5px 12px; border:1px solid var(--line); border-radius:7px; background:var(--surface); backdrop-filter:blur(6px); }

.hero__core{ display:flex; flex-direction:column; align-items:flex-start; margin-block:auto; }
.hero__status{ display:inline-flex; align-items:center; gap:10px; padding:8px 15px; border:1px solid var(--line); border-radius:999px; background:rgba(255,255,255,.025); backdrop-filter:blur(8px); margin-bottom:34px; }
.hero__status-txt{ font-size:11px; letter-spacing:.08em; color:var(--ink-2); }

.hero__title{
  font-weight:800; letter-spacing:-0.04em; line-height:0.9;
  font-size:clamp(48px, 12.5vw, 184px);
  text-transform:uppercase;
}
.hero__title .line{ display:block; overflow:hidden; }
.hero__title .line > *{ display:block; }
.hero__title .line:nth-child(2){ color:transparent; -webkit-text-stroke:1.4px var(--ink-2); }

.hero__role{ display:flex; flex-wrap:wrap; align-items:center; gap:14px; margin-top:30px; }
.hero__role-tag{ font-size:12.5px; letter-spacing:.14em; color:var(--ink); border:1px solid var(--line-hard); padding:8px 14px; border-radius:7px; background:var(--surface); }
.hero__role-amp{ color:var(--accent); font-size:18px; }

.hero__lede{ max-width:560px; margin-top:30px; font-size:clamp(15px,1.7vw,18px); color:var(--ink-2); line-height:1.65; }
.hero__lede em{ color:var(--ink); border-bottom:1px solid var(--accent-dim); }

.hero__cta{ display:flex; flex-wrap:wrap; gap:14px; margin-top:40px; }

/* buttons */
.btn{ display:inline-flex; align-items:center; gap:10px; font-size:14px; font-weight:600; padding:15px 24px; border-radius:10px; border:1px solid var(--line-hard); transition:transform .3s var(--ease), background .3s, color .3s, border-color .3s, box-shadow .3s; will-change:transform; }
.btn svg{ transition:transform .3s var(--ease); }
.btn--primary{ background:var(--accent); color:#000; border-color:var(--accent); box-shadow:0 0 0 rgba(0,255,102,0); }
.btn--primary:hover{ box-shadow:0 8px 40px rgba(0,255,102,.28); }
.btn--primary:hover svg{ transform:translateX(4px); }
.btn--ghost{ background:var(--surface); color:var(--ink); }
.btn--ghost:hover{ background:var(--surface-2); border-color:var(--ink-3); }

/* hero stats */
.hero__stats{ display:grid; grid-template-columns:repeat(4,1fr); gap:1px; margin-top:44px; border:1px solid var(--line); border-radius:14px; overflow:hidden; background:var(--line-soft); position:relative; z-index:2; }
.stat{ background:rgba(5,6,9,.55); backdrop-filter:blur(6px); padding:24px 22px; display:flex; flex-direction:column; gap:6px; }
.stat__num{ font-size:clamp(28px,4vw,46px); font-weight:800; letter-spacing:-0.03em; line-height:1; display:inline; }
.stat__suf{ font-size:clamp(18px,2.4vw,26px); font-weight:700; color:var(--accent); margin-left:1px; }
.stat__lbl{ font-size:10px; letter-spacing:.12em; color:var(--ink-3); margin-top:8px; }
@media (max-width:720px){ .hero__stats{ grid-template-columns:repeat(2,1fr); } }

.hero__scroll{ position:absolute; left:50%; bottom:26px; transform:translateX(-50%); display:flex; flex-direction:column; align-items:center; gap:10px; font-size:9.5px; letter-spacing:.28em; color:var(--ink-3); z-index:2; }
.hero__scroll-line{ width:1px; height:38px; background:linear-gradient(var(--accent),transparent); animation:scrolldown 2s var(--ease) infinite; transform-origin:top; }
@keyframes scrolldown{ 0%{ transform:scaleY(0); } 40%{ transform:scaleY(1); } 100%{ transform:scaleY(0); transform-origin:bottom; } }
@media (max-width:720px){ .hero__top{ top:86px; } .hero__scroll{ display:none; } }

/* ═══════════════════════ MARQUEE ═══════════════════════ */
.marquee{ overflow:hidden; border-block:1px solid var(--line); padding-block:18px; background:linear-gradient(var(--onyx),var(--bg)); }
.marquee__track{ display:flex; align-items:center; gap:34px; white-space:nowrap; width:max-content; animation:marquee 38s linear infinite; }
.marquee__track span{ font-family:var(--mono); font-size:13px; letter-spacing:.12em; color:var(--ink-2); }
.marquee__dot{ color:var(--accent) !important; font-size:8px !important; }
@keyframes marquee{ to{ transform:translateX(-50%); } }
.marquee:hover .marquee__track{ animation-play-state:paused; }

/* ═══════════════════════ SECTION SHELL ═══════════════════════ */
.section{ position:relative; padding-block:clamp(90px,12vw,170px); }
.section__head{ max-width:760px; margin-bottom:clamp(48px,7vw,90px); }
.section__idx{ font-size:11px; letter-spacing:.2em; color:var(--accent); display:inline-block; margin-bottom:20px; padding-left:18px; position:relative; }
.section__idx::before{ content:""; position:absolute; left:0; top:50%; width:10px; height:1px; background:var(--accent); }
.section__title{ font-size:clamp(32px,5.2vw,68px); font-weight:800; letter-spacing:-0.035em; line-height:1.02; }
.section__lede{ margin-top:22px; font-size:clamp(15px,1.6vw,18px); color:var(--ink-3); max-width:620px; line-height:1.65; }

/* ═══════════════════════ BENTO STACK ═══════════════════════ */
.bento{ display:grid; grid-template-columns:repeat(4,1fr); grid-auto-rows:minmax(220px,auto); gap:14px; }
.cell{
  position:relative; overflow:hidden; border:1px solid var(--line); border-radius:18px;
  background:linear-gradient(180deg, var(--surface-2), var(--surface));
  padding:26px; display:flex; flex-direction:column;
  transition:border-color .4s var(--ease), transform .4s var(--ease), background .4s;
}
.cell--lg{ grid-column:span 2; grid-row:span 2; }
.cell--wide{ grid-column:span 2; }
.cell:hover{ border-color:var(--line-hard); transform:translateY(-4px); }
.cell__top{ display:flex; justify-content:space-between; align-items:center; margin-bottom:auto; }
.cell__id{ font-size:11px; color:var(--ink-3); letter-spacing:.1em; }
.cell__status{ display:flex; align-items:center; gap:7px; font-size:10px; letter-spacing:.12em; color:var(--ink-2); }
.cell__title{ font-size:clamp(18px,2vw,23px); font-weight:700; letter-spacing:-0.02em; line-height:1.15; margin-top:28px; }
.cell--lg .cell__title{ font-size:clamp(24px,3vw,34px); }
.cell__desc{ font-size:13.5px; color:var(--ink-3); margin-top:12px; line-height:1.55; max-width:34ch; }

/* tags reveal on hover */
.cell__tags{
  display:flex; flex-wrap:wrap; gap:7px; margin-top:18px;
  max-height:0; opacity:0; overflow:hidden;
  transition:max-height .5s var(--ease), opacity .4s var(--ease), margin-top .4s var(--ease);
}
.cell:hover .cell__tags{ max-height:200px; opacity:1; }
.cell__tags li{ font-size:10.5px; letter-spacing:.04em; color:var(--ink-2); border:1px solid var(--line); padding:5px 9px; border-radius:6px; background:rgba(0,0,0,.3); transition:border-color .3s, color .3s; }
.cell:hover .cell__tags li{ border-color:rgba(0,255,102,.22); }
.cell__tags li:hover{ color:var(--accent); border-color:var(--accent); }

.cell__glow{ position:absolute; width:280px; height:280px; border-radius:50%; pointer-events:none; left:var(--mx,50%); top:var(--my,50%); transform:translate(-50%,-50%); background:radial-gradient(circle, rgba(0,255,102,.14), transparent 65%); opacity:0; transition:opacity .4s; }
.cell:hover .cell__glow{ opacity:1; }

@media (max-width:900px){ .bento{ grid-template-columns:repeat(2,1fr); } .cell--lg{ grid-column:span 2; grid-row:span 1; } .cell--wide{ grid-column:span 2; } }
@media (max-width:560px){ .bento{ grid-template-columns:1fr; } .cell--lg,.cell--wide{ grid-column:span 1; } .cell__tags{ max-height:200px; opacity:1; } }

/* ═══════════════════════ CASE STUDIES ═══════════════════════ */
.work{ padding-bottom:clamp(60px,8vw,110px); }
.case{ border-top:1px solid var(--line); padding-block:clamp(56px,7vw,96px); }
.case__grid{ display:grid; grid-template-columns:1fr 1.05fr; gap:clamp(36px,5vw,90px); align-items:center; }
.case__grid--rev .case__meta{ order:2; }
.case__grid--rev .case__schematic{ order:1; }

.case__no{ font-size:12px; letter-spacing:.2em; color:var(--accent); }
.case__tag{ display:inline-block; margin-left:14px; font-size:10px; letter-spacing:.16em; color:var(--ink-3); border:1px solid var(--line); padding:4px 9px; border-radius:6px; vertical-align:middle; }
.case__title{ font-size:clamp(26px,3.4vw,46px); font-weight:800; letter-spacing:-0.03em; line-height:1.05; margin-top:22px; }
.case__block{ margin-top:26px; }
.case__lbl{ font-size:10.5px; letter-spacing:.16em; color:var(--accent-dim); }
.case__block p{ margin-top:9px; font-size:15px; color:var(--ink-2); line-height:1.65; max-width:46ch; }
.case__block em{ color:var(--accent); }
.case__stack{ display:flex; flex-wrap:wrap; gap:8px; margin-top:28px; }
.case__stack li{ font-size:10.5px; letter-spacing:.05em; color:var(--ink-2); border:1px solid var(--line); padding:6px 11px; border-radius:7px; background:var(--surface); }

/* schematic frame */
.schematic{ position:relative; border:1px solid var(--line); border-radius:18px; padding:30px 26px 26px; background:
  linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.008)),
  repeating-linear-gradient(0deg, transparent 0 27px, rgba(255,255,255,.018) 27px 28px),
  repeating-linear-gradient(90deg, transparent 0 27px, rgba(255,255,255,.018) 27px 28px);
  overflow:hidden;
}
.schematic::before{ content:""; position:absolute; inset:0; border-radius:18px; padding:1px; background:linear-gradient(140deg, rgba(0,255,102,.18), transparent 40%); -webkit-mask:linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite:xor; mask-composite:exclude; pointer-events:none; }
.schematic__cap{ position:relative; z-index:2; display:block; font-size:10px; letter-spacing:.18em; color:var(--ink-3); margin-bottom:14px; }
.diagram{ width:100%; height:auto; position:relative; z-index:2; }

/* diagram primitives */
.node rect{ fill:rgba(10,12,16,.85); stroke:var(--line-hard); stroke-width:1; transition:stroke .3s, fill .3s; }
.node:hover rect{ stroke:var(--accent); fill:rgba(0,255,102,.05); }
.node--accent rect{ stroke:rgba(0,255,102,.5); fill:rgba(0,255,102,.06); }
.dlabel{ fill:var(--ink); font-family:var(--mono); font-size:12px; font-weight:600; text-anchor:middle; letter-spacing:.02em; }
.dsub{ fill:var(--ink-3); font-family:var(--mono); font-size:9px; text-anchor:middle; letter-spacing:.06em; }
.dquote{ fill:var(--accent); font-family:var(--mono); font-size:11px; text-anchor:middle; letter-spacing:.06em; }
.edge{ fill:none; stroke:var(--line-hard); stroke-width:1.3; }
.edge.flow{ stroke:rgba(0,255,102,.45); stroke-dasharray:4 5; animation:dash 1s linear infinite; }
@keyframes dash{ to{ stroke-dashoffset:-18; } }
.packet{ fill:var(--accent); filter:drop-shadow(0 0 5px var(--accent)); }
.packet--hot{ fill:var(--blue); filter:drop-shadow(0 0 6px var(--blue)); }

@media (max-width:860px){ .case__grid{ grid-template-columns:1fr; } .case__grid--rev .case__meta{ order:1; } .case__grid--rev .case__schematic{ order:2; } }

/* ═══════════════════════ DOCTRINE ═══════════════════════ */
.doctrine__quote{ font-size:clamp(24px,4vw,52px); font-weight:600; letter-spacing:-0.03em; line-height:1.22; max-width:18ch; position:relative; padding-left:8px; }
.doctrine__quote em{ color:var(--accent); }
.doctrine__mark{ position:absolute; left:-34px; top:-18px; font-size:90px; color:var(--line-hard); }
.doctrine__quote cite{ display:block; margin-top:34px; font-size:12px; letter-spacing:.16em; color:var(--ink-3); font-style:normal; }

/* quote + 3D visual, side by side */
.doctrine__feature{ display:grid; grid-template-columns:1.05fr .95fr; gap:clamp(30px,5vw,72px); align-items:center; margin:clamp(22px,4vw,44px) 0 clamp(56px,8vw,96px); }
.doctrine__feature .doctrine__quote{ max-width:none; margin:0; }

/* ── 3D wireframe core (pure CSS 3D) ── */
.doctrine__viz{ position:relative; }
.viz-stage{ position:relative; width:100%; min-height:380px; display:grid; place-items:center; perspective:1000px; }
.viz-stage::before{ content:""; position:absolute; width:clamp(240px,80%,340px); aspect-ratio:1; border-radius:50%; background:radial-gradient(circle, rgba(0,255,102,.12), transparent 62%); }
.viz-orbit{ position:relative; width:200px; height:200px; transform-style:preserve-3d; }
.viz-cube{ position:absolute; inset:0; transform-style:preserve-3d; }
.viz-cube--out{ animation:vizspin 22s linear infinite; }
.viz-cube--in{ width:110px; height:110px; top:45px; left:45px; animation:vizspin-rev 16s linear infinite; }
@keyframes vizspin{ from{ transform:rotateX(-26deg) rotateY(0); } to{ transform:rotateX(-26deg) rotateY(360deg); } }
@keyframes vizspin-rev{ from{ transform:rotateX(20deg) rotateY(360deg); } to{ transform:rotateX(20deg) rotateY(0); } }

.viz-face{ position:absolute; display:block; }
.viz-cube--out .viz-face{ width:200px; height:200px; border:1px solid rgba(0,255,102,.20); background:radial-gradient(circle at 50% 50%, rgba(0,255,102,.05), transparent 72%); }
.viz-cube--out .f1{ transform:translateZ(100px); }
.viz-cube--out .f2{ transform:rotateY(180deg) translateZ(100px); }
.viz-cube--out .f3{ transform:rotateY(90deg)  translateZ(100px); }
.viz-cube--out .f4{ transform:rotateY(-90deg) translateZ(100px); }
.viz-cube--out .f5{ transform:rotateX(90deg)  translateZ(100px); }
.viz-cube--out .f6{ transform:rotateX(-90deg) translateZ(100px); }
.viz-cube--in .viz-face{ width:110px; height:110px; border:1px solid rgba(58,155,255,.40); background:rgba(58,155,255,.05); }
.viz-cube--in .f1{ transform:translateZ(55px); }
.viz-cube--in .f2{ transform:rotateY(180deg) translateZ(55px); }
.viz-cube--in .f3{ transform:rotateY(90deg)  translateZ(55px); }
.viz-cube--in .f4{ transform:rotateY(-90deg) translateZ(55px); }
.viz-cube--in .f5{ transform:rotateX(90deg)  translateZ(55px); }
.viz-cube--in .f6{ transform:rotateX(-90deg) translateZ(55px); }

.viz-core{ position:absolute; top:50%; left:50%; width:26px; height:26px; margin:-13px; border-radius:50%; background:radial-gradient(circle, #00ff66, rgba(0,255,102,0) 70%); box-shadow:0 0 28px rgba(0,255,102,.7); animation:viz-pulse 2.8s var(--ease) infinite; }
@keyframes viz-pulse{ 0%,100%{ transform:scale(.78); opacity:.8; } 50%{ transform:scale(1.18); opacity:1; } }
.viz-label{ position:absolute; bottom:4px; left:0; right:0; text-align:center; font-size:9.5px; letter-spacing:.22em; color:var(--ink-3); }

@media (max-width:860px){
  .doctrine__feature{ grid-template-columns:1fr; gap:24px; }
  .viz-stage{ min-height:300px; }
}

.doctrine__grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-top:clamp(48px,7vw,84px); }
.principle{ border:1px solid var(--line); border-radius:16px; padding:26px 22px; background:var(--surface); transition:border-color .4s var(--ease), transform .4s var(--ease), background .4s; }
.principle:hover{ border-color:var(--line-hard); transform:translateY(-4px); background:var(--surface-2); }
.principle__no{ font-size:11px; letter-spacing:.14em; color:var(--accent); }
.principle h4{ font-size:17px; font-weight:700; letter-spacing:-0.01em; margin-top:18px; line-height:1.25; }
.principle p{ font-size:13.5px; color:var(--ink-3); line-height:1.6; margin-top:12px; }
@media (max-width:900px){ .doctrine__grid{ grid-template-columns:repeat(2,1fr); } }
@media (max-width:520px){ .doctrine__grid{ grid-template-columns:1fr; } }

/* ═══════════════════════ TERMINAL CONTACT ═══════════════════════ */
.terminal{ border:1px solid var(--line); border-radius:16px; overflow:hidden; background:
  linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.006)); backdrop-filter:blur(10px); box-shadow:0 40px 120px rgba(0,0,0,.6); }
.terminal__bar{ display:flex; align-items:center; gap:14px; padding:14px 18px; border-bottom:1px solid var(--line); background:rgba(255,255,255,.02); }
.terminal__dots{ display:flex; gap:7px; }
.terminal__dots i{ width:11px; height:11px; border-radius:50%; background:var(--ink-4); }
.terminal__dots i:first-child{ background:#ff5f57; }
.terminal__dots i:nth-child(2){ background:#febc2e; }
.terminal__dots i:nth-child(3){ background:#28c840; }
.terminal__path{ font-size:11.5px; color:var(--ink-3); }
.terminal__state{ margin-left:auto; display:flex; align-items:center; gap:7px; font-size:10px; letter-spacing:.1em; color:var(--ink-2); }

.terminal__body{ padding:26px 22px; font-size:13.5px; line-height:1.95; color:var(--ink-2); min-height:190px; }
.terminal__body .line{ white-space:pre-wrap; word-break:break-word; }
.terminal__body .pr{ color:var(--accent); }
.terminal__body .cmd{ color:var(--ink); }
.terminal__body .out{ color:var(--ink-3); }
.terminal__body .ok{ color:var(--accent); }
.terminal__body .blue{ color:#3a9bff; }
.term-caret{ display:inline-block; width:8px; height:15px; background:var(--accent); vertical-align:-2px; margin-left:3px; animation:blink 1s steps(1) infinite; }
@keyframes blink{ 50%{ opacity:0; } }

.terminal__links{ display:grid; grid-template-columns:repeat(3,1fr); border-top:1px solid var(--line); }
.conn{ padding:24px 22px; border-right:1px solid var(--line); display:flex; flex-direction:column; gap:8px; transition:background .3s; position:relative; overflow:hidden; }
.conn:last-child{ border-right:none; }
.conn::after{ content:""; position:absolute; left:0; bottom:0; height:2px; width:0; background:var(--accent); transition:width .35s var(--ease); }
.conn:hover{ background:rgba(0,255,102,.05); }
.conn:hover::after{ width:100%; }
.conn__lbl{ font-size:11px; letter-spacing:.1em; color:var(--accent); }
.conn__val{ font-size:14px; color:var(--ink); letter-spacing:-0.01em; }
@media (max-width:680px){ .terminal__links{ grid-template-columns:1fr; } .conn{ border-right:none; border-bottom:1px solid var(--line); } .conn:last-child{ border-bottom:none; } }

/* ═══════════════════════ FOOTER ═══════════════════════ */
.footer{ border-top:1px solid var(--line); padding-block:40px; background:var(--onyx); }
.footer__inner{ display:flex; flex-direction:column; gap:20px; }
.footer__sig{ font-size:12px; letter-spacing:.12em; color:var(--ink-2); }
.footer__meta{ display:flex; flex-wrap:wrap; gap:18px; justify-content:space-between; font-size:10.5px; letter-spacing:.1em; color:var(--ink-4); }
.footer__hash{ color:var(--ink-3); }

/* ═══════════════════════ REVEAL ANIMATIONS ═══════════════════════ */
[data-reveal]{ opacity:0; transform:translateY(34px); transition:opacity .9s var(--ease), transform .9s var(--ease); }
[data-reveal].is-in{ opacity:1; transform:none; }
[data-reveal-line]{ transform:translateY(110%); transition:transform 1s var(--ease); }
.is-in [data-reveal-line], [data-reveal-line].is-in{ transform:none; }

[data-case] .case__meta > *{ opacity:0; transform:translateY(28px); transition:opacity .8s var(--ease), transform .8s var(--ease); }
[data-case].is-in .case__meta > *{ opacity:1; transform:none; }
[data-case].is-in .case__meta > *:nth-child(2){ transition-delay:.06s; }
[data-case].is-in .case__meta > *:nth-child(3){ transition-delay:.12s; }
[data-case].is-in .case__meta > *:nth-child(4){ transition-delay:.18s; }
[data-case].is-in .case__meta > *:nth-child(5){ transition-delay:.24s; }
[data-case] .case__schematic{ opacity:0; transform:translateY(34px) scale(.98); transition:opacity 1s var(--ease), transform 1s var(--ease); }
[data-case].is-in .case__schematic{ opacity:1; transform:none; transition-delay:.1s; }

/* stagger helper for grids */
.is-in [data-stagger]{ opacity:1 !important; transform:none !important; }

/* ═══════════════════════ PERSIAN / RTL ═══════════════════════ */
.lang-fa{
  /* Persian glyphs fall back to Vazirmatn; Latin keeps its native face */
  --sans:'Vazirmatn','Inter',-apple-system,system-ui,sans-serif;
  --mono:'JetBrains Mono','Vazirmatn',ui-monospace,monospace;
  letter-spacing:0;
}

/* Persian prose: looser leading, no negative tracking (hurts Arabic script) */
html[dir="rtl"] .hero__lede,
html[dir="rtl"] .section__lede,
html[dir="rtl"] .case__block p,
html[dir="rtl"] .principle p,
html[dir="rtl"] .cell__desc{ line-height:1.95; }
html[dir="rtl"] .hero__title,
html[dir="rtl"] .section__title,
html[dir="rtl"] .case__title,
html[dir="rtl"] .cell__title,
html[dir="rtl"] .principle h4,
html[dir="rtl"] .doctrine__quote{ letter-spacing:0; }

/* Persian display type needs more leading than the tight Latin values,
   and the pull-quote needs a wider measure so it doesn't break awkwardly */
html[dir="rtl"] .hero__title{ line-height:1.04; }
html[dir="rtl"] .hero__title .line{ padding-bottom:.04em; }
html[dir="rtl"] .section__title{ line-height:1.18; }
html[dir="rtl"] .case__title,
html[dir="rtl"] .cell__title{ line-height:1.35; }
html[dir="rtl"] .doctrine__quote{ line-height:1.6; font-weight:500; }
html[dir="rtl"] .doctrine__quote cite{ letter-spacing:0; }

/* ── Latin / code clusters where character + token ORDER must stay left-to-right.
      These keep direction:ltr but are still positioned by the RTL flow (so they
      sit on the correct, mirrored side — only their internal reading is LTR). ── */
html[dir="rtl"] .marquee,
html[dir="rtl"] .terminal,
html[dir="rtl"] .schematic,
html[dir="rtl"] .hero__loc,
html[dir="rtl"] .hero__clock,
html[dir="rtl"] .hero__status,
html[dir="rtl"] .hero__role,
html[dir="rtl"] .hero__stats,
html[dir="rtl"] .case__no,
html[dir="rtl"] .case__tag,
html[dir="rtl"] .cell__status,
html[dir="rtl"] .cell__id,
html[dir="rtl"] .nav__monogram,
html[dir="rtl"] .stat,
html[dir="rtl"] .footer__sig,
html[dir="rtl"] .footer__meta{ direction:ltr; }

/* section index: mirror the leader line + padding to the right */
html[dir="rtl"] .section__idx{ padding-left:0; padding-right:18px; }
html[dir="rtl"] .section__idx::before{ left:auto; right:0; }

/* doctrine quote mark + padding mirror to the right */
html[dir="rtl"] .doctrine__mark{ left:auto; right:-34px; }
html[dir="rtl"] .doctrine__quote{ padding-left:0; padding-right:8px; }

/* underlines grow from the right edge in RTL */
html[dir="rtl"] .nav__links a::after{ left:auto; right:0; }
html[dir="rtl"] .conn::after{ left:auto; right:0; }
