/* =========================================================
   STUDIO 20 · base.css
   Estructura y componentes comunes a las 20 plantillas.
   Cada plantilla redefine variables y estilos en themes.css.
   ========================================================= */

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5f5f66;
  --surface: #f4f4f5;
  --line: rgba(0, 0, 0, .12);
  --accent: #2f5bea;
  --accent-fg: #ffffff;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --wrap: 1200px;
  --gutter: clamp(20px, 5vw, 48px);
  --header-h: 64px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --d: 800ms;           /* duración de las apariciones */
  --stagger: 90ms;      /* retraso entre elementos escalonados */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; margin: 0 0 .5em; font-weight: 700; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }

.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.section { padding-block: clamp(72px, 10vw, 140px); position: relative; }
.section__head { max-width: 680px; margin-bottom: clamp(32px, 5vw, 56px); }
.section__head p { color: var(--muted); font-size: 1.1rem; }
.h-xl { font-size: clamp(2.6rem, 7vw, 5.6rem); letter-spacing: -.03em; }
.h-lg { font-size: clamp(2rem, 4.6vw, 3.6rem); letter-spacing: -.02em; }
.h-md { font-size: clamp(1.4rem, 2.6vw, 2rem); letter-spacing: -.01em; }
.lead { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--muted); max-width: 46ch; }
.muted { color: var(--muted); }
.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: 12px; top: -60px; z-index: 100;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  transition: top .2s;
}
.skip-link:focus { top: 12px; }

/* ---------- Foco visible ---------- */
:focus-visible { outline: 3px solid var(--focus, var(--accent)); outline-offset: 3px; border-radius: 4px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .8em 1.5em;
  border: 1px solid transparent; border-radius: var(--btn-radius, 999px);
  background: var(--accent); color: var(--accent-fg);
  font-weight: 600; font-size: 1rem; text-decoration: none; line-height: 1.1;
  cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -12px var(--accent); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; transition-duration: .08s; }
