/* ==========================================================
   JUGO DE MAGUEY · TIENDA EN LÍNEA · Base
   Tokens de diseño, reset, tipografía, botones y formularios
   ========================================================== */

:root {
  /* Marca · Jugo de Maguey El Jalisciense (verde agave + ámbar, mismos tokens que jugodemaguey.online) */
  --brand: #285a49;
  --brand-600: #1f4a3c;
  --brand-700: #173a30;
  --brand-50: #e8f1eb;
  --brand-100: #dbe8de;
  /* Acento: ámbar del maguey (texto oscuro encima) */
  --accent: #e08a2e;
  --accent-400: #eb9a45;
  --accent-100: #f8e7d4;
  --accent-50: #fdf5ec;
  --blue: #1d8a4b;
  --blue-50: #e6f3ea;

  /* Neutros cálidos-verdosos */
  --ink: #13211c;
  --ink-2: #2c3d36;
  --muted: #51615a;
  --subtle: #7f8f87;
  --line: #d9e2d8;
  --line-2: #c9d5c8;
  --bg: #f2f5f0;
  --bg-2: #e7ede5;
  --surface: #FFFFFF;
  --dark: #0f2a22;

  /* Estados */
  --ok: #1B7A45;   --ok-bg: #E6F4EC;
  --warn: #8f4d07; --warn-bg: #FBEEDD;
  --info: #24604c; --info-bg: #E6F0EA;
  --danger: #B91E26; --danger-bg: #FDECEC;
  --demo: #5B3FD0; --demo-bg: #F0ECFF;

  /* Tipografía: Young Serif para títulos grandes, Figtree para interfaz (como el sitio) */
  --font-serif: "Young Serif", Georgia, "Times New Roman", serif;
  --font-display: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Espaciado y forma */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --gutter: clamp(16px, 4vw, 32px);
  --container: 1240px;
  --header-h: 72px;

  /* Profundidad */
  --sh-1: 0 1px 2px rgba(19, 33, 28, .05), 0 1px 1px rgba(19, 33, 28, .03);
  --sh-2: 0 1px 2px rgba(19, 33, 28, .05), 0 6px 16px -4px rgba(19, 33, 28, .08);
  --sh-3: 0 2px 4px rgba(19, 33, 28, .05), 0 18px 40px -12px rgba(19, 33, 28, .18);
  --ring: 0 0 0 3px rgba(40, 90, 73, .28);

  /* Movimiento (curva tipo iOS, críticamente amortiguada) */
  --ease: cubic-bezier(.32, .72, 0, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --t-fast: 120ms;
  --t: 220ms;
  --t-slow: 380ms;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 24px); }
html.is-locked { overflow: hidden; }
body {
  margin: 0; min-height: 100vh;
  font: 400 1rem/1.55 var(--font-body);
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-600); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-700); }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-family: var(--font-display); color: var(--ink); text-wrap: balance; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
table { border-collapse: collapse; width: 100%; }
dl, dd { margin: 0; }
summary { cursor: pointer; }
[hidden] { display: none !important; }
#app { display: flex; flex-direction: column; min-height: 100vh; }
#main { flex: 1; outline: none; }

/* Foco visible y consistente */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1:focus, h2:focus { outline: none; }

/* ---------- Tipografía (tracking y leading según tamaño) ---------- */
.display {
  font: 400 clamp(2.3rem, 5.4vw, 4.1rem)/1.04 var(--font-serif);
  letter-spacing: -0.015em; margin-bottom: .35em;
}
.h1 { font: 400 clamp(1.85rem, 3.5vw, 2.7rem)/1.1 var(--font-serif); letter-spacing: -0.01em; }
.h2 { font: 400 clamp(1.55rem, 2.6vw, 2.15rem)/1.14 var(--font-serif); letter-spacing: -0.005em; }
.h3 { font: 750 clamp(1.2rem, 1.8vw, 1.4rem)/1.2 var(--font-display); letter-spacing: -0.01em; }
.h4 { font: 700 1.05rem/1.3 var(--font-display); letter-spacing: -0.005em; display: flex; align-items: center; gap: .45rem; }
.h4 .icon { width: 18px; height: 18px; color: var(--brand); }
.lead { font-size: clamp(1.02rem, 1.4vw, 1.15rem); line-height: 1.55; color: var(--ink-2); max-width: 62ch; }
.eyebrow { font: 700 .75rem/1.2 var(--font-body); letter-spacing: .09em; text-transform: uppercase; color: var(--brand); margin-bottom: .55rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.eyebrow--accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: 0; }
.label { display: block; font-weight: 650; font-size: .875rem; margin-bottom: .4rem; color: var(--ink-2); }
.optional { font-weight: 450; color: var(--subtle); font-size: .8rem; }
s { color: var(--subtle); }

