/* ==========================================================================
   Katalogo · Sistema de diseño base
   Tokens, tipografía, curvas de movimiento y superficies del navegador.
   Lo usan la página de ventas, las tiendas y el panel.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Superficies (neutro frío, un solo acento) */
  --canvas: #f2f3f0;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --surface-3: #eceee9;
  --ink: #0d0f0c;
  --ink-2: #434840;
  --ink-3: #62675f;
  --hairline: rgba(13, 15, 12, 0.08);
  --hairline-strong: rgba(13, 15, 12, 0.14);

  --accent: #077a4b;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2e9;
  --accent-soft-ink: #05603a;
  --danger: #b42318;
  --danger-soft: #fdecea;

  /* Profundidad: sombras teñidas del fondo, siempre con desplazamiento */
  --shadow-1: 0 1px 2px rgba(16, 32, 22, 0.05), 0 2px 8px -2px rgba(16, 32, 22, 0.06);
  --shadow-2: 0 2px 4px rgba(16, 32, 22, 0.04), 0 12px 32px -8px rgba(16, 32, 22, 0.14);
  --shadow-3: 0 4px 8px rgba(16, 32, 22, 0.05), 0 32px 64px -16px rgba(16, 32, 22, 0.24);

  /* Forma: controles en píldora, contenedores a 16px */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* Movimiento (Emil Kowalski / Apple) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --t-press: 140ms;
  --t-fast: 180ms;
  --t-ui: 240ms;
  --t-sheet: 420ms;

  /* Tipografía */
  --font: "Geist Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0b0c0b;
    --surface: #141614;
    --surface-2: #1a1d1a;
    --surface-3: #222622;
    --ink: #f1f3ef;
    --ink-2: #bcc2ba;
    --ink-3: #939a91;
    --hairline: rgba(255, 255, 255, 0.08);
    --hairline-strong: rgba(255, 255, 255, 0.14);

    --accent: #34c98b;
    --accent-ink: #04140c;
    --accent-soft: #11291d;
    --accent-soft-ink: #7fe0b4;
    --danger: #ff8a7a;
    --danger-soft: #2a1512;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 32px -8px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 4px 8px rgba(0, 0, 0, 0.3), 0 32px 64px -16px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--hairline-strong) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "ss01", "cv11";
}

/* Superficies del navegador, tematizadas */
::selection { background: var(--accent); color: var(--accent-ink); }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
input, textarea, select { caret-color: var(--accent); }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

.num { font-variant-numeric: tabular-nums; }

/* Marca: el "Ya" siempre en el verde de Katalogo (no cambia con el color de cada tienda) */
.ya { color: #077a4b; }
@media (prefers-color-scheme: dark) { .ya { color: #34c98b; } }
.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;
}

/* Tracking según tamaño: negativo en display, neutro en texto */
h1, h2, h3 { text-wrap: balance; margin: 0; font-weight: 640; }
p { text-wrap: pretty; }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--ink);
  --btn-ink: var(--canvas);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 560;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--accent { --btn-bg: var(--accent); --btn-ink: var(--accent-ink); }
.btn--ghost { --btn-bg: transparent; --btn-ink: var(--ink); box-shadow: inset 0 0 0 1px var(--hairline-strong); }
.btn--soft { --btn-bg: var(--surface-3); --btn-ink: var(--ink); }
.btn--sm { min-height: 38px; padding: 0 16px; font-size: 0.875rem; }
.btn--block { width: 100%; }

/* Botón con icono anidado ("button-in-button") */
.btn--nest { padding-right: 6px; }
.btn__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--btn-ink) 14%, transparent);
  font-size: 1.05rem;
  transition: transform var(--t-ui) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { box-shadow: var(--shadow-2); }
  .btn--ghost:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }
  .btn--nest:hover .btn__icon { transform: translate(2px, -1px) scale(1.05); }
}

/* ---------- Campos ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 0.8125rem; font-weight: 560; color: var(--ink-2); }
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px evita el zoom de iOS */
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 84px; }
select.input {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.field__error { font-size: 0.8125rem; color: var(--danger); min-height: 0; }
.field__error:empty { display: none; }
.field__help { font-size: 0.8125rem; color: var(--ink-3); }

/* Iconos Phosphor: tamaño óptico */
.ph-light, .ph, .ph-fill { line-height: 1; }

/* ---------- Movimiento reducido / transparencia reducida ---------- */
/* Movimiento reducido = menos y más suave, no cero: se conservan los fundidos
   de opacidad y color; cada componente quita su propio desplazamiento. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:active { transform: none; }
  .btn--nest .btn__icon { transition: none; }
}
