@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(/fonts/archivo-latin-wdth-normal.woff2) format("woff2-variations");
}

@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url(/fonts/martian-mono-latin-wdth-normal.woff2) format("woff2-variations");
}

:root {
  --g: clamp(1rem, 3vw, 2.5rem);
  --pie: 2.6rem;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --salida: cubic-bezier(0.16, 1, 0.3, 1);
  /* La torre ocupa todo el alto disponible: una fila de texto = una fracción de ese alto. */
  --fs-torre: calc((100dvh - var(--pie) - 1.5rem) / var(--filas, 120));
}

/* Colores: reloj.js calcula --c-* según la hora y el minuto (interpolando entre paletas clave).
   Sin JS se usan los valores de medianoche. */

:root {
  --asfalto: var(--c-fondo, #0a0412);
  --asfalto-2: var(--c-fondo2, #170a24);
  --linea: var(--c-linea, #33184d);
  --hueso: var(--c-texto, #f6ecff);
  --gris: var(--c-gris, #b49ad0);
  --piedra: var(--c-piedra, #ff2e97);
  --limon: var(--c-acento, #fcee0a);
  --limon-tinta: var(--c-acentoTinta, #fcee0a);
  --sobre-limon: var(--c-sobreAcento, #0a0412);
  --glitch-a: var(--c-glitchA, #ff003c);
  --glitch-b: var(--c-glitchB, #00f0ff);
  --agua: var(--c-agua, #7a35c8);

  color-scheme: dark;
}

:root {
  scrollbar-color: var(--linea) var(--asfalto);
}

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

html,
body {
  height: 100%;
}

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) var(--pie);
  grid-template-areas:
    "panel torre"
    "pie pie";
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--asfalto);
  color: var(--hueso);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.5;
  caret-color: var(--limon-tinta);
  transition: background-color 2s linear, color 2s linear;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

h1,
p,
ol,
pre,
figure {
  margin: 0;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

:focus-visible {
  outline: 2px solid var(--limon-tinta);
  outline-offset: 2px;
}

.ico {
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.2em;
  vertical-align: -0.08em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
}

/* Panel izquierdo */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1rem, 3vh, 2.25rem);
  min-height: 0;
  padding: clamp(1.25rem, 5vh, 3.5rem) var(--g) clamp(1rem, 3vh, 2rem);
}

/* El río Segura: llena el hueco entre la cabecera y la lista. */

.rio {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  margin-inline: calc(var(--g) * -1);
  overflow: hidden;
}

.rio pre {
  position: absolute;
  inset: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-stretch: 75%;
  line-height: 1;
  white-space: pre;
  user-select: none;
}

.rio-agua {
  color: var(--agua);
}

.rio-glitch {
  color: var(--glitch-b);
}

.rio-nombre {
  position: absolute;
  right: var(--g);
  bottom: 0.25rem;
  padding: 0 0.4rem;
  background: var(--asfalto);
  color: var(--gris);
  font-size: 0.75rem;
}

.contenido {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vh, 1.75rem);
}

.marca {
  display: inline-block;
  color: var(--piedra);
  font-family: var(--sans);
  font-size: clamp(3.25rem, min(10.5vw, 19vh), 10rem);
  font-weight: 900;
  font-stretch: 125%;
  line-height: 0.82;
  letter-spacing: -0.035em;
  text-decoration: none;
  padding-bottom: 0.16em; /* deja sitio a la «y» */
}

.marca span {
  color: var(--hueso);
}

/* Fallo de neón: dos copias desplazadas y recortadas en franjas, de vez en cuando y al navegar. */

.marca {
  position: relative;
}

.marca::before,
.marca::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.marca::before {
  color: var(--glitch-a);
  animation: fallo-a 9s steps(1, end) infinite;
}

.marca::after {
  color: var(--glitch-b);
  animation: fallo-b 9s steps(1, end) infinite;
}

.marca.glitch::before {
  animation: fallo-a 300ms steps(1, end) 1;
}

.marca.glitch::after {
  animation: fallo-b 300ms steps(1, end) 1;
}

@keyframes fallo-a {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: none; }
  91% { opacity: 0.9; transform: translate(-0.05em, 0.02em); clip-path: inset(12% 0 58% 0); }
  93% { opacity: 0.9; transform: translate(0.04em, -0.01em); clip-path: inset(62% 0 8% 0); }
  95% { opacity: 0.9; transform: translate(-0.02em, 0); clip-path: inset(38% 0 40% 0); }
  97% { opacity: 0; }
}

@keyframes fallo-b {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: none; }
  92% { opacity: 0.85; transform: translate(0.05em, -0.02em); clip-path: inset(48% 0 30% 0); }
  94% { opacity: 0.85; transform: translate(-0.03em, 0.01em); clip-path: inset(5% 0 75% 0); }
  96% { opacity: 0; }
}

.quien {
  margin-top: 0.4rem;
  color: var(--gris);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.proyectos {
  max-width: 46rem;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--linea);
}

.proyectos a {
  display: grid;
  grid-template-columns: 2.25rem 10.5rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 1rem;
  padding: clamp(0.4rem, 1.3vh, 0.7rem) 0.6rem;
  border-bottom: 1px solid var(--linea);
  text-decoration: none;
  transition: background-color 90ms linear;
}

.proyectos a:hover {
  background: var(--asfalto-2);
}

.num {
  color: var(--gris);
  font-size: 0.75rem;
}

.nombre {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 750;
  font-stretch: 110%;
}

.linea {
  overflow: hidden;
  color: var(--gris);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.codigo {
  padding: 0.05rem 0.4rem;
  border: 1px solid currentColor;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.codigo-open {
  color: var(--limon-tinta);
}

.codigo-soon {
  color: var(--gris);
  border-style: dashed;
}

.proyectos a[aria-current="page"],
.proyectos a.htmx-request {
  background: var(--limon);
  color: var(--sobre-limon);
}

.proyectos a:is([aria-current="page"], .htmx-request) :is(.num, .linea, .codigo) {
  color: var(--sobre-limon);
}

/* Lectura: lo que cambia htmx */

.lectura {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.6rem;
  max-width: 46rem;
  min-height: clamp(7rem, 19vh, 9.5rem);
  padding: 1rem 1.15rem;
  border: 1px solid var(--linea);
  view-transition-name: lectura;
}

.lectura-titulo {
  font-family: var(--sans);
  font-size: 1.35rem;
  font-weight: 800;
  font-stretch: 110%;
  line-height: 1.1;
}

.lectura-titulo span {
  margin-left: 0.6rem;
  color: var(--gris);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  font-stretch: 100%;
  white-space: nowrap;
}

.lectura-texto {
  max-width: 56ch;
  font-size: 0.92rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.lectura-meta {
  color: var(--gris);
  font-size: 0.75rem;
}

.lectura-enlaces {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}

.lectura-enlaces a {
  color: var(--limon-tinta);
  font-size: 0.82rem;
}

/* La torre */

.torre {
  grid-area: torre;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 0;
  padding: 0 var(--g) 0.5rem;
  border-left: 1px solid var(--linea);
  overflow: hidden;
}

.torre pre {
  font-family: var(--mono);
  font-size: var(--fs-torre);
  font-stretch: 75%;
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  user-select: none;
}

.torre-cuerpo {
  position: relative;
  animation: levitar 7s ease-in-out infinite alternate;
}

.torre-piedra {
  color: var(--piedra);
}

.torre-chispa {
  position: absolute;
  inset: 0;
  color: var(--glitch-a);
  pointer-events: none;
}

.torre-sombra {
  margin-top: calc(var(--fs-torre) * var(--hueco, 6));
  color: var(--agua);
  transform-origin: center;
  animation: encoger 7s ease-in-out infinite alternate;
}

@keyframes levitar {
  to {
    transform: translateY(calc(var(--fs-torre) * -3));
  }
}

@keyframes encoger {
  to {
    opacity: 0.55;
    transform: scaleX(0.8);
  }
}

/* Pie */

.pie {
  grid-area: pie;
  display: flex;
  align-items: center;
  gap: 0 1.5rem;
  padding: 0 var(--g);
  border-top: 1px solid var(--linea);
  overflow: hidden;
  color: var(--gris);
  font-size: 0.75rem;
  white-space: nowrap;
}

.pie a {
  color: var(--hueso);
}

.pie a:hover {
  color: var(--limon-tinta);
}

.reloj {
  display: none;
  align-items: center;
  gap: 0.6rem;
}

.js .reloj {
  display: inline-flex;
}

.reloj-fuente {
  display: inline-flex;
  border: 1px solid var(--linea);
}

.reloj-fuente button {
  padding: 0.1rem 0.5rem;
  border: 0;
  background: transparent;
  color: var(--gris);
  font: inherit;
  cursor: pointer;
}

.reloj-fuente button[aria-pressed="true"] {
  background: var(--limon);
  color: var(--sobre-limon);
}

.reloj-fuente button:hover {
  color: var(--hueso);
}

/* En «auto», la ciudad que manda va subrayada. */
.reloj-fuente button.activa:not([aria-pressed="true"]) {
  color: var(--hueso);
  text-decoration: underline;
  text-decoration-color: var(--limon-tinta);
  text-underline-offset: 0.3em;
}

/* Muestra del color de fondo que daría cada ciudad ahora mismo. */
.reloj-fuente button[data-fase]::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.35em;
  border: 1px solid var(--gris);
  background: var(--muestra, transparent);
  vertical-align: 0.02em;
}

.miembros a + a {
  margin-left: 0.6rem;
}

.credito {
  margin-left: auto;
}

.pie .credito {
  color: var(--gris);
}

/* Cambio de proyecto con htmx: el texto nuevo se escribe de izquierda a derecha. */

::view-transition-old(lectura) {
  animation: none;
  opacity: 0;
}

::view-transition-new(lectura) {
  animation: 200ms steps(12, end) both escribir;
}

@keyframes escribir {
  from {
    clip-path: inset(0 100% 0 0);
  }
}

/* Móvil: la torre pasa detrás del texto, en tenue. */

@media (max-width: 52rem) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "panel"
      "pie";
  }

  .panel {
    position: relative;
    z-index: 1;
  }

  .torre {
    position: fixed;
    top: 0;
    right: 0;
    bottom: var(--pie);
    z-index: 0;
    padding-right: 0;
    border: 0;
    opacity: 0.32;
    pointer-events: none;
  }

  .proyectos a {
    grid-template-columns: 1.6rem minmax(0, 1fr) auto;
    background: color-mix(in srgb, var(--asfalto) 70%, transparent);
  }

  .linea {
    grid-column: 2;
    grid-row: 2;
  }

  .codigo {
    grid-column: 3;
    grid-row: 1;
  }

  .lectura {
    background: color-mix(in srgb, var(--asfalto) 85%, transparent);
  }

  .lectura-titulo span {
    display: block;
    margin: 0.3rem 0 0;
    white-space: normal;
  }

  .pie {
    flex-wrap: wrap;
    align-content: center;
    gap: 0.15rem 1.1rem;
    min-height: var(--pie);
    padding-block: 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
  }

  .miembros,
  .reloj-hora {
    display: none;
  }

  .js .reloj {
    display: flex;
    flex-basis: 100%;
  }

  .reloj-fuente button {
    padding-inline: 0.32rem;
  }

  .credito {
    margin-left: 0;
  }
}

@media (max-height: 44rem) {
  .linea {
    display: none;
  }

  .panel {
    gap: 0.75rem;
    padding-top: 1rem;
  }

  .proyectos a {
    padding-block: 0.3rem;
  }

  .lectura {
    gap: 0.4rem;
    min-height: 0;
    padding: 0.7rem 0.9rem;
  }

  .lectura-titulo {
    font-size: 1.15rem;
  }

  .lectura-texto {
    font-size: 0.82rem;
    line-height: 1.45;
  }
}

.rio.corto {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .torre-cuerpo,
  .torre-sombra,
  .marca::before,
  .marca::after {
    animation: none;
  }

  ::view-transition-old(lectura),
  ::view-transition-new(lectura) {
    animation: none;
  }
}

:root {
  --filas: 120;
  --hueco: 6;
  --cols: 80;
}
