/* ============================================================
   SABLE — precision desktop hi-fi
   Style register: "Steve Jobs" — systematic, light, restrained.
   Signature: blueprint / precision-instrument language.
   Demo build for the Stack Studios portfolio.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* colour — warm gallery paper tuned to the product photography, one rationed accent */
  --paper:    #F1EDE6;   /* matches the studio-shot background so product floats seamlessly */
  --paper-2:  #EAE6DD;
  --mist:     #E4DFD5;
  --ink:      #16161A;
  --ink-soft: #33353B;
  --graphite: #6A6B67;
  --hairline: rgba(22, 22, 26, 0.10);
  --hairline-2: rgba(22, 22, 26, 0.05);
  --cobalt:   #2447F5;   /* blueprint accent — measurement lines, focus, live cursor ONLY */
  --sig:      var(--cobalt);                                  /* Stack Studios signature — the demo's own accent */
  --sig-line: color-mix(in srgb, var(--sig) 55%, transparent);

  /* type — Geist superfamily: clean, modern, technical-premium */
  --display: "Geist", system-ui, -apple-system, sans-serif;
  --body:    "Geist", system-ui, -apple-system, sans-serif;
  --mono:    "Geist Mono", ui-monospace, "SF Mono", monospace;

  /* spacing — spacious scale */
  --s-1: 8px;  --s-2: 16px; --s-3: 24px; --s-4: 40px;
  --s-5: 64px; --s-6: 96px; --s-7: 140px;
  --section: clamp(96px, 12vw, 200px);
  --gutter: clamp(20px, 5vw, 48px);
  --maxw: 1200px;

  --speed: 480ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* studio house curve — shared across the demos (part of the signature) */
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 500; letter-spacing: -0.03em; line-height: 1.02; }
p { margin: 0; }
::selection { background: var(--cobalt); color: #fff; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section); }
.rule { border: 0; border-top: 1px solid var(--hairline-2); margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px;
}
.skip-link:focus { left: 8px; }

/* ---------- Type scale ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--graphite);
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 22px; height: 1px; background: var(--cobalt); display: inline-block;
}
.display-xl { font-size: clamp(2.9rem, 9vw, 7.5rem); font-weight: 500; }
.display-l  { font-size: clamp(2.2rem, 6vw, 4.6rem); font-weight: 500; }
.display-m  { font-size: clamp(1.7rem, 3.6vw, 2.9rem); font-weight: 500; }
.lede { font-size: clamp(1.05rem, 1.6vw, 1.32rem); line-height: 1.55; color: var(--ink-soft); max-width: 40ch; }
.muted { color: var(--graphite); }
.measure { max-width: 62ch; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-family: var(--display); font-weight: 600; font-size: 1.12rem; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.brand-mark { flex: none; color: var(--ink); }
.brand-mark rect { transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
  .brand:hover .brand-mark rect { animation: eq 1000ms ease-in-out infinite; }
  .brand:hover .brand-mark rect:nth-child(1) { animation-delay: 120ms; }
  .brand:hover .brand-mark rect:nth-child(2) { animation-delay: 0ms; }
  .brand:hover .brand-mark rect:nth-child(3) { animation-delay: 200ms; }
  .brand:hover .brand-mark rect:nth-child(4) { animation-delay: 80ms; }
  @keyframes eq { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.5); } }
}
.nav-links { display: flex; gap: var(--s-4); align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-links a { font-size: 0.92rem; color: var(--ink-soft); position: relative; padding-block: 4px; transition: color 200ms; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1px; width: 0; background: var(--cobalt);
  transition: width 240ms var(--ease);
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after { width: 100%; }
/* nav CTA button — higher specificity than `.nav-links a` so its light text wins on the dark pill */
.nav-links a.btn-primary { color: var(--paper); padding-block: 12px; }
.nav-links a.btn-primary:hover, .nav-links a.btn-primary[aria-current="page"] { color: var(--paper); }
.nav-links a.btn-primary::after { display: none; }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 1.5px; background: var(--ink); margin: 5px 0; transition: transform 240ms, opacity 240ms; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--body); font-size: 0.95rem; font-weight: 500;
  padding: 14px 26px; border-radius: 100px; border: 1px solid transparent;
  transition: transform 160ms var(--ease), background 200ms, color 200ms, border-color 200ms;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; transform: translateY(-1px); }
