/* ==========================================================================
   MIGA — hoja de estilos única.
   Sin framework, sin build de CSS, sin JS. Un solo archivo, se lee entero.
   ========================================================================== */

/* --- Tipografías --------------------------------------------------------
   Apfel Grotezk (Collletttivo) para display. Poné los .woff2 en /static/fonts/.
   Si el archivo no está, cae a Arial Black y el sitio igual funciona.
   El texto corrido es Times New Roman de sistema: cero pedidos de red. */

@font-face {
  font-family: "Apfel Grotezk";
  src: url("/fonts/ApfelGrotezk-Fett.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Apfel Grotezk";
  src: url("/fonts/ApfelGrotezk-Satt.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* --- Variables ---------------------------------------------------------- */

:root {
  --negro:    #000000;
  --tinta:    #0d0d0d;
  --papel:    #faf7f6;
  --cyan:     #01ffd9;
  --amarillo: #e3ff2a;
  --magenta:  #ee01ff;
  --teal:     #42abb6;
  --rojo:     #ff3838;
  --azul:     #0066ff;   /* el azul de link de toda la vida */
  --violeta:  #551a8b;   /* visitado */

  --display: "Apfel Grotezk", "Arial Black", Impact, sans-serif;
  --texto:   "Times New Roman", Times, Georgia, serif;

  --hoja: 893px;         /* ancho de la hoja, igual que el Figma */
  --aire: clamp(1.25rem, 4vw, 3.5rem);

  /* Ancho del tile de sanguches. El gif trae DOS sanguches, y en el frame
     entran 3 pares por fila: 1366/3 = 455px, o sea 33,34vw. El piso de
     340px evita que en el celular queden de confite; el techo de 560px
     evita que en un monitor ancho se coman la pantalla.
     El raver NO lleva medida: va a 50x60, natural. */
  --sanguche: clamp(340px, 33.34vw, 560px);
  --sanguche-fondo: clamp(120px, 12.45vw, 210px);
}

/* --- Base --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--texto);
  color: var(--tinta);
  background-color: var(--negro);
}

img, video, iframe { max-width: 100%; }
img, video { height: auto; display: block; }

a { color: var(--azul); }
a:visited { color: var(--violeta); }
a:focus-visible {
  outline: 3px solid var(--magenta);
  outline-offset: 2px;
}

/* ==========================================================================
   PORTADA
   ========================================================================== */

body.portada {
  position: relative;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  background-color: var(--negro);
  background-image: url("/img/dancing_raver_smaller.gif");
  background-repeat: repeat;
  background-size: auto;
  background-position: left top;
}

/* Banda de sanguches de fondo */
body.portada::before {
  content: "";
  position: absolute;
  inset: 8.2% 0 11.8%;
  background-image: url("/img/sanguche.gif");
  background-repeat: repeat;
  background-size: var(--sanguche) auto;
  background-position: center top;
  pointer-events: none;
  z-index: 0;
}

/* El contenido central ocupa todo el alto libre (flex: 1) para empujar
   el bloque inferior (fuego + marquesina + pie) directo al fondo */
.portada__caja {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  padding: var(--aire) var(--aire) clamp(1rem, 3svh, 2rem);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  row-gap: clamp(2rem, 5svh, 4rem);
}

.marca {
  margin: 0;
  /* 66svh es la proporcion del frame (508 de 767). El tope por ancho
     manda en celular; el tope por alto, en ventanas bajas. */
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 508 siempre que entre; si no entra se achica solo. Sin numeros magicos:
   la fila mide 1fr de una caja de alto definido, asi que el max-height resuelve. */
.marca img {
  width: min(80vw, 508px);
  height: auto;
  max-height: 100%;
  object-fit: contain;
}

.entrar-caja { margin: 0; }

.entrar {
  position: relative;                 /* ancla del glow de abajo */
  display: inline-block;
  min-width: 118px;
  padding: .35em 1em;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.25rem, 4vw, 1.875rem);  /* 30px */
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  user-select: none;
  background-image: linear-gradient(-68.83deg, var(--amarillo) 6.65%, var(--magenta) 92.04%);
}
.entrar:visited { color: #fff; }

/* Glow animado detras del boton. Se pinta con z-index:-1, o sea por
   detras del degrade del propio boton: lo que se ve es el halo que
   sobresale por el escalado y el blur. Aparece en hover. */
.entrar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, #1CB5E0, #000851, #00C9FF, #92FE9D,
                              #FC466B, #3F5EFB, #3F2B96, #A8C0FF, #FDBB2D, #3A1C71);
  background-size: 500%;
  transform: scaleX(1.1) scaleY(1.2);
  filter: blur(7px);
  opacity: 0;
  transition: opacity .25s ease;
  animation: flowing 10s ease infinite;
}
.entrar:hover::after,
.entrar:focus-visible::after { opacity: 1; }
.entrar:active { filter: brightness(.9); }

@keyframes flowing {
  0%   { background-position: 0 0; }
  50%  { background-position: 400% 0; }
  100% { background-position: 0 0; }
}

/* ==========================================================================
   MANIFIESTO / PÁGINAS INTERIORES
   ========================================================================== */

/* DEGRADE CON DITHER REAL.
   CSS no sabe cuantizar un linear-gradient, asi que el degrade viene
   pre-ditherizado: /img/grad-dither-10.png, un tile de 64x1544 con Bayer
   ordenado 8x8 sobre la rampa cyan->negro. Se repite en X a tamano natural,
   asi la trama queda 1:1 y no se interpola. Debajo de los 1544px, negro.
   Variantes segun cuanto quieras que se note: -6 (grueso), -10, -16 (fino). */
body.manifiesto {
  position: relative;
  background-color: var(--negro);
  background-image: url("/img/backgroundbluebubble.gif");
  background-repeat: repeat;
  background-size: auto;              /* 64x1544, sin escalar */
  background-position: left top;
  image-rendering: pixelated;         /* que en retina no lo suavice */
}
/* image-rendering se hereda: hay que devolverlo a normal o las fotos
   de las fichas salen pixeladas. */
body.manifiesto *,
body.manifiesto::before { image-rendering: auto; }

/* Banda de sanguches. En el frame arranca a 127px del tope y corta 80px
   antes del final. Va en ::before porque un background cubre siempre
   toda la caja y no se puede recortar. */
body.manifiesto::before {
  content: "";
  position: absolute;
  inset: 127px 0 80px;
  background-image: url("/img/patron-sanguches-hex.png");
  background-repeat: repeat;
  background-size: var(--sanguche-fondo) auto;
  background-position: center top;
  pointer-events: none;
  z-index: 0;
}

/* Sanguche grande sobreimpreso, colgando del angulo superior izquierdo.
   Del frame de 1366: x=-231, y=-153, 947x517. Todo en vw para que
   escale como una sola pieza a cualquier ancho. */
.sanguche-grande {
  position: absolute;
  top: -9.5vw;
  left: -9.1vw;
  width: 52.33vw;
  height: auto;
  z-index: 2;                         /* por encima de la hoja */
  pointer-events: none;
  user-select: none;
}

main {
  position: relative;
  z-index: 1;                         /* por encima de la banda de sanguches */
  display: flow-root;                 /* frena el colapso de margenes: sin esto
                                         el margen de .hoja se escapa del body y
                                         corre 176px hacia abajo el origen de
                                         todo lo posicionado (sello, ::before) */
  padding: 0 var(--aire) clamp(2rem, 6vw, 5rem);
}

/* La hoja de papel */
.hoja {
  max-width: var(--hoja);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1.25rem, 4vw, 2.5rem);
  background: var(--papel);
}

article.hoja {
  margin-top: clamp(2.5rem, 12.9vw, 11rem);   /* 176px a 1366, como el frame */
}

/* Sello: el circulito de MIGA arriba a la derecha */
.sello {
  position: absolute;
  top: clamp(.5rem, 1vw, 1rem);
  right: clamp(.5rem, 1.5vw, 1.25rem);
  width: clamp(72px, 16vw, 218px);
  z-index: 3;
}
.sello img { width: 100%; height: auto; }

/* --- Títulos y texto ---------------------------------------------------- */

.titulo {
  margin: 0 0 clamp(1rem, 3vw, 2rem);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 4.375rem);   /* 70px */
  line-height: 1;
  letter-spacing: .2em;
  text-indent: .2em;                        /* compensa el tracking del final */
  text-transform: uppercase;
  text-align: center;
}

.bajada {
  margin: 0 0 clamp(1.25rem, 3vw, 2.25rem);
  font-size: clamp(1.375rem, 3.6vw, 2.625rem);   /* 42px */
  line-height: 1.1;
  letter-spacing: .02em;
}
.bajada em, .bajada i { font-style: italic; }

.cuerpo {
  font-size: clamp(1.0625rem, 2vw, 1.75rem);     /* 28px */
  line-height: 1.14;
  letter-spacing: .02em;
}
.cuerpo > * + * { margin-top: .7em; }
.cuerpo ul { padding-left: 1.5em; margin: 0; }
.cuerpo li + li { margin-top: .45em; }
.cuerpo strong { font-weight: 700; }
.cuerpo a { text-underline-offset: .1em; }

/* --- Bloque de firmas --------------------------------------------------- */

.hoja--firmas {
  margin-top: 19px;   /* el respiro exacto entre hojas del Figma */
  padding-top: clamp(1.25rem, 3vw, 1.5rem);
  padding-bottom: clamp(1.25rem, 3vw, 1.5rem);
}

.rotulo {
  margin: 0 0 .4em;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1rem, 2.2vw, 1.5625rem);   /* 25px */
  line-height: 1.12;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--tinta);
}
.rotulo + .firmas { margin-bottom: clamp(1rem, 2.5vw, 1.75rem); }
.firmas + .rotulo { margin-top: 0; }

