/* MaFe Studio · base de todas las webs.
   No se toca por cliente: lo que cambia (color, familia, pesos) va en marca.css.
   Orden: tokens → reset → base → disposición → componentes → utilidades. */

@layer tokens, reset, base, disposicion, componentes, utilidades;

/* ---------- Tokens ---------- */
@layer tokens {
  :root {
    --margen: clamp(16px, 2.2vw, 40px);       /* margen exterior: igual en toda la web */
    --calle: clamp(12px, 1.6vw, 30px);        /* separación entre columnas */
    --junta: 6px;                             /* separación entre fotos de una rejilla */
    --seccion: clamp(96px, 12vw, 200px);      /* aire entre secciones */
    --cabecera: 72px;
    --cols: 12;

    --t-micro: 12px;
    --t-pequeno: 14px;
    --t-cuerpo: clamp(16px, .35vw + 15px, 20px);
    --t-entradilla: clamp(26px, 2.6vw, 46px);
    --t-titular: clamp(42px, 6vw, 104px);
    --t-display: clamp(60px, 13vw, 240px);

    --suave: cubic-bezier(.22, .8, .16, 1);
    --dur: 700ms;
  }
  @media (max-width: 900px) { :root { --cols: 6; } }
  @media (max-width: 600px)  { :root { --cols: 4; --cabecera: 60px; } }
}

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, ul, ol, figure, blockquote, address { margin: 0; }
  ul, ol { padding: 0; list-style: none; }
  img, video, svg { display: block; max-width: 100%; height: auto; }
  a { color: inherit; text-decoration: none; }
  button, input, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  address { font-style: normal; }
  * { border-radius: 0; }                     /* MaFe: nada redondeado */
}

/* ---------- Base ---------- */
@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: var(--cabecera); }
  html:has(.menu:popover-open) { overflow: hidden; }
  body {
    font-family: var(--familia);
    font-weight: var(--peso-normal);
    font-size: var(--t-cuerpo);
    line-height: 1.55;
    background: var(--oscuro-fondo);
    color: var(--oscuro-texto);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
  }
  p { text-wrap: pretty; max-width: 68ch; }
  em { font-style: var(--enfasis, italic); }
  strong, b { font-weight: var(--peso-fuerte); }
  ::selection { background: var(--acento-texto); color: var(--acento-fondo); }
  :focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

  [data-modo] { background: var(--fondo); color: var(--texto); }
  [data-modo="oscuro"] { --fondo: var(--oscuro-fondo); --texto: var(--oscuro-texto); --texto-2: var(--oscuro-texto-2); --linea: var(--oscuro-linea); }
  [data-modo="claro"]  { --fondo: var(--claro-fondo);  --texto: var(--claro-texto);  --texto-2: var(--claro-texto-2);  --linea: var(--claro-linea); }
  [data-modo="acento"] { --fondo: var(--acento-fondo); --texto: var(--acento-texto); --texto-2: var(--acento-texto-2); --linea: var(--acento-linea); }

  @media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
  }
}

/* ---------- Disposición ---------- */
@layer disposicion {
  .reticula {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    column-gap: var(--calle);
    row-gap: calc(var(--calle) * 2);
    padding-inline: var(--margen);
  }
  .celda { grid-column: var(--de, 1) / var(--a, -1); }
  @media (max-width: 900px) {
    .celda { grid-column: var(--de-t, 1) / var(--a-t, -1); }
  }
  @media (max-width: 600px) {
    .celda { grid-column: var(--de-m, 1) / var(--a-m, -1); }
  }

  .seccion { padding-block: var(--seccion); container-type: inline-size; }
  .seccion--pegada { padding-block-start: 0; }

  .rejilla {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--junta);
    padding-inline: var(--margen);
  }
  .rejilla--sangre { padding-inline: 0; }
  @container (max-width: 640px) { .rejilla { grid-template-columns: 1fr; } }

  .pila { display: grid; gap: 1.5rem; align-content: start; }
}

