/* ==========================================================================
   base.css — P.A. Perez Physio
   Brand tokens, reset, typography, root accessibility defaults.
   ========================================================================== */

/* ---------- Brand tokens ---------- */
:root {
  /* Colors */
  --brand-cyan: #18B6E8;
  --brand-cyan-deep: #0891BC;
  --brand-cyan-soft: #E8F7FC;
  --ink: #0A1628;
  --ink-soft: #1E2A3F;
  --ink-muted: #54627A;
  --paper: #FAFAF7;
  --paper-pure: #FFFFFF;
  --line: #D8DEE8;
  --success: #16A34A;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Fluid type scale (clamp-based, mobile → desktop) */
  --fs-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --fs-sm: clamp(0.875rem, 0.84rem + 0.2vw, 0.9375rem);
  --fs-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --fs-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.25rem);
  --fs-xl: clamp(1.375rem, 1.25rem + 0.6vw, 1.5rem);
  --fs-2xl: clamp(1.75rem, 1.5rem + 1vw, 2.125rem);
  --fs-3xl: clamp(2.25rem, 1.9rem + 1.6vw, 3rem);
  --fs-4xl: clamp(3rem, 2.4rem + 2.8vw, 4.25rem);
  --fs-5xl: clamp(3.75rem, 2.8rem + 4vw, 5.75rem);

  /* Spacing (8px base) */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-6: 3rem;
  --space-8: 4rem;
  --space-12: 6rem;
  --space-16: 8rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(10, 22, 40, 0.04), 0 1px 3px rgba(10, 22, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(10, 22, 40, 0.06), 0 8px 24px rgba(10, 22, 40, 0.04);
  --shadow-lg: 0 12px 24px rgba(10, 22, 40, 0.08), 0 24px 48px rgba(10, 22, 40, 0.06);

  /* Motion */
  --ease-out-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-smooth: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 150ms;
  --dur-base: 280ms;
  --dur-slow: 600ms;

  /* Layout */
  --container-max: 1200px;
  --container-pad: clamp(1.25rem, 4vw, 2.5rem);
  --header-h: 72px;
}

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

* {
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

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

ul,
ol {
  list-style: none;
}

/* ---------- Typography defaults ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

h1 { font-size: var(--fs-5xl); font-weight: 400; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-4xl); letter-spacing: -0.025em; }
h3 { font-size: var(--fs-3xl); }
h4 { font-size: var(--fs-2xl); }
h5 { font-size: var(--fs-xl); font-weight: 500; }
h6 { font-size: var(--fs-lg); font-weight: 500; }

p {
  text-wrap: pretty;
  max-width: 68ch;
}

em {
  font-style: italic;
  font-family: var(--font-display);
}

strong {
  font-weight: 600;
  color: var(--ink);
}

.mono,
code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  letter-spacing: -0.01em;
}

.overline {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand-cyan-deep);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--brand-cyan);
  color: var(--paper-pure);
}
::-moz-selection {
  background: var(--brand-cyan);
  color: var(--paper-pure);
}

/* ---------- Focus-visible ---------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--brand-cyan-deep);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Reduced motion ---------- */
@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;
  }
}

/* ---------- Utility helpers ---------- */
.visually-hidden {
  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;
  top: -40px;
  left: 0;
  background: var(--ink);
  color: var(--paper-pure);
  padding: var(--space-1) var(--space-2);
  z-index: 1000;
  transition: top var(--dur-fast) var(--ease-out-smooth);
}
.skip-link:focus {
  top: 0;
}

/* ---------- Fixed grain overlay ----------
   Subtle, pointer-events-none, per taste-skill performance guardrails.
   Placed fixed so it doesn't re-render on scroll.
*/
.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}
@media (prefers-reduced-motion: reduce) {
  .grain-overlay { display: none; }
}

/* Tabular figures helper — apply to numeric data */
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ---------- Print ---------- */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .site-header,
  .site-footer,
  nav,
  button,
  video {
    display: none !important;
  }
  a {
    text-decoration: underline;
  }
  .section {
    page-break-inside: avoid;
  }
}