.firmas {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .35em 1.5em;
  font-size: clamp(1rem, 1.8vw, 1.25rem);     /* 20px */
  line-height: 1.4;
}

/* --- Página de firmante ------------------------------------------------- */

.miga-de-pan {
  margin: 0 0 clamp(1rem, 2.5vw, 1.75rem);
  font-size: clamp(.875rem, 1.5vw, 1.0625rem);
  letter-spacing: .02em;
}
.miga-de-pan span { color: #666; }

.ficha {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(1rem, 3vw, 2rem);
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
  padding-bottom: clamp(1.25rem, 3vw, 2rem);
  border-bottom: 2px solid var(--tinta);
}
.ficha__foto {
  width: clamp(120px, 26vw, 220px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  flex: 0 0 auto;
}
.ficha__texto { flex: 1 1 16rem; min-width: 0; }

.titulo--firmante {
  text-align: left;
  text-indent: 0;
  letter-spacing: .04em;
  font-size: clamp(1.75rem, 5.5vw, 3.25rem);
  margin-bottom: .35em;
}
.bajada--chica {
  font-size: clamp(1.125rem, 2.4vw, 1.75rem);
  margin-bottom: .4em;
}
.ficha__sitio {
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
}

/* Figuras dentro del cuerpo */
.figura { margin: 1.25em 0; }
.figura img, .figura video { width: 100%; }
.figura figcaption {
  margin-top: .4em;
  font-size: .72em;
  line-height: 1.25;
  color: #444;
}
.marco-video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}
.marco-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Anillo: navegación entre firmantes */
.anillo {
  max-width: var(--hoja);
  margin: 19px auto 0;
  padding: clamp(.75rem, 2vw, 1rem) clamp(1.25rem, 4vw, 2.5rem);
  background: var(--papel);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5em 1.5em;
  font-size: clamp(.9375rem, 1.7vw, 1.125rem);
}
.anillo--libre {
  margin: 0;
  background: var(--papel);
  border-top: 2px solid var(--negro);
  justify-content: center;
}

/* ==========================================================================
   TIRA DE FUEGO + CONTADOR
   ========================================================================== */

/* Bloque inferior continuo sobre fondo negro sólido */
body.portada > .tira,
body.portada > .marquesina,
body.portada > .pie {
  flex: none;
  position: relative;
  z-index: 2;
  background: var(--negro);
  margin: 0;
}

/* Tira de fuego pegada a la marquesina */
.tira {
  position: relative;
  background: var(--negro);
  line-height: 0;
}

.tira__fuego {
  height: clamp(26px, 4svh, 36px);
  background: url("/img/flamingline.gif") repeat-x left center;
  background-size: auto 100%;
}

/* Contador sobreimpreso centrado sobre el fuego */
.contador {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  font-family: var(--display);
  font-weight: 700;
  font-size: .625rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--papel);
  pointer-events: none;
  line-height: 1;
}

