/* ============================================================
   ERGÖK — THEME FOUNDATION  ("Cryo-Industrial")
   Loads AFTER styles.css + app.css. This is the single source of
   truth for design tokens, the type scale, motion tokens, surface
   primitives and the button system.

   Layer order (see app/Views/layouts/main.php):
     1. styles.css   legacy design system
     2. app.css      legacy application layer
     3. theme.css    ← THIS FILE (foundation)
     4. motion.css   motion primitives
     5. chrome.css   header / topbar / nav / footer
     6. home.css     homepage compositions
     7. pages.css    inner pages

   Rules for every file after this one:
   - Never redefine a token here; consume it.
   - Never restyle `.btn*`, `h1..h4`, `.eyebrow`, `.section*` globally;
     scope any deviation under your own component class.
   ============================================================ */

/* ------------------------------------------------------------
   1. TOKENS — light
   ------------------------------------------------------------ */
:root,
html[data-theme="light"] {
  /* Brand ramp — cold cyan through deep ice blue */
  --brand-100: #e8f8fe;
  --brand-200: #c2ecfb;
  --brand-300: #7dd9f7;
  --brand-400: #2cc2f3;
  --brand-500: #00aeef;
  --brand-600: #0090c9;
  --brand-700: #00719f;
  --brand-800: #005a7e;
  --brand-900: #06384d;

  /* Neutral steel ramp */
  --steel-0: #ffffff;
  --steel-25: #f7fafc;
  --steel-50: #eef3f7;
  --steel-100: #e3eaf0;
  --steel-200: #d5dee6;
  --steel-300: #b8c5d0;
  --steel-400: #8b9aa8;
  --steel-500: #57627a;
  --steel-600: #39465c;
  --steel-700: #26314a;
  --steel-800: #1a2336;
  --steel-900: #0f172a;  /* night black — the project's darkest ink */
  --steel-950: #080e1a;

  /* Semantic surfaces */
  --surface-raised: #ffffff;
  --surface-sunken: #e6ecf4;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --surface-glass-strong: rgba(255, 255, 255, 0.88);
  --surface-invert: #0f172a;

  /* Hairlines & edges */
  --line-soft: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.17);
  --edge-top: rgba(255, 255, 255, 0.9);
  --edge-glow: rgba(0, 174, 239, 0.35);

  /* Signature gradients */
  --grad-brand: linear-gradient(120deg, #00aeef 0%, #22c9f5 45%, #6fe0ff 100%);
  --grad-brand-deep: linear-gradient(135deg, #0090c9 0%, #00aeef 55%, #55d7fb 100%);
  --grad-ice: linear-gradient(155deg, #ffffff 0%, #eaf6fc 45%, #d6edf8 100%);
  --grad-steel: linear-gradient(160deg, #1a2336 0%, #0f172a 60%, #141d33 100%);
  --grad-sheen: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.55) 46%,
    rgba(255, 255, 255, 0.85) 50%,
    rgba(255, 255, 255, 0.55) 54%,
    transparent 80%
  );
  --grad-hairline: linear-gradient(90deg, transparent, var(--brand-500) 35%, var(--brand-300) 60%, transparent);

  /* Elevation — cyan-tinted, layered */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm2: 0 2px 4px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 10px rgba(15, 23, 42, 0.06), 0 14px 32px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 8px 18px rgba(15, 23, 42, 0.07), 0 28px 60px rgba(15, 23, 42, 0.13);
  --shadow-xl: 0 14px 30px rgba(15, 23, 42, 0.09), 0 46px 96px rgba(15, 23, 42, 0.18);
  --shadow-brand: 0 10px 24px rgba(0, 174, 239, 0.25), 0 24px 60px rgba(0, 174, 239, 0.16);
  --shadow-inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.85);

  /* Focus */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand-500);

  /* Geometry */
  --chamfer: 16px;
  --chamfer-sm: 9px;
  --rule-w: 3px;

  /* Texture */
  --grain-opacity: 0.035;
  --mesh-1: rgba(0, 174, 239, 0.14);
  --mesh-2: rgba(109, 224, 255, 0.12);
  --mesh-3: rgba(15, 23, 42, 0.05);
}

/* ------------------------------------------------------------
   2. TOKENS — dark
   ------------------------------------------------------------ */