.btn--ghost { background: transparent; color: var(--fg); border-color: currentColor; }
.btn--ghost:hover { box-shadow: none; background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn--small { min-height: 40px; padding: .55em 1.1em; font-size: .92rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.link {
  font-weight: 600; text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .3s var(--ease);
}
.link:hover { background-size: 100% 1px; }

/* ---------- Cabecera y menú ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--header-bg, color-mix(in srgb, var(--bg) 82%, transparent));
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--header-line, var(--line));
}
.header__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; text-decoration: none; letter-spacing: -.01em; }
.brand__mark { width: 28px; height: 28px; flex: none; }
.nav { display: flex; align-items: center; gap: 28px; }
.nav a { text-decoration: none; font-size: .95rem; color: var(--nav-fg, var(--muted)); transition: color .2s; }
.nav a:hover { color: var(--fg); }
.nav .btn { color: var(--accent-fg); }
.menu-toggle {
  display: none; width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer;
  border-radius: 10px; position: relative;
}
.menu-toggle span {
  position: absolute; left: 11px; right: 11px; height: 2px; background: var(--fg); border-radius: 2px;
  transition: transform .3s var(--ease), opacity .2s;
}
.menu-toggle span:nth-child(1) { top: 15px; }
.menu-toggle span:nth-child(2) { top: 21px; }
.menu-toggle span:nth-child(3) { top: 27px; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 12px var(--gutter) 28px;
    background: var(--menu-bg, var(--bg));
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 40px -24px rgba(0,0,0,.25);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: transform .35s var(--ease-out), opacity .25s var(--ease), visibility 0s linear .35s;
  }
  .nav[data-open="true"] {
    transform: none; opacity: 1; visibility: visible;
    transition: transform .35s var(--ease-out), opacity .25s var(--ease), visibility 0s;
  }
  .nav a { padding: 14px 0; font-size: 1.1rem; border-bottom: 1px solid var(--line); color: var(--fg); }
  .nav .btn { margin-top: 16px; border-bottom: 0; }
}

/* ---------- Productos (estructura base; cada tema la reinterpreta) ---------- */
.products { display: grid; gap: var(--products-gap, 24px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.product { position: relative; display: flex; flex-direction: column; }
.product__media { position: relative; aspect-ratio: var(--media-ratio, 4 / 3); overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.product__media > svg, .product__media > img { width: 100%; height: 100%; object-fit: cover; }
.product__body { padding-top: 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product__body h3 { font-size: 1.35rem; margin: 0; }
.product__body p { margin: 0; color: var(--muted); }
.product__price { font-weight: 700; color: var(--fg) !important; margin-top: auto !important; padding-top: 10px; }
.tag { display: inline-block; font-size: .8rem; font-weight: 600; padding: .3em .7em; border-radius: 999px; background: var(--surface); color: var(--muted); }

/* ---------- Medios intercambiables (logo, fotos del cliente) ---------- */
.media { position: relative; overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.media > svg, .media > img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Formulario de demostración ---------- */
.form { display: grid; gap: 16px; }
.form__row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .95rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid var(--field-line, var(--line)); border-radius: var(--field-radius, 10px);
  background: var(--field-bg, var(--bg)); color: var(--fg);
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.field [aria-invalid="true"] { border-color: #c62828; }
.field__error { color: #c62828; font-size: .9rem; min-height: 0; }
.field__error:empty { display: none; }
.demo-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px; font-size: .95rem;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg)); color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.demo-note::before { content: "i"; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--accent); color: var(--accent-fg); }
.form-status { min-height: 1.5em; font-weight: 600; }
.form-status:empty { display: none; }

/* ---------- Carrusel accesible ---------- */
.carousel { position: relative; }
.carousel__track {
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--slide-w, min(78%, 320px));
  gap: var(--slide-gap, 16px); overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-padding-inline: 4px; padding: 12px 4px 20px; scrollbar-width: none; overscroll-behavior-x: contain;
}
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__track > * { scroll-snap-align: start; }
.carousel__controls { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 8px; }
.carousel__btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); cursor: pointer; display: grid; place-items: center;
  transition: background-color .2s, opacity .2s, transform .15s;
}
.carousel__btn:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
.carousel__btn:active:not(:disabled) { transform: scale(.94); }
.carousel__btn:disabled { opacity: .35; cursor: default; }
.carousel__btn svg { width: 18px; height: 18px; }

/* ---------- Filtros ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: .45em 1em; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); cursor: pointer; font-size: .95rem;
  transition: background-color .2s, color .2s, border-color .2s, transform .15s;
}
.chip:hover { border-color: var(--fg); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
[data-filter-item][hidden] { display: none !important; }
.filter-status { font-size: .95rem; color: var(--muted); margin: 12px 0 0; }

/* =========================================================
   MOVIMIENTO
   Los estados ocultos solo existen con JS activo y sin
   "reducir movimiento": sin JS, todo es visible.
   ========================================================= */

/* Entrada escalonada del hero */
.motion [data-hero] {
  opacity: 0; transform: translate3d(0, var(--hero-y, 22px), 0);
  transition: opacity var(--hero-d, 900ms) var(--ease-out), transform var(--hero-d, 900ms) var(--ease-out);
  transition-delay: calc(120ms + var(--i, 0) * var(--hero-stagger, 110ms));
}
.motion.is-ready [data-hero] { opacity: 1; transform: none; }

/* Aparición al entrar en pantalla */
.motion [data-reveal] {
  opacity: 0; transform: translate3d(0, 28px, 0);
  transition: opacity var(--d) var(--ease-out), transform var(--d) var(--ease-out), clip-path var(--d) var(--ease-out);
  transition-delay: calc(var(--i, 0) * var(--stagger));
}
.motion [data-reveal].is-in { opacity: 1; transform: none; }
.motion [data-reveal="fade"] { transform: none; }
.motion [data-reveal="scale"] { transform: scale(.94); }
.motion [data-reveal="left"] { transform: translate3d(-36px, 0, 0); }
.motion [data-reveal="right"] { transform: translate3d(36px, 0, 0); }
.motion [data-reveal="mask"] { opacity: 1; transform: none; clip-path: inset(0 0 98% 0); }
.motion [data-reveal="mask"].is-in { clip-path: inset(0 0 0 0); }
.motion [data-reveal="wipe"] { opacity: 1; transform: none; clip-path: inset(0 98% 0 0); }
.motion [data-reveal="wipe"].is-in { clip-path: inset(0 0 0 0); }

/* Texto que entra línea a línea desde una máscara */
.lines { display: block; }
.lines > span { display: block; overflow: hidden; padding-bottom: .06em; margin-bottom: -.06em; }
.lines > span > span { display: block; }
.motion .lines[data-lines] > span > span {
  transform: translate3d(0, 105%, 0);
  transition: transform var(--lines-d, 1000ms) var(--ease-out);
  transition-delay: calc(150ms + var(--i, 0) * var(--lines-stagger, 120ms));
}
.motion.is-ready .lines[data-lines="load"] > span > span,
.motion .lines[data-lines="view"].is-in > span > span { transform: none; }

/* Animaciones en bucle: solo corren cuando el elemento está en pantalla */
[data-loop]:not(.is-visible), [data-loop]:not(.is-visible) *,
[data-loop]:not(.is-visible)::before, [data-loop]:not(.is-visible)::after { animation-play-state: paused !important; }

/* Progreso de scroll: --p va de 0 (entra por abajo) a 1 (sale por arriba) */
[data-scroll] { --p: .5; }
.parallax { transform: translate3d(0, calc((var(--p) - .5) * var(--px, 60px)), 0); will-change: transform; }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; transition-delay: 0s !important;
  }
  .parallax { transform: none !important; }
}

/* ---------- Contacto (estructura por defecto) ---------- */
.contact__grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(32px, 5vw, 64px); align-items: start; }
@media (max-width: 860px) { .contact__grid { grid-template-columns: 1fr; } }