.btn:active, .btn-primary:active, .nav-toggle:active, .nav-links a:active { transform: scale(0.97); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
.btn-ghost:hover { border-color: var(--ink); }
.btn .arrow { transition: transform 220ms var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

/* focus — cobalt ring, never removed */
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; border-radius: 3px; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(48px, 8vw, 96px); padding-bottom: var(--section); overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: var(--s-5); align-items: center; }
.hero h1 { margin-top: var(--s-3); }
.hero .lede { margin-top: var(--s-3); }
.hero-cta { margin-top: var(--s-4); display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- The Sable One — pure CSS render ---------- */
.stage { position: relative; aspect-ratio: 1 / 1.05; display: grid; place-items: center; }
.device {
  position: relative; width: 60%; aspect-ratio: 1 / 1.6;
  display: flex; flex-direction: column;
  filter: drop-shadow(0 40px 60px rgba(19,20,23,0.16));
}
.device-cap {
  height: 14%; border-radius: 46% 46% 8% 8% / 60% 60% 8% 8%;
  background: linear-gradient(150deg, #e8e9e5 0%, #c9cbc4 40%, #eceee8 60%, #b9bcb4 100%);
  border: 1px solid rgba(19,20,23,0.10);
}
.device-body {
  flex: 1; margin-top: -1px;
  background:
    repeating-linear-gradient(115deg, rgba(19,20,23,0.055) 0 1.5px, transparent 1.5px 4px),
    linear-gradient(150deg, #34363b 0%, #17181b 55%, #26282d 100%);
  border-radius: 4px 4px 12px 12px;
  position: relative;
}
.device-body::after {
  /* soft top light */
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(160deg, rgba(255,255,255,0.10), transparent 45%);
}
.device-cap.bottom {
  height: 6%; border-radius: 8% 8% 40% 40% / 8% 8% 70% 70%;
  background: linear-gradient(150deg, #c9cbc4, #eceee8 60%, #b9bcb4);
}
/* dimension annotations (blueprint signature) */
.dim { position: absolute; font-family: var(--mono); font-size: 0.68rem; color: var(--cobalt); letter-spacing: 0.02em; }
.dim-line { position: absolute; background: var(--cobalt); opacity: 0.85; }
.dim-h { height: 1px; top: 50%; }
.dim-v { width: 1px; right: 8%; }
.dim-tick { position: absolute; width: 1px; height: 9px; background: var(--cobalt); top: -4px; }

/* draw-in animation */
.draw { transform-origin: left center; }
@media (prefers-reduced-motion: no-preference) {
  .draw { animation: draw 900ms var(--ease) both; }
  .draw-2 { animation-delay: 140ms; }
  .draw-3 { animation-delay: 260ms; }
  @keyframes draw { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 0.85; } }
  /* hidden state only applies when JS is present (html.js), so no-JS users always see content */
  .js .fade-up { opacity: 0; transform: translateY(18px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); }
  .js .fade-up.in { opacity: 1; transform: none; }

  /* Hero load choreography — a single orchestrated moment on first paint */
  /* Note: the hero h1 is intentionally omitted here — it is driven by the
     signature's sig-mask/sig-rise reveal instead, so it doesn't double-animate. */
  .js .hero .eyebrow, .js .hero .lede, .js .hero .hero-cta, .js .hero .stage-photo {
    opacity: 0; transform: translateY(24px);
    transition: opacity 850ms var(--ease), transform 850ms var(--ease);
  }
  .js .hero.loaded .eyebrow    { opacity: 1; transform: none; transition-delay: 60ms; }
  .js .hero.loaded .lede       { opacity: 1; transform: none; transition-delay: 320ms; }
  .js .hero.loaded .hero-cta   { opacity: 1; transform: none; transition-delay: 460ms; }
  .js .hero.loaded .stage-photo{ opacity: 1; transform: none; transition-delay: 240ms; }
}

/* ---------- Photographic media ---------- */
.stage-photo {
  position: relative; border-radius: 18px; overflow: hidden;
  aspect-ratio: 4 / 5; background: transparent;
  perspective: 1000px;
  transition: box-shadow 400ms var(--ease);
}
.stage-photo:hover { box-shadow: 0 30px 80px rgba(22,22,26,0.10); }
.stage-photo .tilt { width: 100%; height: 100%; transition: transform 260ms var(--ease); will-change: transform; transform: scale(1.06); transform-origin: center; }
.stage-photo img { width: 100%; height: 100%; object-fit: cover; }
#preview-img { transition: opacity 280ms var(--ease); }
.feature-media img, .band-media img { transition: transform 700ms var(--ease); }
.feature-media:hover img, .band-media:hover img { transform: scale(1.04); }
/* one restrained blueprint annotation, over empty background — the signature */
.hero-dim { position: absolute; top: 10%; bottom: 10%; right: 16px; width: 1px; background: var(--cobalt); opacity: 0.85; transform-origin: top center; }
.hero-dim::before, .hero-dim::after { content: ""; position: absolute; right: -4px; width: 9px; height: 1px; background: var(--cobalt); }
.hero-dim::before { top: 0; } .hero-dim::after { bottom: 0; }
.hero-dim span {
  position: absolute; top: 50%; right: 5px; transform: translateY(-50%) rotate(90deg); transform-origin: right center;
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.04em; color: var(--cobalt);
  background: #efece4; padding: 1px 5px; white-space: nowrap;
}
@media (prefers-reduced-motion: no-preference) {
  .hero-dim { animation: drawv 1000ms var(--ease) 200ms both; }
  @keyframes drawv { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 0.85; } }
}
.feature-media { padding: 0; }
.feature-media img { width: 100%; height: 100%; object-fit: cover; }
.band-media { border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; background: transparent; }
.band-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait { border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; background: var(--mist); margin-bottom: var(--s-3); }
.portrait img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Spec strip ---------- */
.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: transparent; }
.spec { background: transparent; padding: var(--s-3) var(--s-4) var(--s-3) 0; }
.spec + .spec { border-left: 1px solid var(--hairline-2); padding-left: var(--s-4); }
.spec .n { font-family: var(--mono); font-size: clamp(1.8rem, 3.4vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.spec .n small { font-size: 0.42em; font-weight: 400; color: var(--graphite); margin-left: 4px; }
.spec .k { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--graphite); margin-top: 10px; }

/* ---------- Feature rows ---------- */
.feature { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); align-items: center; }
.feature.rev .feature-media { order: -1; }
.feature-media {
  aspect-ratio: 4 / 3; border-radius: 14px;
  background: linear-gradient(135deg, var(--paper-2), var(--mist));
  position: relative; overflow: hidden; display: grid; place-items: center;
}
.feature-media .glyph { width: 44%; opacity: 0.9; }
.feature h3 { margin-bottom: var(--s-2); }

/* ---------- Section header ---------- */
.sec-head { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4); align-items: end; margin-bottom: var(--s-5); }
.sec-head .display-l { max-width: 16ch; }

/* ---------- Big statement ---------- */
.statement { text-align: center; }
.statement .display-l { max-width: 20ch; margin-inline: auto; }

/* ---------- Tech table ---------- */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table tr { border-top: 1px solid var(--hairline); }
.spec-table tr:last-child { border-bottom: 1px solid var(--hairline); }
.spec-table th, .spec-table td { text-align: left; padding: var(--s-3) 0; vertical-align: top; font-weight: 400; }
.spec-table th { width: 34%; color: var(--graphite); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }
.spec-table td { font-size: 1.02rem; font-variant-numeric: tabular-nums; }

/* ---------- Buy ---------- */
.buy-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: var(--s-6); align-items: start; }
.option { border: 1px solid var(--hairline); border-radius: 10px; padding: var(--s-3); display: flex; gap: var(--s-3); align-items: center; cursor: pointer; transition: border-color 200ms; margin-bottom: var(--s-2); }
.option:hover { border-color: var(--ink-soft); }
.option input { accent-color: var(--cobalt); width: 18px; height: 18px; }
.option .swatch { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--hairline); }
.option .price { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.price-total { font-family: var(--mono); font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--hairline); padding-block: var(--s-6) var(--s-4); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--s-4); }
.footer h4 { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--graphite); font-weight: 400; margin-bottom: var(--s-2); }
.footer nav a { display: block; padding: 6px 0; color: var(--ink-soft); font-size: 0.92rem; }
.footer nav a:hover { color: var(--ink); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: var(--s-5); padding-top: var(--s-3); border-top: 1px solid var(--hairline); flex-wrap: wrap; gap: var(--s-2); }
.footer-bottom, .footer-bottom a { font-size: 0.82rem; color: var(--graphite); }
.demo-flag {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--graphite); border: 1px solid var(--hairline); border-radius: 100px; padding: 5px 12px;
}

