/* ============================================================================
   Obsidian & Glass Terminal — portfolio stylesheet
   Vanilla CSS. No build step, no preprocessor.
   Order: tokens → reset → primitives → layout → sections → responsive
   ========================================================================== */

/* ---------------------------------- tokens -------------------------------- */
:root {
  /* surfaces */
  --bg:            #0D1117;
  --surface-1:     #161B22;
  --surface-2:     #21262D;
  --surface-glass: rgba(22, 27, 34, 0.62);

  /* lines */
  --border:        #30363D;
  --border-soft:   rgba(48, 54, 61, 0.6);
  --border-glow:   rgba(56, 189, 248, 0.45);

  /* accents */
  --emerald:       #2EA043;
  --emerald-soft:  rgba(46, 160, 67, 0.16);
  --cyan:          #38BDF8;
  --cyan-soft:     rgba(56, 189, 248, 0.14);
  --gold:          #E5C07B;
  --gold-soft:     rgba(229, 192, 123, 0.14);
  --danger:        #F85149;

  /* text */
  --text:          #F0F6FC;
  --text-muted:    #8B949E;
  --text-dim:      #6E7681;

  /* type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  /* rhythm */
  --shell:   1200px;
  --gap:     clamp(1rem, 2.2vw, 1.5rem);
  --radius:  16px;
  --radius-sm: 10px;
  --radius-lg: 24px;

  /* motion */
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --dur:       .45s;
  --dur-fast:  .2s;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 18px 40px -20px rgba(0,0,0,.85);
  --shadow-glow: 0 0 0 1px rgba(56,189,248,.25), 0 22px 60px -28px rgba(56,189,248,.5);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(1rem, .96rem + .18vw, 1.06rem);
  line-height: 1.65;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient field behind everything — cheap, GPU-free, no repaint cost */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70ch 50ch at 12% -10%, rgba(46,160,67,.10), transparent 60%),
    radial-gradient(60ch 45ch at 92% 8%,  rgba(56,189,248,.10), transparent 62%),
    radial-gradient(80ch 60ch at 50% 108%, rgba(229,192,123,.06), transparent 65%);
}

