/* Margin Studio — página de Inicio */

/* ---------- Portada ---------- */
.portada {
  position: relative; height: 100vh; height: 100svh; min-height: 620px;
  overflow: hidden; isolation: isolate;
  background: var(--oliva-profundo);
}
html.fondo-animado .portada { background: var(--oliva-profundo); }
.escena { position: absolute; inset: 0; z-index: -1; }
.escena picture, .escena-fija, .escena-3d { position: absolute; inset: 0; width: 100%; height: 100%; }
.escena-fija { object-fit: cover; object-position: 50% 50%; }
.escena picture.con-parallax { transition: transform 1.1s var(--ease-out); will-change: transform; }
.escena-3d { opacity: 0; transition: opacity .8s var(--ease-out); }
.escena.gl-listo .escena-3d { opacity: 1; }

.portada-contenido {
  position: absolute; left: 0; right: 0; bottom: 104px;
  display: grid; gap: 20px; justify-items: start;
  max-width: none;
}
.portada-contenido .display { font-size: clamp(2.75rem, 1.2rem + 4.4vw, 6rem); max-width: min(8.6em, 52vw); }
.portada-contenido .texto { max-width: min(30em, 46vw); color: #E3DFD5; }
@media (max-aspect-ratio: 1/1) {
  .portada-contenido .display, .portada-contenido .texto { max-width: 30em; }
}
.botones { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

.portada-barra {
  position: absolute; left: 0; right: 0; bottom: 20px; max-width: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  font-size: var(--t-etiqueta); font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--fg-2);
}
.pb-der { justify-self: end; }
.pb-bajar {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 20px;
  border-radius: var(--r-pill); border: 1px solid rgba(236, 232, 223, .32); border: 1px solid color-mix(in srgb, var(--piedra) 32%, transparent);
  color: var(--piedra); letter-spacing: .08em;
  transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out), transform .16s var(--ease-out);
}
.pb-bajar:active { transform: scale(.97); }
.flecha-abajo { display: inline-block; }
html.anim:not(.reduce) .flecha-abajo { animation: bajar 2.4s var(--ease-in-out) infinite; }
@keyframes bajar { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(3px); } }
@media (hover: hover) and (pointer: fine) {
  .pb-bajar:hover { border-color: var(--piedra); background: color-mix(in srgb, var(--piedra) 8%, transparent); }
}
@media (max-width: 599px) {
  .portada-barra .pb-lado { display: none; }
  .portada-barra { grid-template-columns: 1fr; justify-items: center; }
  .portada-contenido { bottom: 88px; gap: 16px; }
  .portada-contenido .texto { font-size: 1rem; line-height: 24px; }
  .botones .btn { flex: 1 1 auto; }
}
@media (min-width: 900px) {
  .portada-contenido { bottom: 120px; }
}

/* ---------- Secciones ---------- */
.sec { padding-block: var(--sec); position: relative; }
.sec-cabeza { display: grid; gap: 20px; margin-bottom: clamp(48px, 7vw, 104px); justify-items: start; }
.sec-cabeza .titulo { max-width: 14em; }

/* 01 Para quién */
.publico { display: grid; gap: 56px; }
.publico-col { border-top: 1px solid var(--linea); padding-top: 24px; }
.publico-col .seccion-t { margin-bottom: 24px; }
.lista-grande { display: flex; flex-wrap: wrap; gap: 4px 0; }
.lista-grande li {
  font-size: var(--t-subtitulo); line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; color: var(--fg);
}
.lista-grande li:not(:last-child)::after { content: ","; margin-right: .35em; color: var(--fg-2); }
.lista-grande li:last-child::after { content: "."; color: var(--fg-2); }
@media (min-width: 900px) {
  .publico { grid-template-columns: 1fr 1fr; gap: 48px; }
}

/* 02 Cómo trabajamos */
.pasos { display: grid; gap: 48px; counter-reset: paso; }
.paso { position: relative; padding-top: 28px; display: grid; gap: 12px; align-content: start; }
.paso-linea { position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--linea); overflow: hidden; }
.paso-linea i { position: absolute; inset: 0; background: var(--fg); transform-origin: left; transform: scaleX(0); }
html:not(.anim) .paso-linea i, html.reduce .paso-linea i { transform: scaleX(1); opacity: .5; }
.paso-num {
  font-size: clamp(3rem, 2rem + 3vw, 5rem); font-weight: 700; letter-spacing: -0.05em; line-height: .9;
  color: var(--acento); font-variant-numeric: tabular-nums; margin-bottom: 16px;
}
.paso .texto { color: var(--fg-2); max-width: 22em; }
@media (min-width: 640px) { .pasos { grid-template-columns: 1fr 1fr; column-gap: 32px; } }
@media (min-width: 1080px) { .pasos { grid-template-columns: repeat(4, 1fr); } }

