@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Tokens de la marca (docs/marca.md del portal). */
:root {
  color-scheme: light dark;
  --papel: #f7f5f0;
  --papel-2: #eeebe4;
  --tinta: #1d1c1a;
  --grafito: #48443e;
  --piedra: #6a655d;
  --linea: #dedad1;
  --acento: #b5470f;
  --acento-hover: #953a0b;
  --sobre-acento: #ffffff;
  --banda: #1d1c1a;
  --reja: #ebe8e1;
  --reja-fuerte: #e1ddd4;

  --fuente: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radio-control: 4px;
  --ease-salida: cubic-bezier(0.16, 1, 0.3, 1);
  --margen: clamp(1rem, 3.2vw, 3rem);
}

/* Tema: el del sistema, salvo que la persona elija otro con el botón (data-tema). */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema='claro']) {
    color-scheme: dark;
    --papel: #1a1917;
    --papel-2: #23211e;
    --tinta: #ebe7e0;
    --grafito: #cbc5bb;
    --piedra: #a8a196;
    --linea: #3a3732;
    --acento: #ec8a52;
    --acento-hover: #f4a578;
    --sobre-acento: #1a1917;
    --banda: #111010;
    --reja: #201f1c;
    --reja-fuerte: #282623;
  }
}

:root[data-tema='oscuro'] {
  color-scheme: dark;
  --papel: #1a1917;
  --papel-2: #23211e;
  --tinta: #ebe7e0;
  --grafito: #cbc5bb;
  --piedra: #a8a196;
  --linea: #3a3732;
  --acento: #ec8a52;
  --acento-hover: #f4a578;
  --sobre-acento: #1a1917;
  --banda: #111010;
  --reja: #201f1c;
  --reja-fuerte: #282623;
}

:root[data-tema='claro'] { color-scheme: light; }

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

html { -webkit-text-size-adjust: 100%; }
a, button { touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--fuente);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--tinta);
  background-color: var(--papel);
  /* Papel de plano: cuadrícula de 24 px con líneas maestras cada 120 px. */
  background-image:
    linear-gradient(var(--reja-fuerte) 1px, transparent 1px),
    linear-gradient(90deg, var(--reja-fuerte) 1px, transparent 1px),
    linear-gradient(var(--reja) 1px, transparent 1px),
    linear-gradient(90deg, var(--reja) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ol, ul, figure { margin: 0; }

a { color: var(--acento); text-underline-offset: 0.2em; }
a:hover { color: var(--acento-hover); }

:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection { background: var(--acento); color: var(--sobre-acento); }

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

/* Cinta de balizamiento con los colores de la marca. */
.cinta {
  position: relative;
  height: 14px;
  flex: none;
  overflow: hidden;
  background-color: var(--banda);
}
.cinta::before {
  content: '';
  position: absolute;
  inset: 0 -40px;
  background-image: repeating-linear-gradient(-45deg, var(--acento) 0 14px, var(--banda) 14px 28px);
  background-size: 39.6px 100%;
}

/* Cabecera */
.cabecera {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2.25rem) var(--margen) 0;
}

.tema {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: var(--radio-control);
  background: var(--papel-2);
  color: var(--tinta);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms ease, color 160ms ease;
}
.tema:hover { color: var(--acento); }
.tema[hidden] { display: none; }
.tema svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tema-sol, .tema-luna { display: none; }
:root[data-tema-actual='oscuro'] .tema-sol { display: block; }
:root[data-tema-actual='claro'] .tema-luna { display: block; }

.logo { display: block; width: 140px; height: 40px; }
.logo-tinta { fill: var(--tinta); }
.logo-pieza { fill: var(--acento); }
.logo-texto {
  font-family: var(--fuente);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  fill: var(--tinta);
}
a.marca { display: inline-block; border-radius: var(--radio-control); }

