/* Tipografía propia (OFL, subconjunto latino, ejes de peso y tamaño óptico). */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('assets/fonts/BricolageGrotesque-latin.woff2') format('woff2');
}
/* Mientras carga (o si falla), Arial ajustado al ancho de Bricolage para que el titular no se desborde. */
@font-face {
  font-family: 'Bricolage Fallback';
  src: local('Arial');
  font-weight: 300 800;
  size-adjust: 103%;
}

:root {
  --paper: #ece6da;
  --ink: #17140f;
  --ink-soft: rgba(23, 20, 15, 0.68);
  --pad: clamp(18px, 2.4vw, 36px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Bricolage Grotesque', 'Bricolage Fallback', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: relative;
  color: var(--ink);
  font-family: var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Grano de puntos de 6 px, luz suave que varía y papel cálido. */
  background:
    radial-gradient(circle at 3px 3px, rgba(60, 44, 22, 0.13) 0.55px, transparent 0.95px) 0 0 / 6px 6px,
    radial-gradient(70% 60% at 22% 8%, rgba(255, 252, 244, 0.7), transparent 70%),
    radial-gradient(60% 55% at 88% 92%, rgba(190, 172, 140, 0.32), transparent 70%),
    radial-gradient(45% 40% at 78% 14%, rgba(255, 249, 236, 0.4), transparent 70%),
    var(--paper);
}

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

/* Titular: HTML detrás del canvas, las tarjetas 3D lo tapan en parte. */
.headline {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 var(--pad);
  font-weight: 800;
  font-variation-settings: 'opsz' 96;
  font-size: min(10.4vw, 26vh);
  line-height: 0.86;
  letter-spacing: -0.055em;
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.headline span { display: block; white-space: nowrap; }

#reel {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#reel:active { cursor: grabbing; }
#reel:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -6px;
  border-radius: 14px;
}

/* Todo lo que va delante del canvas deja pasar los arrastres. */
.name, #info {
  position: fixed;
  z-index: 3;
  margin: 0;
  pointer-events: none;
}

.name {
  top: calc(var(--safe-top) + var(--pad));
  left: var(--pad);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.25;
}
.name span { display: block; }
.name-main { font-weight: 650; font-size: 1.0625rem; letter-spacing: -0.015em; }
.name-role { color: var(--ink-soft); font-size: 0.9375rem; }

#cta {
  position: fixed;
  z-index: 3;
  top: calc(var(--safe-top) + var(--pad));
  right: var(--pad);
  padding: 0.95em 1.55em;
  border-radius: 999px;
  background: var(--ink);
  color: #f6f1e6;
  font: 500 0.9375rem/1 var(--font);
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.18s ease;
}
#cta:hover { background: #3a342b; }
#cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

#info {
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + var(--pad));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--pad);
  text-align: center;
}

#caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: min(100%, 46rem);
  min-height: 4.6rem;
  transition: opacity 0.16s ease;
}
#caption.is-out { opacity: 0; }

.cap-title { margin: 0; font-size: 1.125rem; line-height: 1.3; letter-spacing: -0.012em; text-wrap: balance; }
.cap-title strong { font-weight: 650; }
.cap-title span { color: var(--ink-soft); }
.cap-desc {
  margin: 0;
  max-width: 100%;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  line-height: 1.4;
  text-wrap: balance;
}
.cap-status {
  margin: 0.1rem 0 0;
  padding: 0.25rem 0.5rem;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
}
.cap-status.is-pending { color: var(--ink-soft); font-weight: 400; }
a.cap-status {
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-thickness: 1px;
}
a.cap-status:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

#hint {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  line-height: 1.2;
}

@media (prefers-reduced-motion: reduce) {
  #caption, #cta { transition: none; }
}

/* Pantallas bajas y poco anchas (la tarjeta crece con el ancho): primero cae la pista,
   después la descripción a una línea. En pantallas anchas la tarjeta se topa por alto y sobra lugar. */
