/* =========================================================
   Babak Ghadri — personal site
   Palette and type follow the portrait (mustard / navy / ink / cream, Vazirmatn)
   ========================================================= */

:root {
  --mustard: #E0AE31;       /* sampled from the portrait background */
  --mustard-deep: #CF9C25;  /* halftone dots on mustard */
  --navy: #172D65;
  --navy-dot: #22397A;
  --blue: #26579B;
  --blueprint: #0B1638;
  --blueprint-ink: #AFC3EE;
  --ink: #040516;
  --cream: #FBEFD9;
  --crimson: #961335;

  --gutter: clamp(16px, 4vw, 56px);
  --nav-h: 72px;
  --radius: clamp(22px, 2.4vw, 36px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
/* no overflow:hidden while stopped: hiding the scrollbar during the loader shifts the layout */

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: clamp(16px, .45vw + 13.5px, 19px);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--mustard); color: var(--ink); }
:focus-visible { outline: 2px solid var(--crimson); outline-offset: 4px; border-radius: 6px; }

.container { width: 100%; max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }
.ltr { direction: ltr; unicode-bidi: isolate; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .75em;
  margin: 0 0 2rem;
  font-size: .95rem;
  font-weight: 700;
}
.eyebrow::before { content: ""; width: 2.6rem; height: 1.5px; background: currentColor; opacity: .6; }
.eyebrow b { font-weight: 800; color: var(--mustard); }

/* masked lines: the inner span rises out of an overflow:hidden box */
.mask { display: inline-block; overflow: hidden; padding: .24em .04em .16em; margin: -.22em 0 -.16em; vertical-align: top; }
.mask > span { display: inline-block; }

/* ---------- loader ---------- */
.loader { position: fixed; inset: 0; z-index: 100; display: none; background: var(--navy); color: var(--cream); overflow: hidden; }
.js .loader { display: grid; place-items: center; }
.loader__dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--navy-dot) 32%, transparent 34%);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0, transparent 65%);
          mask-image: radial-gradient(circle at 50% 50%, #000 0, transparent 65%);
}
.loader__name { position: relative; overflow: hidden; padding: .05em .1em .2em; font-size: clamp(2.6rem, 8vw, 7rem); font-weight: 900; line-height: 1.3; }
.loader__name span { display: block; }
.loader__count {
  position: absolute; left: var(--gutter); bottom: var(--gutter);
  overflow: hidden; padding-top: .1em;
  font-size: clamp(3rem, 7vw, 6.5rem); font-weight: 900; line-height: 1.1; color: var(--mustard);
}
.loader__num { display: block; }

/* ---------- chrome: progress, cursor, nav ---------- */
.progress {
  position: fixed; inset: 0 0 auto; z-index: 70; height: 3px;
  background: var(--crimson);
  transform: scaleX(0); transform-origin: right;
}