/* Composición principal */
.obra {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: center;
  gap: clamp(2rem, 4vw, 4.5rem);
  padding: clamp(2rem, 5vw, 4rem) var(--margen) clamp(3rem, 6vw, 5rem);
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

h1 {
  font-size: clamp(2.25rem, 0.9rem + 4.4vw, 4.75rem);
  line-height: 1;
  letter-spacing: -0.035em;
  font-weight: 800;
  text-wrap: balance;
}

.entrada {
  margin-top: clamp(1.25rem, 2.5vw, 2rem);
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  line-height: 1.45;
  max-width: 34rem;
}

.pronto {
  margin-top: 0.75rem;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 700;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

/* Estado de la obra */
.estado { margin-top: clamp(2rem, 4vw, 3rem); max-width: 34rem; }

.barra {
  margin-top: 0.75rem;
  height: 12px;
  background: var(--papel-2);
  border-radius: 2px;
  overflow: hidden;
}

.barra-relleno {
  position: relative;
  display: block;
  height: 100%;
  width: 62.5%;
  overflow: hidden;
  background-color: var(--acento);
  transform-origin: left center;
}
.barra-relleno::before {
  content: '';
  position: absolute;
  inset: 0 -23px 0 -23px;
  background-image: repeating-linear-gradient(-45deg, transparent 0 8px, rgb(255 255 255 / 0.16) 8px 16px);
  background-size: 22.6px 100%;
}

.fases {
  list-style: none;
  padding: 0;
  margin-top: 0.625rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  font-size: 0.9375rem;
  color: var(--grafito);
}

.fase { display: flex; align-items: center; gap: 0.4rem; }
.fase::before {
  content: '';
  flex: none;
  width: 9px;
  height: 9px;
  border: 2px solid var(--piedra);
}
.fase--hecha::before { background: var(--grafito); border-color: var(--grafito); }
.fase--actual { color: var(--tinta); font-weight: 700; }
.fase--actual::before { background: var(--acento); border-color: var(--acento); }

/* Contacto */
.contacto { margin-top: clamp(2rem, 4vw, 3rem); }

.contacto-fila {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.boton {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0.7rem 1.25rem;
  background: var(--acento);
  color: var(--sobre-acento);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radio-control);
  transition: background-color 160ms ease, transform 160ms var(--ease-salida);
}
.boton:hover { background: var(--acento-hover); color: var(--sobre-acento); }
.boton:active { transform: translateY(1px); }

.redes { list-style: none; padding: 0; display: flex; gap: 0.25rem; }
.redes a {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--tinta);
  border-radius: var(--radio-control);
  transition: color 160ms ease, background-color 160ms ease;
}
.redes a:hover { color: var(--acento); background: var(--papel-2); }

.icono { width: 24px; height: 24px; fill: currentColor; }
.icono--trazo { fill: none; stroke: currentColor; stroke-width: 2; }
.icono--trazo .icono-punto { fill: currentColor; stroke: none; }

/* Plano de la bancada */
.plano { justify-self: end; width: 100%; max-width: 680px; }
.plano svg { display: block; width: 100%; height: auto; overflow: visible; }
.plano figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--piedra);
  font-variant-numeric: tabular-nums;
}

.suelo { stroke: var(--piedra); stroke-width: 2; }
.banco rect { fill: var(--tinta); }
.pieza { fill: var(--acento); }
.escuadra, .llave, .lapiz, .calibre-regla { fill: var(--grafito); }
.lapiz-punta { fill: var(--piedra); }
.hueco { fill: var(--papel); }
.calibre-marcas { stroke: var(--papel); stroke-width: 2; }
.cota-linea { fill: none; stroke: var(--piedra); stroke-width: 1.5; }
.cota-punto { fill: var(--piedra); }
.cota-texto {
  font-family: var(--fuente);
  font-size: 26px;
  fill: var(--grafito);
  font-variant-numeric: tabular-nums;
}

/* Pie */
.pie {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem var(--margen) 1.5rem;
  background: var(--papel);
  font-size: 0.9375rem;
  color: var(--grafito);
}
.pie a { color: var(--tinta); }
.pie a:hover { color: var(--acento); }