/* ---------- Breadcrumb / page hero ---------- */
.page-hero { padding-top: var(--s-6); }
.crumbs { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.1em; color: var(--graphite); text-transform: uppercase; margin-bottom: var(--s-3); }
.crumbs a:hover { color: var(--ink); }

/* ============================================================
   STACK STUDIOS SIGNATURE — recurring craft, in this demo's own
   accent (--sig). Seam hairline · one orchestrated first-load
   moment · footer mark · press feedback. Style-agnostic by design.
   ============================================================ */
.sig-kicker { display:inline-flex; align-items:center; gap:14px; }
.sig-seam   { display:inline-block; width:34px; height:1px; background:var(--sig); transform-origin:left center; flex:none; }
.sig-mask   { display:block; overflow:hidden; padding-block:.12em; margin-block:-.12em; }
.sig-rule   { display:flex; align-items:center; gap:16px; }
.sig-rule::after { content:""; flex:1; height:1px; background:var(--sig-line); }
.sig-credit  { display:inline-flex; align-items:center; gap:9px; }
.sig-emblem  { width:15px; height:15px; color:var(--sig); flex:none; }
/* sable's .eyebrow paints its own leading ::before hairline — suppress it on the
   hero kicker so the animated sig-seam is the single leading line (no doubled rule). */
