/* Red Empresarial Hispana — CSS moderno, sin JavaScript */

@layer reset, base, componentes, utilidades, movimiento;

/* ---------- Transiciones entre páginas (View Transitions entre documentos) ---------- */
@view-transition {
  navigation: auto;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  ul, ol { padding: 0; list-style: none; }
}

@layer base {
  :root {
    color-scheme: light dark;

    --marino: oklch(0.16 0.008 255);   /* negro profundo */
    --marino-2: oklch(0.23 0.012 255);
    --acento: oklch(0.8 0.14 70);
    --acento-fuerte: oklch(0.72 0.15 62);
    --azul: oklch(0.64 0.12 250);      /* azul acero */

    --fondo: light-dark(oklch(0.99 0.003 90), oklch(0.14 0.006 255));
    --fondo-suave: light-dark(oklch(0.96 0.006 90), oklch(0.18 0.008 255));
    --superficie: light-dark(#fff, oklch(0.2 0.01 255));
    --texto: light-dark(oklch(0.22 0.01 255), oklch(0.94 0.005 255));
    --texto-suave: light-dark(oklch(0.48 0.012 255), oklch(0.74 0.01 255));
    --borde: light-dark(oklch(0.9 0.006 255), oklch(0.29 0.01 255));
    --enlace: light-dark(oklch(0.48 0.13 250), oklch(0.74 0.12 250));

    --fuente: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --fuente-titulo: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

    --radio: 0.9rem;
    --sombra: 0 1px 2px oklch(0 0 0 / 0.08), 0 8px 24px oklch(0 0 0 / 0.12);
    --ancho: 72rem;
    --cabecera-alto: 4.5rem;
  }

  html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--cabecera-alto) + 1rem);
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    font-family: var(--fuente);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--texto);
    background: var(--fondo);
  }

  h1, h2, h3 {
    font-family: var(--fuente-titulo);
    line-height: 1.15;
    text-wrap: balance;
    letter-spacing: -0.01em;
  }
  h1 { font-size: clamp(2.2rem, 1.4rem + 3.5vw, 3.8rem); }
  h2 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); }
  h3 { font-size: 1.3rem; }
  p { text-wrap: pretty; }
  p + p { margin-top: 1rem; }

  a { color: var(--enlace); text-underline-offset: 0.2em; }
  :focus-visible { outline: 3px solid var(--acento-fuerte); outline-offset: 3px; border-radius: 4px; }
  ::selection { background: var(--acento); color: var(--marino); }
}