h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.03em; font-weight: 700; }
p  { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

a {
  color: var(--cyan);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: #7DD3FC; }

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

.mono { font-family: var(--font-mono); font-size: .78em; letter-spacing: .02em; }

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

.skip-link {
  position: absolute; left: 50%; top: 0;
  transform: translate(-50%, -140%);
  z-index: 200;
  padding: .7rem 1.2rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text);
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

.anchor-target { position: absolute; top: 0; }

.shell {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
}

.icon {
  width: 1.05em; height: 1.05em;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

/* -------------------------------- primitives ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .78rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-align: center;
  position: relative;
  isolation: isolate;
  transition: transform var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-2px); border-color: #484F58; }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(180deg, #2EA043, #238636);
  border-color: rgba(46,160,67,.7);
  color: #fff;
  box-shadow: 0 12px 30px -14px rgba(46,160,67,.9);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #35B850, #2A9A42);
  border-color: #3FB950;
  box-shadow: 0 18px 40px -16px rgba(46,160,67,1);
  color: #fff;
}

.btn-ghost {
  background: rgba(33, 38, 45, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn-ghost:hover {
  border-color: var(--border-glow);
  box-shadow: 0 0 0 1px rgba(56,189,248,.18), 0 16px 36px -22px rgba(56,189,248,.7);
  color: var(--text);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-quiet:hover { color: var(--text); border-color: var(--border); }

.btn-sm { padding: .5rem .85rem; font-size: .85rem; }
.btn-block { display: flex; justify-content: center; width: 100%; }

.tag {
  display: inline-block;
  padding: .3rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(13,17,23,.6);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .74rem;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.tag:hover {
  color: var(--cyan);
  border-color: var(--border-glow);
  background: var(--cyan-soft);
  transform: translateY(-2px);
}
.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; }

.grad-text {
  background: linear-gradient(100deg, var(--cyan) 0%, #7EE787 45%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.inline-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-weight: 600;
  font-size: .9rem;
  margin-top: .4rem;
}
.inline-link span { transition: transform var(--dur-fast) var(--ease); }
.inline-link:hover span { transform: translateX(4px); }

/* Shared card chrome: glass surface + a glow that follows the cursor */
.bento-card, .project-card, .service-card, .cap-card, .terminal {
  position: relative;
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.bento-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    rgba(56,189,248,.16),
    transparent 65%
  );
}
.bento-card:hover .bento-glow,
.project-card:hover .bento-glow,
.service-card:hover .bento-glow { opacity: 1; }

.bento-card:hover, .project-card:hover, .service-card:hover {
  border-color: var(--border-glow);
}

/* JS tilt target */
.tilt {
  transform-style: preserve-3d;
  transition: transform var(--dur) var(--ease), border-color var(--dur-fast) var(--ease);
  will-change: transform;
}

/* ------------------------------ reveal system ----------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* --------------------------------- header --------------------------------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  background: rgba(13,17,23,.55);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.site-header.is-stuck {
  background: rgba(13,17,23,.86);
  border-bottom-color: var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 68px;
}

.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); }
.brand-mark { display: grid; place-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .95rem; letter-spacing: -0.02em; }
.brand-sub { color: var(--text-dim); }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: .25rem; }
.site-nav a {
  display: block;
  padding: .45rem .7rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a.is-active { color: var(--text); }
.site-nav a.is-active::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--emerald), var(--cyan));
}

.header-actions { display: flex; align-items: center; gap: .7rem; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px; height: 38px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.nav-toggle span {
  display: block; height: 2px; border-radius: 2px;
  background: var(--text);
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.scroll-progress {
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--emerald), var(--cyan), var(--gold));
  transition: width .1s linear;
}

/* ---------------------------------- hero ---------------------------------- */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 100svh;
  padding: 8rem 0 5rem;
  isolation: isolate;
  overflow: hidden;
}

.hero-canvas-wrap { position: absolute; inset: 0; z-index: -2; }
#hero-canvas { width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s var(--ease); }
#hero-canvas.is-ready { opacity: 1; }

/* Static stand-in shown until (or instead of) the WebGL scene */
.hero-canvas-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(38ch 38ch at 72% 42%, rgba(56,189,248,.20), transparent 62%),
    radial-gradient(30ch 30ch at 60% 60%, rgba(46,160,67,.16), transparent 66%);
  filter: blur(8px);
  transition: opacity 1s var(--ease);
}
.hero-canvas-wrap.is-live .hero-canvas-fallback { opacity: 0; }

[dir="rtl"] .hero-canvas-fallback {
  background:
    radial-gradient(38ch 38ch at 28% 42%, rgba(56,189,248,.20), transparent 62%),
    radial-gradient(30ch 30ch at 40% 60%, rgba(46,160,67,.16), transparent 66%);
}

.hero-veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(13,17,23,.94) 0%, rgba(13,17,23,.72) 46%, rgba(13,17,23,.30) 100%);
}

/* This element is the .shell too, so it must keep the shell's gutter and
   centring. The 62ch measure belongs on the children, which then stack flush
   left inside it — capping the shell itself would centre the whole column. */
.hero-inner { position: relative; text-align: left; }
/* 40rem, not ch: `ch` resolves against each child's own font size, so the
   display-size h1 would get an enormous cap and never wrap. */
.hero-inner > * { max-width: 40rem; }

