/* ==========================================================================
   Mekanism — styles
   Dark glass theme. Tokens first, then layout, then motion.
   ========================================================================== */

:root {
  --bg: #07090c;
  --fg: #eef0f3;
  --fg-muted: #a3abb6;
  --fg-faint: #7f8794;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #e2b263;          /* warm brass */
  --accent-soft: #f4d9a6;
  --glass-bg: rgba(255, 255, 255, 0.035);
  --glass-bg-hover: rgba(255, 255, 255, 0.055);
  --glass-highlight: rgba(255, 255, 255, 0.10);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --content-w: 64rem;
}

/* Reset ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { color-scheme: dark; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
ul { list-style: none; padding: 0; }

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

.visually-hidden {
  position: absolute !important; 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: 1rem; top: -3rem;
  padding: 0.5rem 0.9rem; border-radius: var(--radius-pill);
  background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600;
  z-index: 100; transition: top 0.2s;
}
.skip-link:focus { top: 1rem; }

/* Ambient background ------------------------------------------------------ */
.ambient {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(40, 52, 78, 0.55), transparent 60%),
    var(--bg);
}
.ambient__parallax { position: absolute; inset: -10%; }
.ambient__orb {
  position: absolute; border-radius: 50%;
  mix-blend-mode: screen;
  will-change: transform;
  animation: drift 48s ease-in-out infinite alternate;
}
.ambient__orb--a {
  width: 60vmax; height: 60vmax; left: -12vmax; top: -20vmax;
  background: radial-gradient(circle at center, rgba(70, 96, 160, 0.52), rgba(70, 96, 160, 0.16) 40%, transparent 70%);
  animation-duration: 54s;
}
.ambient__orb--b {
  width: 52vmax; height: 52vmax; right: -16vmax; top: 10vmax;
  background: radial-gradient(circle at center, rgba(226, 178, 99, 0.26), rgba(226, 178, 99, 0.08) 40%, transparent 70%);
  animation-duration: 66s; animation-delay: -20s;
}
.ambient__orb--c {
  width: 56vmax; height: 56vmax; left: 20vmax; bottom: -30vmax;
  background: radial-gradient(circle at center, rgba(52, 118, 128, 0.40), rgba(52, 118, 128, 0.12) 40%, transparent 70%);
  animation-duration: 72s; animation-delay: -40s;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  33%  { transform: translate3d(6vw, -4vh, 0) scale(1.06); }
  66%  { transform: translate3d(-4vw, 5vh, 0) scale(0.97); }
  100% { transform: translate3d(3vw, 2vh, 0) scale(1.03); }
}

/* Cursor lamp: a soft light that follows the pointer (positioned by main.js). */
.cursor-light {
  position: absolute; left: 0; top: 0;
  width: 70vmax; height: 70vmax;
  background: radial-gradient(circle at center, rgba(190, 205, 240, 0.16), rgba(190, 205, 240, 0.05) 30%, transparent 60%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.2s var(--ease-out);
  will-change: transform;
}
.cursor-light.is-on { opacity: 1; }

/* Gear train. Sized and populated by main.js; scaled as a unit on small screens. */
.gears {
  position: absolute;
  right: -225px; top: -2vh;
  transform-origin: top right;
  pointer-events: auto;
  cursor: grab;
  touch-action: pan-y;
}
.gears.is-dragging { cursor: grabbing; }
.gear {
  position: absolute;
  will-change: transform;
  overflow: visible;
}
.gear__teeth { stroke-width: 1.4; }
.gear__pitch { fill: none; stroke: currentColor; stroke-width: 0.8; stroke-dasharray: 2 6; opacity: 0.45; }
.gear__rim { fill: none; stroke: currentColor; stroke-width: 1.1; opacity: 0.85; }
.gear__rim--inner { stroke-width: 0.8; opacity: 0.5; }
.gear__spoke { fill: currentColor; opacity: 0.35; stroke: currentColor; stroke-width: 0.6; }
.gear__hub { fill: rgba(255, 255, 255, 0.03); stroke: currentColor; stroke-width: 1.1; }
.gear__axle { fill: currentColor; opacity: 0.9; }
.gear--silver { color: rgba(214, 222, 236, 0.30); }
.gear--silver .gear__stop-a { stop-color: rgba(230, 236, 248, 0.55); }
.gear--silver .gear__stop-b { stop-color: rgba(230, 236, 248, 0.12); }
.gear--brass { color: rgba(226, 178, 99, 0.38); }
.gear--brass .gear__stop-a { stop-color: rgba(244, 217, 166, 0.70); }
.gear--brass .gear__stop-b { stop-color: rgba(226, 178, 99, 0.16); }

/* Fine grain to keep gradients from banding. */
.ambient__grain {
  position: absolute; inset: 0; opacity: 0.35; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

/* Glass ------------------------------------------------------------------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  isolation: isolate;
}
/* Top-edge highlight: the "lit rim" of the glass. */
.glass::before {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, var(--glass-highlight), transparent 38%);
  -webkit-mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  mask-composite: exclude;
  padding: 1px;
  opacity: 0.9;
}
/* Fallback when backdrop-filter is unsupported: use a more opaque fill. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(14, 17, 23, 0.92); }
}

/* Pointer spotlight / specular glare (set via --mx/--my in main.js) */
[data-spotlight]::after {
  content: "";
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.085), transparent 60%);
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}
[data-spotlight]:hover::after,
[data-spotlight]:focus-within::after { opacity: 1; }