@layer componentes {
  .contenedor {
    width: min(100% - 2.5rem, var(--ancho));
    margin-inline: auto;
  }
  .contenedor--angosto { width: min(100% - 2.5rem, 46rem); }

  .saltar {
    position: absolute; left: 1rem; top: -4rem;
    background: var(--acento); color: var(--marino);
    padding: 0.6rem 1rem; border-radius: 0.5rem; z-index: 100;
    &:focus { top: 1rem; }
  }

  /* ----- Cabecera ----- */
  .cabecera {
    position: sticky; top: 0; z-index: 50;
    height: var(--cabecera-alto);
    background: color-mix(in oklab, var(--marino) 94%, transparent);
    backdrop-filter: blur(10px);
    color: #fff;
    view-transition-name: cabecera; /* se mantiene fija durante la navegación */
  }
  .cabecera__fila {
    height: 100%;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  }

  .marca {
    display: inline-flex; align-items: center; gap: 0.65rem;
    color: inherit; text-decoration: none;
    font-family: var(--fuente-titulo); font-size: 1.15rem;
    strong { color: var(--acento); font-weight: 700; }
  }
  .marca__logo { width: 2rem; height: 2rem; color: oklch(0.26 0.014 255); outline: 1px solid oklch(1 0 0 / 0.2); border-radius: 0.5rem; }

  .menu-boton {
    display: grid; gap: 5px; place-content: center;
    width: 2.75rem; height: 2.75rem;
    background: transparent; border: 1px solid oklch(1 0 0 / 0.3); border-radius: 0.6rem;
    cursor: pointer;
    span { display: block; width: 1.3rem; height: 2px; background: #fff; border-radius: 2px; }
  }

  /* Menú móvil con el atributo popover (sin JS) */
  .menu {
    inset: var(--cabecera-alto) 0 auto 0;
    width: 100%; margin: 0; border: 0;
    padding: 1rem 1.25rem 1.5rem;
    background: var(--marino); color: #fff;
    display: none;
    flex-direction: column; gap: 1rem;
    &:popover-open { display: flex; }
    ul { display: grid; gap: 0.25rem; }
    a:not(.boton) {
      display: block; padding: 0.75rem 0.5rem;
      color: #fff; text-decoration: none; border-radius: 0.5rem;
      &:hover { background: oklch(1 0 0 / 0.1); }
      &[aria-current="page"] { color: var(--acento); font-weight: 600; }
    }
  }

  @media (min-width: 58rem) {
    .menu-boton { display: none; }
    .menu, .menu:not(:popover-open) {
      position: static; inset: auto; width: auto; padding: 0; background: none;
      display: flex; flex-direction: row; align-items: center; gap: 1.5rem;
      overflow: visible;
    }
    .menu ul { display: flex; gap: 0.25rem; }
    .menu a:not(.boton) { padding: 0.5rem 0.8rem; }
  }

  /* ----- Botones ----- */
  .boton {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.8rem 1.4rem; border-radius: 999px; border: 2px solid transparent;
    font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
    &:hover { transform: translateY(-2px); }
  }
  .boton--acento { background: var(--acento); color: var(--marino); &:hover { background: var(--acento-fuerte); } }
  .boton--borde { border-color: var(--borde); color: var(--texto); &:hover { border-color: var(--texto-suave); } }
  .boton--borde-claro { border-color: oklch(1 0 0 / 0.45); color: #fff; &:hover { border-color: #fff; } }
  .acciones { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.75rem; }

  /* ----- Portada ----- */
  .hero {
    background:
      radial-gradient(60rem 30rem at 85% -10%, oklch(0.5 0.11 250 / 0.28), transparent),
      var(--marino);
    color: #fff;
    padding-block: clamp(3rem, 8vw, 6.5rem);
  }
  .hero__rejilla { display: grid; gap: 3rem; align-items: center; }
  @media (min-width: 58rem) { .hero__rejilla { grid-template-columns: 1.3fr 1fr; } }
  .hero h1 em { display: block; font-style: italic; color: var(--acento); }
  .lead { font-size: 1.2rem; color: inherit; opacity: 0.88; margin-top: 1.25rem; max-width: 40rem; }
  .ilustracion {
    border-radius: 1.25rem; overflow: hidden;
    border: 1px solid oklch(1 0 0 / 0.12);
    box-shadow: 0 30px 60px -20px oklch(0 0 0 / 0.6);
    img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
  }
  .encabezado__rejilla { display: grid; gap: 2.5rem; align-items: center; }
  @media (min-width: 58rem) { .encabezado__rejilla { grid-template-columns: 1.15fr 1fr; gap: 4rem; } }

  .tarjeta__img {
    width: calc(100% + 3.5rem); max-width: none; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
    margin: -1.75rem -1.75rem 0.4rem; border-radius: var(--radio) var(--radio) 0 0;
  }

  .etiqueta {
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--acento-fuerte); margin-bottom: 0.75rem;
  }
  .hero .etiqueta, .encabezado .etiqueta { color: var(--acento); }
  .encabezado { overflow: clip; }

  .icono {
    flex: none; display: grid; place-items: center;
    width: 2.8rem; height: 2.8rem; border-radius: 0.8rem;
    background: var(--acento); color: var(--marino);
    font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums;
  }

  /* ----- Secciones ----- */
  .encabezado {
    background: var(--marino); color: #fff;
    padding-block: clamp(2.5rem, 6vw, 4.5rem);
  }
  .seccion { padding-block: clamp(3rem, 7vw, 5.5rem); }
  .seccion--suave { background: var(--fondo-suave); }
  .seccion__cab { margin-bottom: 2.5rem; max-width: 40rem; }

  .rejilla { display: grid; gap: 1.5rem; }
  @media (min-width: 48rem) { .rejilla--3 { grid-template-columns: repeat(3, 1fr); } }

  .tarjeta {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.85rem;
    background: var(--superficie); border: 1px solid var(--borde);
    border-radius: var(--radio); padding: 1.75rem; box-shadow: var(--sombra);
    transition: transform 0.25s, border-color 0.25s;
    &:hover { transform: translateY(-4px); border-color: var(--acento-fuerte); }
    p { color: var(--texto-suave); flex: 1; }
  }

  .enlace {
    font-weight: 600; text-decoration: none;
    &::after { content: " →"; transition: margin 0.2s; }
    &:hover::after { margin-left: 0.3rem; }
  }

  .dividida { display: grid; gap: 2.5rem; align-items: start; }
  @media (min-width: 58rem) { .dividida { grid-template-columns: 1fr 1fr; gap: 4rem; } }
  @media (min-width: 58rem) { .dividida--formulario { grid-template-columns: 0.8fr 1fr; } }
  .dividida h2 { margin-bottom: 1rem; }

  .checks {
    display: grid; gap: 1rem;
    li { position: relative; padding-left: 2.2rem; }
    li::before {
      content: ""; position: absolute; left: 0; top: 0.2rem;
      width: 1.4rem; height: 1.4rem; border-radius: 50%;
      background: var(--acento)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 8.5 2.5 2.5L12 5.5' fill='none' stroke='%230b0d10' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat;
    }
  }

  .recuadro {
    background: var(--superficie); border: 1px solid var(--borde);
    border-radius: var(--radio); padding: 2rem; box-shadow: var(--sombra);
  }
  .puntos li { padding-block: 0.6rem; border-bottom: 1px solid var(--borde); &:last-child { border: 0; } }

  .pasos {
    display: grid; gap: 1.5rem; counter-reset: paso;
    @media (min-width: 48rem) { grid-template-columns: repeat(3, 1fr); }
    li { counter-increment: paso; border-top: 3px solid var(--acento); padding-top: 1.25rem; }
    li::before {
      content: counter(paso, decimal-leading-zero);
      font-family: var(--fuente-titulo); font-size: 2rem; color: var(--acento-fuerte);
    }
    h3 { margin-block: 0.25rem 0.5rem; }
    p { color: var(--texto-suave); }
  }

  .apilado { display: grid; gap: 1.5rem; }
  .servicio {
    display: flex; gap: 1.5rem; align-items: flex-start;
    background: var(--superficie); border: 1px solid var(--borde);
    border-radius: var(--radio); padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: var(--sombra);
    h2 { margin-bottom: 0.6rem; }
    p { color: var(--texto-suave); margin-bottom: 1rem; }
  }

  /* ----- Preguntas frecuentes ----- */
  details {
    border-bottom: 1px solid var(--borde);
    summary {
      cursor: pointer; padding-block: 1.1rem; font-weight: 600; list-style: none;
      display: flex; justify-content: space-between; gap: 1rem;
      &::-webkit-details-marker { display: none; }
      &::after { content: "+"; font-size: 1.5rem; line-height: 1; color: var(--acento-fuerte); transition: rotate 0.25s; }
    }
    &[open] summary::after { rotate: 45deg; }
    p { padding-bottom: 1.2rem; color: var(--texto-suave); }
    &::details-content {
      block-size: 0; overflow: clip;
      transition: block-size 0.3s, content-visibility 0.3s allow-discrete;
    }
    &[open]::details-content { block-size: auto; }
  }
  @supports (interpolate-size: allow-keywords) {
    :root { interpolate-size: allow-keywords; }
  }

  /* ----- Llamado a la acción ----- */
  .cta { padding-block: 0 clamp(3rem, 7vw, 5.5rem); }
  .cta__caja {
    background: var(--marino); color: #fff; text-align: center;
    border-radius: 1.5rem; padding: clamp(2rem, 6vw, 4rem);
    background-image: radial-gradient(30rem 15rem at 100% 0, oklch(0.5 0.11 250 / 0.3), transparent);
    p { opacity: 0.88; margin: 0.75rem auto 0; max-width: 34rem; }
    .acciones { justify-content: center; }
  }

  /* ----- Formularios ----- */
  .formulario {
    display: grid; gap: 1.25rem;
    background: var(--superficie); border: 1px solid var(--borde);
    border-radius: var(--radio); padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: var(--sombra);
  }
  .campo { display: grid; gap: 0.4rem; border: 0; padding: 0; min-width: 0; }
  label, legend { font-weight: 600; font-size: 0.95rem; }
  .opcional { font-weight: 400; color: var(--texto-suave); }
  input:not([type="checkbox"]), select, textarea {
    width: 100%; padding: 0.75rem 0.9rem;
    background: var(--fondo); border: 1.5px solid var(--borde); border-radius: 0.6rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    &:focus { outline: none; border-color: var(--acento-fuerte); box-shadow: 0 0 0 4px color-mix(in oklab, var(--acento) 35%, transparent); }
    &:user-invalid { border-color: oklch(0.6 0.2 25); }
  }
  textarea { resize: vertical; min-height: 7rem; }
  .opcion {
    display: flex; align-items: flex-start; gap: 0.6rem; font-weight: 400; cursor: pointer;
    input { width: 1.15rem; height: 1.15rem; margin-top: 0.3rem; accent-color: var(--acento-fuerte); }
  }
  fieldset.campo { gap: 0.6rem; legend { margin-bottom: 0.4rem; } }

  .datos {
    display: grid; gap: 0.25rem; margin-block: 1.25rem 1.5rem;
    dt { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--texto-suave); margin-top: 0.75rem; }
    dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
  }

  /* Validación sin JavaScript: el mensaje aparece solo cuando el usuario ya interactuó */
  .error { display: none; font-size: 0.88rem; font-weight: 500; color: oklch(0.55 0.2 25); }
  @media (prefers-color-scheme: dark) { .error { color: oklch(0.75 0.15 25); } }
  .campo:has(:user-invalid) .error { display: block; }
  select:user-invalid { border-color: oklch(0.6 0.2 25); }
  input:user-valid:not([type="checkbox"]), textarea:user-valid { border-color: oklch(0.65 0.15 150); }

  /* Campo trampa para bots, fuera de pantalla */
  .trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

  /* ----- Páginas de gracias / error ----- */
  .aviso { padding-block: clamp(4rem, 12vw, 8rem); text-align: center; }
  .aviso__caja { display: grid; justify-items: center; gap: 0.5rem; .acciones { justify-content: center; } }
  .aviso__icono {
    width: 4.5rem; height: 4.5rem; border-radius: 50%; margin-bottom: 1rem;
    background: var(--acento) center / 55% no-repeat;
    &--ok { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8.5 3 3 6-7' fill='none' stroke='%230b0d10' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
    &--mal { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.5v5.5M8 12v.5' fill='none' stroke='%230b0d10' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }
  }
  .aviso .lead { color: var(--texto-suave); opacity: 1; }

  /* ----- Pie ----- */
  .pie {
    background: var(--marino); color: oklch(1 0 0 / 0.8);
    padding-top: 3.5rem; font-size: 0.97rem;
    a { color: inherit; text-underline-offset: 0.2em; &:hover { color: var(--acento); } }
    h2 { font-family: var(--fuente); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--acento); margin-bottom: 0.9rem; }
    li + li { margin-top: 0.4rem; }
  }
  .pie__rejilla { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
  .marca--pie { color: #fff; margin-bottom: 0.75rem; }
  .pie__legal p + p { margin-top: 0; }
  .pie__legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; margin-top: 2.5rem; padding-block: 1.5rem; border-top: 1px solid oklch(1 0 0 / 0.15); font-size: 0.88rem; opacity: 0.8; }
}

/* ---------- Movimiento ---------- */
@layer movimiento {
  /* Transición entre páginas: el contenido sale y entra con un desplazamiento suave */
  main { view-transition-name: contenido; }

  ::view-transition-group(*) { animation-duration: 0.45s; animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1); }
  ::view-transition-old(contenido) { animation: 0.25s ease-in both salida; }
  ::view-transition-new(contenido) { animation: 0.45s 0.1s cubic-bezier(0.2, 0.7, 0.2, 1) both entrada; }

  @keyframes salida { to { opacity: 0; translate: 0 -0.75rem; } }
  @keyframes entrada { from { opacity: 0; translate: 0 1.25rem; } }

  /* Aparición al hacer scroll (animaciones ligadas al scroll, sin JS) */
  @supports (animation-timeline: view()) {
    .reveal {
      animation: aparecer linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 35%;
    }
    @keyframes aparecer { from { opacity: 0; translate: 0 2rem; } }
  }

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