/* =============================================================================
   Essence Clinic — Design Tokens (CSS Custom Properties)
   Fonte: site/design-system.md v0.1.0-draft · constituição v1.2.0
   Camadas: 1) primitivas  2) semânticas por tema de superfície  3) componente
   ATENÇÃO: primitivas marcadas "ext" dependem da Emenda 1.3.0.
   ========================================================================== */

:root {
  /* ---------- 1. PRIMITIVAS · paleta canônica (constituição §Padrões) ------ */
  --e-midnight:      #090D3F;
  --e-deep-purple:   #3C2359;
  --e-amethyst:      #692166;
  --e-roxo:          #5E208E;
  --e-pale-cream:    #EEDBCB;
  --e-white:         #FFFFFF;

  /* ---------- 1b. PRIMITIVAS derivadas · ext ------------------------------ */
  /* Superfície escura — Emenda 1.10.0. NÃO confundir com --e-midnight, que segue
     sendo TEXTO sobre claro e anel de foco. Aqui é o CHÃO das seções escuras. */
  --e-ground:        #4C1B5A;             /* Amethyst + Midnight 30% — patch 1.10.1, restaurado pelo 1.10.3 */
  --e-ground-raised: #572964;             /* ground + white 6% — mesma derivação do neutral-900 */
  --e-ground-rgb:    76, 27, 90;          /* para os rgba() de overlay e vidro */

  --e-amethyst-600:  var(--e-amethyst);
  --e-amethyst-500:  #7B3C78;
  --e-amethyst-700:  #5B1E60;
  --e-amethyst-800:  #4C1B5A;

  --e-roxo-500:      #713B9C;
  --e-roxo-600:      var(--e-roxo);
  --e-roxo-700:      #511D82;
  --e-roxo-800:      #441A76;

  --e-cream-50:      #F8F1EA;
  --e-cream-100:     #F5E9E0;
  --e-cream-200:     #F1E2D5;
  --e-cream-300:     var(--e-pale-cream);
  --e-cream-400:     #D7C6BD;

  --e-neutral-50:    #F8F8F9;
  --e-neutral-100:   #F0F0F3;
  --e-neutral-200:   #E1E2E8;
  --e-neutral-300:   #C2C2CF;
  --e-neutral-400:   #A2A3B6;
  --e-neutral-500:   #84869F;
  --e-neutral-600:   #5F6282;
  --e-neutral-700:   #494C71;
  --e-neutral-800:   #272A56;
  --e-neutral-900:   #181C4B;

  --e-error-50:      #FDECF0;
  --e-error-300:     #F5A3B4;
  --e-error-650:     #96153A;
  --e-success-50:    #E8F5EF;
  --e-success-300:   #7FC9AC;
  --e-success-650:   #166145;
  --e-warning-50:    #FBF1DE;
  --e-warning-300:   #F0C46A;
  --e-warning-800:   #734B00;

  --e-lilac-300:     #B69BCC; /* tier B — opcional */

  /* ---------- TIPOGRAFIA -------------------------------------------------- */
  --font-display: "Playfair Display", "Iowan Old Style", Georgia, serif;
  --font-body:    "DM Sans", "Helvetica Neue", Arial, sans-serif;

  --text-display-1: clamp(2.5rem, 1.333rem + 5.19vw, 6rem);
  --text-display-2: clamp(2.125rem, 1.333rem + 3.52vw, 4.5rem);
  --text-h1:        clamp(1.875rem, 1.333rem + 2.41vw, 3.5rem);
  --text-h2:        clamp(1.625rem, 1.292rem + 1.48vw, 2.625rem);
  --text-h3:        clamp(1.375rem, 1.167rem + 0.926vw, 2rem);
  --text-h4:        clamp(1.188rem, 1.083rem + 0.463vw, 1.5rem);
  --text-body-lg:   clamp(1.062rem, 1rem + 0.278vw, 1.25rem);
  --text-body:      clamp(1.062rem, 1.042rem + 0.093vw, 1.125rem);
  --text-body-sm:   clamp(0.9375rem, 0.9167rem + 0.093vw, 1rem);
  --text-caption:   clamp(0.8125rem, 0.7917rem + 0.093vw, 0.875rem);
  --text-overline:  0.75rem;

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold:600;
  --weight-bold:    700;

  --leading-tight:   1.05;
  --leading-display: 1.12;
  --leading-heading: 1.2;
  --leading-snug:    1.35;
  --leading-body:    1.6;
  --leading-loose:   1.75;

  --tracking-display:  -0.02em;
  --tracking-heading:  -0.01em;
  --tracking-body:      0;
  --tracking-overline:  0.12em;

  /* ---------- ESPAÇO ------------------------------------------------------ */
  --space-0: 0;      --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;   --space-5: 1.25rem; --space-6: 1.5rem;  --space-8: 2rem;
  --space-10: 2.5rem;--space-12: 3rem;   --space-16: 4rem;   --space-20: 5rem;
  --space-24: 6rem;  --space-32: 8rem;   --space-40: 10rem;

  /* ---------- FORMA ------------------------------------------------------- */
  --radius-none: 0;  --radius-sm: 4px;  --radius-md: 8px;
  --radius-lg: 16px; --radius-xl: 24px; --radius-pill: 999px;

  /* ---------- LAYOUT ------------------------------------------------------ */
  --container-prose:   68ch;
  --container-content: 1160px;
  --container-wide:    1320px;
  --page-margin:  20px;
  --grid-gutter:  16px;
  --section-py: clamp(3.5rem, 2rem + 6vw, 8rem);
  --target-min: 24px;
  --target-rec: 44px;

  /* ---------- MOVIMENTO --------------------------------------------------- */
  --dur-instant: 80ms;  --dur-fast: 160ms; --dur-base: 240ms;
  --dur-slow: 360ms;    --dur-reveal: 520ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-entrance: cubic-bezier(0, 0, 0, 1);
  --ease-exit:     cubic-bezier(0.3, 0, 1, 1);
  --ease-gesture:  cubic-bezier(0.34, 0.01, 0.16, 1);

  /* ---------- ELEVAÇÃO (só em superfície clara) --------------------------- */
  --elev-1: 0 1px 2px rgba(9,13,63,0.06), 0 1px 3px rgba(9,13,63,0.04);
  --elev-2: 0 2px 6px rgba(9,13,63,0.08), 0 6px 16px rgba(9,13,63,0.06);
  --elev-3: 0 8px 24px rgba(9,13,63,0.10), 0 16px 40px rgba(9,13,63,0.08);

  /* ---------- FOCO (primitivas canônicas — sem emenda) -------------------- */
  --focus-width: 2px;
  --focus-offset: 2px;
}