.eyebrow {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: .55rem;
  padding: .38rem .8rem;
  margin-bottom: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(22,27,34,.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
}
.eyebrow-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.hero-title {
  font-size: clamp(2.4rem, 1.4rem + 4.4vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  margin-bottom: 1.35rem;
  text-wrap: balance;
}

.hero-sub {
  font-size: clamp(1.02rem, .98rem + .35vw, 1.22rem);
  color: var(--text-muted);
  margin-bottom: 2.1rem;
  text-wrap: pretty;
}

.hero-cta { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: 3rem; }

.hero-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem 1.4rem;
  margin: 0;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border-soft);
  text-align: left;
}
.hero-fact dt { color: var(--text-dim); margin-bottom: .25rem; }
.hero-fact dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 1.1rem + .8vw, 1.7rem);
  font-weight: 700;
  color: var(--text);
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  color: var(--text-dim);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.scroll-hint span { display: inline-block; animation: bob 2.2s var(--ease) infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* -------------------------------- sections -------------------------------- */
.section { padding: clamp(2.5rem, 3vw, 7.5rem) 0; position: relative; }
.section-alt { background: linear-gradient(180deg, transparent, rgba(22,27,34,.45) 12%, rgba(22,27,34,.45) 88%, transparent); }

.section-head { max-width: 60ch; margin-bottom: clamp(2.2rem, 4vw, 3.4rem); }
.section-index {
  display: block;
  color: var(--emerald);
  text-transform: uppercase;
  letter-spacing: .16em;
  margin-bottom: .8rem;
}
.section-title {
  font-size: clamp(1.85rem, 1.35rem + 2.1vw, 2.9rem);
  margin-bottom: .85rem;
  text-wrap: balance;
}
.section-lede { color: var(--text-muted); font-size: 1.05rem; text-wrap: pretty; }

/* ------------------------------- bento grid ------------------------------- */
.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}
.bento-card { padding: 1.5rem; display: flex; flex-direction: column; }
.bento .span-2 { grid-column: span 2; }
.bento .span-3 { grid-column: span 4; }

.bento-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .16em;
  margin-bottom: .6rem;
}
.bento-metric {
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 1.6rem + 2.4vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: .7rem;
  background: linear-gradient(180deg, #fff, #9FB0C0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bento-metric .unit { font-size: .42em; color: var(--text-muted); margin-left: .25rem; -webkit-text-fill-color: var(--text-muted); }
.bento-copy { color: var(--text-muted); font-size: .93rem; }
.bento-copy-tight { max-width: 52ch; }


.bento-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

/* heatmap */
.heatmap-legend {
  display: flex; align-items: center; gap: .3rem;
  color: var(--text-dim);
}
.heatmap-legend i { width: 11px; height: 11px; border-radius: 3px; display: block; }

.heatmap-scroll { overflow-x: auto; padding-bottom: .5rem; }
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  min-width: max-content;
}
.hm-cell {
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.hm-cell:hover, .hm-cell:focus-visible {
  transform: scale(1.45);
  box-shadow: 0 0 0 1px var(--cyan);
  z-index: 1;
}

/* Shared level palette for cells and legend swatches */
.hm-cell[data-level="0"], .heatmap-legend i[data-level="0"] { background: #1B2028; }
.hm-cell[data-level="1"], .heatmap-legend i[data-level="1"] { background: rgba(46,160,67,.30); }
.hm-cell[data-level="2"], .heatmap-legend i[data-level="2"] { background: rgba(46,160,67,.55); }
.hm-cell[data-level="3"], .heatmap-legend i[data-level="3"] { background: rgba(46,160,67,.82); }
.hm-cell[data-level="4"], .heatmap-legend i[data-level="4"] { background: #3FB950; box-shadow: 0 0 10px rgba(63,185,80,.55); }

.heatmap-readout { color: var(--text-dim); margin-top: .9rem; min-height: 1.4em; }

/* ---------------------------- why work together --------------------------- */
.why-block {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--border-soft);
}
.why-title { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.7rem); margin-bottom: 1.4rem; }

.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--gap);
}
.why-item {
  position: relative;
  padding-left: 2.6rem;
}
.why-num {
  position: absolute;
  left: 0; top: .1rem;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--cyan);
  font-size: .7rem;
}
.why-item h4 { font-size: 1rem; margin-bottom: .4rem; }
.why-item p { color: var(--text-muted); font-size: .91rem; }

