/* ==========================================================================
   PESU — Foundation layer
   Design tokens, reset, typographic system, motion primitives, utilities.
   Everything downstream (components, home, product) composes from here.
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */
:root {
  /* Surface & ink — warm, never pure black or pure white */
  --ink:            #12100E;
  --ink-2:          #1B1815;
  --ink-3:          #262119;
  --basalt:         #3A342C;
  --alabaster:      #F7F3ED;
  --gypsum:         #EFE8DD;
  --dune:           #DCCEBB;
  --sand:           #C6B49A;

  /* Accents — metal, clay, shade */
  --gilt:           #B08D4F;
  --gilt-soft:      #D6BC8B;
  --gilt-deep:      #8A6C36;
  --clay:           #A9765A;
  --palm:           #38402F;

  /* Semantic roles (light section default) */
  --bg:             var(--alabaster);
  --fg:             var(--ink);
  --fg-muted:       rgba(18, 16, 14, 0.58);
  --fg-faint:       rgba(18, 16, 14, 0.34);
  --line:           rgba(18, 16, 14, 0.14);
  --line-soft:      rgba(18, 16, 14, 0.08);
  --accent:         var(--gilt-deep);

  /* Type */
  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-sans:    "Jost", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --step--2: clamp(0.66rem, 0.63rem + 0.14vw, 0.74rem);
  --step--1: clamp(0.78rem, 0.75rem + 0.16vw, 0.88rem);
  --step-0:  clamp(0.94rem, 0.90rem + 0.20vw, 1.06rem);
  --step-1:  clamp(1.15rem, 1.06rem + 0.42vw, 1.42rem);
  --step-2:  clamp(1.45rem, 1.25rem + 0.95vw, 2.10rem);
  --step-3:  clamp(1.95rem, 1.55rem + 1.90vw, 3.10rem);
  --step-4:  clamp(2.60rem, 1.85rem + 3.55vw, 4.60rem);
  --step-5:  clamp(3.30rem, 1.90rem + 6.60vw, 7.20rem);

  --tracking-wide:  0.22em;
  --tracking-wider: 0.42em;

  /* Space — an 8pt rhythm with fluid section gutters */
  --sp-1: 0.5rem;  --sp-2: 0.75rem; --sp-3: 1rem;   --sp-4: 1.5rem;
  --sp-5: 2rem;    --sp-6: 3rem;    --sp-7: 4.5rem; --sp-8: 7rem;
  --section-y: clamp(5rem, 3rem + 9vw, 11rem);
  --gutter:    clamp(1.25rem, 0.6rem + 3.2vw, 4.5rem);
  --measure:   62ch;
  --shell:     1560px;

  /* Motion — one easing curve for the whole house */
  --ease:      cubic-bezier(0.16, 1, 0.30, 1);
  --ease-io:   cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast:  260ms;
  --dur:       620ms;
  --dur-slow:  1100ms;

  --header-h: 84px;
}

/* Dark inversion — applied per-section, not per-page */
.on-dark {
  --bg:        var(--ink);
  --fg:        var(--alabaster);
  --fg-muted:  rgba(247, 243, 237, 0.60);
  --fg-faint:  rgba(247, 243, 237, 0.32);
  --line:      rgba(247, 243, 237, 0.16);
  --line-soft: rgba(247, 243, 237, 0.08);
  --accent:    var(--gilt-soft);
  background: var(--bg);
  color: var(--fg);
}

/* --- 2. Reset ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-weight: 300;
  line-height: 1.65;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

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

ul, ol { list-style: none; padding: 0; }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

::selection { background: var(--gilt); color: var(--alabaster); }

/* --- 3. Typography ------------------------------------------------------ */
.display {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.display--xl { font-size: var(--step-5); }
.display--l  { font-size: var(--step-4); }
.display--m  { font-size: var(--step-3); }
.display--s  { font-size: var(--step-2); }

.display em {
  font-style: italic;
  font-weight: 300;
}

.eyebrow {
  font-size: var(--step--2);
  font-weight: 400;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
}
.eyebrow::before {
  content: "";
  width: 2.25rem;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}
.eyebrow--bare::before { display: none; }

.lede {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--fg-muted);
  max-width: 46ch;
  font-weight: 300;
}

.prose { max-width: var(--measure); color: var(--fg-muted); }
.prose p + p { margin-top: 1.15em; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --- 4. Layout ---------------------------------------------------------- */
.shell {
  width: min(100% - var(--gutter) * 2, var(--shell));
  margin-inline: auto;
}
.shell--narrow { width: min(100% - var(--gutter) * 2, 1080px); }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(3rem, 2rem + 5vw, 6rem); }
.section--flush-top { padding-top: 0; }

.grid { display: grid; gap: var(--sp-6); }
.rule { height: 1px; background: var(--line); border: 0; }

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-5); }

