/* Sarha Clinic design system. Tokens and rules mirror DESIGN.md §3. */
@layer reset, tokens, base, layout, components, utilities;

/* ---------------------------------------------------------------- fonts */
/* Public Sans, cut by assets/fonts/build_fonts.py (weights 400-700) */
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/public-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212;
}
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/public-sans-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F;
}
/* metric-matched fallback so the swap causes no layout shift */
@font-face {
  font-family: 'Public Sans Fallback';
  src: local('Arial');
  size-adjust: 102.2%;
  ascent-override: 92.9%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* ---------------------------------------------------------------- reset */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-height: 100svh; }
  img, svg, video, picture { display: block; max-width: 100%; height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  p, h1, h2, h3, h4, li, dd, figcaption { overflow-wrap: break-word; }
  ul[role='list'], ol[role='list'] { list-style: none; padding: 0; }
}

/* --------------------------------------------------------------- tokens */
@layer tokens {
  :root {
    color-scheme: light;

    /* neutrals: soft cool grey page, white bands, pale blue top band */
    --canvas: #F5F6F8;
    --surface: #FFFFFF;
    --line: #E6E8EE;
    --line-strong: #CDD1DB;
    --ink: #161A3D;
    --muted: #555869;

    /* brand-derived */
    --blue: #2534D1;
    --blue-hover: #1A26A8;
    --blue-tint: #EEF0FD;
    --rose: #FF99CC;
    --rose-deep: #A8285F;
    --rose-tint: #FDEEF5;
    --night: #0F1230;
    --night-2: #171B45;

    /* logo originals: only for the heritage split rule */
    --logo-rose: #FF99CC;
    --logo-blue: #0000FF;

    /* functional */
    --whatsapp: #1F7A4D;
    --whatsapp-hover: #17603C;
    --open: #1F7A4D;
    --closed: #A8285F;

    /* type */
    --font-display: 'Public Sans', 'Public Sans Fallback', Arial, sans-serif;
    --font-body: 'Public Sans', 'Public Sans Fallback', Arial, sans-serif;
    /* fluid scale 360 -> 1440 px */
    --step--1: clamp(0.875rem, 0.85rem + 0.11vw, 0.9375rem);
    --step-0: clamp(1.0625rem, 1.04rem + 0.09vw, 1.125rem);
    --step-1: clamp(1.1875rem, 1.125rem + 0.28vw, 1.375rem);
    --step-2: clamp(1.375rem, 1.25rem + 0.56vw, 1.75rem);
    --step-3: clamp(1.75rem, 1.5rem + 1.11vw, 2.5rem);
    --step-4: clamp(2.25rem, 1.75rem + 2.22vw, 3.75rem);
    --step-5: clamp(2.75rem, 1.92rem + 3.7vw, 5.5rem);

    /* space (4 px base) */
    --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
    --s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 6rem; --s-10: 8rem;
    --section: clamp(3rem, 2rem + 3.5vw, 5.5rem);

    /* shape */
    --radius: 12px;
    --radius-lg: 24px;
    --radius-pill: 999px;
    --shadow-float: 0 8px 28px rgb(22 26 61 / 0.14), 0 1px 3px rgb(22 26 61 / 0.08);

    /* layout */
    --max: 75rem;
    --gutter: clamp(1rem, 0.5rem + 2.2vw, 2.5rem);
    --measure: 68ch;

    /* motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 200ms;

    /* header height, read by sticky offsets */
    --header-h: 4.5rem;
  }

  /* theme-aware art and UI */
  :root {
    --btn-fg: #FFFFFF;
    --cad-line: #000000;    /* caduceus + logo outlines */
    --cad-fill: #FFFFFF;    /* caduceus white areas (staff, wings) */
    --cad-blue: #0000FF;    /* logo blue */
    --band-hero: #E6EAF8;   /* top band on every page */
    --band-alt: #FFFFFF;    /* alternating sections */
  }

  /* ---- dark: follows the system unless the visitor picked a theme ---- */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
      color-scheme: dark;
      --canvas: #10131F;
      --surface: #171B2B;
      --line: #272C42;
      --line-strong: #3A405C;
      --ink: #E8EAF3;
      --muted: #A2A7BC;
      --blue: #8F9DFF;
      --blue-hover: #B3BDFF;
      --blue-tint: #1C2140;
      --night: #0A0C16;
      --btn-fg: #10131F;
      --cad-line: #B9BED3;
      --cad-fill: #1B2036;
      --cad-blue: #5B7BFF;
      --band-hero: #161B30;
      --band-alt: #141725;
      --shadow-float: 0 8px 28px rgb(0 0 0 / 0.5), 0 1px 3px rgb(0 0 0 / 0.4);
    }
  }
  :root[data-theme='dark'] {
    color-scheme: dark;
    --canvas: #10131F;
    --surface: #171B2B;
    --line: #272C42;
    --line-strong: #3A405C;
    --ink: #E8EAF3;
    --muted: #A2A7BC;
    --blue: #8F9DFF;
    --blue-hover: #B3BDFF;
    --blue-tint: #1C2140;
    --night: #0A0C16;
    --btn-fg: #10131F;
    --cad-line: #B9BED3;
    --cad-fill: #1B2036;
    --cad-blue: #5B7BFF;
    --band-hero: #161B30;
    --band-alt: #141725;
    --shadow-float: 0 8px 28px rgb(0 0 0 / 0.5), 0 1px 3px rgb(0 0 0 / 0.4);
  }
}