.cursor {
  position: fixed; top: 0; left: 0; z-index: 90;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cream); mix-blend-mode: difference;
  pointer-events: none; opacity: 0;
  transition: width .45s var(--ease), height .45s var(--ease), opacity .3s;
}
.cursor.is-on { opacity: 1; }
.cursor.is-hover { width: 64px; height: 64px; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

.nav {
  position: fixed; inset: 0 0 auto; z-index: 60; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding-inline: var(--gutter);
  color: var(--cream); mix-blend-mode: difference;
  pointer-events: none;
}
.nav a { pointer-events: auto; }
.nav__logo { display: flex; align-items: center; gap: .55em; font-size: 1.12rem; font-weight: 900; }
.nav__logo i { width: .5em; height: .5em; border-radius: 50%; background: currentColor; }
.nav__links { display: flex; gap: clamp(1.1rem, 2.6vw, 2.6rem); font-size: .98rem; font-weight: 700; }
.nav__links a { position: relative; padding-block: .2em; }
.nav__links a::after {
  content: ""; position: absolute; inset: auto 0 0; height: 1.5px; background: currentColor;
  transform: scaleX(0); transform-origin: left; transition: transform .55s var(--ease);
}
.nav__links a:hover::after { transform: scaleX(1); transform-origin: right; }

/* ---------- hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  height: 100vh; min-height: 540px;  /* 100vh, not svh: svh leaves a black band under the hero on mobile browsers */
  background: var(--mustard); color: var(--navy);
}
.hero__dots {
  position: absolute; inset: 0; z-index: 0;
  background-image: radial-gradient(var(--mustard-deep) 30%, transparent 33%);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(circle at 26% 56%, #000 0, rgba(0,0,0,.55) 20%, transparent 44%);
          mask-image: radial-gradient(circle at 26% 56%, #000 0, rgba(0,0,0,.55) 20%, transparent 44%);
}
.hero__name {
  position: absolute; z-index: 1; top: 50%; right: var(--gutter);
  margin: 0; transform: translateY(-62%);
  font-size: clamp(3.9rem, 13.2vw, 14.5rem); font-weight: 900; line-height: .9;
  color: var(--navy);
}
/* tall top padding (cancelled by the negative margin) so the dots above ق etc. aren't clipped */
.hero__name .line { display: block; overflow: hidden; padding: .32em .03em .22em; margin: -.26em 0 -.24em; }
.hero__name .line > span { display: block; }
.hero__name .line + .line { margin-right: 1.1em; }

.hero__role {
  position: absolute; z-index: 3; top: calc(var(--nav-h) + 3vh); right: var(--gutter);
  margin: 0; font-size: .95rem; font-weight: 800;
}

.hero__portrait {
  position: absolute; z-index: 2; left: 0; bottom: 0;
  width: min(100svh, 62vw); aspect-ratio: 1;
  transform-origin: 70.16% 50.94%;   /* centre of the near (dark) lens */
  will-change: transform; pointer-events: none;
}
.hero__portrait img { width: 100%; height: 100%; }

.hero__foot {
  position: absolute; z-index: 3; right: var(--gutter); bottom: clamp(24px, 6vh, 64px);
  display: flex; align-items: center; gap: clamp(1.2rem, 2.4vw, 2.4rem);
}
.hero__intro { order: 2; max-width: 23ch; margin: 0; font-size: clamp(1rem, 1.15vw, 1.22rem); font-weight: 600; line-height: 1.85; }

.badge { position: relative; flex: none; display: grid; place-items: center; width: clamp(96px, 8.6vw, 128px); aspect-ratio: 1; color: var(--navy); }
.badge > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; animation: spin 18s linear infinite; }
.badge text { direction: ltr; font-family: "Vazirmatn", sans-serif; font-size: 13px; font-weight: 800; fill: currentColor; }
.badge__arrow {
  display: grid; place-items: center; width: 40%; aspect-ratio: 1; border-radius: 50%;
  background: var(--navy); color: var(--mustard);
  transition: transform .6s var(--ease);
}
.badge__arrow svg { width: 46%; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; animation: nudge 1.8s var(--ease) infinite; }
.badge:hover .badge__arrow { transform: scale(1.15); }

.hero__ink { position: absolute; inset: 0; z-index: 5; background: var(--ink); opacity: 0; pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes nudge { 0%, 100% { transform: translateY(-12%); } 50% { transform: translateY(14%); } }

/* ---------- manifesto ---------- */
.manifesto { position: relative; padding: clamp(80px, 14vh, 160px) 0 clamp(90px, 16vh, 180px); }
.manifesto__text { margin: 0; max-width: 21em; font-size: clamp(1.8rem, 4.3vw, 4.4rem); font-weight: 800; line-height: 1.55; }
.manifesto__text em { font-style: normal; color: var(--mustard); }

/* ---------- services ---------- */
.services { position: relative; padding: 4vh 0 12vh; }
.services__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem 3rem; margin-bottom: clamp(56px, 10vh, 120px); }
.services__title { margin: 0; font-size: clamp(3.4rem, 10vw, 10.5rem); font-weight: 900; line-height: 1.02; }
.services__title .accent { color: var(--mustard); }
.services__lead { max-width: 27ch; margin: 0 0 1.2em; font-size: clamp(1rem, 1.2vw, 1.2rem); opacity: .72; }

.cards { position: relative; }
.card {
  --bg: var(--cream); --fg: var(--ink); --line: var(--navy); --accent: var(--blue);
  position: sticky; top: calc(var(--nav-h) + 8px + var(--i) * 14px);
  height: min(calc(100svh - var(--nav-h) - 84px), 740px); min-height: 460px;
  margin-bottom: 7vh;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg); color: var(--fg);
  transform-origin: 50% 0;
}
.card:last-child { margin-bottom: 0; }
.card--cream   { --bg: var(--cream);   --fg: var(--ink);   --line: var(--navy);  --accent: var(--blue); }
.card--navy    { --bg: var(--navy);    --fg: var(--cream); --line: var(--cream); --accent: var(--mustard); }
.card--mustard { --bg: var(--mustard); --fg: var(--ink);   --line: var(--ink);   --accent: var(--navy); }
.card--blue    { --bg: var(--blue);    --fg: var(--cream); --line: var(--cream); --accent: var(--mustard); }
.card--print   {
  --bg: var(--blueprint); --fg: var(--cream); --line: var(--blueprint-ink); --accent: var(--mustard);
  background-image:
    linear-gradient(rgba(175,195,238,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(175,195,238,.08) 1px, transparent 1px);
  background-size: 32px 32px;
  box-shadow: inset 0 0 0 1px rgba(175,195,238,.2);
}
.card__shade { position: absolute; inset: 0; z-index: 2; background: var(--ink); opacity: 0; pointer-events: none; }

.card__inner {
  height: 100%;
  display: grid; grid-template-columns: 1.1fr .9fr; grid-template-rows: auto 1fr;
  gap: 0 clamp(24px, 4vw, 72px);
  padding: clamp(22px, 3.2vw, 52px);
}
.card__top { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-weight: 800; }
.card__num { font-size: clamp(1.1rem, 1.4vw, 1.4rem); }
.card__num::after { content: ""; display: inline-block; width: .5em; height: .5em; margin-right: .5em; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.card__en { direction: ltr; font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; opacity: .7; }
.card__text { align-self: end; padding-bottom: .4rem; }
.card__title { margin: 0 0 .25em; font-size: clamp(2.6rem, 6.2vw, 6.6rem); font-weight: 900; line-height: 1.12; }
.card__desc { max-width: 30ch; margin: 0 0 1.5em; font-size: clamp(1rem, 1.25vw, 1.28rem); line-height: 1.85; opacity: .85; }
.card__tags { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.card__tags li {
  direction: ltr; padding: .42em 1.05em; border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--fg) 40%, transparent);
  font-size: .9rem; font-weight: 700; line-height: 1.5;
}
.card__art { align-self: center; justify-self: center; width: min(100%, 50svh); aspect-ratio: 1; }

/* line art */
.art { width: 100%; height: 100%; overflow: visible; fill: none; stroke: var(--line); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.art .draw { stroke-dasharray: 1; }
.art__halo { stroke-dasharray: 2 12; opacity: .35; transform-origin: 200px 200px; animation: spin 50s linear infinite; }
.art__pkts circle, .art__pkt { fill: var(--accent); stroke: none; }
.art__nodes path { fill: var(--bg); }
.art__core { fill: var(--line); stroke: none; }
.art__ports { stroke: var(--bg); stroke-width: 4; }
.art__leds circle { fill: var(--accent); stroke: none; animation: blink 1.6s steps(2, jump-none) infinite; animation-delay: calc(var(--d) * -.5s); }
.art__vms rect { fill: var(--accent); fill-opacity: 0; stroke-width: 2.5; animation: vm 4.2s ease-in-out infinite; animation-delay: calc(var(--d) * .32s); }
.art__ring { stroke: var(--accent); stroke-width: 2; transform-origin: 200px 200px; animation: ring 2.8s var(--ease) infinite; }
.art__ring--late { animation-delay: 1.4s; }
.art__bars rect { fill: var(--line); stroke: none; transform-box: fill-box; transform-origin: center; animation: eq 1.1s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -.17s); }
.art__glyph { stroke: var(--accent); stroke-width: 3.5; }
.art__spark { fill: var(--accent); stroke: none; }
.art__spin { transform-origin: 200px 200px; animation: spark 7s ease-in-out infinite; }
.art__twinkle { transform-origin: 326px 92px; animation: twinkle 2.4s ease-in-out infinite; }
.art__code { direction: ltr; fill: var(--line); stroke: none; font: 900 30px "Vazirmatn", sans-serif; opacity: .7; }

@keyframes blink { 50% { opacity: .2; } }
@keyframes vm { 0%, 12% { fill-opacity: 0; } 30%, 70% { fill-opacity: 1; } 88%, 100% { fill-opacity: 0; } }
@keyframes ring { 0% { transform: scale(.85); opacity: 0; } 25% { opacity: .9; } 100% { transform: scale(1.38); opacity: 0; } }
@keyframes eq { from { transform: scaleY(.28); } to { transform: scaleY(1); } }
@keyframes spark { 0%, 100% { transform: rotate(0) scale(.92); } 50% { transform: rotate(90deg) scale(1.06); } }
@keyframes twinkle { 0%, 100% { transform: scale(.4); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }

/* ---------- toolbox marquee ---------- */
.stack { position: relative; overflow: clip; padding: clamp(120px, 22vh, 240px) 0 clamp(110px, 18vh, 200px); color: var(--ink); }
.stack__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem 3rem; margin-bottom: clamp(48px, 9vh, 110px); }
.stack__head .eyebrow b { color: var(--crimson); }
.stack__title { margin: 0; font-size: clamp(2.3rem, 5.6vw, 5.6rem); font-weight: 900; line-height: 1.18; }
.stack__note { max-width: 24ch; margin: 0 0 .8em; opacity: .6; }

.marquee { display: flex; overflow: hidden; direction: ltr; font-size: clamp(3.4rem, 9.6vw, 10.5rem); font-weight: 900; line-height: 1.22; letter-spacing: -.02em; }
.marquee--b { color: var(--navy); }
.marquee__track { display: flex; flex: none; will-change: transform; }
.marquee__group { display: flex; flex: none; align-items: center; }
.marquee__group > span { flex: none; padding-inline: .3em; }
.marquee .o { color: var(--blue); }
.marquee--b .o { color: var(--crimson); }
.star {
  flex: none; width: .36em; height: .36em; background: var(--mustard-deep);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}

/* ---------- contact ---------- */
.contact { position: relative; display: flex; flex-direction: column; min-height: 100svh; color: var(--ink); }
.contact__bg { position: absolute; inset: 0; z-index: 0; background: var(--mustard); }
.contact__bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(var(--mustard-deep) 30%, transparent 33%);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0, transparent 46%);
          mask-image: radial-gradient(circle at 50% 30%, #000 0, transparent 46%);
}
.contact__inner {
  position: relative; z-index: 1; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(120px, 18vh, 200px) var(--gutter) clamp(64px, 10vh, 120px);
  text-align: center;
}
.contact__avatar {
  width: clamp(112px, 11vw, 164px); aspect-ratio: 1; margin-bottom: 2.2rem;
  border-radius: 50%;
  /* portrait as a background: some mobile browsers (Samsung) don't clip a transformed <img> to the radius */
  background: var(--navy) url("../assets/portrait-cut.webp?v=11") 40% 100% / 90% no-repeat;
  box-shadow: 0 0 0 6px var(--mustard), 0 0 0 7.5px var(--ink);
}
.contact .eyebrow b { color: var(--crimson); }
.contact__title { margin: 0 0 .3em; font-size: clamp(3rem, 9vw, 9.5rem); font-weight: 900; line-height: 1.1; }
.contact__lead { max-width: 34ch; margin: 0 0 2.4rem; font-size: clamp(1.02rem, 1.3vw, 1.3rem); font-weight: 500; }
.contact__links { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; }