html[data-theme="dark"] {
  --brand-100: #06384d;
  --brand-200: #075873;
  --brand-300: #0a7ea6;
  --brand-400: #12a8d8;
  --brand-500: #1ad4ff;
  --brand-600: #4fe0ff;
  --brand-700: #8aeaff;
  --brand-800: #b9f3ff;
  --brand-900: #e3fbff;

  --surface-raised: #17203a;
  --surface-sunken: #0b1220;
  --surface-glass: rgba(15, 23, 42, 0.7);
  --surface-glass-strong: rgba(11, 18, 32, 0.92);
  --surface-invert: #eef2f5;

  --line-soft: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.16);
  --edge-top: rgba(255, 255, 255, 0.08);
  --edge-glow: rgba(26, 212, 255, 0.4);

  --grad-brand: linear-gradient(120deg, #0a7ea6 0%, #1ad4ff 50%, #8aeaff 100%);
  --grad-brand-deep: linear-gradient(135deg, #075873 0%, #12a8d8 55%, #4fe0ff 100%);
  --grad-ice: linear-gradient(155deg, #1a2438 0%, #131c30 50%, #0d1424 100%);
  --grad-steel: linear-gradient(160deg, #141d33 0%, #0b1220 60%, #0f172a 100%);
  --grad-sheen: linear-gradient(
    100deg,
    transparent 20%,
    rgba(26, 212, 255, 0.18) 46%,
    rgba(26, 212, 255, 0.34) 50%,
    rgba(26, 212, 255, 0.18) 54%,
    transparent 80%
  );
  --grad-hairline: linear-gradient(90deg, transparent, var(--brand-500) 35%, var(--brand-400) 60%, transparent);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm2: 0 2px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.42), 0 14px 32px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 8px 18px rgba(0, 0, 0, 0.46), 0 28px 60px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 14px 30px rgba(0, 0, 0, 0.5), 0 46px 96px rgba(0, 0, 0, 0.55);
  --shadow-brand: 0 10px 24px rgba(26, 212, 255, 0.2), 0 24px 60px rgba(26, 212, 255, 0.12);
  --shadow-inset-top: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --grain-opacity: 0.05;
  --mesh-1: rgba(26, 212, 255, 0.16);
  --mesh-2: rgba(0, 120, 170, 0.16);
  --mesh-3: rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------
   3. MOTION TOKENS
   Consumed by motion.css, chrome.css, home.css, pages.css.
   ------------------------------------------------------------ */
:root {
  --dur-1: 120ms;   /* micro: colour, opacity */
  --dur-2: 220ms;   /* control state change */
  --dur-3: 380ms;   /* component transition */
  --dur-4: 640ms;   /* entrance */
  --dur-5: 900ms;   /* hero / large surface */
  --dur-6: 1400ms;  /* ambient */

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);        /* default, = legacy --ease */
  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* slight overshoot */
  --ease-emphasis: cubic-bezier(0.2, 0.8, 0.2, 1);

  --stagger: 70ms;
}

/* ------------------------------------------------------------
   4. TOKEN BRIDGE — remap the legacy variables onto the new ramps
   so every existing rule inherits the refreshed palette.
   ------------------------------------------------------------ */
:root,
html[data-theme="light"] {
  --bg: #eaeff4;
  --surface: var(--steel-0);
  --surface-2: var(--steel-50);
  --text: var(--steel-900);
  --muted: var(--steel-500);
  --line: var(--steel-200);
  --accent: var(--brand-500);
  --accent-ink: var(--brand-600);
  --accent-soft: var(--brand-100);
  --accent-dark: var(--brand-700);
  --elev-1: var(--shadow-sm2);
  --elev-2: var(--shadow-md);
  --elev-3: var(--shadow-lg);
  --shadow: var(--shadow-md);
  --shadow-sm: var(--shadow-sm2);
  --header-bg: var(--surface-glass);
  --cta-band-bg: var(--grad-steel);
  --topbar-bg: var(--steel-900);
  --hero-ink: #f3f8fb;
}

html[data-theme="dark"] {
  --bg: #080e1a;
  --surface: var(--surface-raised);
  --surface-2: #131b30;
  --text: #edf2f6;
  --muted: #93a3b1;
  --line: #222d38;
  --accent: var(--brand-500);
  --accent-ink: var(--brand-500);
  --accent-soft: #0d2836;
  --accent-dark: var(--brand-400);
  --elev-1: var(--shadow-sm2);
  --elev-2: var(--shadow-md);
  --elev-3: var(--shadow-lg);
  --shadow: var(--shadow-md);
  --shadow-sm: var(--shadow-sm2);
  --header-bg: var(--surface-glass);
  --cta-band-bg: var(--grad-steel);
  --topbar-bg: var(--steel-950);
}

/* ------------------------------------------------------------
   5. TYPEFACE + FLUID TYPE SCALE

   ONE family, not two. The old pairing (Barlow Condensed display over
   Manrope body) read as two unrelated voices on the same page, and the
   condensed all-caps headline is a poster voice, not a corporate one.
   Inter carries the whole site: headings win their weight from size and
   weight, not from a second typeface.

   Case rule — the other half of "corporate":
     · headings (h1–h4, display)  sentence case, tight tracking
     · eyebrows, labels, buttons, nav, stat captions  UPPERCASE + wide
       tracking, and only at small sizes where caps stay legible.
   Never uppercase a heading again; the copy in lang/*.php is already
   written in sentence case for exactly this.

   Inter is wider than a condensed face, so every display step comes
   down a notch to keep the same measure.
   ------------------------------------------------------------ */
:root,
html[data-theme="light"],
html[data-theme="dark"] {
  --font-display: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

:root {
  --fs-display: clamp(2.5rem, 1.25rem + 4.4vw, 5rem);
  --fs-h1: clamp(2.1rem, 1.35rem + 2.6vw, 3.4rem);
  --fs-h2: clamp(1.7rem, 1.2rem + 1.75vw, 2.6rem);
  --fs-h3: clamp(1.22rem, 1.05rem + 0.7vw, 1.6rem);
  --fs-h4: clamp(1.04rem, 0.96rem + 0.34vw, 1.22rem);
  --fs-lead: clamp(1.02rem, 0.96rem + 0.3vw, 1.18rem);
  --fs-body: 1rem;
  --fs-sm: 0.9rem;
  --fs-xs: 0.79rem;
  --fs-micro: 0.72rem;

  /* Retuned for Inter: it sets looser than a condensed face, so display
     sizes need real negative tracking and caps need a touch less. */
  --track-display: -0.028em;
  --track-tight: -0.014em;
  --track-wide: 0.1em;
  --track-wider: 0.16em;
}

/* Inter's optical-size axis: let the browser pick the right cut per size. */
html {
  font-optical-sizing: auto;
}

body {
  font-size: 16px;
  line-height: 1.7;
  font-weight: 450;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(ellipse 60% 50% at 85% -8%, var(--mesh-1), transparent 60%),
    radial-gradient(ellipse 46% 42% at -8% 34%, var(--mesh-2), transparent 58%),
    radial-gradient(ellipse 70% 50% at 50% 108%, var(--mesh-3), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 60% 50% at 85% -8%, var(--mesh-1), transparent 60%),
    radial-gradient(ellipse 46% 42% at -8% 34%, var(--mesh-2), transparent 58%),
    radial-gradient(ellipse 70% 50% at 50% 108%, var(--mesh-3), transparent 62%),
    var(--bg);
  background-attachment: fixed;
}

h1,
.h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: var(--track-display);
  text-transform: none;
  text-wrap: balance;
}

h2,
.h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: var(--track-display);
  text-transform: none;
  text-wrap: balance;
}

h3,
.h3 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: 1.28;
  font-weight: 650;
  letter-spacing: var(--track-tight);
  text-transform: none;
}