.visually-hidden {
  position: absolute !important;
  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;
  top: 0; left: 50%;
  transform: translate(-50%, -120%);
  z-index: 999;
  background: var(--ink);
  color: var(--alabaster);
  padding: 0.85rem 1.5rem;
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* --- 5. Material surfaces ----------------------------------------------
   Stand-ins for commissioned photography. Each surface is a layered
   gradient stack + an SVG-filtered grain overlay, so nothing depends on a
   binary asset and every swatch can be re-tinted from a single custom prop.
   ----------------------------------------------------------------------- */
.surface {
  position: relative;
  overflow: hidden;
  background: var(--surface-base, var(--dune));
  isolation: isolate;
}
/* A single photographic light pass, so every material sits in the same room */
.surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 85% at 18% 6%, rgba(255,255,255,0.22), transparent 55%),
    linear-gradient(196deg, transparent 55%, rgba(24,20,16,0.16));
}

.surface::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: var(--grain, 0.22);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 2;
}

/* Named materials — used by swatches, cards and the configurator preview */
.mat-travertine {
  --surface-base: #E3D8C6;
  --grain: 0.24;
  background-image:
    radial-gradient(120% 60% at 16% 8%,  rgba(255,253,247,.72), transparent 58%),
    radial-gradient(70% 55% at 76% 30%,  rgba(255,250,240,.40), transparent 60%),
    radial-gradient(90% 60% at 84% 88%,  rgba(146,124,94,.30),  transparent 62%),
    radial-gradient(60% 40% at 38% 66%,  rgba(168,146,114,.16), transparent 64%),
    repeating-linear-gradient(183deg,
      rgba(255,252,244,.10) 0 2px, transparent 2px 5px,
      rgba(150,128,98,.055) 5px 7px, transparent 7px 13px),
    linear-gradient(168deg, #EDE4D3, #CFBEA3);
}
.mat-oak {
  --surface-base: #9E7A52;
  --grain: 0.26;
  background-image:
    radial-gradient(120% 60% at 18% 6%, rgba(255,232,198,.34), transparent 60%),
    repeating-linear-gradient(91deg, rgba(60,38,18,.13) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(89deg, rgba(255,226,186,.10) 0 1px, transparent 1px 17px),
    repeating-linear-gradient(90deg, rgba(60,38,18,.07) 0 9px, transparent 9px 34px),
    linear-gradient(152deg, #B58F61, #795734);
}
.mat-alabaster {
  --surface-base: #F0E9DC;
  --grain: 0.10;
  background-image:
    radial-gradient(85% 65% at 26% 14%, rgba(255,255,255,.96), transparent 66%),
    radial-gradient(60% 80% at 84% 86%, rgba(206,180,132,.34), transparent 62%),
    radial-gradient(120% 40% at 50% 50%, rgba(255,250,240,.5), transparent 70%),
    linear-gradient(140deg, #F8F3E9, #DCD1BD);
}
.mat-brass {
  --surface-base: #B08D4F;
  --grain: 0.12;
  background-image:
    linear-gradient(112deg, rgba(255,244,214,.55) 0 6%, transparent 22%, rgba(255,244,214,.22) 38%, transparent 58%),
    repeating-linear-gradient(104deg,
      rgba(255,240,204,.20) 0 1px, transparent 1px 3px,
      rgba(90,66,26,.16) 3px 4px, transparent 4px 8px),
    linear-gradient(154deg, #E7CE96 0%, #B08D4F 34%, #7C5F28 58%, #C8A768 78%, #8E6F35 100%);
}
.mat-basalt {
  --surface-base: #3A342C;
  --grain: 0.30;
  background-image:
    radial-gradient(90% 55% at 24% 10%, rgba(255,255,255,.13), transparent 62%),
    radial-gradient(70% 60% at 82% 88%, rgba(0,0,0,.28), transparent 60%),
    linear-gradient(152deg, #494136, #201C17);
}
.mat-boucle {
  --surface-base: #D9CDB9;
  --grain: 0.34;
  background-image:
    radial-gradient(circle at 28% 28%, rgba(255,255,255,.34) 0 22%, transparent 24%),
    radial-gradient(circle at 66% 62%, rgba(126,106,80,.16) 0 20%, transparent 22%),
    radial-gradient(120% 70% at 16% 6%, rgba(255,252,244,.55), transparent 62%),
    linear-gradient(142deg, #E6DCCC, #C2B199);
  background-size: 9px 9px, 13px 13px, 100% 100%, 100% 100%;
}
.mat-clay {
  --surface-base: #A9765A;
  background-image:
    radial-gradient(90% 70% at 25% 20%, rgba(255,236,220,.55), transparent 60%),
    linear-gradient(150deg, #B98166, #7E523B);
}

/* --- 6. Motion ---------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition:
    opacity var(--dur-slow) var(--ease),
    transform var(--dur-slow) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* Line-by-line mask reveal for display copy */
.line-mask { display: block; overflow: hidden; }
.line-mask > span {
  display: block;
  transform: translate3d(0, 110%, 0);
  transition: transform var(--dur-slow) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.is-in .line-mask > span,
.line-mask.is-in > span { transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
  .line-mask > span { transform: none; }
}