/* 03 Por qué */
.por-que { display: grid; gap: 0; }
.por-que-cabeza { margin-bottom: 48px; }
.razones { border-top: 1px solid var(--linea); }
.razon {
  display: grid; gap: 8px; padding-block: 28px; border-bottom: 1px solid var(--linea);
}
.razon .texto { color: var(--fg-2); }
@media (min-width: 900px) {
  .por-que { grid-template-columns: 5fr 7fr; gap: 48px; align-items: start; }
  .por-que-cabeza { position: sticky; top: calc(var(--header-h) + 48px); margin-bottom: 0; }
  .razon { grid-template-columns: 1.1fr 1fr; align-items: baseline; gap: 32px; padding-block: 36px; }
}

/* ---------- 04 Proyectos ---------- */
.proyectos { position: relative; padding-top: var(--sec); padding-bottom: clamp(64px, 8vw, 120px); }
.proy-cabeza { display: grid; gap: 20px; justify-items: start; margin-bottom: 48px; }
.proy-escenario { position: relative; }
.proy-gl { display: none; }

/* Marco simple de navegador para las capturas */
.marco {
  background: var(--hueso); border-radius: var(--r-md); overflow: hidden;
  box-shadow: 0 0 0 1px rgba(30, 36, 26, .08);
}
.marco-barra { display: flex; gap: 6px; align-items: center; height: 28px; padding-inline: 12px; background: var(--hueso); }
.marco-barra i { width: 8px; height: 8px; border-radius: 50%; background: var(--arena); }
.marco img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; background: var(--oliva-profundo); }