@media (min-width: 600px)  { :root { --page-margin: 32px; --grid-gutter: 24px; } }
@media (min-width: 900px)  { :root { --page-margin: 48px; } }
@media (min-width: 1200px) { :root { --page-margin: 80px; --grid-gutter: 32px; } }

/* =============================================================================
   2. SEMÂNTICAS POR TEMA DE SUPERFÍCIE
   Aplicar com data-surface no elemento de seção. Padrão do documento: white.
   ========================================================================== */

[data-surface="white"], :root {
  --color-bg:              var(--e-white);
  --color-bg-subtle:       var(--e-neutral-50);
  --color-bg-raised:       var(--e-white);
  --color-text:            var(--e-midnight);      /* 18.41:1 */
  --color-text-secondary:  var(--e-neutral-600);   /*  5.91:1 */
  --color-text-muted:      var(--e-neutral-500);   /*  3.56:1 — só ≥24px/19px bold */
  --color-text-inverse:    var(--e-white);
  --color-border:          var(--e-neutral-200);   /* decorativo */
  --color-border-strong:   var(--e-neutral-500);   /*  3.56:1 — controles */
  --color-action:          var(--e-amethyst-600); /* 10.45:1 — Emenda 1.9.0 */
  --color-action-hover:    var(--e-amethyst-700);  /* 11.67:1 */
  --color-action-active:   var(--e-amethyst-800);  /* 13.03:1 */
  --color-on-action:       var(--e-white);         /* 10.45:1 sobre amethyst */
  --color-link:            var(--e-amethyst-600);
  --color-accent:          var(--e-roxo-600);      /* 10.13:1 — Emenda 1.9.0 */
  --color-focus:           var(--e-midnight);      /* 18.41:1 */
  --shadow-card:           var(--elev-1);
}

