/* =================================================================
   ADN Valencia — mobile-first
   Base = phone portrait. Tablet (>=720px) y desktop (>=960px) son
   progressive enhancement.
   ================================================================= */

:root {
  --paper: #F4F2EE;
  --paper-soft: #ECE8E0;
  --ink: #1A1815;
  --ink-soft: #4B453E;
  --rule: #D8D2C8;
  --accent: #9B6B3F;
  --serif: "Source Serif 4", "EB Garamond", Georgia, serif;
  --sans: "Source Sans 3", "Public Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
a:hover, a:focus-visible { border-bottom-color: var(--accent); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }

/* ---------- header / footer ---------- */
.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 20px 28px;
  border-bottom: 1px solid var(--rule);
}
.site-header .kicker {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px 0;
}
.site-header h1 {
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  margin: 0 0 16px 0;
  line-height: 1.1;
}
.site-header .subtitle {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0;
  line-height: 1.65;
}
.site-header .header-link {
  margin: 22px 0 0 0;
  font-size: 0.88rem;
  font-family: var(--sans);
}
.site-header .header-link a {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
  padding-bottom: 1px;
}
.site-header .header-link a:hover,
.site-header .header-link a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.site-footer p { margin: 0; }

/* ---------- grid of pieces ---------- */
.grid { max-width: 1200px; margin: 0 auto; }

.piece {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding: 36px 20px;
  border-bottom: 1px solid var(--rule);
}
.piece:last-of-type { border-bottom: none; }

.rail { min-width: 0; }
.piece-name {
  font-size: 1.35rem;
  margin: 0 0 6px 0;
  line-height: 1.2;
}
.epigraph {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.98rem;
}

/* ---------- collapsibles (full width below the row) ---------- */
details.adn-block,
details.gaps-block {
  padding: 0;
  border-top: 1px solid var(--rule);
}

details summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "+";
  font-family: var(--serif);
  color: var(--accent);
  display: inline-block;
  width: 1.4em;
}
details[open] summary::before { content: "−"; }

.adn-content,
.gaps-content {
  padding: 6px 0 24px 0;
  max-width: 64ch;
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--ink);
}
.adn-content h1 { font-size: 1.2rem; margin: 0 0 14px 0; }
.adn-content h2 {
  font-size: 0.74rem;
  margin: 24px 0 8px 0;
  color: var(--accent);
  font-family: var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}
.adn-content h3 { font-size: 0.95rem; margin: 16px 0 6px 0; }
.adn-content p, .adn-content ul, .adn-content ol { margin: 8px 0 12px 0; }
.adn-content ul { padding-left: 1.3em; }
.adn-content li { margin: 4px 0; }

.gaps-list { list-style: none; padding: 0; margin: 0; }
.gaps-list > li { margin: 0; border-bottom: 1px dashed var(--rule); }
.gaps-list > li:last-child { border-bottom: none; }
.gaps-list details summary {
  padding: 10px 0;
  font-size: 0.76rem;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--mono);
}
.gaps-list .gap-content {
  padding: 4px 0 14px 0;
  font-family: var(--serif);
  font-size: 0.92rem;
}
.gaps-list .gap-content h1,
.gaps-list .gap-content h2,
.gaps-list .gap-content h3 { font-size: 0.95rem; margin: 12px 0 4px 0; color: var(--accent); }
.gaps-list .gap-content p { margin: 6px 0; }
.gaps-list .gap-content ul,
.gaps-list .gap-content ol { margin: 6px 0; padding-left: 1.3em; }

