/* =====================================================================
   ENCODEX — shared content-page chrome (MONOLITH v6.0)
   ---------------------------------------------------------------------
   The landing (index.html) carries the live Sentinel Studio scene and
   keeps its chrome inline. These interior pages (services / projects /
   lab / contact) are lightweight documents that must read as the SAME
   site: identical tokens, top bar, frosted menu and status bar, minus
   the Three.js weight. A flat CSS backdrop stands in for the room.

   Transition-ready: cross-document View Transitions are opted in below,
   and the persistent chrome (bar top, bar bottom, brand) is named so a
   navigation holds it still while the content cross-fades. Build the
   bespoke motion on top of these hooks.
   ===================================================================== */

/* ---- self-hosted latin subsets (same files the landing preloads) ---- */
@font-face {
  font-family: 'Michroma';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/michroma-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(/fonts/hanken-grotesk-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Kode Mono';
  font-style: normal; font-weight: 400 500; font-display: swap;
  src: url(/fonts/kode-mono-latin.woff2) format('woff2');
}

/* ---------------------------------------------------------------------------
   Lens vignette — the composer grade's, restored.
   The film stack (src/Post.js) closed every shot with an elliptical vignette:
       vec2 vc = fromCenter * vec2(1.0, 1.35);
       col *= 1.0 - smoothstep(0.14, 0.68, dot(vc, vc)) * uVignette;   // 1.2
   Dropping the composer for the direct ACES path (src/DirectPost.js) dropped
   it too. It is the one grade element reproducible EXACTLY in CSS: a plain
   multiply toward black on already-tonemapped sRGB, which is algebraically
   what an rgba(0,0,0,a) layer does — so a = 1 - vig, sampled off the real
   curve (max error 1.13/255).

   Radii are explicit percentages, NOT farthest-corner: the GLSL works in raw
   uv, so its ellipse is fixed in uv space and stretches with the viewport
   (px ratio = 1.35 x aspect). Percentages resolve x against width and y
   against height, which reproduces that at every aspect; farthest-corner
   would use W/H and lose the 1.35 vertical squeeze entirely.
   The 87.49% -> 100% solid pair is load-bearing: 1.2 x smoothstep saturates
   before the corner, so the outer diagonal really is flat black.

   Composited into each page's EXISTING scrim layer stack — no extra element,
   no extra compositor pass.
   --------------------------------------------------------------------------- */
:root {
  --lens-vignette: radial-gradient(
    ellipse 84.0% 62.22% at 50% 50%,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0) 44.54%,
    rgba(0, 0, 0, 0.016) 50%,
    rgba(0, 0, 0, 0.061) 55%,
    rgba(0, 0, 0, 0.138) 60%,
    rgba(0, 0, 0, 0.248) 65%,
    rgba(0, 0, 0, 0.390) 70%,
    rgba(0, 0, 0, 0.556) 75%,
    rgba(0, 0, 0, 0.738) 80%,
    rgba(0, 0, 0, 0.918) 85%,
    rgba(0, 0, 0, 1) 87.49%,
    rgba(0, 0, 0, 1) 100%
  );
}

:root {
  --bg: #05070b;
  --bg-2: #0f131a;
  --line: #1b212b;
  --txt: #edf1f5;
  --txt-2: #97a1af;
  --txt-3: #5f6b79;
  --txt-4: #333b47;
  --hi: #ffffff;
  --cut: 12px;
  --f-disp: 'Michroma', 'Hanken Grotesk', sans-serif;
  --f-text: 'Hanken Grotesk', system-ui, sans-serif;
  --f-mono: 'Kode Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: clamp(20px, 4vw, 46px);
}

/* Native cross-document View Transitions are intentionally NOT opted into: the
   JS robot interstitial (src/transition.js) owns page transitions. Opting in
   would run a native VT on top of the interstitial and ghost the chrome over
   the black seam. The `view-transition-name`s below are left as inert hooks. */

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

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--f-text);
  -webkit-font-smoothing: antialiased;
  /* clear the fixed top + bottom HUD bars */
  padding: 62px 0 44px;
}

body.menu-open { overflow: hidden; }

/* ---- flat cinematic backdrop (stands in for the live room) ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, #070a10 0%, var(--bg) 46%, #04060a 100%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  /* faint grid, fading out toward the edges + a soft top glow */
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 72%);
  opacity: 0.5;
}

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

