/* Monona Candybar · "espesor y luz"
   Capas: reset → tokens → base → layout → components → pages → utilities */
@layer reset, tokens, base, layout, components, pages, utilities;

@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Nunito Sans";
  src: url("../fonts/nunito-sans.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  /* El atributo hidden tiene que ganarle a cualquier display (por ejemplo el de img, svg) */
  [hidden] { display: none !important; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  fieldset { border: 0; padding: 0; min-width: 0; }
  legend { padding: 0; }
}

@layer tokens {
  :root {
    --brand-magenta: #d81b60;
    --brand-magenta-dark: #a3154a;
    --brand-gold: #f2b705;
    --brand-gold-soft: #fce7a6;
    --bg-blush: #fdf1f5;
    --bg-base: #fffbf7;
    --surface: #ffffff;
    --text: #2b2230;
    --text-muted: #6e6472;
    --border: #eadfe4;
    --success: #2e7d32;
    --error: #c62828;
    --info: #1d5fa8;

    /* Sombras de "espesor": simulan el canto del polifan debajo de los botones */
    --foam-depth: 0 4px 0 var(--brand-magenta-dark);
    --foam-depth-pressed: 0 1px 0 var(--brand-magenta-dark);
    --card-depth: 0 3px 0 var(--border);
    --glow: drop-shadow(0 0 10px rgb(242 183 5 / 0.85)) drop-shadow(0 0 24px rgb(242 183 5 / 0.45));

    --font-display: "Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif;
    --font-ui: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.09rem);
    --step-1: clamp(1.2rem, 1.1rem + 0.45vw, 1.42rem);
    --step-2: clamp(1.44rem, 1.25rem + 0.9vw, 1.95rem);
    --step-3: clamp(1.73rem, 1.4rem + 1.6vw, 2.75rem);
    --step-4: clamp(2.07rem, 1.5rem + 2.8vw, 3.8rem);

    --radius: 14px;
    --radius-lg: 22px;
    --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);
    --max: 1180px;

    --dur-fast: 150ms;
    --dur-base: 250ms;
    --dur-cut: 600ms;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@layer base {
  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
  body {
    font-family: var(--font-ui);
    font-size: var(--step-0);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-base);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
  h1 { font-size: var(--step-3); }
  h2 { font-size: var(--step-2); }
  h3 { font-size: var(--step-1); }
  a { color: var(--brand-magenta-dark); text-underline-offset: 3px; }
  a:hover { color: var(--brand-magenta); }
  :focus-visible { outline: 3px solid var(--brand-gold); outline-offset: 2px; border-radius: 6px; }
  ::selection { background: var(--brand-gold-soft); }
  p + p { margin-top: 0.75em; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
}

@layer layout {
  .container { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }
  main { flex: 1; padding-block: clamp(1.5rem, 1rem + 2vw, 3rem); }
  .stack > * + * { margin-top: var(--stack, 1rem); }
  .grid { display: grid; gap: clamp(0.9rem, 0.6rem + 1vw, 1.5rem); grid-template-columns: repeat(auto-fill, minmax(min(100%, 155px), 1fr)); }
  @media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
  .split { display: grid; gap: clamp(1.5rem, 1rem + 2vw, 3rem); }
  @media (min-width: 900px) { .split { grid-template-columns: 1.15fr 1fr; align-items: start; } }
  .section { margin-top: clamp(2.5rem, 2rem + 3vw, 5rem); }
  .section__head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
  .section__head h2 { position: relative; padding-bottom: 0.5rem; }
  .section__head h2::after {
    content: ""; position: absolute; left: 0; bottom: 0; width: 56px; height: 5px; border-radius: 999px; background: var(--brand-gold);
  }
}

@layer components {
  /* Encabezado */
  .header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .header__inner { display: flex; align-items: center; gap: 1rem; min-height: 68px; }
  .logo { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; color: var(--brand-magenta); text-decoration: none; line-height: 1; }
  .logo span { color: var(--text); font-weight: 500; }
  .nav { display: none; gap: 1.25rem; margin-left: 1.5rem; }
  .nav a { color: var(--text); text-decoration: none; font-weight: 700; }
  .nav a:hover { color: var(--brand-magenta); }
  @media (min-width: 860px) { .nav { display: flex; } }
  .header__actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
  .search { display: none; }
  @media (min-width: 640px) { .search { display: block; } }
  .search input { border: 1px solid var(--border); background: var(--bg-base); border-radius: 999px; padding: 0.5rem 1rem; width: 200px; }

  .cart-link { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border-radius: 999px; color: var(--text); text-decoration: none; }
  .cart-link:hover { background: var(--bg-blush); }
  /* Acceso a la cuenta: solo el ícono en celular (44 px tocables), con texto desde pantallas medianas */
  .account-link { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-width: 44px; min-height: 44px; padding-inline: 0.4rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--step--1); }
  .account-link:hover { background: var(--bg-blush); }
  .account-link__text { display: none; }
  @media (min-width: 720px) { .account-link__text { display: inline; } }
  .cart-link__count {
    position: absolute; top: 2px; right: 0; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: 999px;
    background: var(--brand-magenta); color: #fff; font-size: 0.75rem; font-weight: 800; display: grid; place-items: center;
  }
  .cart-link__count--bump { animation: bump var(--dur-base) var(--ease); }
  /* Rebote del contador del carrito al agregar un producto */
  @keyframes bump { 50% { transform: scale(1.35); } }

  /* Botones con canto de polifan */
  .btn {
    --btn-bg: var(--brand-magenta); --btn-bg-hover: var(--brand-magenta-dark); --btn-fg: #fff; --btn-depth: var(--foam-depth);
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 48px; padding: 0.7rem 1.4rem;
    border: 0; border-radius: var(--radius); background: var(--btn-bg); color: var(--btn-fg); font-weight: 800; text-decoration: none;
    box-shadow: var(--btn-depth); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast);
  }
  /* Al pasar el mouse solo cambia el fondo de cada variante (--btn-bg-hover).
     Antes el hover pisaba el fondo y el texto, y el botón fantasma quedaba con texto invisible. */
  .btn:hover { --btn-bg: var(--btn-bg-hover); }
  .btn:active { transform: translateY(3px); box-shadow: var(--foam-depth-pressed); }
  .btn--ghost { --btn-bg: var(--surface); --btn-bg-hover: var(--bg-blush); --btn-fg: var(--brand-magenta-dark); box-shadow: 0 0 0 2px var(--border), 0 3px 0 var(--border); }
  .btn--gold { --btn-bg: var(--brand-gold); --btn-bg-hover: #e0a800; --btn-fg: var(--text); --btn-depth: 0 4px 0 #b88a00; }
  .btn--small { min-height: 44px; padding: 0.4rem 0.9rem; font-size: var(--step--1); }
  .btn--block { width: 100%; }
  .btn[disabled] { opacity: 0.5; pointer-events: none; }
  .link-btn { background: none; border: 0; color: var(--brand-magenta-dark); text-decoration: underline; padding: 0; font-weight: 700; }
  .link-btn:hover { color: var(--brand-magenta); }

  /* Tarjetas de producto */
  .card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--card-depth); display: flex; flex-direction: column; text-decoration: none; color: inherit;
    transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
  }
  /* El efecto de elevar solo en dispositivos con mouse: en el celular se quedaba pegado después de tocar */
  @media (hover: hover) {
    .card:hover { transform: translateY(-4px); box-shadow: 0 8px 0 var(--border); color: inherit; }
  }
  .card__media { aspect-ratio: 1; background: var(--bg-blush); display: grid; place-items: center; overflow: hidden; }
  .card__media img { width: 100%; height: 100%; object-fit: cover; }
  .card__body { padding: 1rem 1.1rem 1.2rem; display: grid; gap: 0.25rem; }
  .card__title { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); }
  .card__price { color: var(--brand-magenta-dark); font-weight: 800; }
  .placeholder { font-family: var(--font-display); font-size: 3rem; color: var(--brand-magenta); opacity: 0.35; }

  /* Formularios */
  .field { display: grid; gap: 0.35rem; }
  .field + .field { margin-top: 1rem; }
  .label { font-weight: 800; }
  .hint { color: var(--text-muted); font-size: var(--step--1); }
  .input, .textarea, .select {
    width: 100%; min-height: 48px; padding: 0.7rem 0.9rem; border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--surface); transition: border-color var(--dur-fast);
  }
  .input:focus, .textarea:focus, .select:focus { border-color: var(--brand-magenta); outline: none; box-shadow: 0 0 0 4px rgb(216 27 96 / 0.12); }
  .textarea { min-height: 110px; resize: vertical; }
  .field--error .input, .field--error .textarea { border-color: var(--error); }
  .error-text { color: var(--error); font-size: var(--step--1); font-weight: 700; }
  .check { display: flex; gap: 0.6rem; align-items: start; }
  .check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand-magenta); flex-shrink: 0; }
  /* Campo trampa (honeypot): oculto para personas, lo completan los bots */
  .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

  /* Avisos */
  .flash { padding: 0.9rem 1.1rem; border-radius: var(--radius); font-weight: 700; margin-bottom: 1.25rem; border: 2px solid; animation: drop var(--dur-base) var(--ease); }
  .flash--success { background: #edf7ee; border-color: #b9dcbb; color: #1f5a22; }
  .flash--error { background: #fdecec; border-color: #f2b8b8; color: #8e1c1c; }
  .flash--info { background: #eaf2fb; border-color: #b9d2ee; color: #164a83; }
  @keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

  .badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: var(--step--1); font-weight: 800; background: var(--bg-blush); color: var(--brand-magenta-dark); }
  .badge--gold { background: var(--brand-gold-soft); color: #6b4f00; }
  .badge--ok { background: #e3f3e4; color: #1f5a22; }
  .badge--muted { background: #eee; color: var(--text-muted); }

  .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(1.1rem, 0.8rem + 1.2vw, 1.75rem); box-shadow: var(--card-depth); }

  /* Tabla simple de resumen */
  .summary { width: 100%; border-collapse: collapse; }
  .summary td { padding: 0.45rem 0; }
  .summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
  .summary tr.summary__total td { border-top: 2px solid var(--border); padding-top: 0.8rem; font-weight: 800; font-size: var(--step-1); }

  /* Chat */
  .chat { display: grid; gap: 0.75rem; max-height: 460px; overflow-y: auto; padding: 0.25rem; scroll-behavior: smooth; }
  .msg { max-width: 85%; padding: 0.65rem 0.9rem; border-radius: 16px; background: var(--bg-blush); white-space: pre-wrap; overflow-wrap: anywhere; animation: drop var(--dur-base) var(--ease); }
  .msg--mine { margin-left: auto; background: var(--brand-magenta); color: #fff; border-bottom-right-radius: 4px; }
  .msg--theirs { border-bottom-left-radius: 4px; }
  .msg--system { max-width: 100%; background: transparent; color: var(--text-muted); font-size: var(--step--1); text-align: center; padding: 0.25rem; }
  .msg__meta { display: block; font-size: 0.75rem; opacity: 0.75; margin-top: 0.25rem; }
  .chat-form { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: end; }
  .chat-form .textarea { min-height: 52px; }
  .chat-form__main { flex: 1; display: grid; gap: 0.5rem; }
  .chat-form__attach { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
  .chat-form.is-dragging .textarea { border-color: var(--brand-magenta); background: var(--bg-blush); }
  .msg__image { display: block; max-width: 100%; max-height: 320px; margin-bottom: 0.4rem; border-radius: 10px; background: #fff; }

  /* Pasos del pedido */
  .steps { display: flex; gap: 0.35rem; flex-wrap: wrap; list-style: none; padding: 0; }
  .steps li { flex: 1 1 110px; padding: 0.5rem 0.6rem; border-radius: 10px; background: #f3edf0; color: var(--text-muted); font-size: var(--step--1); font-weight: 700; text-align: center; }
  .steps li.is-done { background: var(--bg-blush); color: var(--brand-magenta-dark); }
  .steps li.is-current { background: var(--brand-magenta); color: #fff; box-shadow: var(--foam-depth); }

  /* Pie */
  .footer { background: var(--text); color: #e9e2ec; padding-block: 2.5rem; margin-top: 3rem; font-size: var(--step--1); }
  .footer a { color: #fff; }
  .footer__grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .footer h2 { font-size: var(--step-0); margin-bottom: 0.5rem; color: var(--brand-gold); }
  .footer ul { list-style: none; padding: 0; display: grid; gap: 0.3rem; }
}

@layer pages {
  /* Cuenta del cliente: invitación en la página del pedido y lista "Mis pedidos". Apilado en celular, en fila desde 720 px */
  .panel--invite { display: grid; gap: 1rem; border-color: var(--brand-gold); background: var(--brand-gold-soft); }
  @media (min-width: 720px) { .panel--invite { grid-template-columns: 1fr auto; align-items: center; } }
  .panel--invite form { margin: 0; }
  .order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
  .order-list__item { display: grid; gap: 0.4rem 0.75rem; justify-items: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; }
  @media (min-width: 720px) { .order-list__item { grid-template-columns: 11rem auto 1fr auto; align-items: center; } }
  .order-list__code { font-weight: 800; color: var(--brand-magenta-dark); text-decoration: none; overflow-wrap: anywhere; }

  /* Portada */
  .hero { background: radial-gradient(1200px 400px at 80% -10%, var(--brand-gold-soft), transparent 60%), var(--bg-blush); border-radius: 0 0 40px 40px; padding-block: clamp(2.5rem, 2rem + 4vw, 5.5rem); margin-top: calc(-1 * clamp(1.5rem, 1rem + 2vw, 3rem)); }
  .hero__grid { display: grid; gap: 2rem; align-items: center; }
  @media (min-width: 900px) { .hero__grid { grid-template-columns: 1.1fr 1fr; } }
  .hero h1 { font-size: var(--step-4); }
  .hero h1 em { font-style: normal; color: var(--brand-magenta); }
  .hero p { font-size: var(--step-1); color: var(--text-muted); margin-top: 1rem; max-width: 34ch; }
  .hero-form { display: flex; gap: 0.6rem; margin-top: 1.75rem; flex-wrap: wrap; }
  .hero-form .input { flex: 1 1 220px; font-size: var(--step-1); font-family: var(--font-display); min-height: 56px; }
  .hero-form .btn { min-height: 56px; }

  /* Logo animado de la portada: primero se dibuja el contorno (stroke-dashoffset) y después se rellena */
  .cut-word { width: 100%; height: auto; overflow: visible; }
  .cut-word text { font-family: var(--font-display); font-weight: 700; font-size: 120px; }
  .cut-word__back { fill: var(--brand-magenta-dark); transform: translate(0, 7px); }
  .cut-word__front {
    fill: var(--brand-magenta); stroke: var(--brand-gold); stroke-width: 3; stroke-dasharray: 1400; stroke-dashoffset: 1400; fill-opacity: 0;
    animation: cut 2.4s var(--ease) 0.2s forwards, fill-in var(--dur-cut) ease 2s forwards;
  }
  @keyframes cut { to { stroke-dashoffset: 0; } }
  @keyframes fill-in { to { fill-opacity: 1; stroke-width: 0; } }
  @media (prefers-reduced-motion: reduce) { .cut-word__front { stroke-dashoffset: 0; fill-opacity: 1; stroke-width: 0; } }

  .categories { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
  .category-tile {
    position: relative; overflow: hidden; display: grid; gap: 0.35rem; padding: 1.6rem 1.4rem 1.4rem; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--card-depth); text-decoration: none; color: inherit;
    transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
  }
  .category-tile::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--brand-magenta);
  }
  .category-tile::after {
    content: "→"; position: absolute; top: 1.3rem; right: 1.4rem; font-family: var(--font-display); font-size: var(--step-2); color: var(--brand-magenta);
    opacity: 0; transform: translateX(-8px); transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  }
  /* Con teclado (focus-visible) el efecto sigue andando; con mouse, solo en dispositivos con hover real */
  @media (hover: hover) {
    .category-tile:hover { transform: translateY(-4px); box-shadow: 0 7px 0 var(--brand-gold-soft); color: inherit; }
    .category-tile:hover::after { opacity: 1; transform: none; }
  }
  .category-tile:focus-visible { transform: translateY(-4px); box-shadow: 0 7px 0 var(--brand-gold-soft); color: inherit; }
  .category-tile:focus-visible::after { opacity: 1; transform: none; }
  .category-tile h3 { color: var(--brand-magenta); }

  .how { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); counter-reset: how; list-style: none; padding: 0; }
  .how li { counter-increment: how; padding: 1.25rem; border-radius: var(--radius-lg); background: var(--bg-blush); }
  .how li::before { content: counter(how); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-magenta); color: #fff; font-family: var(--font-display); font-weight: 700; margin-bottom: 0.6rem; box-shadow: var(--foam-depth); }

  /* Configurador */
  /* Vista previa del nombre: tipografía, medida y luces. Se muestra arriba de la columna en escritorio */
  .preview {
    border-radius: var(--radius-lg); background: linear-gradient(180deg, #fff 0%, var(--bg-blush) 100%);
    border: 1px solid var(--border); padding: 1.5rem; min-height: 320px; display: grid; gap: 1rem; align-content: center; overflow: hidden;
  }
  @media (min-width: 900px) { .preview { position: sticky; top: 88px; } }
  .preview__wall { display: grid; place-items: center; min-height: 200px; position: relative; }
  .preview__name {
    font-family: var(--font-display); font-weight: 700; color: var(--brand-magenta); font-size: clamp(2rem, 1rem + 5vw, 4.5rem);
    text-align: center; line-height: 1.05; overflow-wrap: anywhere; text-shadow: 0 5px 0 var(--brand-magenta-dark);
    transition: filter var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  }
  .preview__render {
    width: auto; height: auto; max-width: 100%; max-height: 9rem; object-fit: contain;
    transition: filter var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  }
  .preview.is-lit .preview__name, .preview.is-lit .preview__render { filter: var(--glow); }
  .preview__photo { width: 100%; border-radius: var(--radius); aspect-ratio: 4 / 3; object-fit: cover; transition: opacity var(--dur-base) var(--ease); }
  .preview__photo.is-sample { aspect-ratio: auto; max-height: 110px; object-fit: contain; }
  .preview__photo.is-fading, .preview__name.is-fading, .preview__render.is-fading { opacity: 0; transform: scale(0.98); }
  .preview__ruler { display: flex; justify-content: center; align-items: center; gap: 0.6rem; color: var(--text-muted); font-weight: 700; font-size: var(--step--1); }
  .preview__ruler::before, .preview__ruler::after { content: ""; flex: 1; max-width: 120px; height: 2px; background: repeating-linear-gradient(90deg, var(--text-muted) 0 2px, transparent 2px 10px); }
  .preview__note { font-size: var(--step--1); color: var(--text-muted); text-align: center; }

  .options { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  /* Con muchas tipografías la lista tiene su propio scroll en vez de alargar la página */
  .options--scroll {
    max-height: 17.5rem; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y proximity;
    padding: 0.5rem; margin-inline: -0.5rem; border-radius: var(--radius); background: color-mix(in srgb, var(--bg-blush) 60%, transparent);
  }
  .options--scroll .option { scroll-snap-align: start; }
  @media (max-width: 899px) {
    .options--scroll { grid-template-columns: repeat(3, 1fr); max-height: 15rem; }
    /* En móvil la vista previa queda fija bajo la cabecera para ver el resultado mientras se elige */
    .preview { position: sticky; top: 69px; z-index: 10; min-height: 0; padding: 0.75rem 1rem; gap: 0.35rem; box-shadow: 0 6px 16px rgb(43 34 48 / 0.08); }
    .preview__wall { min-height: 0; }
    .preview__render { max-height: 4.5rem; }
    .preview__name { font-size: clamp(1.75rem, 8vw, 2.5rem); }
    .preview__note, .preview__photo { display: none; }
  }
  /* Opciones de tipografía y medida: el input real queda oculto y se estiliza el recuadro (.option__box) */
  .option { position: relative; }
  .option input { position: absolute; opacity: 0; inset: 0; }
  .option__box {
    display: grid; gap: 0.3rem; place-items: center; text-align: center; padding: 0.75rem; min-height: 64px; border: 2px solid var(--border);
    border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color var(--dur-fast), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast);
  }
  .option__box img { height: 40px; width: 100%; object-fit: contain; }
  .option__code { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); color: var(--brand-magenta); }
  .option__sub { font-size: var(--step--1); color: var(--text-muted); }
  .option input:checked + .option__box { border-color: var(--brand-magenta); box-shadow: 0 3px 0 var(--brand-magenta-dark); transform: translateY(-2px); }
  .option input:focus-visible + .option__box { outline: 3px solid var(--brand-gold); outline-offset: 2px; }

  .switch { display: flex; align-items: center; gap: 0.9rem; padding: 0.9rem 1rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
  .switch input { appearance: none; width: 52px; height: 30px; border-radius: 999px; background: #ddd; position: relative; flex-shrink: 0; transition: background var(--dur-base); cursor: pointer; }
  .switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform var(--dur-base) var(--ease); }
  .switch input:checked { background: var(--brand-gold); }
  .switch input:checked::after { transform: translateX(22px); }

  .price-box { display: flex; justify-content: space-between; align-items: end; gap: 1rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--bg-blush); }
  .price-box__amount { font-family: var(--font-display); font-weight: 700; font-size: var(--step-3); color: var(--brand-magenta-dark); font-variant-numeric: tabular-nums; line-height: 1; }
  .price-box__detail { font-size: var(--step--1); color: var(--text-muted); }
  /* Pulso del precio cada vez que cambia la medida o las luces */
  .price-box.is-updating .price-box__amount { animation: pulse var(--dur-base) var(--ease); }
  @keyframes pulse { 50% { transform: scale(1.06); } }

  .mobile-bar { position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgb(43 34 48 / 0.08); }
  .mobile-bar__price { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); color: var(--brand-magenta-dark); }
  @media (min-width: 900px) { .mobile-bar { display: none; } }
  .has-mobile-bar { padding-bottom: 90px; }
  @media (min-width: 900px) { .has-mobile-bar { padding-bottom: 0; } }
  /* El pie queda fuera de main: reserva el lugar de la barra fija */
  @media (max-width: 899px) {
    body:has(.mobile-bar) .footer { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  }

  /* Ficha de producto */
  .gallery { border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-blush); aspect-ratio: 1; display: grid; place-items: center; }
  .gallery img { width: 100%; height: 100%; object-fit: cover; }

  /* Carrito */
  .cart-line { display: grid; grid-template-columns: 72px 1fr; gap: 1rem; padding-block: 1rem; border-bottom: 1px solid var(--border); align-items: center; }
  .cart-line__thumb { width: 72px; height: 72px; border-radius: 12px; background: var(--bg-blush); overflow: hidden; display: grid; place-items: center; }
  .cart-line__thumb img { width: 100%; height: 100%; object-fit: contain; }
  .cart-line__actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.4rem; }
  .qty { width: 72px; min-height: 44px; padding: 0.3rem 0.5rem; border: 2px solid var(--border); border-radius: 10px; }

  .breadcrumb { font-size: var(--step--1); color: var(--text-muted); margin-bottom: 1rem; }
  .breadcrumb a { color: inherit; }
  .prose { max-width: 70ch; }
  .prose h2 { margin-top: 2rem; margin-bottom: 0.5rem; font-size: var(--step-1); }
  .prose ul { padding-left: 1.25rem; }
  .empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
  .debug { text-align: left; white-space: pre-wrap; margin-top: 1.5rem; font-size: 0.8rem; }
}

@layer utilities {
  .muted { color: var(--text-muted); }
  .center { text-align: center; }
  .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
  .row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
  .visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nums { font-variant-numeric: tabular-nums; }
}

@view-transition { navigation: auto; }