/* -------------------------------- projects -------------------------------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--gap);
}
.project-card { display: flex; flex-direction: column; }

.project-media {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: zoom-in;
}
.project-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-1);
}
.thumb-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(48,54,61,.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(48,54,61,.55) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(70% 70% at 50% 50%, #000, transparent);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000, transparent);
}
.thumb-orb {
  position: absolute;
  left: 50%; top: 50%;
  width: 55%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  filter: blur(6px);
  transition: transform .6s var(--ease);
}
.thumb-emerald .thumb-orb { background: radial-gradient(circle at 35% 32%, rgba(126,231,135,.9), rgba(46,160,67,.15) 60%, transparent 72%); }
.thumb-cyan    .thumb-orb { background: radial-gradient(circle at 35% 32%, rgba(125,211,252,.9), rgba(56,189,248,.15) 60%, transparent 72%); }
.thumb-gold    .thumb-orb { background: radial-gradient(circle at 35% 32%, rgba(245,222,179,.9), rgba(229,192,123,.15) 60%, transparent 72%); }

.project-card:hover .thumb-orb { transform: translate(-50%, -50%) scale(1.12); }

.project-zoom {
  position: absolute;
  right: .75rem; bottom: .75rem;
  padding: .25rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13,17,23,.75);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.project-card:hover .project-zoom,
.project-media:focus-visible .project-zoom { opacity: 1; transform: none; }

.project-body { padding: 1.4rem; display: flex; flex-direction: column; gap: .9rem; flex: 1; }
.project-kicker { color: var(--gold); text-transform: uppercase; letter-spacing: .14em; }
.project-title { font-size: 1.3rem; }

.project-facts { margin: 0; display: grid; gap: .85rem; }
.project-facts dt {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: .25rem;
}
.project-facts dd { margin: 0; color: var(--text-muted); font-size: .93rem; }
.project-facts .result { color: var(--text); }
.project-facts .result strong { color: #7EE787; font-weight: 700; }

.project-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; padding-top: .4rem; }

/* Real screenshots share the thumbnail's frame. */
.project-shot {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top center;
  background: var(--surface-1);
  transition: transform .6s var(--ease);
}
.project-card:hover .project-shot { transform: scale(1.03); }

/* Cards past the first three stay out of the layout until asked for. */
.project-extra[hidden] { display: none; }

/* Staggered arrival — the "already scrolled past" feel, without the scrolling. */
@keyframes project-arrive {
  from { opacity: 0; transform: translateY(34px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
/* `both` fill holds the from-state during the stagger delay, so a card cannot
   flash in at full opacity before its turn — and cannot strand at 0 either. */
.project-extra.is-arriving {
  animation: project-arrive .62s var(--ease) both;
  animation-delay: var(--arrive-delay, 0ms);
}

.project-reveal {
  display: flex;
  justify-content: center;
  margin-top: clamp(1.5rem, 3vw, 2.2rem);
}
.project-reveal[hidden] { display: none; }

/* -------------------------------- services -------------------------------- */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--gap);
}
.service-card { padding: 1.6rem; display: flex; flex-direction: column; gap: .85rem; }
.service-card-featured { border-color: rgba(56,189,248,.35); }

.service-flag {
  position: absolute;
  top: 0; right: 1.2rem;
  padding: .28rem .65rem;
  border: 1px solid rgba(56,189,248,.4);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--cyan-soft);
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.service-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--cyan);
}
.service-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.service-title { font-size: 1.18rem; }
.service-copy { color: var(--text-muted); font-size: .95rem; }

.service-list { display: grid; gap: .5rem; margin: .3rem 0; }
.service-list li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--text-muted);
  font-size: .92rem;
}
.service-list li::before {
  content: "";
  position: absolute;
  left: 0; top: .55em;
  width: 9px; height: 9px;
  border-radius: 3px;
  background: var(--emerald-soft);
  border: 1px solid var(--emerald);
}

/* Headline price — the one number a client is scanning for. */
.service-price {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin-top: auto;
  padding: .8rem 1rem;
  border: 1px solid rgba(229, 192, 123, .35);
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
}
.price-amount {
  font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--gold);
}
.price-unit { color: var(--text-muted); font-size: .9rem; }

.service-model {
  color: var(--gold);
  padding: .4rem 0;
  border-top: 1px dashed var(--border);
  margin-top: auto;
}
/* When a price block is present it already owns the push-to-bottom. */
.service-price + .service-model { margin-top: 0; }