/* =====================================================================
   TOP BAR — brand + notched menu toggle (identical to the landing)
   ===================================================================== */
.site-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 62px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: linear-gradient(to bottom, rgba(4,5,8,0.82), rgba(4,5,8,0));
  view-transition-name: site-top;
}
.site-brand { display: inline-flex; align-items: center; view-transition-name: site-brand; }
.site-brand img { display: block; height: 18px; width: auto; }

.menutoggle {
  position: relative;
  width: 42px; height: 34px; padding: 0;
  background: rgba(10, 13, 18, 0.45);
  border: 1px solid #313a47;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  cursor: pointer;
  transition: border-color 0.4s ease, background-color 0.4s ease;
}
.menutoggle:hover { border-color: #55606f; background: rgba(16, 20, 27, 0.62); }
.menutoggle span {
  position: absolute; left: 13px; right: 13px; height: 1px;
  background: var(--hi);
  transition: transform 0.5s cubic-bezier(0.2,0.7,0.2,1), top 0.5s cubic-bezier(0.2,0.7,0.2,1);
}
.menutoggle .l1 { top: 13px; }
.menutoggle .l2 { top: 19px; }
body.menu-open .menutoggle .l1 { top: 16px; transform: rotate(45deg); }
body.menu-open .menutoggle .l2 { top: 16px; transform: rotate(-45deg); }
@media (min-width: 861px) {
  .menutoggle { width: 60px; height: 48px; }
  .menutoggle span { left: 18px; right: 18px; }
  .menutoggle .l1 { top: 19px; }
  .menutoggle .l2 { top: 28px; }
  body.menu-open .menutoggle .l1 { top: 23px; }
  body.menu-open .menutoggle .l2 { top: 23px; }
}

/* =====================================================================
   FROSTED FULL-SCREEN MENU (shared nav across every page)
   ===================================================================== */
.site-menu {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(20px, 7vw, 46px);
  background: rgba(4, 5, 8, 0.82);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
}
body.menu-open .site-menu {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity 0.7s ease;
}
.menu-links { display: flex; flex-direction: column; }
.menu-links a {
  display: flex; align-items: baseline; gap: 16px;
  padding: 21px 2px;
  border-bottom: 1px solid rgba(27, 33, 43, 0.7);
  font-family: var(--f-disp);
  font-size: clamp(21px, 6.4vw, 32px);
  letter-spacing: 0.09em;
  color: #ccd3dc;
  transition: color 0.5s ease, opacity 0.5s ease,
    transform 0.65s cubic-bezier(0.16,0.6,0.2,1),
    filter 0.5s ease, border-color 0.5s ease, text-shadow 0.5s ease;
}
.menu-links a:first-child { border-top: 1px solid rgba(27, 33, 43, 0.7); }
.menu-links a i {
  font: 400 10px var(--f-mono); font-style: normal;
  letter-spacing: 0.18em; color: var(--txt-3);
  transition: color 0.5s ease;
}
.menu-links a::after {
  content: '→'; margin-left: auto; align-self: center;
  font-family: var(--f-mono); font-size: 0.4em; color: var(--hi);
  opacity: 0; transform: translateX(-12px);
  transition: opacity 0.5s ease, transform 0.65s cubic-bezier(0.16,0.6,0.2,1);
}
/* rack-focus hover: siblings defocus, the pointed one pulls sharp */
.menu-links:hover a { color: #59636f; opacity: 0.55; filter: blur(2px); }
.menu-links a:hover {
  color: var(--hi); opacity: 1; filter: none; transform: translateX(22px);
  border-bottom-color: rgba(174, 182, 194, 0.45);
  text-shadow: 0 0 26px rgba(237, 241, 245, 0.32);
}
.menu-links a:hover i { color: #cfd6dd; }
.menu-links a:hover::after { opacity: 1; transform: none; }
/* current page — held white, no arrow, a live tick */
.menu-links a[aria-current='page'] { color: var(--hi); }
.menu-links:hover a[aria-current='page'] { opacity: 1; filter: none; }
.menu-links a[aria-current='page']::after { content: none; }
.menu-links a[aria-current='page'] .tick {
  align-self: center; width: 4px; height: 4px; margin-left: auto;
  background: var(--hi); box-shadow: 0 0 6px rgba(237, 241, 245, 0.8);
  animation: pulse 3.6s ease-in-out infinite;
}
.menu-foot {
  position: absolute; left: clamp(20px, 7vw, 46px); right: clamp(20px, 7vw, 46px);
  bottom: 30px; display: flex; flex-direction: column; gap: 10px;
  font: 400 8.5px var(--f-mono); letter-spacing: 0.16em; color: var(--txt-3);
}
/* language selector — lives in the top bar, grouped with the menu toggle,
   always visible (not buried in the frosted menu) */
.top-aux { display: flex; align-items: center; gap: clamp(13px, 2.4vw, 22px); }
.lang-switch { display: flex; align-items: center; gap: 11px; }
.lang-switch a {
  color: var(--txt-2); text-decoration: none;
  font: 500 10.5px var(--f-mono); letter-spacing: 0.14em; line-height: 1;
  transition: color 0.3s ease;
}
.lang-switch a:hover { color: var(--txt); }
.lang-switch a.on { color: var(--hi); }
/* Arabic endonym: kill tracking (breaks cursive joining) + nudge size up a
   touch so the script reads at parity with the Latin codes beside it */
.lang-switch a[lang="ar"] { letter-spacing: 0; font-size: 12px; }
@media (min-width: 861px) { .lang-switch a { font-size: 11px; } .lang-switch a[lang="ar"] { font-size: 12.5px; } }
@keyframes pulse { 0%, 100% { opacity: 0.32; } 50% { opacity: 1; } }

/* =====================================================================
   BOTTOM STATUS BAR (shared, held across navigations)
   ===================================================================== */
.site-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 44px;
  z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  border-top: 1px solid rgba(27, 33, 43, 0.7);
  background: linear-gradient(to top, rgba(4,5,8,0.82), rgba(4,5,8,0));
  font: 400 9.5px var(--f-mono); letter-spacing: 0.16em;
  view-transition-name: site-bottom;
}
.site-bottom .ref, .site-bottom .ver { color: var(--txt-4); }
.site-bottom .metrics { display: flex; align-items: center; gap: 15px; color: var(--txt-3); }
.site-bottom .metrics b { color: var(--txt); font-weight: 400; }
.site-bottom .metrics .slash { color: var(--txt-4); }
@media (max-width: 860px) { .site-bottom .metrics { display: none; } }

/* =====================================================================
   CONTENT
   ===================================================================== */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) var(--gutter) 96px;
}