/* Pastillas con fondo negro para aislar el texto del fuego */
.contador span {
  background: var(--negro);
  padding: .2em .4em;
  line-height: 1;
}

.contador img {
  background: var(--negro);
  padding: 2px 4px;
  height: clamp(16px, 2.4svh, 22px);
  width: auto;
  display: block;
}

/* ==========================================================================
   BOTON DE SONIDO — angulo superior derecho de la portada
   ========================================================================== */

.son {
  position: absolute;
  top: clamp(.6rem, 1.4vw, 1.25rem);
  right: clamp(.6rem, 1.4vw, 1.25rem);
  z-index: 3;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  line-height: 0;
  cursor: pointer;
}
/* El sprite real mide 28x32. Se muestra a multiplos exactos para que la
   grilla de pixeles no quede rota: 84 = 28x3, 56 = 28x2. */
.son img {
  display: block;
  width: 84px;
  height: auto;
  image-rendering: pixelated;
}
.son:hover img   { filter: brightness(1.25); }
.son:active img  { transform: translateY(1px); }
/* Apagado: gris y apagado, sin necesidad de un segundo archivo. */
.son[aria-pressed="false"] img { filter: grayscale(1) brightness(.5); }

@media (max-width: 640px) {
  .son img { width: 56px; }
}

