/* ============================================================
   POLYAZIN — pure (HTML/CSS/Tailwind CDN/JS/jQuery)
   Monochrome, product-led system (polymer.ws style)
   ============================================================ */
:root {
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);

  --color-paper: #edecea;

  /* Brand */
  --primary: #2540eb;
  --primary-600: #1c31c4; /* darker — hover/active */
  --on-primary: #ffffff;

  /* Image duotone — grayscale source tinted toward the brand blue so every
     photo carries the primary colour instead of plain greyscale. */
  --img-tint: grayscale(1) sepia(1) hue-rotate(195deg) saturate(1.8)
    brightness(0.98) contrast(1.03);
  --img-tint-hover: grayscale(1) sepia(1) hue-rotate(195deg) saturate(2.4)
    brightness(1.06) contrast(1.05);
}

/* scheme-* sets tokens only (overlays on images);
   theme-* also paints background + text colour (full sections). */
.scheme-light,
.theme-light {
  --bg: #edecea;
  --panel: #e4e3e0;
  --fg: #141414;
  --muted: #6c6c6c;
  --line: rgba(20, 20, 20, 0.14);
  --btn-bg: rgba(20, 20, 20, 0.05);
}
.scheme-dark,
.theme-dark {
  --bg: #161616;
  --panel: #1e1e1e;
  --fg: #f0f0ee;
  --muted: #a2a2a2;
  --line: rgba(240, 240, 240, 0.16);
  --btn-bg: rgba(240, 240, 240, 0.07);
}
.theme-light,
.theme-dark {
  background: var(--bg);
  color: var(--fg);
}

/* ---------------- Lenis ---------------- */
html.lenis,
html.lenis body {
  height: auto;
}
.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}
.lenis.lenis-stopped {
  overflow: hidden;
}
.lenis.lenis-smooth iframe {
  pointer-events: none;
}

/* ---------------- Base ---------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  background: var(--color-paper);
  color: #141414;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
@media (pointer: fine) {
  body[data-cursor="on"],
  body[data-cursor="on"] * {
    cursor: none;
  }
}
::selection {
  background: var(--primary);
  color: var(--on-primary);
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}
img {
  display: block;
  max-width: 100%;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ---------------- Typography ---------------- */
.font-display {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.font-mono {
  font-family: var(--font-mono);
}
.label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.t-display {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
}
.t-title {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-size: clamp(1.35rem, 2.6vw, 2.3rem);
}

/* ---------------- Layout ---------------- */
.shell {
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 3.5vw, 3rem);
}
.section {
  padding-block: clamp(3.5rem, 8vw, 7rem);
}

/* ---------------- Media ---------------- */
.media {
  position: relative;
  overflow: hidden;
  background: #cbcac6;
}
.theme-dark .media {
  background: #2a2a2a;
}
.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: var(--img-tint);
  transition: transform 0.9s var(--ease-out-expo),
    filter 0.7s var(--ease-out-expo);
  will-change: transform;
}
.media-zoom:hover img,
a:hover .media-zoom img,
.group:hover .media-zoom img {
  transform: scale(1.05);
}

/* The hero and the Process Portrait images are already baked to the brand blue
   duotone, so skip the global grayscale tint — keeping their native blues rich.
   Other photos still get .media's tint for a consistent monochrome look. */
.hero-img .media img,
#featured .media img {
  filter: none;
}

/* ---------------- Systems split — hover expand ---------------- */
@media (min-width: 768px) {
  /* Lock the row to a constant height so only the column widths animate.
     3 / 2 keeps the resting layout identical to two 3:4 columns. */
  #systems > .grid {
    aspect-ratio: 3 / 2;
    grid-template-rows: 1fr;
    transition: grid-template-columns 0.85s var(--ease-out-expo);
  }
  /* Let columns shrink below their content size and fill the locked height. */
  #systems > .grid > a {
    min-width: 0;
    min-height: 0;
  }
  #systems > .grid .media {
    height: 100%;
  }
  /* Widen the hovered card, narrow its neighbour; the image (object-fit:cover)
     fills the new width. */
  #systems > .grid:has(> a:first-child:hover) {
    grid-template-columns: 1.4fr 0.6fr;
  }
  #systems > .grid:has(> a:last-child:hover) {
    grid-template-columns: 0.6fr 1.4fr;
  }
}