.eyebrow.sig-kicker::before { content:none; }

@media (prefers-reduced-motion: no-preference){
  /* First-load choreography — pure CSS, plays on load once the inline <head>
     bootstrap adds `.js` (synchronous, before first paint). Gated on `.js`, NOT
     `.hero.loaded`: sable's script sets window.__enh which suppresses the
     bootstrap's `.loaded`, so the signature can't depend on it. With JS off or
     reduced motion the rules simply don't apply and all content is fully visible.
     Seam draws → headline rises from its mask → hero items stagger up. */
  .js .sig-seam      { animation:sig-draw .70s var(--ease) .12s both; }
  .js .sig-mask > h1 { animation:sig-rise .85s var(--ease) .18s both; }
  .js .sig-hero      { animation:sig-up   .60s var(--ease) both; }
  .js .sig-d1 { animation-delay:.08s; }
  .js .sig-d2 { animation-delay:.30s; }
  .js .sig-d3 { animation-delay:.40s; }
  @keyframes sig-draw { from{transform:scaleX(0);}        to{transform:scaleX(1);} }
  @keyframes sig-rise { from{transform:translateY(118%);} to{transform:translateY(0);} }
  @keyframes sig-up   { from{opacity:0;transform:translateY(20px);} to{opacity:1;transform:none;} }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero-grid, .feature, .buy-grid { grid-template-columns: 1fr; }
  .feature.rev .feature-media { order: 0; }
  .sec-head { grid-template-columns: 1fr; gap: var(--s-2); }
  .specs { grid-template-columns: repeat(2, 1fr); gap: var(--s-2) 0; }
  .spec + .spec { border-left: 0; padding-left: 0; }
  .spec:nth-child(even) { border-left: 1px solid var(--hairline-2); padding-left: var(--s-4); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--s-4) var(--s-3); }
  .stage { max-width: 380px; margin-inline: auto; }
  .nav-links {
    position: fixed; inset: 60px 0 auto 0; background: var(--paper);
    flex-direction: column; align-items: flex-start; gap: 0; padding: var(--s-2) var(--gutter) var(--s-3);
    border-bottom: 1px solid var(--hairline); transform: translateY(-120%); transition: transform 300ms var(--ease);
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links li { width: 100%; border-top: 1px solid var(--hairline-2); }
  .nav-links a { display: block; padding: 14px 0; font-size: 1.05rem; }
  .nav-toggle { display: block; }
  .nav-links .btn { margin-top: var(--s-2); }
}
@media (max-width: 520px) {
  .specs { grid-template-columns: 1fr; }
  .spec:nth-child(even) { border-left: 0; padding-left: 0; }
  .spec + .spec { border-top: 1px solid var(--hairline-2); padding-top: var(--s-2); }
  .footer-grid { grid-template-columns: 1fr; }
}