/* ----------------------------------------------------------------- base */
@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1rem); }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.6;
    font-kerning: normal;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1, h2, h3, .display {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.015em;
    text-wrap: balance;
    color: var(--ink);
  }
  h1 { font-size: var(--step-4); }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-2); line-height: 1.2; letter-spacing: -0.01em; }
  p { text-wrap: pretty; }

  a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
  a:hover { color: var(--blue-hover); text-decoration-thickness: 2px; }

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

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

  strong { font-weight: 650; }
  small { font-size: var(--step--1); }
}

/* --------------------------------------------------------------- layout */
@layer layout {
  .wrap {
    width: min(100% - 2 * var(--gutter), var(--max));
    margin-inline: auto;
  }
  .section { padding-block: var(--section); }
  .section--tight { padding-block: calc(var(--section) * 0.6); }
  .band-hero { background: var(--band-hero); color: var(--ink); }
  /* page intros sitting on the band need room below the text */
  .intro.band-hero { padding-bottom: clamp(2.5rem, 1.5rem + 3vw, 4rem) !important; margin-bottom: var(--s-6); }
  .band-alt { background: var(--band-alt); }
  .prose { max-width: var(--measure); }
  .prose > * + * { margin-top: 1em; }
  .prose h2 { margin-top: 1.6em; font-size: var(--step-3); }
  .prose h3 { margin-top: 1.4em; }
  .prose ul { padding-left: 1.2em; }
  .prose li + li { margin-top: 0.35em; }
  .stack > * + * { margin-top: var(--stack, var(--s-4)); }
  .cluster { display: flex; flex-wrap: wrap; gap: var(--cluster, var(--s-3)); align-items: center; }
}

/* ----------------------------------------------------------- components */
@layer components {
  .lead { font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 40ch; }

  .btn {
    --btn-bg: var(--blue);
    --btn-bg-hover: var(--blue-hover);
    --btn-color: var(--btn-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55em;
    min-height: 48px;
    padding: 0.7em 1.35em;
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--btn-bg);
    color: var(--btn-color);
    font-weight: 600;
    font-size: var(--step-0);
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), border-color var(--dur);
  }
  .btn:hover { background: var(--btn-bg-hover); color: var(--btn-color); text-decoration: none; }
  .btn:active { transform: translateY(1px); }
  .btn svg { width: 1.15em; height: 1.15em; flex: none; }
  .btn--whatsapp { --btn-bg: var(--whatsapp); --btn-bg-hover: var(--whatsapp-hover); --btn-color: #fff; }
  .btn--ghost {
    --btn-bg: transparent;
    --btn-bg-hover: var(--surface);
    --btn-color: var(--ink);
    border-color: var(--line-strong);
  }
  .btn--ghost:hover { border-color: var(--ink); }
  .btn--sm { min-height: 44px; padding: 0.55em 1.1em; font-size: var(--step--1); }


  .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.25em 0.75em;
    border-radius: var(--radius-pill);
    font-size: var(--step--1);
    font-weight: 600;
    background: var(--blue-tint);
    color: var(--blue);
  }
  .chip--rose { background: var(--rose-tint); color: var(--rose-deep); }
}

/* ------------------------------------------------------------ utilities */
@layer utilities {
  .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;
    left: var(--s-4);
    top: -100px;
    z-index: 100;
    padding: var(--s-3) var(--s-4);
    background: var(--ink);
    color: var(--canvas);
    border-radius: var(--radius);
    font-weight: 600;
  }
  .skip-link:focus { top: var(--s-4); color: var(--canvas); }
  .muted { color: var(--muted); }
  .center { text-align: center; }
  .mt-0 { margin-top: 0 !important; }

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