/* Systems split — a gentle, slow zoom on hover (just the image easing up). */
#systems .media img {
  transition: transform 1.6s var(--ease-out-expo);
}
#systems .group:hover .media-zoom img {
  transform: scale(1.08);
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.8rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.4s var(--ease-out-expo), color 0.4s var(--ease-out-expo),
    border-color 0.4s var(--ease-out-expo);
}
.btn .arrow {
  transition: transform 0.45s var(--ease-out-expo);
}
.btn:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.btn:hover .arrow {
  transform: translate(3px, -3px);
}

/* Reveal button — its label unfurls and folds back on its own, looping
   gently and forever. Pauses (and stays open) on hover so it stays usable. */
.btn-reveal {
  gap: 0;
}
.btn-reveal .btn-label {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  margin-right: 0;
  opacity: 0;
  transform: translateX(0.5em);
  animation: btn-unfurl 4.6s var(--ease-in-out-quart) infinite;
}
@keyframes btn-unfurl {
  /* held closed — just the arrow */
  0%,
  10% {
    max-width: 0;
    margin-right: 0;
    opacity: 0;
    transform: translateX(0.5em);
  }
  /* eased open, then held to be read */
  35%,
  65% {
    max-width: 12rem;
    margin-right: 0.6em;
    opacity: 1;
    transform: translateX(0);
  }
  /* eased closed again, then held */
  90%,
  100% {
    max-width: 0;
    margin-right: 0;
    opacity: 0;
    transform: translateX(0.5em);
  }
}
/* Hover/focus freezes the loop in place so it stays readable and clickable. */
.btn-reveal:hover .btn-label,
.btn-reveal:focus-visible .btn-label {
  animation-play-state: paused;
}
/* NOTE: the global reduce-motion block (see bottom of file) strips this loop's
   duration/iteration via `* { ...!important }`. A scoped exception there keeps
   THIS button looping even when the OS reports reduce-motion — which it often
   does on Windows Server, the reason the loop appeared frozen before. */
.btn-icon {
  width: 3rem;
  height: 3rem;
  padding: 0;
  justify-content: center;
}

/* ---------------- Preloader brandmark ---------------- */
.pl-mark {
  width: clamp(88px, 12vw, 132px);
  height: auto;
  overflow: visible;
  /* lift it slightly above dead-centre so it sits above the counter row */
  margin-top: -6vh;
}
.pl-mark .track {
  stroke: rgba(240, 240, 240, 0.1);
}
.pl-mark .draw {
  stroke: #bcbcba; /* cool grey — JS tints it to brand blue as it finishes */
  stroke-dasharray: 1;
  stroke-dashoffset: 1; /* JS draws this 1 -> 0 in time with the counter */
  filter: drop-shadow(0 0 8px rgba(37, 64, 235, 0.3));
}
.pl-mark .hex {
  fill: #d8d8d6;
  opacity: 0; /* JS pops it in near the end */
}
/* soft breathing halo behind the mark — faint brand-blue glow */
.pl-mark-wrap::before {
  content: "";
  position: absolute;
  width: clamp(190px, 26vw, 300px);
  aspect-ratio: 1;
  margin-top: -6vh;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(90, 116, 255, 0.16),
    rgba(90, 116, 255, 0) 68%
  );
  animation: pl-halo 2.6s ease-in-out infinite;
}
@keyframes pl-halo {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* ---------------- Brand signature (scroll-drawn mark) ----------------
   A giant brandmark that draws + fills itself in step with the scroll.
   Defaults below paint the FINISHED mark, so with no JS / reduced-motion
   the section simply shows the completed logo. The `.has-anim` overrides
   reset it to the empty start state that the scroll scrub then reveals. */
.sig-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(82vw, 760px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(90, 116, 255, 0.18),
    rgba(90, 116, 255, 0) 70%
  );
  pointer-events: none;
}
.sig-stage {
  position: relative;
  z-index: 1;
  gap: clamp(1.1rem, 3vw, 2.2rem);
}
.sig-mark {
  width: clamp(200px, 40vw, 500px);
  height: auto;
  overflow: visible;
  will-change: transform;
}
.sig-mark .track {
  stroke: rgba(240, 240, 240, 0.1);
}
.sig-mark .draw {
  stroke: var(--primary); /* finished colour by default */
  stroke-dasharray: 1;
  stroke-dashoffset: 0; /* fully drawn by default */
  filter: drop-shadow(0 0 12px rgba(37, 64, 235, 0.35));
}
.sig-mark .hex {
  fill: var(--primary);
  opacity: 1; /* filled by default */
}
.sig-word {
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.01em;
  font-size: clamp(2.4rem, 9vw, 7rem);
}
.sig-sub {
  letter-spacing: 0.45em;
}
/* Empty start state — only when the scroll animation is live (no FOUC, graceful no-JS). */
.has-anim .sig-mark .draw {
  stroke: #bcbcba;
  stroke-dashoffset: 1;
}
.has-anim .sig-mark .hex {
  opacity: 0;
}
.has-anim .sig-kicker,
.has-anim .sig-word,
.has-anim .sig-sub {
  opacity: 0;
}