[data-surface="cream"] {
  --color-bg:              var(--e-pale-cream);
  --color-bg-subtle:       var(--e-cream-100);
  --color-bg-raised:       var(--e-cream-50);
  --color-text:            var(--e-midnight);      /* 13.70:1 */
  --color-text-secondary:  var(--e-neutral-700);   /*  6.12:1 */
  --color-text-muted:      var(--e-neutral-600);   /*  4.40:1 — só ≥24px/19px bold */
  --color-text-inverse:    var(--e-white);
  --color-border:          var(--e-cream-400);
  --color-border-strong:   var(--e-neutral-600);   /*  4.40:1 */
  --color-action:          var(--e-amethyst-600); /*  7.78:1 vs fundo — Emenda 1.9.0 */
  --color-action-hover:    var(--e-amethyst-700);  /*  8.69:1 */
  --color-action-active:   var(--e-amethyst-800);  /*  9.70:1 */
  --color-on-action:       var(--e-white);         /* 10.45:1 sobre amethyst */
  --color-link:            var(--e-amethyst-600);
  --color-accent:          var(--e-roxo-600);      /*  7.54:1 — Emenda 1.9.0 */
  --color-focus:           var(--e-midnight);      /* 13.70:1 */
  --shadow-card:           none;                   /* usar hairline, não sombra */
}

[data-surface="midnight"] {
  --color-bg:              var(--e-ground);        /* Emenda 1.10.0 — era --e-midnight */
  --color-bg-subtle:       var(--e-ground-raised);
  --color-bg-raised:       var(--e-ground-raised);
  --color-text:            var(--e-white);         /* 10.45:1 */
  --color-text-secondary:  var(--e-pale-cream);    /*  7.78:1 */
  --color-text-muted:      var(--e-neutral-300);   /*  5.93:1 — era neutral-400, que cai a 4.20:1 */
  --color-text-inverse:    var(--e-midnight);
  --color-border:          rgba(238,219,203,0.16);
  --color-border-strong:   rgba(238,219,203,0.55);
  --color-action:          var(--e-pale-cream);    /* 13.70:1 — Amethyst NÃO serve aqui (1.76:1) */
  --color-action-hover:    var(--e-cream-100);
  --color-action-active:   var(--e-cream-400);
  --color-on-action:       var(--e-midnight);      /* 13.70:1 sobre creme */
  --color-link:            var(--e-pale-cream);    /* obrigatoriamente sublinhado */
  --color-accent:          var(--e-pale-cream);
  --color-focus:           var(--e-pale-cream);    /* 13.70:1 */
  --shadow-card:           none;
}

[data-surface="deep-purple"] {
  --color-bg:              var(--e-deep-purple);
  --color-bg-subtle:       var(--e-midnight);
  --color-bg-raised:       rgba(238,219,203,0.06);
  --color-text:            var(--e-white);         /* 13.32:1 */
  --color-text-secondary:  var(--e-pale-cream);    /*  9.91:1 */
  --color-text-muted:      var(--e-neutral-300);   /*  7.55:1 */
  --color-text-inverse:    var(--e-deep-purple);
  --color-border:          rgba(238,219,203,0.18);
  --color-border-strong:   rgba(238,219,203,0.60);
  --color-action:          var(--e-pale-cream);    /*  9.91:1 */
  --color-action-hover:    var(--e-cream-100);
  --color-action-active:   var(--e-cream-400);
  --color-on-action:       var(--e-deep-purple);
  --color-link:            var(--e-pale-cream);
  --color-accent:          var(--e-pale-cream);
  --color-focus:           var(--e-pale-cream);    /*  9.91:1 */
  --shadow-card:           none;
}

/* ---------- Feedback (independente de superfície; par claro/escuro) ------- */
[data-surface="white"], [data-surface="cream"], :root {
  --color-error:      var(--e-error-650);   /* ≥6.3:1 nas duas */
  --color-error-bg:   var(--e-error-50);
  --color-success:    var(--e-success-650);
  --color-success-bg: var(--e-success-50);
  --color-warning:    var(--e-warning-800);
  --color-warning-bg: var(--e-warning-50);
}
[data-surface="midnight"], [data-surface="deep-purple"] {
  --color-error:      var(--e-error-300);   /* 9.45:1 sobre midnight */
  --color-error-bg:   rgba(150,21,58,0.22);
  --color-success:    var(--e-success-300); /* 9.51:1 */
  --color-success-bg: rgba(22,97,69,0.24);
  --color-warning:    var(--e-warning-300); /* 11.23:1 */
  --color-warning-bg: rgba(115,75,0,0.26);
}

/* =============================================================================
   3. BASE OBRIGATÓRIA
   ========================================================================== */

:where(body) {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
}

:where(h1,h2,h3,.u-display) {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}

:where(p, li) { text-wrap: pretty; max-width: var(--container-prose); }

/* Números tabulares obrigatórios em preço, telefone, horário e aritmética */
.u-tnum, :where(time, .price, .phone, .cycle-math) {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Foco visível — nunca remover; nunca substituir por outline:none */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

@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;
  }
}
