/* ==========================================================================
   Contessa — base: tokens, reset, typography, themes, buttons, forms
   ========================================================================== */

:root {
  /* Palette */
  --porcelain: #F2E8E5;
  --porcelain-2: #E9DBD6;
  --ink: #110D0F;
  --ink-2: #1D1719;
  --ink-3: #2A2225;
  --lacquer: #7B1428;
  --lacquer-hi: #9C1E36;
  --nude: #D8B7AC;
  --pearl: #C8C2D3;
  --bone: #FFFCFA;
  --muted-light: #6F605D;
  --muted-dark: #A99D9B;
  --chrome: linear-gradient(115deg, #f7f2f6 0%, #c9c3d6 22%, #fdf6f1 40%, #b8b3c7 58%, #efe6ee 76%, #cfc8d8 100%);

  /* Type */
  --f-display: 'Bodoni Moda', 'Didot', 'Bodoni 72', Georgia, serif;
  --f-sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --fs-mast: clamp(4.6rem, 1.2rem + 17vw, 19.5rem);
  --fs-h1: clamp(2.7rem, 1.4rem + 5.4vw, 7rem);
  --fs-h2: clamp(2.1rem, 1.3rem + 3.4vw, 4.6rem);
  --fs-h3: clamp(1.35rem, 1.1rem + 1vw, 2rem);
  --fs-lead: clamp(1.1rem, 1rem + 0.45vw, 1.35rem);
  --fs-body: clamp(1rem, 0.96rem + 0.18vw, 1.1rem);
  --fs-small: 0.875rem;
  --fs-label: 0.72rem;

  /* Space — deliberately uneven rhythm */
  --gutter: clamp(1rem, 0.6rem + 2.2vw, 2.75rem);
  --space-2xl: clamp(7rem, 4rem + 10vw, 14rem);
  --space-xl: clamp(5rem, 3rem + 6vw, 9rem);
  --space-l: clamp(3rem, 2rem + 3vw, 5rem);
  --space-m: clamp(1.75rem, 1.2rem + 1.5vw, 2.75rem);
  --space-s: 1rem;
  --max: 1440px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.83, 0, 0.17, 1);
  --t-fast: 180ms;
  --t-med: 420ms;

  --nav-h: 76px;
}

/* Themes: salon = porcelain, academy/backstage = ink */
[data-theme="porcelain"], :root {
  --bg: var(--porcelain);
  --bg-2: var(--porcelain-2);
  --fg: var(--ink);
  --muted: var(--muted-light);
  --line: rgba(17, 13, 15, 0.14);
  --line-strong: rgba(17, 13, 15, 0.42);
  --accent: var(--lacquer);
}
[data-theme="ink"] {
  --bg: var(--ink);
  --bg-2: var(--ink-2);
  --fg: var(--porcelain);
  --muted: var(--muted-dark);
  --line: rgba(242, 232, 229, 0.14);
  --line-strong: rgba(242, 232, 229, 0.45);
  --accent: var(--nude);
}
[data-theme] { background-color: var(--bg); color: var(--fg); }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }
body {
  background: var(--porcelain);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: var(--fs-body);
  font-variation-settings: 'wdth' 100;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
/* Match the page's base world so sub-pixel seams between same-theme sections stay invisible */
body[data-nav-theme="ink"] { background: var(--ink); }
img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
ul[class], ol[class] { list-style: none; padding: 0; }
h1, h2, h3, h4 { font-weight: 400; line-height: 1.02; text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--lacquer); color: var(--bone); }

[hidden] { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.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 {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 200;
  padding: 0.7rem 1rem; background: var(--ink); color: var(--porcelain);
  transform: translateY(-160%); transition: transform var(--t-fast);
}
.skip:focus { transform: none; }

:focus-visible { outline: 2px solid var(--lacquer); outline-offset: 3px; border-radius: 2px; }
main:focus { outline: none; }
[data-theme="ink"] :focus-visible { outline-color: var(--nude); }

/* Typography */
.display, .h1, .h2 { font-family: var(--f-display); font-optical-sizing: auto; letter-spacing: -0.02em; }
.h1 { font-size: var(--fs-h1); }
.h2 { font-size: var(--fs-h2); }
.h3 { font-family: var(--f-display); font-size: var(--fs-h3); line-height: 1.15; }
.display em, .h1 em, .h2 em, .h3 em { font-style: italic; }
.lead { font-size: var(--fs-lead); line-height: 1.5; max-width: 38ch; }
.muted { color: var(--muted); }
.label {
  font-family: var(--f-sans);
  font-size: var(--fs-label);
  font-weight: 600;
  font-variation-settings: 'wdth' 72;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1.4;
}
.label--accent { color: var(--accent); }
.prose p + p { margin-top: 1em; }
.prose { max-width: 60ch; }

/* Layout helpers */
.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--space-xl); position: relative; }
.section--tight { padding-block: var(--space-l); }
.section--loose { padding-block: var(--space-2xl); }
.rule { border: 0; border-top: 1px solid var(--line); }