.sr-only { 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: 12px; top: -60px; z-index: 1000; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--r-sm); transition: top var(--t) var(--ease); }
.skip-link:focus { top: 12px; color: #fff; }
.noscript { padding: 1rem; text-align: center; background: var(--accent-100); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(48px, 7vw, 96px); }
.section--tint { background: var(--bg-2); }
.section--dark { background: var(--dark); color: #E9EEF7; }
.section--dark .h2 { color: #fff; }
.section__head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: clamp(20px, 3vw, 36px); flex-wrap: wrap; }
.section__head .h2, .section__head .h3 { margin: 0; }
.section__head--center { flex-direction: column; align-items: center; text-align: center; }
.stack { display: grid; gap: .75rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding-block: .85rem; border-top: 1px solid var(--line); }
.row-between:first-of-type { border-top: 0; }
.row-center { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.sticky { position: sticky; top: calc(var(--header-h) + 20px); }

/* Entrada de vistas: fundido + desplazamiento corto */
#main.is-entering > * { animation: view-in var(--t-slow) var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Iconos ---------- */
.icon, [data-lucide] { width: 1.15em; height: 1.15em; flex-shrink: 0; display: inline-block; vertical-align: -0.18em; stroke-width: 1.9; }
i[data-lucide] { display: inline-block; }

/* ---------- Botones (respuesta al presionar, no al soltar) ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .62rem 1.15rem;
  font: 650 .95rem/1.1 var(--font-body); letter-spacing: -0.005em; text-decoration: none; white-space: nowrap;
  color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd); border-radius: var(--r-sm);
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
}
.btn:hover { color: var(--btn-fg); }
.btn:active:not(:disabled) { transform: scale(.97); transition-duration: 60ms; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 1.1em; height: 1.1em; }
.btn--primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: var(--brand); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 16px -8px rgba(1, 48, 140, .65); }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--brand-600); --btn-bd: var(--brand-600); }
.btn--secondary { --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-2); box-shadow: var(--sh-1); }
.btn--secondary:hover:not(:disabled) { --btn-bd: var(--ink-2); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { --btn-bg: var(--bg-2); }
.btn--danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn--danger-text { --btn-fg: var(--danger); }
.btn--on-dark { --btn-bg: rgba(255,255,255,.08); --btn-fg: #fff; --btn-bd: rgba(255,255,255,.22); }
.btn--on-dark:hover { --btn-bg: rgba(255,255,255,.16); }
.btn--lg { min-height: 52px; padding: .8rem 1.4rem; font-size: 1rem; border-radius: var(--r-md); }
.btn--sm { min-height: 36px; padding: .4rem .8rem; font-size: .85rem; }
.btn--block { width: 100%; }
.btn.is-added { --btn-bg: var(--ok); --btn-bd: var(--ok); }
.btn[aria-busy="true"] { cursor: progress; }

.link-btn { display: inline-flex; align-items: center; gap: .35rem; font-weight: 650; font-size: .92rem; color: var(--brand-600); text-decoration: none; background: none; border: 0; padding: 0; }
.link-btn .icon { transition: transform var(--t) var(--ease); }
.link-btn:hover .icon { transform: translateX(2px); }
.link-btn:has(.icon:first-child):hover .icon:first-child { transform: translateX(-2px); }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink-2); transition: background-color var(--t) var(--ease), transform var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-bg); }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1rem; margin-bottom: 1rem; }
.field { display: grid; gap: .35rem; align-content: start; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field--wide { grid-column: span 1; }
.field label, .label-row label { font-weight: 650; font-size: .875rem; color: var(--ink-2); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 46px; padding: .65rem .85rem;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-size: 1rem; line-height: 1.3;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background-color var(--t) var(--ease);
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--ring); outline: none; }
input[readonly] { background: var(--bg); color: var(--muted); }
[aria-invalid="true"] { border-color: var(--danger) !important; background: #FFFBFB !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(185, 30, 38, .2) !important; }
.field__error { color: var(--danger); font-size: .83rem; font-weight: 550; margin: 0; display: flex; gap: .3rem; }
.field__error::before { content: "!"; display: inline-grid; place-items: center; flex-shrink: 0; width: 15px; height: 15px; margin-top: 2px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; }
.hint-text { font-size: .8rem; color: var(--muted); margin: 0; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }

.select { position: relative; }
.select select { padding-right: 2.4rem; cursor: pointer; }
.select > .icon, .select > svg { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.select--sm select { min-height: 38px; font-size: .88rem; padding-block: .4rem; }

.check { display: flex; gap: .65rem; align-items: flex-start; cursor: pointer; font-size: .93rem; line-height: 1.4; }
.check input { appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--line-2); border-radius: 6px; background: var(--surface) center/12px no-repeat; transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t-fast) var(--ease); cursor: pointer; }
.check input:checked { background-color: var(--brand); border-color: var(--brand); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.check input:active { transform: scale(.9); }
.check input:focus-visible { box-shadow: var(--ring); outline: none; }
.check input[aria-invalid="true"] { border-color: var(--danger); }

.pw { position: relative; }
.pw input { padding-right: 3rem; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: var(--r-sm); display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); }

.form-alert { display: flex; gap: .5rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--r-sm); background: var(--danger-bg); color: var(--danger); font-weight: 550; font-size: .92rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }

/* ---------- Spinner / skeleton ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; opacity: .85; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader { display: flex; align-items: center; justify-content: center; gap: .7rem; padding: 72px 16px; color: var(--muted); font-weight: 550; }
.sk { background: linear-gradient(90deg, var(--bg-2) 25%, #EFE8DF 37%, var(--bg-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
.sk-media { aspect-ratio: 4/5; border-radius: 0; }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-btn { height: 44px; margin-top: 14px; border-radius: var(--r-sm); }
.w-40 { width: 40%; } .w-70 { width: 70%; } .w-90 { width: 90%; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Accesibilidad de movimiento, transparencia y contraste ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  #main.is-entering > * { animation: fade-only 160ms ease both !important; animation-duration: 160ms !important; }
  @keyframes fade-only { from { opacity: 0; } to { opacity: 1; } }
  .btn:active:not(:disabled), .icon-btn:active { transform: none; }
}
@media (prefers-contrast: more) {
  :root { --line: #B8AC9F; --line-2: #8C8076; --muted: #4D433D; }
}