h4 {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  line-height: 1.38;
  font-weight: 650;
  letter-spacing: -0.006em;
  text-transform: none;
}

p {
  text-wrap: pretty;
}

/* Eyebrow — now a bracketed micro-label with a leading rule */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.85rem;
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--track-wider);
  text-transform: uppercase;
  line-height: 1;
}

.eyebrow::before {
  content: "";
  width: 1.9rem;
  height: 2px;
  flex: none;
  background: var(--grad-brand);
  transform-origin: left;
}

.section-head {
  max-width: 46rem;
  margin-bottom: 2.75rem;
}

.section-lead {
  font-size: var(--fs-lead);
  line-height: 1.72;
  color: var(--muted);
  max-width: 58ch;
}

/* --- case reset for the frozen layers ------------------------------------
   styles.css sets `text-transform: uppercase` on the display headings and
   cannot be edited. These selectors match its specificity exactly and,
   loading later, win — so headings follow the sentence-case rule above
   everywhere, not just where theme.css owns the element. Small caps
   labels (eyebrows, models, nav, form legends, footer links) are
   deliberately left alone: caps at label size is the corporate idiom. */
.page-hero h1,
.hero h1,
.hero-title,
.hero-title-line,
.hero-title-accent,
.path-card h3,
.product-card h3,
.product-detail-body h1,
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.section-head h2,
.cta-band h2 {
  text-transform: none;
  letter-spacing: var(--track-display);
}

/* ------------------------------------------------------------
   6. SURFACE PRIMITIVES
   Utility classes the later layers compose with.
   ------------------------------------------------------------ */

/* Frosted panel */
.u-glass {
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-md), var(--shadow-inset-top);
}

/* Precision-engineered corner cut (top-left + bottom-right) */
.u-chamfer {
  clip-path: polygon(
    var(--chamfer) 0,
    100% 0,
    100% calc(100% - var(--chamfer)),
    calc(100% - var(--chamfer)) 100%,
    0 100%,
    0 var(--chamfer)
  );
}

