@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&family=IBM+Plex+Mono:wght@400&display=swap');

:root {
  --void: #f2eee4;
  --paper: #17140f;
  --dim-1: rgba(23, 20, 15, 0.85);
  --dim-2: rgba(23, 20, 15, 0.55);
  --dim-3: rgba(23, 20, 15, 0.3);
  --dim-4: rgba(23, 20, 15, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--dim-1);
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: var(--dim-1);
  text-decoration: none;
  transition: opacity 0.6s ease;
}

a:hover, a:focus-visible {
  opacity: 1;
  color: var(--paper);
}

a:focus-visible {
  outline: 1px solid var(--dim-2);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='3' intercept='-1'/%3E%3CfeFuncG type='linear' slope='3' intercept='-1'/%3E%3CfeFuncB type='linear' slope='3' intercept='-1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 150px 150px;
  animation: grain-shift 1.4s steps(7) infinite;
}

@keyframes grain-shift {
  0%   { background-position: 0px 0px; }
  14%  { background-position: 40px -30px; }
  28%  { background-position: -25px 45px; }
  42%  { background-position: -50px -15px; }
  57%  { background-position: 30px 35px; }
  71%  { background-position: -35px -40px; }
  85%  { background-position: 45px 10px; }
  100% { background-position: 0px 0px; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
}

.home-link {
  position: fixed;
  bottom: 24px;
  left: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--dim-1);
  z-index: 5;
  animation: drift 9s ease-in-out infinite, pulse 6s ease-in-out infinite;
}

@keyframes drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(4px, -5px); }
  50%  { transform: translate(-3px, 3px); }
  75%  { transform: translate(-5px, -3px); }
  100% { transform: translate(0, 0); }
}

@keyframes pulse {
  0%   { opacity: 0.3; }
  50%  { opacity: 0.85; }
  100% { opacity: 0.3; }
}

.home-link:hover, .home-link:focus-visible {
  color: var(--paper);
  opacity: 1;
}

.shift-1 { margin-left: 0; }
.shift-2 { margin-left: 3em; }
.shift-3 { margin-left: 1em; }
.shift-4 { margin-left: 4.5em; }
.shift-5 { margin-left: 2em; }

@media (max-width: 600px) {
  .shift-1, .shift-2, .shift-3, .shift-4, .shift-5 { margin-left: 0; }
}

.read-time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--dim-3);
  margin-bottom: 2.5rem;
}

.edition-link {
  position: fixed;
  top: 24px;
  left: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--dim-3);
  text-decoration: none;
  z-index: 5;
  transition: color 0.3s ease, letter-spacing 0.4s ease, transform 0.4s ease;
}

.edition-link:hover, .edition-link:focus-visible {
  color: var(--paper);
  letter-spacing: 0.16em;
  transform: skewX(-2deg) scale(1.03);
}

.utc-clock {
  position: fixed;
  top: 24px;
  right: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--dim-3);
  z-index: 5;
}

.scale-select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--dim-3);
  display: flex;
  gap: 14px;
  margin-bottom: 0.6rem;
}

.scale-select span {
  cursor: pointer;
  transition: color 0.3s ease;
}

.scale-select span.active {
  color: var(--paper);
}

.scale-select span:hover {
  color: var(--dim-1);
}

body.scale-cuantico .a, body.scale-cuantico .verse { font-size: 13px; }
body.scale-cuantico .q, body.scale-cuantico .title { font-size: 12px; }
body.scale-cuantico .frame { font-size: 11px; }

body.scale-cosmico .a, body.scale-cosmico .verse { font-size: 23px; }
body.scale-cosmico .q, body.scale-cosmico .title { font-size: 21px; }
body.scale-cosmico .frame { font-size: 18px; }


/* marca de edición: colofón, no navegación */
.edicion {
  position: fixed;
  bottom: 24px;
  right: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--dim-3);
  z-index: 5;
  pointer-events: none;
}

/* hilo: una palabra del texto que cruza a otra voz */
main { position: relative; }

.hilo {
  color: inherit;
  border-bottom: 1px solid var(--dim-3);
  transition: border-color 0.5s ease, color 0.3s ease;
}

/* el nombre de la otra voz aparece en el margen, a la altura de la línea */
.hilo::after {
  content: attr(data-voz);
  position: absolute;
  left: calc(100% + 1.2rem);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.04em;
  line-height: 1.8;
  white-space: nowrap;
  color: var(--dim-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.hilo:hover, .hilo:focus-visible {
  border-bottom-color: var(--dim-1);
}

.hilo:hover::after, .hilo:focus-visible::after {
  opacity: 0.75;
}

.hilo:focus, .hilo:focus-visible {
  outline: none;
}

.hilo:focus-visible {
  box-shadow: 0 1px 0 0 var(--paper);
  border-bottom-color: var(--paper);
}

@media (max-width: 880px) {
  .hilo::after { display: none; }
}

.hilo:target {
  animation: llegada 2.6s ease;
}

@keyframes llegada {
  0%   { border-bottom-color: var(--paper); color: var(--paper); }
  100% { border-bottom-color: var(--dim-3); }
}

.hilo-trazo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
  opacity: 1;
}

.hilo-trazo line {
  stroke: rgba(23, 20, 15, 0.55);
  stroke-width: 1;
  fill: none;
}

.hilo-trazo.fuera {
  opacity: 0;
  transition: opacity 1.4s ease;
}

body.scale-cuantico .edicion { font-size: 11px; }

/* Negro de llegada a Vacío y Origen: mismo degradado y mismo grano que la portada, para que no haya salto al hacer clic */
:root { --entry-bg: radial-gradient(ellipse at 50% 46%, #262420 0%, #1a1815 58%, #11100e 100%); }
html.entering::after, .portal::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='3' intercept='-1'/%3E%3CfeFuncG type='linear' slope='3' intercept='-1'/%3E%3CfeFuncB type='linear' slope='3' intercept='-1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 150px 150px; opacity: 0.11; mix-blend-mode: screen;
  animation: grain-shift 1.4s steps(7) infinite;
}
html.entering::after { position: fixed; z-index: 99; }