/* Aviso legal */
.legal {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  padding: clamp(1.5rem, 4vw, 3rem) calc(var(--margen) - clamp(1.25rem, 3vw, 2.5rem)) clamp(3rem, 6vw, 5rem);
}
.legal-hoja {
  background: var(--papel);
  padding: clamp(1.25rem, 3vw, 2.5rem);
}
.legal h1 { font-size: clamp(2.25rem, 1.5rem + 3vw, 3.5rem); max-width: none; }
.legal h2 { font-size: 1.25rem; margin-top: 2rem; }
.legal p { margin-top: 0.75rem; max-width: 65ch; }
.legal dl { margin: 1.25rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; }
.legal dt { font-weight: 700; }
.legal dd { margin: 0; }

/* Móvil */
@media (max-width: 860px) {
  .obra { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .plano { max-width: 520px; justify-self: start; }
}

@media (max-width: 420px) {
  .legal dl { grid-template-columns: 1fr; gap: 0.15rem; }
  .legal dd { margin-bottom: 0.6rem; }
}

/* Movimiento: solo si la persona no ha pedido reducirlo. */
@media (prefers-reduced-motion: no-preference) {
  .cinta::before { animation: cinta-avanza 1.5s linear 3; }
  .cinta--pie::before { animation-direction: reverse; }

  .texto > * { animation: sube 700ms var(--ease-salida) both; }
  .texto > :nth-child(2) { animation-delay: 80ms; }
  .texto > :nth-child(3) { animation-delay: 160ms; }
  .texto > :nth-child(4) { animation-delay: 240ms; }
  .texto > :nth-child(5) { animation-delay: 320ms; }

  .barra-relleno { animation: crece 1200ms var(--ease-salida) 500ms both; }
  .barra-relleno::before { animation: rayas 1.2s linear 3; }
  .fase--actual::before { animation: parpadeo 1.2s ease-in-out 1.8s 2; }

  .plano svg * { transform-box: fill-box; }
  .b-pata, .b-trav, .b-tablero, .herr { animation: monta 650ms var(--ease-salida) both; }
  .b-pata { animation-delay: 200ms; }
  .b-pata--2 { animation-delay: 280ms; }
  .b-trav { animation-delay: 400ms; }
  .b-tablero { animation-delay: 520ms; }
  .herr--1 { animation-delay: 700ms; }
  .herr--2 { animation-delay: 800ms; }
  .herr--3 { animation-delay: 900ms; }
  .pieza { animation: posa 800ms var(--ease-salida) 1050ms both; }
  .calibre { animation: aparece 500ms ease 1650ms both; }
  .calibre-cursor { animation: cierra 900ms var(--ease-salida) 1900ms both; }
  .cota-linea {
    stroke-dasharray: 1;
    animation: traza 900ms var(--ease-salida) 1500ms both;
  }
  .cota--2 .cota-linea { animation-delay: 1650ms; }
  .cota--3 .cota-linea { animation-delay: 2100ms; }
  .cota-texto, .cota-punto { animation: aparece 500ms ease 2000ms both; }
  .cota--3 .cota-texto, .cota--3 .cota-punto { animation-delay: 2500ms; }

  .boton:hover { transform: translateY(-1px); }
  .boton:active { transform: translateY(1px); }
}

@keyframes cinta-avanza { to { transform: translateX(39.6px); } }
@keyframes rayas { to { transform: translateX(22.6px); } }
@keyframes sube { from { opacity: 0; transform: translateY(20px); } }
@keyframes monta { from { opacity: 0; transform: translateY(18px); } }
@keyframes posa { from { opacity: 0; transform: translateY(-70px); } }
@keyframes cierra { from { transform: translateX(46px); } }
@keyframes aparece { from { opacity: 0; } }
@keyframes traza { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes crece { from { transform: scaleX(0); } }
@keyframes parpadeo { 50% { opacity: 0.35; } }