.engagement-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  margin-top: var(--gap);
  padding: 1.3rem 1.6rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(22,27,34,.4);
}
.engagement-note p { color: var(--text-muted); max-width: 62ch; }
.engagement-note strong { color: var(--text); }

/* ------------------------------ capabilities ------------------------------ */
/* Four capability cards sit as a clean 2×2 rather than an orphaned 3+1 row. */
.cap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}
.cap-card { padding: 1.6rem; display: flex; flex-direction: column; gap: .9rem; }
.cap-title { display: flex; align-items: baseline; gap: .6rem; font-size: 1.15rem; }
.cap-num { color: var(--cyan); }
.cap-copy { color: var(--text-muted); font-size: .95rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: auto; }

/* -------------------------------- timeline -------------------------------- */
.timeline { position: relative; padding-left: 2.2rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: .4rem; bottom: .4rem;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}
/* Progress line height is driven by JS scroll position */
.timeline::after {
  content: "";
  position: absolute;
  left: 7px; top: .4rem;
  width: 2px;
  height: var(--timeline-progress, 0%);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--emerald), var(--cyan));
  box-shadow: 0 0 14px rgba(56,189,248,.6);
  transition: height .15s linear;
}

.timeline-item { position: relative; padding-bottom: 2.4rem; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -2.2rem; top: .45rem;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.timeline-item.is-visible .timeline-dot {
  border-color: var(--emerald);
  box-shadow: 0 0 0 4px rgba(46,160,67,.14), 0 0 16px rgba(46,160,67,.5);
}

.timeline-date { color: var(--cyan); letter-spacing: .1em; margin-bottom: .35rem; }
.timeline-role { font-size: 1.12rem; margin-bottom: .5rem; }
.timeline-org { color: var(--text-muted); font-weight: 500; font-size: .92rem; }
.timeline-copy { color: var(--text-muted); font-size: .95rem; max-width: 66ch; }
.timeline-copy + .timeline-copy { margin-top: .7rem; }
.timeline-copy strong { color: var(--text); font-weight: 600; }

/* ------------------------------- direction -------------------------------- */
.direction {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: clamp(2rem, 4vw, 3rem);
  padding: clamp(1.5rem, 3.5vw, 2.4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(56,189,248,.06), transparent 55%),
    var(--surface-glass);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}
.direction-title { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.7rem); margin-bottom: .9rem; }
.direction-copy p { color: var(--text-muted); font-size: .97rem; max-width: 60ch; }
.direction-copy p + p { margin-top: .8rem; }

.direction-roles {
  display: grid;
  gap: .55rem;
  align-content: start;
}
.direction-role {
  display: grid;
  gap: .2rem;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--cyan);
  border-radius: var(--radius-sm);
  background: rgba(13,17,23,.5);
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.direction-role:hover { border-color: var(--border-glow); border-left-color: var(--emerald); transform: translateX(3px); }
.direction-role .mono { color: var(--text); font-size: .8rem; letter-spacing: .04em; }
.direction-why { color: var(--text-dim); font-size: .84rem; line-height: 1.5; }

@media (max-width: 900px) {
  .direction { grid-template-columns: 1fr; }
}

/* --------------------------------- contact -------------------------------- */
.contact-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.contact-intro { max-width: 56ch; }

.terminal { margin-top: 2rem; box-shadow: var(--shadow-2); }
.terminal-bar {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem .85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; display: block; }
.dot-red { background: #FF5F57; } .dot-gold { background: #FEBC2E; } .dot-green { background: #28C840; }
.terminal-title { margin-left: .6rem; color: var(--text-dim); }

.terminal-body { padding: 1rem 1.1rem 1.1rem; font-size: .84rem; line-height: 1.9; }
.terminal-body .prompt { color: var(--emerald); }
.terminal-body .cmd { color: var(--text); }
.terminal-body .out { color: var(--text-muted); word-break: break-all; }
.terminal-body .out-accent { color: var(--gold); }
.terminal-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }

/* Direct channels — no form, because a static site has nothing to post to. */
.channels { display: grid; gap: .8rem; align-content: start; }