@media (max-height: 700px) and (max-aspect-ratio: 13/10), (max-height: 500px) {
  #hint { display: none; }
}
@media (max-height: 620px) and (max-aspect-ratio: 13/10) {
  #caption { min-height: 4.4rem; }
  .cap-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Celular: el botón baja, ancho completo y dentro del área segura. */
@media (max-width: 699px) {
  .headline {
    font-size: 17.5vw;
    line-height: 0.88;
  }
  .headline span { white-space: normal; }

  #cta {
    top: auto;
    left: var(--pad);
    right: var(--pad);
    bottom: calc(var(--safe-bottom) + var(--pad));
    padding: 0;
    height: 3.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
  }

  #info { bottom: calc(var(--safe-bottom) + var(--pad) + 3.4rem + 0.75rem); }
  #caption { min-height: 6.4rem; }
  .cap-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
  }
  /* Zona táctil de 44 px sin cambiar el aspecto: el padding extra se compensa con margen negativo. */
  a.cap-status { padding-block: calc(0.25rem + 9px); margin-block: calc(0.1rem - 9px) -9px; }
}

/* Celular bajo: la descripción pasa a una línea y la leyenda devuelve ese alto al carrete. */
@media (max-width: 699px) and (max-height: 620px) {
  #caption { min-height: 4.4rem; }
  .cap-desc { -webkit-line-clamp: 1; }
}

/* Celular en horizontal: vuelve la composición de escritorio, comprimida a la altura. */
@media (orientation: landscape) and (max-height: 500px) {
  .headline {
    font-size: min(10.4vw, 19vh);
    line-height: 0.86;
  }
  .headline span { white-space: nowrap; }

  #cta {
    top: calc(var(--safe-top) + var(--pad));
    right: var(--pad);
    bottom: auto;
    left: auto;
    height: auto;
    display: block;
    padding: 0.85em 1.4em;
    font-size: 0.9375rem;
  }

  #info { bottom: calc(var(--safe-bottom) + 0.6rem); }
  #caption { min-height: 0; gap: 0.1rem; }
  .cap-title { font-size: 1rem; }
  .cap-desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; }
  a.cap-status { padding-block: calc(0.25rem + 9px); margin-block: calc(0.1rem - 9px) -9px; }
}
/* Si ni así entra, cae la descripción. */
@media (orientation: landscape) and (max-height: 360px) {
  .cap-desc { display: none; }
}

/* Sin WebGL: la página pasa a flujo normal y puede scrollear en vertical. */
.is-fallback, .is-fallback body { height: auto; min-height: 100%; overflow: auto; overflow-x: hidden; }
.is-fallback body {
  padding:
    calc(var(--safe-top) + 5.5rem) var(--pad)
    calc(var(--safe-bottom) + var(--pad));
}
.is-fallback .name { position: absolute; }
.is-fallback .headline {
  position: static;
  margin-bottom: clamp(2rem, 6vw, 4rem);
  font-size: min(10.4vw, 8rem);
}
.is-fallback .headline span { white-space: normal; }

#fallback {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: clamp(1.5rem, 3vw, 2.5rem);
  max-width: 76rem;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}
#fallback li { display: flex; flex-direction: column; gap: 0.3rem; }
#fallback img {
  display: block;
  width: 100%;
  aspect-ratio: 1600 / 1060;
  object-fit: cover;
  margin-bottom: 0.6rem;
  border-radius: 14px;
  background: rgba(23, 20, 15, 0.08);
}
#fallback h2 { margin: 0; font-size: 1.125rem; font-weight: 650; letter-spacing: -0.012em; line-height: 1.3; }
#fallback h2 span { color: var(--ink-soft); font-weight: 400; }
#fallback p { margin: 0; color: var(--ink-soft); font-size: 0.9375rem; line-height: 1.45; }
#fallback .cap-status { align-self: flex-start; margin: 0.2rem 0 0; padding: 0.25rem 0; }

@media (max-width: 699px) {
  .is-fallback body { padding-bottom: calc(var(--safe-bottom) + var(--pad) + 3.4rem + 1.5rem); }
  #fallback .cap-status { padding-block: calc(0.25rem + 9px); margin-block: calc(0.2rem - 9px) -9px; }
}