/* ---------------- Cursor ---------------- */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  border-radius: 999px;
  will-change: transform;
  mix-blend-mode: difference;
  opacity: 0;
}
.cursor-dot {
  width: 6px;
  height: 6px;
  background: #fff;
}
.cursor-ring {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: width 0.3s var(--ease-out-expo), height 0.3s var(--ease-out-expo),
    background 0.3s var(--ease-out-expo), opacity 0.3s ease;
}
.cursor-ring.is-hover {
  width: 66px;
  height: 66px;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------------- Header ---------------- */
.announce {
  background: var(--primary);
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
}
.navrow {
  /* Fully transparent — no background fill on scroll. The logo + nav colour
     adapts to whatever section is currently behind the fixed bar. */
  color: #f0f0ee;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: color 0.5s var(--ease-out-expo);
}
/* Over a light section the logo + nav turn near-black (the section's ink);
   over dark sections they stay white (the default above). */
.navrow.on-light {
  color: #141414;
}
.nav-link {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Letter-by-letter hover: on hover each glyph rises + fades in, one after
   another from first to last (~0.035s apart). JS (GSAP) replays it per hover.
   Rest state is a readable, slightly-dimmed word (also the no-JS fallback). */
.lh {
  display: inline-block;
  white-space: nowrap;
}
.lh-char {
  display: inline-block;
  overflow: hidden;
  line-height: 1.5; /* headroom so descenders (y, g, p) aren't clipped at rest */
  vertical-align: top;
}
.lh-in {
  display: block;
  opacity: 0.7;
  will-change: transform, opacity;
}

/* mobile menu */
.mobile-menu {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.6s var(--ease-in-out-quart);
}
.mobile-menu.is-open {
  clip-path: inset(0 0 0% 0);
}

/* hamburger */
.burger span {
  position: absolute;
  left: 0;
  height: 1px;
  width: 100%;
  background: currentColor;
  transition: all 0.3s ease;
}
.burger span:nth-child(1) {
  top: 1px;
}
.burger span:nth-child(2) {
  bottom: 1px;
}
.burger.is-open span:nth-child(1) {
  top: 50%;
  transform: rotate(45deg);
}
.burger.is-open span:nth-child(2) {
  bottom: 50%;
  transform: rotate(-45deg);
}

/* ---------------- Product card ---------------- */
.product-card {
  display: flex;
  flex-direction: column;
}
.product-card .media {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--panel);
}

/* ---- Cool hover: lift + deeper zoom + colour lift + light-sweep + CTA ---- */
.product-card .group {
  transition: transform 0.6s var(--ease-out-expo);
  will-change: transform;
}
.product-card .group:hover {
  transform: translateY(-6px);
}
.product-card .media {
  transition: box-shadow 0.6s var(--ease-out-expo);
}
.product-card .group:hover .media {
  box-shadow: 0 26px 52px -24px rgba(20, 20, 20, 0.5);
}

/* deeper zoom on hover — keep the product shot in its native colour (no tint) */
.product-card .media img {
  filter: none;
  transition: transform 1.1s var(--ease-out-expo),
    filter 0.7s var(--ease-out-expo);
}
.product-card .group:hover .media-zoom img {
  transform: scale(1.09);
  filter: none;
}

/* light-sweep gliding diagonally across the image */
.product-card .media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.28) 50%,
    transparent 65%
  );
  transform: translateX(-130%);
  transition: transform 0.9s var(--ease-out-expo);
}
.product-card .group:hover .media::after {
  transform: translateX(130%);
}