/* Links */
.link-u {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-weight: 600; font-variation-settings: 'wdth' 85;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size var(--t-med) var(--ease-out);
}
.link-u:hover { background-size: 0% 1px; background-position: 100% 100%; }

/* Buttons */
.btn {
  --btn-bg: transparent; --btn-fg: var(--fg); --btn-bd: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.6em;
  min-height: 3.25rem; padding: 0.8rem 1.6rem;
  border: 1px solid var(--btn-bd); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 0.82rem; font-weight: 600; font-variation-settings: 'wdth' 80;
  letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
  overflow: hidden; isolation: isolate;
  transition: color var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out), transform var(--t-fast);
}
.btn::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--btn-fill, var(--fg));
  clip-path: ellipse(0% 0% at 50% 110%);
  transition: clip-path 560ms var(--ease-out);
}
.btn:hover::before, .btn:focus-visible::before { clip-path: ellipse(80% 140% at 50% 100%); }
.btn:hover, .btn:focus-visible { color: var(--btn-hover-fg, var(--bg)); }
.btn:active { transform: scale(0.98); }
.btn--sm { min-height: 2.6rem; padding: 0.55rem 1.15rem; font-size: 0.74rem; }
.btn--block { width: 100%; }
.btn--solid { --btn-bg: var(--fg); --btn-fg: var(--bg); --btn-bd: var(--fg); --btn-fill: var(--lacquer); --btn-hover-fg: var(--bone); }
.btn--lacquer { --btn-bg: var(--lacquer); --btn-fg: var(--bone); --btn-bd: var(--lacquer); --btn-fill: var(--ink); --btn-hover-fg: var(--bone); }
[data-theme="ink"] .btn--lacquer { --btn-fill: var(--bone); --btn-hover-fg: var(--ink); }
.btn--ghost { --btn-fill: var(--fg); }
.btn--pearl { --btn-bg: var(--chrome); --btn-fg: var(--ink); --btn-bd: transparent; --btn-fill: var(--lacquer); --btn-hover-fg: var(--bone); background-size: 200% 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn .arrow { transition: transform var(--t-med) var(--ease-out); }
.btn:hover .arrow { transform: translateX(4px); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; min-height: 2.4rem; padding: 0.4rem 1rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-size: 0.8rem; font-weight: 500; font-variation-settings: 'wdth' 85;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip:hover { border-color: var(--fg); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Forms */
.field { display: grid; gap: 0.4rem; }
.field > label:not(.radio):not(.check), .field > legend { font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; font-variation-settings: 'wdth' 75; }
.field .opt { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.85rem 0; border: 0; border-bottom: 1px solid var(--line-strong);
  background: transparent; border-radius: 0; font-size: 1rem;
  transition: border-color var(--t-fast);
}
.field textarea { resize: vertical; min-height: 5rem; }
.field select { appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23887' stroke-width='1.5'/%3E%3C/svg%3E") right 0.25rem center no-repeat; padding-right: 1.5rem; }
[data-theme="ink"] .field select option { background: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-bottom-color: var(--accent); border-bottom-width: 2px; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-bottom-color: #C2273F; }
.field--radios { border: 0; padding: 0; display: grid; gap: 0.6rem; }
.radio, .check { display: flex; gap: 0.75rem; align-items: flex-start; font-size: 0.95rem; cursor: pointer; }
.radio input, .check input { accent-color: var(--lacquer); width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; flex: none; }
.radio small { display: block; color: var(--muted); font-size: 0.8rem; }
.radio--disabled { opacity: 0.45; cursor: not-allowed; }
.form-error { color: #C2273F; font-size: 0.9rem; font-weight: 500; }
[data-theme="ink"] .form-error { color: #FF8C9B; }
.form-grid { display: grid; gap: 1.6rem 2rem; }
@media (min-width: 720px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }

/* Pill options (radio / checkbox as pills) */
.pill-opt { position: relative; display: inline-flex; cursor: pointer; }
.pill-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill-opt span {
  display: inline-flex; align-items: center; gap: 0.4em; min-height: 2.75rem; padding: 0.5rem 1.1rem;
  border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.9rem;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.pill-opt em { font-style: normal; color: var(--muted); font-size: 0.82rem; }
.pill-opt input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pill-opt input:checked + span em { color: inherit; opacity: 0.75; }
.pill-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-opt:hover span { border-color: var(--fg); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