/* =========================================================
   FOTOS, CONTENIDO DE CLIENTES (UGC), RESEÑAS, PREGUNTAS Y PIE
   Heredan colores, radios y tipografías de cada plantilla.
   ========================================================= */
.ph-img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Muro UGC: columnas tipo red social, con fotos y vídeos verticales */
.ugc { --ugc-card: var(--bg); --ugc-tilt: 0deg; }
.ugc__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 32px; margin-bottom: clamp(28px, 4vw, 48px); }
.ugc__head .lead { margin: 0; }
.ugc__tag { margin: 0; font-weight: 700; font-size: 1.05rem; padding: .45em 1em; border-radius: 999px; background: var(--fg); color: var(--bg); }
.ugc__grid { columns: 3 260px; column-gap: 18px; }
.ugc__post { break-inside: avoid; margin: 0 0 18px; background: var(--ugc-card); border-radius: min(var(--radius), 18px); padding: 8px 8px 12px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 30px -24px rgba(0,0,0,.35); rotate: var(--ugc-tilt);
  transition: rotate .4s var(--ease), translate .4s var(--ease), box-shadow .4s var(--ease); }
.ugc__post:nth-child(even) { rotate: calc(var(--ugc-tilt) * -1); }
.ugc__post:hover { rotate: 0deg; translate: 0 -4px; box-shadow: 0 0 0 1px var(--line), 0 26px 40px -26px rgba(0,0,0,.45); }
.ugc__media { position: relative; overflow: hidden; border-radius: max(calc(min(var(--radius), 18px) - 4px), 0px); aspect-ratio: 4 / 5; background: var(--surface); }
.ugc__post--reel .ugc__media { aspect-ratio: 9 / 16; }
.ugc__media .ph-img { transition: transform .8s var(--ease-out); }
.ugc__post:hover .ph-img { transform: scale(1.04); }
.ugc__ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 16px;
  background: radial-gradient(120% 80% at 20% 10%, color-mix(in srgb, var(--accent) 45%, var(--bg)), color-mix(in srgb, var(--accent) 12%, var(--surface)) 60%, var(--surface)); }