/* ==========================================================================
   MARQUESINA Y PIE
   ========================================================================== */

.marquesina {
  overflow: hidden;
  background: var(--negro);
  padding: clamp(.3rem, 1vw, .5rem) 0;
  white-space: nowrap;
}

.marquesina__riel {
  display: inline-flex;
  animation: correr 28s linear infinite;
  will-change: transform;
}
.marquesina__grupo {
  font-family: var(--texto);
  font-size: clamp(1.5rem, 4.5vw, 2.75rem);   /* 44px */
  line-height: 1.1;
  letter-spacing: .02em;
  padding-right: .4em;
}
.marquesina .a { color: var(--amarillo); }
.marquesina .b { color: var(--magenta); }
.marquesina .c { color: var(--teal); }
.marquesina .d { color: var(--rojo); }

@keyframes correr {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.pie {
  margin: 0;
  padding: clamp(.35rem, 1vw, .6rem) var(--aire);
  background: var(--negro);
  text-align: center;
}

.pie p {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: .5625rem;
  letter-spacing: .12em;
  color: var(--papel);
}

.pie__logo {
  margin: 0 auto;
}

/* ==========================================================================
   LAYOUT LIBRE — el firmante hace lo que quiere, nosotros no metemos mano
   ========================================================================== */

body.libre {
  background: #fff;
  color: #000;
  font-family: var(--texto);
}
body.libre main { padding: 0; }

/* ==========================================================================
   AJUSTES
   ========================================================================== */

/* En pantallas chicas el sello estorba: lo achicamos y lo dejamos fijo. */
@media (max-width: 640px) {
  .sello {
    position: fixed;
    top: auto;
    bottom: .5rem;
    right: .5rem;
    width: 64px;
    opacity: .92;
  }
  .cuerpo { line-height: 1.28; }
  .bajada { line-height: 1.15; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marquesina__riel { animation: none; }
  .entrar::after { animation: none; }
  .marquesina { white-space: normal; text-align: center; }
  .marquesina__grupo + .marquesina__grupo { display: none; }
}

@media print {
  body { background: #fff !important; }
  .sello, .marquesina, .anillo { display: none; }
  .hoja { max-width: none; padding: 0; }
}


/* ==========================================================================
   WEBRING
   ========================================================================== */

.miga-webring {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #000;
  padding: 4px 8px;
  border: 1px solid #01ffd9;
  font-family: monospace;
}

.miga-webring a {
  color: #e3ff2a;
  text-decoration: none;
  font-weight: bold;
}

.miga-webring a:hover {
  color: #ee01ff;
}

.miga-webring img {
  display: block;
  image-rendering: pixelated;
}