/* Animated border beam: a slow light travelling around the edge. */
@property --beam {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.glass--beam::before {
  background:
    conic-gradient(from var(--beam, 0deg) at 50% 50%,
      transparent 0deg,
      rgba(244, 217, 166, 0.55) 40deg,
      transparent 80deg,
      transparent 360deg),
    linear-gradient(180deg, var(--glass-highlight), transparent 38%);
  animation: beam 9s linear infinite;
}
@keyframes beam { to { --beam: 360deg; } }

/* Layout ------------------------------------------------------------------ */
.topbar, main, .footer { position: relative; z-index: 1; }

.topbar {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.5rem clamp(1.25rem, 4vw, 2.5rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.topbar__brand {
  display: inline-flex; align-items: center; gap: 0.7rem;
  text-decoration: none; font-weight: 700; letter-spacing: -0.01em;
}
.topbar__mark { width: 30px; height: 30px; }
.topbar__name { font-size: 0.98rem; }
.topbar__nav { display: flex; gap: 0.25rem; }
.topbar__nav a {
  text-decoration: none; color: var(--fg-muted); font-size: 0.9rem; font-weight: 500;
  padding: 0.45rem 0.85rem; border-radius: var(--radius-pill);
  transition: color 0.25s, background-color 0.25s;
}
.topbar__nav a:hover { color: var(--fg); background: rgba(255, 255, 255, 0.05); }

main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem) 2rem;
}

/* Hero -------------------------------------------------------------------- */
.hero {
  min-height: calc(100dvh - 7rem);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  padding: clamp(3rem, 10vh, 7rem) 0 clamp(4rem, 12vh, 8rem);
}
/* Let pointer events fall through empty page space to the gears beneath,
   while every real piece of content stays interactive. */
.topbar, main, .hero, .section, .footer { pointer-events: none; }
.topbar > *, .hero > *, .section > *, .footer > * { pointer-events: auto; }
.hero__eyebrow {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--fg-muted);
}
/* The wordmark is split into letter spans by main.js. Each letter carries its
   own copy of the gradient, positioned in the h1's coordinate space (--w is the
   h1 width, --ox the letter's offset, both set by JS) so the sheen reads as one
   continuous sweep. --sx is the sweep progress, animated on the h1. */
@property --sx {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
.wordmark {
  --sx: 0;
  margin-top: 1.25rem;
  font-size: clamp(3.25rem, 12vw, 8.5rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.95;
  color: var(--fg);
  animation: sheen 14s ease-in-out infinite;
}
@keyframes sheen {
  0%, 20%  { --sx: 0; }
  55%, 70% { --sx: 1; }
  100%     { --sx: 0; }
}
.wordmark__letter { display: inline-block; }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .wordmark__letter {
    background-image: linear-gradient(100deg,
      rgba(255, 255, 255, 0.92) 0%,
      #ffffff 30%,
      var(--accent-soft) 50%,
      #ffffff 70%,
      rgba(255, 255, 255, 0.92) 100%);
    background-size: calc(var(--w, 600px) * 2.6) 100%;
    background-position: calc(var(--w, 600px) * -1.6 * (1 - var(--sx)) - var(--ox, 0px)) 0;
    background-repeat: repeat-x; /* ends match, so tiling is seamless */
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}
/* Letter-by-letter intro. */
html.js .wordmark__letter {
  opacity: 0;
  transform: translate3d(0, 0.28em, 0);
  filter: blur(14px);
}
html.js.is-loaded .wordmark__letter {
  animation: letter-in 1.1s var(--ease-out) forwards;
  animation-delay: calc(140ms + var(--n, 0) * 55ms);
}
@keyframes letter-in {
  to { opacity: 1; transform: none; filter: blur(0); }
}
.hero__lede {
  margin-top: 1.75rem;
  max-width: 34rem;
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  font-weight: 400;
  color: var(--fg-muted);
  text-wrap: balance;
}
.hero__status { margin-top: 2.5rem; }

.status {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1.05rem 0.55rem 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.01em;
  color: var(--fg);
}
.status__dot {
  position: relative; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(226, 178, 99, 0.7);
}
.status__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse 2.6s var(--ease-out) infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Sections ---------------------------------------------------------------- */
.section { padding: clamp(3rem, 8vh, 6rem) 0; }
.section__head { max-width: 36rem; margin-bottom: 2.25rem; }
.section__kicker {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.section__title {
  margin-top: 0.6rem;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
}
.section__lede { margin-top: 0.9rem; color: var(--fg-muted); text-wrap: pretty; }

/* Project cards ----------------------------------------------------------- */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  gap: 1rem;
  perspective: 1200px;
}
.card { --i: 0; display: flex; }
.card__surface {
  flex: 1;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  min-height: 13.5rem;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  transition: background-color 0.4s var(--ease-out), border-color 0.4s var(--ease-out),
              transform 0.55s var(--ease-out);
}
.card__surface:hover { background: var(--glass-bg-hover); border-color: var(--line-strong); }
.card__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card__icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--fg-muted);
}
.card__icon svg { width: 20px; height: 20px; }
.card__body { display: flex; flex-direction: column; gap: 0.4rem; margin-top: auto; }
.card__kind {
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-faint);
}
.card__title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.card__title a { text-decoration: none; }
.card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card__desc { color: var(--fg-muted); font-size: 0.95rem; }