/* Versión simple (sin animaciones o sin 3D): un proyecto debajo del otro */
.proy-lista { display: grid; gap: 96px; padding-inline: var(--gutter); max-width: calc(var(--ancho) + var(--gutter) * 2); margin-inline: auto; }
.proy { display: grid; gap: 28px; }
.proy-num { font-size: var(--t-etiqueta); letter-spacing: .16em; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.proy-nombre {
  /* el nombre más largo nunca invade la captura */
  font-size: min(clamp(3.25rem, 1.5rem + 8.4vw, 10.5rem), calc((37vw - 72px) / (var(--letras, 6) * 0.64))); line-height: .86; letter-spacing: -0.055em;
  font-weight: 700; color: var(--fg); margin-top: 8px;
}
.proy-meta { margin-top: 16px; font-size: var(--t-seccion); font-weight: 600; color: var(--fg); letter-spacing: -0.01em; }
.proy-desc { margin-top: 8px; color: var(--fg-2); max-width: 30em; }
.pildoras { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.pildoras li {
  font-size: .8125rem; font-weight: 600; line-height: 1; padding: 8px 12px;
  border-radius: var(--r-pill); border: 1px solid var(--linea); color: var(--fg);
}
.proy-enlace { margin-top: 24px; }
.proy-indice, .proy-navegar { display: none; }
.proy-todos { margin-top: 72px; }
@media (min-width: 900px) {
  .proy { grid-template-columns: 1fr 1fr; align-items: center; gap: 48px; }
  .proy .marco { order: 2; transform: perspective(1400px) rotateY(-9deg) rotateX(3deg); }
}

/* Versión de recorrido: un proyecto por pantalla, fijo mientras se baja */
html.proy-recorrido .proy-escenario { height: 100vh; height: 100svh; overflow: hidden; }
html.proy-recorrido .proy-lista { position: absolute; inset: 0; display: block; padding: 0; max-width: none; }
html.proy-recorrido .proy {
  position: absolute; inset: 0; display: block; visibility: hidden;
}
html.proy-recorrido .proy.activo { visibility: visible; }
html.proy-recorrido .proy-texto {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 96px; max-width: 760px;
}
html.proy-recorrido .proy-nombre { overflow: hidden; padding-bottom: .06em; }
@media (min-width: 900px) {
  /* el nombre nunca pasa por debajo de la captura */
  html.proy-recorrido .proy-nombre { max-width: calc(37vw - 72px); }
}
html.proy-recorrido .proy-nombre .ni { display: inline-block; }
html.proy-recorrido .proy .marco {
  position: absolute; right: 12%; top: 50%; width: min(48vw, 760px); order: 0;
  transform: translateY(-58%) perspective(1600px) rotateY(-14deg) rotateX(5deg) rotateZ(-1deg);
  transition: opacity .6s var(--ease-out);
}
html.proy-recorrido.proy-webgl .proy .marco { opacity: 0; pointer-events: none; }
html.proy-recorrido .proy-gl { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
html.proy-recorrido .proy-indice {
  display: block; position: absolute; right: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 2;
}
html.proy-recorrido .proy-indice ol { display: grid; gap: 4px; }
html.proy-recorrido .proy-indice button {
  display: flex; gap: 14px; align-items: baseline; width: 100%; justify-content: flex-end;
  padding: 8px 0; font-size: .875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-2); transition: color .25s var(--ease-out);
}
html.proy-recorrido .proy-indice button span { font-size: 11px; font-variant-numeric: tabular-nums; }
html.proy-recorrido .proy-indice button[aria-current="true"] { color: var(--piedra); }
html.proy-recorrido .proy-indice button::after {
  content: ""; width: 0; height: 1px; background: currentColor; align-self: center; transition: width .3s var(--ease-out);
}
html.proy-recorrido .proy-indice button[aria-current="true"]::after { width: 24px; }
@media (hover: hover) and (pointer: fine) {
  html.proy-recorrido .proy-indice button:hover { color: var(--piedra); }
}
html.proy-recorrido .proy-navegar {
  display: flex; justify-content: space-between; position: absolute; left: var(--gutter); right: var(--gutter); bottom: 28px; z-index: 2;
  border-top: 1px solid var(--linea); padding-top: 14px;
}
html.proy-recorrido .proy-navegar button {
  font-size: .875rem; font-weight: 500; color: var(--fg-2); min-height: 40px;
  transition: color .2s var(--ease-out), opacity .2s var(--ease-out);
}
html.proy-recorrido .proy-navegar button[hidden] { display: inline-block; visibility: hidden; }
html.proy-recorrido .proy-navegar .n { color: var(--piedra); font-weight: 600; }
@media (hover: hover) and (pointer: fine) {
  html.proy-recorrido .proy-navegar button:hover { color: var(--piedra); }
}
@media (max-width: 899px) {
  .proy-nombre { font-size: min(clamp(3.25rem, 1.5rem + 8.4vw, 10.5rem), calc((100vw - 32px) / (var(--letras, 6) * 0.66))); }
  html.proy-recorrido .proy-indice { display: none; }
  html.proy-recorrido .proy .marco {
    left: var(--gutter); right: var(--gutter); width: auto; top: calc(var(--header-h) + 16px);
    transform: perspective(1200px) rotateX(6deg) rotateY(-6deg);
  }
  html.proy-recorrido .proy-texto { bottom: 84px; }
  html.proy-recorrido .proy-meta { margin-top: 10px; font-size: 1.125rem; }
  html.proy-recorrido .pildoras { margin-top: 14px; }
  html.proy-recorrido .proy-enlace { margin-top: 14px; }
  html.proy-recorrido .proy-navegar button { font-size: .8125rem; }
}
@media (max-height: 720px) and (min-width: 900px) {
  html.proy-recorrido .proy-nombre { font-size: clamp(3rem, 1rem + 7vw, 7.5rem); }
}

/* ---------- 05 Cierre ---------- */
.cierre .wrap { display: grid; gap: 28px; justify-items: start; }
.cierre .display { max-width: 9em; }
.cierre-pie { display: grid; gap: 28px; justify-items: start; margin-top: 12px; }
.cierre-pie .texto { color: var(--fg-2); max-width: 26em; font-size: 1.1875rem; line-height: 1.5; }
@media (min-width: 900px) {
  .cierre-pie { grid-template-columns: minmax(0, 28em) auto; align-items: end; gap: 48px; }
}

/* Teléfonos chicos o de pantalla baja: textos de proyectos un poco más compactos */
@media (max-width: 899px) and (max-height: 700px) {
  html.proy-recorrido .proy-num { display: none; }
  html.proy-recorrido .proy-nombre { font-size: min(2.75rem, calc((100vw - 32px) / (var(--letras, 6) * 0.66))); }
  html.proy-recorrido .proy-meta { margin-top: 6px; font-size: 1rem; }
  html.proy-recorrido .proy-desc { font-size: .9375rem; line-height: 1.4; margin-top: 6px; }
  html.proy-recorrido .pildoras { margin-top: 10px; gap: 6px; }
  html.proy-recorrido .pildoras li { padding: 6px 10px; font-size: .75rem; }
}

/* ---------- Vista previa de un proyecto, dentro de un móvil ---------- */
.proy-ver { margin-top: 18px; }
.proy-ver .enlace { cursor: pointer; }
html.proy-recorrido .proy-escenario { cursor: pointer; }
.vista {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; z-index: 300;
  padding: calc(var(--header-h) * 0.4) var(--gutter) 20px; border: 0;
  background: rgba(30, 36, 26, .96); color: var(--piedra);
  grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center; gap: 16px;
  opacity: 0; transition: opacity .3s var(--ease-out), display .3s allow-discrete, overlay .3s allow-discrete;
}
.vista[open] { display: grid; opacity: 1; }
@starting-style { .vista[open] { opacity: 0; } }
.vista::backdrop { background: transparent; }
.vista-cabeza { width: min(560px, 100%); display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.vista-cabeza .etiqueta { color: var(--oliva-claro); }
.vista-titulo { font-size: var(--t-subtitulo); line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; color: var(--piedra); margin-top: 6px; }
.vista-cerrar {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-pill); border: 1px solid rgba(236, 232, 223, .35); color: var(--piedra); font-weight: 600; font-size: .9375rem;
  transition: border-color .2s var(--ease-out), transform .16s var(--ease-out);
}
.vista-cerrar:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .vista-cerrar:hover { border-color: var(--piedra); } }
.vista-telefono {
  height: 100%; max-height: 780px; aspect-ratio: 390 / 844; min-height: 0;
  background: #0E110C; border-radius: 46px; padding: 11px;
  box-shadow: 0 0 0 1px rgba(236, 232, 223, .12), 0 40px 80px -30px rgba(0, 0, 0, .7);
  transform: translateY(0); transition: transform .5s var(--ease-out);
}
@starting-style { .vista[open] .vista-telefono { transform: translateY(24px); } }
.vista-pantalla {
  width: 100%; height: 100%; overflow-y: auto; overscroll-behavior: contain; border-radius: 36px; background: #000;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.vista-pantalla::-webkit-scrollbar { display: none; }
.vista-pantalla img { display: block; width: 100%; height: auto; }
.vista-pantalla:focus-visible { outline: 2px solid var(--oliva-claro); outline-offset: 4px; }
.vista-ayuda { font-size: var(--t-pequeno); color: #B9B5AA; text-align: center; }
html.vista-abierta { overflow: hidden; }
@media (max-width: 599px) {
  .vista { padding-top: 14px; gap: 12px; }
  .vista-telefono { border-radius: 38px; padding: 8px; }
  .vista-pantalla { border-radius: 30px; }
  .vista-titulo { font-size: 1.375rem; }
}
@media (max-width: 899px) and (max-height: 700px) {
  html.proy-recorrido .proy-ver { margin-top: 10px; }
}

/* =====================================================================
   Portada nueva: espiral de capturas, título gigante y textos abajo
   ===================================================================== */
.portada, html.fondo-animado .portada { background: transparent; height: 100vh; height: 100svh; min-height: 480px; }
/* teléfono en horizontal: la portada entra entera en la pantalla */
@media (max-height: 500px) and (orientation: landscape) {
  .portada, html.fondo-animado .portada { min-height: 0; }
  .portada-pie .texto { max-width: 46em; }
}
.espiral { position: absolute; inset: 0; perspective: 1300px; perspective-origin: 50% 42%; overflow: hidden; }
.espiral-mundo { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.esp-tarjeta {
  --tw: clamp(150px, 17vw, 280px);
  position: absolute; left: calc(var(--tw) / -2); top: calc(var(--tw) * -0.3125); width: var(--tw); aspect-ratio: 16 / 10;
  padding: 0; border-radius: 10px; overflow: hidden; background: #111; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(236, 232, 223, .14), 0 24px 50px -24px rgba(0, 0, 0, .85);
  backface-visibility: hidden; will-change: transform, opacity;
  transition: box-shadow .3s var(--ease-out), filter .3s var(--ease-out);
}
.esp-tarjeta img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
@media (hover: hover) and (pointer: fine) {
  .esp-tarjeta:hover { box-shadow: 0 0 0 2px var(--oliva-claro), 0 24px 50px -24px rgba(0, 0, 0, .85); }
}
.esp-tarjeta:focus-visible { outline: 2px solid var(--oliva-claro); outline-offset: 3px; }
/* Sin animaciones: la espiral se ve quieta, ordenada */
html:not(.anim) .esp-tarjeta, html.reduce .esp-tarjeta { transition: none; }

.portada-titulo {
  position: absolute; z-index: 3; left: var(--gutter); right: var(--gutter); top: 44%; transform: translateY(-50%);
  font-size: clamp(3.4rem, 0.6rem + 10.5vw, 12.5rem); line-height: .88; letter-spacing: -0.055em; font-weight: 700;
  text-transform: uppercase; color: var(--piedra); pointer-events: none;
  text-shadow: 0 4px 40px rgba(0, 0, 0, .55);
}
.portada-titulo .w { display: inline-block; will-change: transform; }
.portada-pie {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 28px; max-width: none;
  display: grid; gap: 10px; justify-items: start;
}
.portada-pie .texto { max-width: 25em; font-size: .9375rem; line-height: 1.45; color: #E3DFD5; text-shadow: 0 2px 16px rgba(0, 0, 0, .6); }
.portada-pie .botones { margin-top: 4px; gap: 10px; }
.portada .pb-bajar { position: absolute; z-index: 4; right: var(--gutter); bottom: 28px; font-size: var(--t-etiqueta); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
@media (max-width: 899px) {
  .portada .pb-bajar { display: none; }
  .portada-titulo { top: 40%; font-size: clamp(2.6rem, 14vw, 5rem); }
  .portada-pie { bottom: 20px; }
  .portada-pie .texto { font-size: .875rem; max-width: 30em; }
}

/* Capturas que siguen al mouse */
.rastro {
  position: absolute; z-index: 2; width: clamp(140px, 14vw, 230px); aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden;
  pointer-events: none; box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .8);
}
.rastro img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }

/* Foto grande a dos colores que abre la sección Proyectos */
.proyectos { padding-top: 0; }
.proy-portada { position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden; display: flex; align-items: flex-end; margin-bottom: clamp(48px, 8vw, 120px); }
.proy-portada-img { position: absolute; inset: 0; will-change: transform; }
.proy-portada-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; }
/* Oscura, casi negra, con sombra */
.ppi-oscura { filter: grayscale(1) brightness(.26) contrast(1.15); }
/* La misma foto en color, que se revela desde el centro al bajar */
.ppi-color {
  --r: 0vmax;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0, #000 calc(var(--r) * 0.72), transparent var(--r));
  mask-image: radial-gradient(circle at 50% 50%, #000 0, #000 calc(var(--r) * 0.72), transparent var(--r));
}
html:not(.anim) .ppi-color, html.reduce .ppi-color { --r: 200vmax; }
.proy-portada-img::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 180px 70px rgba(5, 6, 4, .9);
  background: linear-gradient(to top, rgba(8, 9, 7, .9) 0%, rgba(8, 9, 7, .35) 38%, rgba(8, 9, 7, 0) 62%);
}
.proy-portada .proy-cabeza { position: relative; z-index: 1; padding-bottom: clamp(40px, 7vw, 96px); margin-bottom: 0; }
.proy-portada .display { font-size: clamp(3.2rem, 1rem + 9vw, 11rem); line-height: .9; letter-spacing: -0.05em; text-transform: uppercase; max-width: none; text-shadow: 0 4px 40px rgba(0, 0, 0, .45); }

/* Para quién: una frase grande y, debajo, ejemplos */
.publico-lema { font-size: var(--t-subtitulo); line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; color: var(--fg); max-width: 22em; }
.publico-ejemplos { margin-top: 14px; color: var(--fg-2); max-width: 32em; }

/* Título de la portada de borde a borde: cada línea se ajusta al ancho */
.portada-titulo .linea { display: block; width: max-content; white-space: nowrap; line-height: .86; letter-spacing: -0.055em; }
.portada-titulo { font-size: clamp(3.4rem, 0.6rem + 10.5vw, 12.5rem); }

/* "Ver todos" entra desde la derecha: que no ensanche la página en el móvil */
.proy-todos { overflow: hidden; overflow-x: clip; overflow-y: visible; }