/* staged entry — settles once <body class="ready"> is set on load */
.rise { opacity: 0; transform: translateY(16px); filter: blur(8px);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(0.16,0.6,0.2,1), filter 1.1s ease; }
body.ready .rise { opacity: 1; transform: none; filter: none; }
body.ready .rise:nth-child(2) { transition-delay: 0.08s; }
body.ready .rise:nth-child(3) { transition-delay: 0.16s; }
body.ready .rise:nth-child(4) { transition-delay: 0.24s; }

/* page header */
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font: 500 10.5px var(--f-mono); letter-spacing: 0.22em; color: var(--txt-3);
  margin-bottom: 22px;
}
.kicker::before {
  content: ''; width: 5px; height: 5px; background: var(--hi);
  box-shadow: 0 0 7px rgba(237, 241, 245, 0.9);
  animation: pulse 3.6s ease-in-out infinite;
}
.page-title {
  margin: 0 0 22px;
  font-family: var(--f-disp); font-weight: 400;
  font-size: clamp(30px, 5.4vw, 62px); line-height: 1.12;
  letter-spacing: 0.02em; text-wrap: balance;
  background: linear-gradient(to bottom, #ffffff 34%, #8e99a7 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.lead {
  max-width: 60ch; margin: 0 0 12px;
  font-size: clamp(14px, 1.3vw, 17px); line-height: 1.7;
  letter-spacing: 0.02em; color: var(--txt-2);
}

.rule { height: 1px; background: var(--line); margin: 54px 0; border: 0; }
.section-label {
  font: 500 10px var(--f-mono); letter-spacing: 0.2em; color: var(--txt-4);
  margin: 0 0 24px; text-transform: uppercase;
}

/* ---- notched surface primitive ---- */
.panel, .card {
  position: relative;
  background: #0a0d12;
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.card {
  padding: 26px 26px 24px;
  transition: border-color 0.3s ease, background-color 0.3s ease, transform 0.3s ease;
}
a.card:hover, .card.hoverable:hover {
  border-color: #3a4553; background: #0c1016; transform: translateY(-3px);
}
.card .ref {
  position: absolute; top: 12px; right: 20px;
  font: 400 9px var(--f-mono); letter-spacing: 0.12em; color: var(--txt-4);
}

/* ---- card grid ---- */
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) { .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.cols-3, .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; } }