.ugc__ph::before { content: ""; position: absolute; inset: 0; opacity: .5;
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--fg) 6%, transparent) 14px 15px); }
.ugc__ph { flex-direction: column; justify-content: center; align-items: center; gap: 8px; color: var(--fg); }
.ugc__ph svg { position: relative; width: 34px; opacity: .55; }
.ugc__ph span { position: relative; font-size: .85rem; font-weight: 600; opacity: .6; }
.ugc__kind { position: absolute; top: 10px; left: 10px; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.88); color: #111; }
.ugc__post figcaption { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px 0; font-size: .9rem; }
.ugc__avatar, .review__avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--accent); color: var(--accent-fg); }
.ugc__who { display: grid; gap: 1px; min-width: 0; }
.ugc__who strong { font-size: .88rem; }
.ugc__who span { color: var(--muted); overflow-wrap: anywhere; }
.demo-tag { margin: 18px 0 0; font-size: .82rem; color: var(--muted); }
@media (max-width: 560px) { .ugc__grid { columns: 2 150px; column-gap: 10px; } .ugc__post { margin-bottom: 10px; padding: 5px 5px 8px; } .ugc__post figcaption { font-size: .8rem; } .ugc__avatar { display: none; } }

/* Reseñas */
.reviews { background: var(--surface); }
.reviews__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 28px; }
.review { margin: 0; padding: 26px; border-radius: min(var(--radius), 20px); background: var(--bg); box-shadow: 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 14px; }
.review__stars { margin: 0; letter-spacing: .12em; color: var(--star, #E8A317); font-size: 1.05rem; }
.review blockquote { margin: 0; flex: 1; }
.review blockquote p { margin: 0; font-size: 1.05rem; line-height: 1.55; }
.review figcaption { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.review figcaption > span:last-child { display: grid; }
.review figcaption span span { color: var(--muted); }
@media (max-width: 860px) { .reviews__grid { grid-template-columns: 1fr; } }

/* Preguntas frecuentes (details nativo: teclado y lector de pantalla incluidos) */
.faq__grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: clamp(24px, 5vw, 64px); align-items: start; }
.faq__item { border-top: 1px solid var(--line); }
.faq__item:last-child { border-bottom: 1px solid var(--line); }
.faq__item summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 0; font-weight: 600; font-size: 1.08rem; }
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary i { flex: none; position: relative; width: 16px; height: 16px; }
.faq__item summary i::before, .faq__item summary i::after { content: ""; position: absolute; left: 0; top: 7px; width: 16px; height: 2px; background: currentColor; transition: transform .3s var(--ease); }
.faq__item summary i::after { transform: rotate(90deg); }
.faq__item[open] summary i::after { transform: rotate(0deg); }
.faq__item summary:hover span { text-decoration: underline; text-underline-offset: 4px; }
.faq__a p { margin: 0 0 20px; color: var(--muted); max-width: 60ch; }
.motion .faq__item[open] .faq__a { animation: faq-in .35s var(--ease-out); }
@keyframes faq-in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 760px) { .faq__grid { grid-template-columns: 1fr; } }

/* Pie completo */
.footer { padding-block: clamp(48px, 7vw, 80px) 28px; border-top: 1px solid var(--line); font-size: .93rem; color: var(--muted); }
.footer__cols { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
.footer__brand p { max-width: 34ch; margin-top: 14px; }
.footer .brand { color: var(--fg); }
.footer h2 { font-family: var(--font); font-size: .82rem; font-weight: 700; color: var(--fg); margin: 0 0 12px; letter-spacing: .02em; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.footer__h-social { margin-top: 20px !important; }
.footer__social { display: flex !important; flex-wrap: wrap; gap: 6px 14px !important; }
.footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .84rem; }
.footer__bottom p { margin: 0; }
.footer__legal span { opacity: .7; }
@media (max-width: 860px) { .footer__cols { grid-template-columns: 1fr 1fr; } .footer__brand { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer__cols { grid-template-columns: 1fr; } }