.channel {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.channel:hover {
  border-color: var(--border-glow);
  background: rgba(22, 27, 34, .8);
  transform: translateY(-3px);
  color: var(--text);
}

.channel-primary {
  border-color: rgba(46, 160, 67, .45);
  background: linear-gradient(180deg, rgba(46,160,67,.14), rgba(22,27,34,.62));
}
.channel-primary:hover { border-color: var(--emerald); }

.channel-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--cyan);
}
.channel-primary .channel-icon { color: #7EE787; border-color: rgba(46,160,67,.4); }
.channel-icon svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.channel-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.channel-text strong { font-size: 1rem; letter-spacing: -0.02em; }
.channel-meta { color: var(--text-muted); font-size: .88rem; }

.channel-go {
  margin-left: auto;
  flex: none;
  color: var(--text-dim);
  transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.channel:hover .channel-go { transform: translateX(4px); color: var(--cyan); }

.channels-note {
  color: var(--text-dim);
  font-size: .88rem;
  padding-top: .4rem;
}

/* --------------------------------- footer --------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(13,17,23,.7);
  padding-top: clamp(2.5rem, 5vw, 4rem);
}
.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 2rem;
  padding-bottom: 2.5rem;
}
.footer-name { font-weight: 700; font-size: 1.05rem; margin-bottom: .3rem; }
.footer-tag { color: var(--text-muted); font-size: .93rem; max-width: 40ch; }

.footer-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
.footer-head {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .16em;
  margin-bottom: .8rem;
}
.footer-nav ul { display: grid; gap: .55rem; }
/* Long values (the email address) must wrap rather than widen the column. */
.footer-nav a {
  color: var(--text-muted);
  font-size: .92rem;
  display: inline-flex;
  align-items: flex-start;
  gap: .5rem;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.footer-nav a .icon { margin-top: .25em; }
.footer-nav a:hover { color: var(--text); }

.footer-base {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  justify-content: space-between;
  padding: 1.1rem 0;
  border-top: 1px solid var(--border-soft);
  color: var(--text-dim);
}
.to-top { color: var(--text-dim); }
.to-top:hover { color: var(--cyan); }

/* --------------------------------- modal ---------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1,4,9,.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade .25s var(--ease);
}

.modal-panel {
  position: relative;
  width: min(100%, 720px);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
  animation: pop .32s var(--ease);
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: translateY(18px) scale(.97); } }

.modal-close {
  position: absolute;
  top: .85rem; right: .85rem;
  z-index: 2;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(13,17,23,.8);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.modal-close:hover { border-color: var(--cyan); transform: rotate(90deg); }
.modal-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.modal-hero { position: relative; aspect-ratio: 21 / 9; overflow: hidden; border-bottom: 1px solid var(--border); }
.modal-shot {
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
  object-position: top center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: clamp(1.3rem, 3vw, 2rem); display: grid; gap: .9rem; }
.modal-title { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); }
.modal-body p { color: var(--text-muted); }
.modal-body h3 { font-size: 1rem; color: var(--text); margin-top: .5rem; }
.modal-body ul { display: grid; gap: .5rem; }
.modal-body ul li {
  position: relative;
  padding-left: 1.4rem;
  color: var(--text-muted);
  font-size: .95rem;
}
.modal-body ul li::before {
  content: "▸";
  position: absolute; left: 0;
  color: var(--emerald);
}

body.modal-open { overflow: hidden; }

/* --------------------------------- toast ---------------------------------- */
.toast {
  position: fixed;
  left: 50%; bottom: 1.5rem;
  transform: translate(-50%, 130%);
  z-index: 200;
  padding: .75rem 1.15rem;
  border: 1px solid rgba(46,160,67,.5);
  border-radius: 999px;
  background: rgba(22,27,34,.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-2);
  font-size: .9rem;
  transition: transform .4s var(--ease);
}
.toast[hidden] { display: block; visibility: hidden; }
.toast.is-visible { transform: translate(-50%, 0); visibility: visible; }

/* ------------------------------- responsive ------------------------------- */
@media (max-width: 1024px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento .span-2, .bento .span-3 { grid-column: span 2; }
}

@media (max-width: 860px) {
  .site-nav {
    position: fixed;
    inset: 68px 0 auto 0;
    margin: 0;
    background: rgba(13,17,23,.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    display: grid;
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s var(--ease);
  }
  .site-nav.is-open { max-height: 70svh; }
  .site-nav ul { flex-direction: column; gap: 0; padding: .6rem 1.25rem 1.4rem; }
  .site-nav a { padding: .85rem .4rem; font-size: 1rem; border-bottom: 1px solid var(--border-soft); border-radius: 0; }
  .site-nav a.is-active::after { display: none; }

  .nav-toggle { display: flex; }
  .header-cta, .status-pill { display: none; }

  .hero { min-height: auto; padding: 7rem 0 4.5rem; }
  .hero-veil { background: linear-gradient(180deg, rgba(13,17,23,.86), rgba(13,17,23,.72)); }
  .scroll-hint { display: none; }

  .cap-grid, .edu-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .bento { grid-template-columns: 1fr; }
  .bento .span-2, .bento .span-3 { grid-column: span 1; }
  /* Two up, still flush left — a spread-out single column reads as centred. */
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; max-width: none; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  .footer-nav { grid-template-columns: 1fr; }
  .engagement-note { flex-direction: column; align-items: flex-start; }
}

/* ------------------------- reduced motion / fallbacks --------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .reveal { opacity: 1; transform: none; }
  .tilt { transform: none !important; }
  .status-dot { animation: none; }
}

@supports not (backdrop-filter: blur(4px)) {
  .bento-card, .project-card, .service-card, .cap-card,
  .terminal, .channel, .site-header { background: var(--surface-1); }
}

/* ----------------------------- language switch ----------------------------- */
.lang-switch { display: flex; align-items: center; gap: .35rem; color: var(--text-dim); }
.lang-option {
  padding: .2rem .4rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.lang-option:hover { color: var(--text); background: var(--surface-2); }
.lang-option.is-active { color: var(--cyan); font-weight: 600; }

/* ---------------------------------- RTL ------------------------------------ */
[dir="rtl"] { --font-sans: "Tajawal", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

[dir="rtl"] .site-nav { margin-left: 0; margin-right: auto; }
[dir="rtl"] .hero-inner { text-align: right; }
[dir="rtl"] .hero-fact { text-align: right; }
[dir="rtl"] .why-item { padding-left: 0; padding-right: 2.6rem; }
[dir="rtl"] .why-num { left: auto; right: 0; }
[dir="rtl"] .project-zoom { right: auto; left: .75rem; }
[dir="rtl"] .service-flag { right: auto; left: 1.2rem; }
[dir="rtl"] .service-list li { padding-left: 0; padding-right: 1.5rem; }
[dir="rtl"] .service-list li::before { left: auto; right: 0; }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 2.2rem; }
[dir="rtl"] .timeline::before,
[dir="rtl"] .timeline::after { left: auto; right: 7px; }
[dir="rtl"] .direction-role { border-left: none; border-right: 2px solid var(--cyan); }
[dir="rtl"] .direction-role:hover { border-left-color: transparent; border-right-color: var(--emerald); }
[dir="rtl"] .direction-role:hover { transform: translateX(-3px); }
[dir="rtl"] .terminal-title { margin-left: 0; margin-right: .6rem; }
[dir="rtl"] .channel-go { margin-left: 0; margin-right: auto; }
[dir="rtl"] .modal-close { right: auto; left: .85rem; }
[dir="rtl"] .modal-body ul li { padding-left: 0; padding-right: 1.4rem; }
[dir="rtl"] .modal-body ul li::before { left: auto; right: 0; content: "◂"; }
[dir="rtl"] .bento-metric .unit { margin-left: 0; margin-right: .25rem; }

@media (max-width: 720px) {
  [dir="rtl"] .hero-facts { text-align: right; }
}

@media print {
  .site-header, .hero-canvas-wrap, .modal, .toast, .scroll-hint { display: none !important; }
  body { background: #fff; color: #000; }
}