.tag {
  display: inline-block;
  font: 500 9px var(--f-mono); letter-spacing: 0.18em; color: var(--txt-3);
  padding: 4px 9px; margin-bottom: 16px;
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}
.card-title {
  font-family: var(--f-disp); font-weight: 400;
  font-size: 15px; letter-spacing: 0.04em; color: var(--txt);
  margin: 0 0 12px;
}
.card-desc { font-size: 13.5px; line-height: 1.65; color: var(--txt-2); margin: 0; }
.card ul { margin: 16px 0 0; padding: 0; list-style: none; }
.card ul li {
  font: 400 12px var(--f-mono); letter-spacing: 0.04em; color: var(--txt-3);
  padding: 7px 0; border-top: 1px solid var(--line);
  display: flex; gap: 10px;
}
.card ul li::before { content: '—'; color: var(--txt-4); }

/* ---- process strip ---- */
.process { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.process .step {
  flex: 1 1 150px; padding: 18px 18px 20px;
  border: 1px solid var(--line); background: #0a0d12;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.process .step .n { font: 400 9px var(--f-mono); letter-spacing: 0.18em; color: var(--txt-4); }
.process .step .t { display: block; margin-top: 10px; font-family: var(--f-disp); font-size: 13px; letter-spacing: 0.05em; color: var(--txt); }
.process .step .d { display: block; margin-top: 8px; font-size: 12px; line-height: 1.55; color: var(--txt-3); }

/* ---- buttons (identical to the landing) ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; cursor: pointer;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.18em;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  border: 1px solid transparent;
}
.btn.primary { background: var(--hi); color: #05070b; }
.btn.primary:hover { background: #cfd6dd; }
.btn.ghost { background: rgba(10, 13, 18, 0.4); border-color: var(--line); color: var(--txt); }
.btn.ghost:hover { border-color: #3a4553; color: var(--hi); }
/* keyboard focus — reset the notch clip so the outline is actually visible */
.btn:focus-visible { clip-path: none; outline: 2px solid var(--hi); outline-offset: 3px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 40px; }

/* ---- contact form (mockup) ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 8px;
  font: 500 9.5px var(--f-mono); letter-spacing: 0.18em; color: var(--txt-3);
}
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 15px;
  background: #070a0e; border: 1px solid var(--line); color: var(--txt);
  font-family: var(--f-text); font-size: 14px; letter-spacing: 0.01em;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  outline: none; transition: border-color 0.2s ease, background-color 0.2s ease;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #3a4553; background: #0a0e13;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* ---- clocks (reused on contact) ---- */
.clocks { display: inline-flex; align-items: center; gap: 13px; flex-wrap: wrap; }
.clocks .clk { display: inline-flex; align-items: baseline; gap: 7px; }
.clocks .clk b { font: 500 9.5px var(--f-mono); letter-spacing: 0.18em; color: var(--txt-3); }
.clocks .clk time { font: 400 12px var(--f-mono); color: #cfd6dd; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.clocks .cdot { width: 3px; height: 3px; border-radius: 50%; background: var(--txt-4); }

/* ---- misc ---- */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 22px; align-items: baseline; }
.dl dt { font: 500 9.5px var(--f-mono); letter-spacing: 0.18em; color: var(--txt-4); }
.dl dd { margin: 0; font-size: 14px; color: var(--txt); }
.dl dd a:hover { color: var(--hi); text-decoration: underline; text-underline-offset: 3px; }

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .rise { transition: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}

/* page-transition pre-paint cover (see src/transition.js). The <head> script
   raises .ex-arriving before first paint on a cross-document arrival, so the
   robot interstitial hands off with no white flash. */
html.ex-arriving::before {
  content: '';
  position: fixed;
  inset: 0;
  background: #05070b;
  z-index: 2147482000;
}