/* ---------- Componentes ---------- */
@layer componentes {

  /* Cabecera: hamburguesa · logo · una acción */
  .cabecera {
    position: fixed; inset: 0 0 auto; z-index: 50;
    height: var(--cabecera);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    padding-inline: var(--margen);
    color: var(--oscuro-texto);
    transition: background-color var(--dur) var(--suave);
  }
  .cabecera[data-estado="solido"] { background: color-mix(in oklab, var(--oscuro-fondo) 94%, transparent); }
  .cabecera__menu { justify-self: start; display: grid; place-items: center; width: 44px; height: 44px; margin-inline-start: -10px; }
  .cabecera__logo { justify-self: center; }
  .logo-texto { font-size: var(--t-pequeno); font-weight: var(--peso-fuerte); letter-spacing: .16em; text-transform: uppercase; }
  .boton--cabecera { justify-self: end; }
  @media (max-width: 600px) {
    .cabecera { column-gap: 12px; }
    .logo-texto { font-size: var(--t-micro); letter-spacing: .12em; }
    .boton--cabecera { min-height: 36px; padding: .55em .9em; }
  }

  .hamburguesa { display: block; width: 26px; height: 8px; border-block: 1px solid currentColor; }

  /* Menú a pantalla completa (API Popover: sin JS para abrir ni cerrar) */
  .menu {
    position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
    margin: 0; border: 0;
    padding: calc(var(--cabecera) + var(--margen)) var(--margen) var(--margen);
    background: var(--oscuro-fondo); color: var(--oscuro-texto);
    opacity: 0;
    transition: opacity .5s var(--suave), display .5s allow-discrete, overlay .5s allow-discrete;
  }
  .menu:popover-open {
    display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); column-gap: var(--calle);
    opacity: 1;
  }
  @starting-style { .menu:popover-open { opacity: 0; } }
  .menu__cerrar { position: absolute; top: 0; left: var(--margen); height: var(--cabecera); }
  .menu__lista { grid-column: 1 / 7; align-self: end; display: grid; gap: .1em; }
  .menu__lista a {
    display: flex; align-items: baseline; gap: .6em;
    font-size: var(--t-titular); font-weight: var(--peso-fino); line-height: 1.05; letter-spacing: -.02em;
    transition: opacity .4s var(--suave);
  }
  .menu__lista:has(a:hover, a:focus-visible) a:not(:hover, :focus-visible) { opacity: .35; }
  .menu__lista [aria-current="page"] { font-style: var(--enfasis, italic); }
  .menu__fotos { grid-column: 8 / -1; position: relative; }
  .menu__fotos .hueco { position: absolute; inset: 0; opacity: 0; transition: opacity .6s var(--suave); }
  .menu__fotos [data-foto="1"] { opacity: 1; }
  .menu:has(.menu__lista li:hover, .menu__lista li:focus-within) .menu__fotos [data-foto] { opacity: 0; }
  .menu:has(li[data-foto="1"]:hover, li[data-foto="1"]:focus-within) .menu__fotos [data-foto="1"],
  .menu:has(li[data-foto="2"]:hover, li[data-foto="2"]:focus-within) .menu__fotos [data-foto="2"],
  .menu:has(li[data-foto="3"]:hover, li[data-foto="3"]:focus-within) .menu__fotos [data-foto="3"],
  .menu:has(li[data-foto="4"]:hover, li[data-foto="4"]:focus-within) .menu__fotos [data-foto="4"],
  .menu:has(li[data-foto="5"]:hover, li[data-foto="5"]:focus-within) .menu__fotos [data-foto="5"],
  .menu:has(li[data-foto="6"]:hover, li[data-foto="6"]:focus-within) .menu__fotos [data-foto="6"] { opacity: 1; }
  @media (max-width: 900px) {
    .menu__lista { grid-column: 1 / -1; }
    .menu__fotos { display: none; }
  }

  /* Hero: 100svh, medio a sangre, texto abajo y a columna */
  .hero { position: relative; min-height: 100svh; display: grid; align-items: end; isolation: isolate; }
  .hero__medio { position: absolute; inset: 0; z-index: -1; }
  .hero__medio > * { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .hero__medio::after { content: ""; position: absolute; inset: 0; background: color-mix(in oklab, #000 28%, transparent); }
  .hero__texto { padding-block: var(--margen); row-gap: 1rem; }
  .hero--corto .display { font-size: var(--t-titular); }

  /* Hueco de foto o vídeo mientras no hay material real */
  .hueco {
    aspect-ratio: var(--proporcion, auto);
    display: grid; place-items: center;
    background: color-mix(in oklab, currentColor 9%, transparent);
  }
  .hueco::after {
    content: attr(data-etiqueta);
    font-size: var(--t-micro); font-weight: var(--peso-fuerte); letter-spacing: .14em; text-transform: uppercase;
    opacity: .55;
  }

  /* Filas con filete: cartas, servicios, precios, datos */
  .filas { border-top: 1px solid var(--linea); }
  .filas li {
    display: grid; grid-template-columns: 2fr 2fr auto; gap: var(--calle);
    padding-block: 1.1rem; border-bottom: 1px solid var(--linea);
  }
  @container (max-width: 640px) { .filas li { grid-template-columns: 1fr auto; } .filas li > :nth-child(2) { grid-row: 2; } }

  /* Acciones */
  .boton {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: .75em 1.4em;
    border: 1px solid currentColor; background: transparent;
    font-size: var(--t-micro); font-weight: var(--peso-fuerte); letter-spacing: .14em; text-transform: uppercase;
    transition: background-color .4s var(--suave), color .4s var(--suave);
  }
  .boton:hover { color: var(--fondo, var(--oscuro-fondo)); background: var(--texto, var(--oscuro-texto)); }
  .enlace { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .3em; }

  /* Formulario rectangular con etiquetas visibles */
  .formulario { row-gap: 2rem; }
  .campo { display: grid; gap: .6rem; font-size: var(--t-micro); font-weight: var(--peso-fuerte); letter-spacing: .14em; text-transform: uppercase; }
  .campo input, .campo textarea {
    width: 100%; padding: .7em 0; border: 0; border-bottom: 1px solid var(--linea); background: transparent;
    font-size: var(--t-cuerpo); font-weight: var(--peso-normal); letter-spacing: 0; text-transform: none;
  }
  .campo :focus-visible { outline: 0; border-bottom-color: currentColor; }

  .cierre__accion { align-self: end; justify-self: end; }
  @media (max-width: 900px) { .cierre__accion { justify-self: start; } }

  /* Pie */
  .pie { padding-block: var(--seccion) var(--margen); }
  .pie__marca { font-size: var(--t-entradilla); font-weight: var(--peso-fino); line-height: 1.1; }
  .pie .pequeno li + li { margin-top: .3rem; }
  .pie__base { margin-top: calc(var(--seccion) / 2); padding-top: 1rem; border-top: 1px solid var(--linea); }
  .pie__firma { text-align: end; }
  @media (max-width: 900px) { .pie__firma { text-align: start; } }

  .saltar { position: fixed; top: -100px; left: var(--margen); z-index: 100; padding: .8em 1.2em; background: var(--oscuro-texto); color: var(--oscuro-fondo); }
  .saltar:focus { top: var(--margen); }
}

/* ---------- Utilidades ---------- */
@layer utilidades {
  .display { font-size: var(--t-display); font-weight: var(--peso-fino); line-height: .95; letter-spacing: -.035em; text-wrap: balance; }
  .titular { font-size: var(--t-titular); font-weight: var(--peso-fino); line-height: 1.02; letter-spacing: -.02em; text-wrap: balance; }
  .entradilla { font-size: var(--t-entradilla); font-weight: var(--peso-fino); line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; max-width: none; }
  .micro { font-size: var(--t-micro); font-weight: var(--peso-fuerte); letter-spacing: .14em; text-transform: uppercase; line-height: 1.5; }
  .pequeno { font-size: var(--t-pequeno); }
  .secundario { color: var(--texto-2); }

  /* Protege rabos y acentos cuando un texto va dentro de una máscara */
  .mascara { padding-block: .12em; margin-block: -.12em; }

  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* Entrada al hacer scroll: solo si el navegador lo soporta y el usuario no pide menos movimiento */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      .aparece { animation: aparece linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
    }
  }
  @keyframes aparece { from { opacity: 0; translate: 0 2.5rem; } }
}