.u-chamfer-sm {
  clip-path: polygon(
    var(--chamfer-sm) 0,
    100% 0,
    100% calc(100% - var(--chamfer-sm)),
    calc(100% - var(--chamfer-sm)) 100%,
    0 100%,
    0 var(--chamfer-sm)
  );
}

/* Gradient hairline separator */
.u-rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--grad-hairline);
}

/* Brand gradient text */
.u-grad-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Hollow display text (big numerals, watermark headings) */
.u-outline-text {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--line-strong);
}

/* Engineering grid backdrop — attach to a positioned element */
.u-grid-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 78%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 78%);
}

/* Fine film grain — attach to a positioned element */
.u-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Accent rule that draws in on reveal */
.u-accent-rule {
  display: block;
  width: 3.5rem;
  height: var(--rule-w);
  background: var(--grad-brand);
  transform-origin: left;
}

/* ------------------------------------------------------------
   7. BUTTON SYSTEM
   Owned here. Later layers must not restyle `.btn` globally.
   ------------------------------------------------------------ */
.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 1rem 1.7rem;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--grad-brand-deep);
  color: var(--steel-900);
  box-shadow: var(--shadow-sm2);
  transition:
    transform var(--dur-2) var(--ease-out),
    box-shadow var(--dur-3) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    filter var(--dur-2) var(--ease-out);
}

/* `--grad-brand-deep` bottoms out at #075873 in dark mode, which leaves the
   dark ink unreadable on the left half of a filled button. Outline buttons
   must keep their own colour here: this selector outranks `.btn-outline`. */
html[data-theme="dark"] .btn:not(.btn-outline) {
  background: linear-gradient(135deg, #12a8d8 0%, #35d2f7 55%, #8aeaff 100%);
  color: var(--steel-900);
}

html[data-theme="dark"] .btn-outline {
  color: var(--accent-ink);
}

html[data-theme="dark"] .btn-outline::before {
  background: linear-gradient(135deg, #12a8d8 0%, #35d2f7 55%, #8aeaff 100%);
}

/* Sheen that sweeps across on hover */
.btn::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  background: var(--grad-sheen);
  transform: translateX(-115%) skewX(-18deg);
  opacity: 0.65;
  transition: transform var(--dur-5) var(--ease-out);
}

.btn:hover::before,
.btn:focus-visible::before {
  transform: translateX(115%) skewX(-18deg);
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
  filter: saturate(1.08);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
  transition-duration: var(--dur-1);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-brand), var(--focus-ring);
}

/* Ghost / outline */
.btn-outline {
  background: transparent;
  color: var(--accent-ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn-outline::before {
  background: var(--grad-brand-deep);
  transform: translateX(0) skewX(0);
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out);
}

.btn-outline:hover,
.btn-outline:focus-visible {
  color: var(--steel-900);
  border-color: transparent;
  box-shadow: var(--shadow-brand);
}

.btn-outline:hover::before,
.btn-outline:focus-visible::before {
  opacity: 1;
  transform: none;
}

html[data-theme="dark"] .btn-outline:hover,
html[data-theme="dark"] .btn-outline:focus-visible {
  color: var(--steel-900);
}

.btn-small {
  padding: 0.66rem 1.05rem;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.btn-lg {
  padding: 1.15rem 2.2rem;
  font-size: 1rem;
}

/* Arrow affordance */
.btn-arrow::after {
  content: "→";
  display: inline-block;
  margin-left: 0.15rem;
  transition: transform var(--dur-3) var(--ease-spring);
}

.btn-arrow:hover::after,
.btn-arrow:focus-visible::after {
  transform: translateX(5px);
}

/* Text link with an underline that wipes in */
.link-underline {
  position: relative;
  color: var(--accent-ink);
  font-weight: 700;
}

.link-underline::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--dur-3) var(--ease-out);
}

.link-underline:hover::after,
.link-underline:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ------------------------------------------------------------
   8. FOCUS & SELECTION
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--brand-500);
  color: var(--steel-900);
}

/* ------------------------------------------------------------
   9. SECTION RHYTHM
   ------------------------------------------------------------ */
.section {
  position: relative;
  padding: clamp(4rem, 7vw, 7rem) 0;
}

.section--spacious {
  padding: clamp(5.5rem, 9vw, 9.5rem) 0;
}

.section--compact {
  padding: clamp(2.75rem, 4.5vw, 4.25rem) 0;
}

.section--alt {
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--surface-2);
}

.container {
  width: min(var(--container), calc(100% - 3rem));
}

@media (min-width: 1400px) {
  :root {
    --container: 1280px;
  }
}