/* ---------- runs strip — base mobile = 2x2 ---------- */
.strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.run-window {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--paper);
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.run-window iframe {
  border: 0;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  transform-origin: top left;
}
.run-window .run-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--mono);
  font-size: 9px;
  color: rgba(244, 242, 238, 0.92);
  background: rgba(26, 24, 21, 0.5);
  padding: 1px 5px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
  opacity: 1; /* visible siempre en touch */
  transition: opacity 200ms ease;
}
.run-window:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- essay ---------- */
.essay {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 20px 56px;
  border-bottom: 1px solid var(--rule);
}
.essay h2 {
  font-size: clamp(1.45rem, 4vw, 2rem);
  margin: 0 0 28px 0;
  line-height: 1.2;
}
.essay-body {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
}
.essay-body p { margin: 0 0 18px 0; }
.essay-body p:last-child { margin-bottom: 0; }
.essay-body strong { font-weight: 600; }
.essay-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-soft);
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--ink-soft);
}
.essay-body h3 {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 32px 0 14px 0;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.essay-back {
  margin: 36px 0 0 0;
  text-align: right;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.essay-back a {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
  padding-bottom: 1px;
}
.essay-back a:hover,
.essay-back a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- lightbox ---------- */
dialog.lightbox {
  border: none;
  background: transparent;
  padding: 0;
  margin: auto;
  max-width: 100vw;
  max-height: 100vh;
  color: var(--paper);
  overflow: visible;
}
dialog.lightbox::backdrop {
  background: rgba(20, 18, 15, 0.88);
  backdrop-filter: blur(2px);
}
.lb-frame {
  position: relative;
  width: min(96vw, 880px);
  aspect-ratio: 4 / 3;
  max-height: 75vh;
  background: var(--paper);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}
.lb-iframe {
  border: 0;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}
.lb-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(26, 24, 21, 0.65);
  color: var(--paper);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--serif);
  transition: background 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.lb-close:hover, .lb-close:active { background: rgba(26, 24, 21, 0.9); }

.lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(26, 24, 21, 0.6);
  color: var(--paper);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--serif);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
  padding: 0 0 4px 0;
  -webkit-tap-highlight-color: transparent;
}
.lb-nav:hover, .lb-nav:active { background: rgba(26, 24, 21, 0.9); }
.lb-prev { left: 10px; padding-right: 4px; }
.lb-next { right: 10px; padding-left: 4px; }

.lb-caption {
  margin: 12px 0 0 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: rgba(244, 242, 238, 0.85);
  text-align: center;
  padding: 0 60px; /* deja sitio para evitar solapar con flechas */
}
.lb-caption a { color: var(--paper); border-bottom-color: rgba(244, 242, 238, 0.4); }
.lb-caption a:hover { border-bottom-color: var(--paper); }
.lb-piece { font-family: var(--serif); font-style: italic; }
.lb-run { font-family: var(--mono); font-size: 0.8rem; }

/* =================================================================
   Tablet (>=720px): respiraciones extra, hover labels en touch híbrido
   ================================================================= */
@media (min-width: 720px) {
  html, body { font-size: 17px; }
  .site-header { padding: 64px 32px 40px; }
  .site-footer { padding: 40px 32px 64px; }
  .piece { padding: 48px 32px; gap: 28px; }
  .piece-name { font-size: 1.5rem; }
  .essay { padding: 72px 32px 64px; }
  .lb-nav { width: 48px; height: 48px; font-size: 28px; }
  .lb-prev { left: 20px; }
  .lb-next { right: 20px; }
}

/* =================================================================
   Desktop (>=960px): rail+strip lado a lado, strip 4×1
   ================================================================= */
@media (min-width: 960px) {
  .site-header { padding: 88px 40px 56px; }
  .site-footer { padding: 48px 40px 80px; }

  .piece {
    grid-template-columns: 280px minmax(0, 1fr);
    column-gap: 40px;
    row-gap: 0;
    padding: 56px 40px;
    align-items: start;
  }
  .rail { grid-column: 1; grid-row: 1; }
  .strip {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-self: start;
  }

  details.adn-block,
  details.gaps-block {
    grid-column: 1 / -1;
    margin-top: 24px;
  }
  details.gaps-block { margin-top: 0; }

  /* run labels: hover-to-show en desktop */
  .run-window .run-label { opacity: 0; }
  .run-window:hover .run-label { opacity: 1; }

  .essay { padding: 96px 40px 80px; }

  .lb-nav { width: 52px; height: 52px; font-size: 30px; }
  .lb-prev { left: 28px; padding-right: 6px; }
  .lb-next { right: 28px; padding-left: 6px; }
  .lb-prev:hover { transform: translateY(-50%) translateX(-2px); }
  .lb-next:hover { transform: translateY(-50%) translateX(2px); }
}

/* =================================================================
   Reduced motion: respeta usuarios sensibles
   ================================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