/* Placeholder "redacted" title bars for unannounced projects */
.card__bars { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.35rem 0 0.2rem; }
.card__bar {
  height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, rgba(255,255,255,0.08), rgba(255,255,255,0.16), rgba(255,255,255,0.08));
  background-size: 200% 100%;
  animation: shimmer 4.5s ease-in-out infinite;
}
.card__bar--short { width: 55%; animation-delay: 0.6s; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.7rem; border-radius: var(--radius-pill);
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--fg-muted);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge--in-development { color: var(--accent); border-color: rgba(226, 178, 99, 0.25); }
.badge--coming-soon { color: var(--fg-muted); }
.badge--live { color: #8fd9b6; border-color: rgba(143, 217, 182, 0.25); }

/* Contact ----------------------------------------------------------------- */
.section--contact { padding-bottom: clamp(2rem, 6vh, 4rem); }
.contact {
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 4vw, 3rem);
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  flex-wrap: wrap;
}
.contact__text { max-width: 30rem; }
.contact__action { padding: 1.5rem; margin: -1.5rem; } /* magnetic capture zone */

.button {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1.35rem; border-radius: var(--radius-pill);
  background: var(--fg); color: var(--bg);
  font-weight: 700; font-size: 0.95rem; text-decoration: none; letter-spacing: -0.01em;
  box-shadow: 0 10px 30px -10px rgba(255, 255, 255, 0.35);
  transform: translate3d(var(--bx, 0px), calc(var(--by, 0px) + var(--lift, 0px)), 0);
  transition: transform 0.3s var(--ease-out), box-shadow 0.35s var(--ease-out), background-color 0.35s;
}
.button svg { transition: transform 0.35s var(--ease-out); }
.button:hover { --lift: -2px; background: #fff; box-shadow: 0 16px 36px -12px rgba(255, 255, 255, 0.45); }
.button:hover svg { transform: translateX(3px); }

/* Footer ------------------------------------------------------------------ */
.footer {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 2rem clamp(1.25rem, 4vw, 2.5rem) 2.5rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-top: 1px solid var(--line);
  color: var(--fg-faint); font-size: 0.85rem;
}

/* Motion: entrance reveals ------------------------------------------------ */
/* Only hide-before-reveal when JS is running (html.js) so content is never trapped. */
html.js .reveal {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 100ms + var(--i, 0) * 90ms);
}
html.js .reveal.is-visible { opacity: 1; transform: none; }

/* Pause CSS motion while the tab is hidden (toggled by main.js; the rAF loop stops too). */
html.is-hidden .ambient__orb,
html.is-hidden .wordmark,
html.is-hidden .card__bar,
html.is-hidden .glass--beam::before,
html.is-hidden .status__dot::after { animation-play-state: paused; }

/* Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ambient__orb, .card__bar, .status__dot::after, .glass--beam::before { animation: none; }
  .wordmark { animation: none; --sx: 0.5; }
  html.js .wordmark__letter { opacity: 1; transform: none; filter: none; animation: none; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  .card__surface, .button, .button svg, .cursor-light { transition: none; }
  .cursor-light { display: none; }
  .gears { cursor: default; }
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1100px) {
  .gears { transform: scale(0.7); right: -200px; top: 2vh; }
}
@media (max-width: 640px) {
  .topbar { padding-top: 1.1rem; padding-bottom: 1.1rem; }
  .topbar__name { display: none; }
  .hero { min-height: calc(88dvh - 5.5rem); padding-top: 2rem; padding-bottom: 3rem; }
  .hero__lede { font-size: 1.02rem; }
  .gears { transform: scale(0.42); right: -95px; top: 58vh; opacity: 0.75; }
  .card__surface { min-height: 0; padding: 1.35rem; }
  .contact { flex-direction: column; align-items: stretch; }
  .contact__action { margin: 0; padding: 0; }
  .button { justify-content: center; }
  .footer { flex-direction: column; gap: 0.35rem; }
}