.btn {
  display: inline-flex; align-items: center; gap: .7em;
  padding: .95em 1.7em; border-radius: 999px;
  background: var(--ink); color: var(--cream);
  font-size: 1.02rem; font-weight: 800; line-height: 1.4;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
.btn .ltr { font-weight: 600; opacity: .7; }
.btn:hover { background: var(--navy); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--cream); }

.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 22px var(--gutter);
  border-top: 1.5px solid rgba(4, 5, 22, .16);
  font-size: .92rem; font-weight: 600;
}
.foot__top:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .nav__links { gap: 1.1rem; font-size: .92rem; }
  .manifesto { padding-top: 48px; }

  .hero__role { top: calc(var(--nav-h) + 1svh); font-size: .88rem; }
  .hero__name { top: calc(var(--nav-h) + 1svh + 2.6rem); transform: none; font-size: min(22vw, 12.4svh); }
  .hero__portrait { width: min(112vw, 62svh); }
  .hero__intro { display: none; }
  /* the hero is 100vh (large viewport); lift the badge by (100vh - 100svh) so the browser's
     bottom toolbar (e.g. Samsung Internet) never covers it */
  .hero__foot { bottom: 28px; bottom: calc(100vh - 100svh + 28px); right: 12px; }

  /* contact buttons stack full-width: label on the right, number / id / address on the left */
  .contact__links { flex-direction: column; align-items: stretch; width: min(100%, 360px); }
  .contact__links .btn { justify-content: space-between; }
  .badge { width: 84px; }

  .card { height: calc(100svh - var(--nav-h) - 72px); min-height: 0; max-height: 720px; margin-bottom: 5vh; }
  .card__inner { display: flex; flex-direction: column; }
  .card__art { flex: 1 1 auto; min-height: 0; width: 100%; aspect-ratio: auto; padding-block: 3svh; }
  .card__art .art { height: 100%; width: auto; margin-inline: auto; }
  .card__text { padding-bottom: 0; }
  .card__desc { margin-bottom: 1.1em; }
  .card__tags li { font-size: .8rem; }
}

@media (max-width: 860px) and (max-height: 700px) {
  .card__desc { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .badge > svg, .badge__arrow svg, .art *, .art__spin, .art__twinkle { animation: none !important; }
}
