/* ============================================================
   Savyio product pages — shared base
   Layout primitives, chrome, and the motion system.
   Colour/type tokens are defined per page in its own page.css,
   so this file never hardcodes a palette.
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* Belt and braces: decorative glows and mid-animation offsets must never
     be able to widen the page. `clip` (unlike `hidden`) does not create a
     scroll container, so position: sticky on the nav keeps working. */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
}

p { margin: 0; }
img, svg { display: block; max-width: 100%; }

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

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

[id] { scroll-margin-top: calc(var(--nav-h) + 20px); }

/* ---------- Layout primitives ---------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--side-pad);
}

.container--wide { max-width: var(--maxw-wide); }

.section { padding-block: var(--section-pad); position: relative; }
.section--alt { background: var(--bg-alt); }

.section-head {
  max-width: 720px;
  margin-bottom: var(--s-12);
}
.section-head--center {
  margin-inline: auto;
  text-align: center;
}

.section-head h2 {
  font-size: var(--fs-h2);
  margin-block: var(--s-4) var(--s-5);
}

.lead {
  color: var(--text-secondary);
  font-size: 1.125rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.accent { color: var(--accent); }

.grad {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 13px 24px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-primary:active { background: var(--accent-press); transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent-border);
  background: var(--accent-dim);
  transform: translateY(-2px);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}

.link-quiet {
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 1px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.link-quiet:hover { color: var(--accent); border-color: var(--accent-border); }

/* ---------- Status pill ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px 13px 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- Nav ---------- */

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -60px;
  z-index: 100;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-small);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus-visible { top: var(--s-4); }

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-6);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: auto;
}
.nav-brand img { width: 26px; height: 26px; border-radius: 6px; }
.nav-brand .sep { color: var(--text-tertiary); font-weight: 300; }
.nav-brand .prod { color: var(--accent); }

.nav-menu {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-menu a {
  color: var(--text-secondary);
  font-size: 0.925rem;
  transition: color var(--dur-fast) var(--ease);
}
.nav-menu a:hover { color: var(--text); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: var(--s-12);
  background: var(--bg-alt);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  align-items: center;
  justify-content: space-between;
  color: var(--text-tertiary);
  font-size: var(--fs-small);
}
.footer-links {
  display: flex;
  gap: var(--s-6);
  flex-wrap: wrap;
}
.footer-links a { transition: color var(--dur-fast) var(--ease); }
.footer-links a:hover { color: var(--accent); }

/* ---------- Cards / tiles ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-5);
}

.tile {
  position: relative;
  padding: var(--s-6);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tile:hover { border-color: var(--border-strong); background: var(--surface-2); }

/* Cursor spotlight — JS writes --mx/--my */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
  background: radial-gradient(
    340px circle at var(--mx, 50%) var(--my, 50%),
    var(--accent-dim),
    transparent 65%
  );
}
.tile:hover::before { opacity: 1; }

.tile > * { position: relative; }

.tile-glyph {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent-border);
  background: var(--accent-dim);
  margin-bottom: var(--s-4);
}
.tile-glyph svg {
  width: 19px;
  height: 19px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.6;
}

.tile h3 {
  font-size: var(--fs-h3);
  margin-bottom: var(--s-2);
}
.tile p {
  color: var(--text-secondary);
  font-size: var(--fs-small);
}

/* ---------- Alternating feature rows ---------- */

.step-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-16);
  align-items: center;
  padding-block: var(--s-12);
}
.step-row--flip .step-copy { order: 2; }
.step-row--flip .step-visual { order: 1; }

.step-num {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-wide);
  color: var(--accent);
  margin-bottom: var(--s-3);
}
.step-copy h3 {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  margin-bottom: var(--s-4);
}
.step-copy p { color: var(--text-secondary); }

.frame {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-shot);
  overflow: hidden;
}

/* ---------- FAQ ---------- */

.faq-list {
  max-width: 780px;
  margin-inline: auto;
  border-top: 1px solid var(--border);
}
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
  position: relative;
  cursor: pointer;
  list-style: none;
  padding: var(--s-5) var(--s-10) var(--s-5) 0;
  font-weight: 550;
  transition: color var(--dur-fast) var(--ease);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: var(--accent); }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: var(--s-2);
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 400;
  transition: transform var(--dur) var(--ease);
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq-item p {
  color: var(--text-secondary);
  font-size: var(--fs-small);
  padding-bottom: var(--s-5);
  max-width: 68ch;
}

/* ---------- Final CTA ---------- */

.cta-final { text-align: center; }
.cta-final h2 {
  font-size: var(--fs-h2);
  margin-bottom: var(--s-4);
}
.cta-final .lead {
  margin-inline: auto;
  max-width: 560px;
  margin-bottom: var(--s-8);
}
.cta-final .btn-row { justify-content: center; }

/* ============================================================
   MOTION
   Reveals are gated on html.js so a no-JS visitor never sees
   a blank page — nothing is hidden unless JS can un-hide it.
   ============================================================ */

html.js .reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 760ms var(--ease) var(--d, 0ms),
              transform 760ms var(--ease) var(--d, 0ms);
}
html.js .reveal.in-view {
  opacity: 1;
  transform: none;
}

html.js .reveal--left  { transform: translate3d(-36px, 12px, 0); }
html.js .reveal--right { transform: translate3d(36px, 12px, 0); }
html.js .reveal--scale { transform: translateY(30px) scale(0.965); }
html.js .reveal--rise  { transform: translateY(56px); }

html.js .reveal--left.in-view,
html.js .reveal--right.in-view,
html.js .reveal--scale.in-view,
html.js .reveal--rise.in-view { transform: none; }

/* Scroll-linked drift. JS writes --pz on the child so the wrapper
   keeps ownership of the reveal transform and the two never fight. */
html.js [data-parallax] {
  transform: translate3d(0, var(--pz, 0px), 0);
  will-change: transform;
}

/* ---------- Reduced motion: content must end fully visible ---------- */

@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;
  }
  html.js .reveal,
  html.js [data-parallax] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
  .step-row {
    grid-template-columns: 1fr;
    gap: var(--s-8);
  }
  .step-row--flip .step-copy { order: 1; }
  .step-row--flip .step-visual { order: 2; }

  /* Once columns stack there is no room for a sideways entrance — the
     36px offset would push the page wider than the viewport. Come in
     vertically instead. */
  html.js .reveal--left,
  html.js .reveal--right { transform: translateY(30px); }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav-menu {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-5);
    padding: var(--s-5) var(--side-pad) var(--s-6);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .nav-menu.is-open { display: flex; }
  .tile-grid { grid-template-columns: 1fr; }
  .footer-inner { justify-content: center; text-align: center; }
}