/* CTA pill that fades + slides up from the corner */
.product-card .media::before {
  content: "View datasheet \2197";
  position: absolute;
  z-index: 3;
  left: 0.85rem;
  bottom: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s var(--ease-out-expo),
    transform 0.5s var(--ease-out-expo);
  pointer-events: none;
}
.product-card .group:hover .media::before {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------- Marquee ---------------- */
.marquee {
  display: flex;
  width: max-content;
  white-space: nowrap;
  will-change: transform;
}
.marquee-item {
  display: inline-flex;
  align-items: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding-right: clamp(1.5rem, 4vw, 3rem);
}

/* ---------------- Reveal helpers ---------------- */
.reveal-line {
  overflow: hidden;
  display: block;
  padding-bottom: 0.04em;
}
.word,
.reveal-word {
  display: inline-block;
  will-change: transform;
}
.char {
  display: inline-block;
  will-change: transform, opacity;
}
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.02em;
}
.line-inner {
  display: block;
  will-change: transform;
}
.hairline {
  height: 1px;
  width: 100%;
  background: var(--line);
}

/* Hidden start states only when JS animation is active (no FOUC, graceful no-JS) */
.has-anim [data-reveal] {
  opacity: 0;
}
.has-anim [data-split] {
  opacity: 0;
}
.has-anim .line-inner {
  opacity: 0;
}

/* hide horizontal scrollbar on the product rail */
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ---------------- Mobile polish ---------------- */
/* Kill the grey tap-flash when buttons/links are pressed on touch devices. */
html {
  -webkit-tap-highlight-color: transparent;
}

/* Lock the page behind the open mobile menu so the background can't scroll. */
html.menu-open,
html.menu-open body {
  overflow: hidden;
}
.mobile-menu {
  overscroll-behavior: contain;
}

/* Hero + lifestyle banner track the *small* viewport height so the mobile
   browser chrome (address bar) never crops the headline on load. Falls back to
   the vh utilities in the markup where svh isn't supported. */
@supports (height: 100svh) {
  #top > .relative {
    min-height: 90svh;
  }
  #about > .scheme-dark {
    min-height: 68svh;
  }
}

/* On touch there's no hover to pause the reveal button, and its label spends
   half the loop folded shut — leaving the primary hero CTA as a bare arrow.
   Pin it open on hover-less devices so "View grade" always reads. */
@media (hover: none) {
  .btn-reveal {
    gap: 0.6em;
  }
  .btn-reveal .btn-label {
    max-width: 12rem;
    margin-right: 0;
    opacity: 1;
    transform: none;
    animation: none;
  }
}

/* The announce strip is long; tighten it on phones so it settles into two tidy
   lines instead of three cramped ones. */
@media (max-width: 640px) {
  .announce {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    line-height: 1.55;
    padding: 0.5rem 0.9rem;
  }
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .cursor-dot,
  .cursor-ring {
    display: none;
  }
  /* Exception: the reveal button's loop IS the element — keep it running even
     under reduce-motion. Higher specificity than `*` + !important wins back the
     duration/iteration the global rule above strips. Scoped to this button only. */
  .btn-reveal .btn-label {
    animation-duration: 4.6s !important;
    animation-iteration-count: infinite !important;
  }
}
