/*
  Las demostraciones de las herramientas, los «gifs» (#145): SVG dibujados desde cero y animados con
  la Web Animations API (comun/gifs.js). Una página que las use enlaza esta hoja además de taller.css.

  Dentro del marco van los colores de la aplicación, «Piedra y tinta» en papel (o en tinta, con el
  tema oscuro), sea cual sea el tramo de color de la sección donde se coloquen. Encima, el grano de
  papel; y, mientras se anima, una palabra grande por paso, como el pie de foto de una revista.
*/

.gif { display: grid; gap: 10px; min-width: 0; margin: 0; }

.gif-marco {
  --fondo: var(--tramo-papel-fondo, #fcfcfb); --superficie: var(--tramo-papel-superficie, #f2f2f0);
  --tinta: var(--tramo-papel-tinta, #141414); --secundario: var(--tramo-papel-secundario, #6d6d6a);
  --linea: var(--tramo-papel-linea, #e2e2df); --acento: var(--tramo-papel-acento, var(--acento-claro));
  --boton: var(--tramo-papel-boton, #141414); --boton-texto: var(--tramo-papel-boton-texto, #fcfcfb);
  --mesa: #e9e9e6;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--linea);
  border-radius: var(--radio, 2px);
  background: var(--fondo);
  color: var(--tinta);
}
@media (prefers-color-scheme: dark) {
  .gif-marco {
    --fondo: var(--tramo-papel-fondo, #121212); --superficie: var(--tramo-papel-superficie, #1b1b1a);
    --tinta: var(--tramo-papel-tinta, #ededeb); --secundario: var(--tramo-papel-secundario, #a2a29e);
    --linea: var(--tramo-papel-linea, #2e2e2c); --acento: var(--tramo-papel-acento, var(--acento-oscuro));
    --boton: var(--tramo-papel-boton, #ededeb); --boton-texto: var(--tramo-papel-boton-texto, #121212);
    --mesa: #2a2a28;
  }
}
/* El Cuaderno de bocetos es la foto de una tablet: sin marco alrededor. */
.gif[data-gif="cuaderno"] .gif-marco { background: transparent; border: 0; }

/* Grano de papel, en su propia capa: no se repinta con la animación. */
.gif-marco::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: url("/comun/gifs/grano.png"); opacity: .7;
}
.gif[data-gif="cuaderno"] .gif-marco::after { inset: 1.6% 1% 1.6% 1%; border-radius: 3% / 5%; }

.gif-svg { display: block; width: 100%; height: auto; aspect-ratio: 640 / 400; }

/* ---- Pie: los pasos (con la rayita que se llena) y el botón Pausa / Reproducir */
.gif-pie { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gif-pasos { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0; padding: 0; list-style: none; counter-reset: paso; }
.gif-pasos li {
  position: relative; counter-increment: paso; padding: 8px 14px 0 0; margin-right: 14px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--secundario);
}
.gif-pasos li::before { content: "0" counter(paso) " "; font-variant-numeric: tabular-nums; }
.gif-pasos li::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--linea); }
.paso-luz {
  position: absolute; left: 0; right: 0; top: -0.5px; z-index: 1; height: 2px;
  background: var(--tinta); transform-origin: 0 50%; transform: scaleX(0);
}
.gif-pausa {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--linea); border-radius: 999px; background: none; color: var(--tinta);
  font: 500 12px var(--letra); letter-spacing: .1em; text-transform: uppercase; cursor: pointer;
}
.gif-pausa[hidden] { display: none; }
.gif-pausa:hover { border-color: var(--tinta); }
.gif-pausa:focus-visible { outline: 2px solid var(--foco, var(--tinta)); outline-offset: 2px; }
.gif-pausa-icono { width: 8px; height: 9px; border-inline: 2.5px solid currentColor; }
.gif:is([data-gif-estado="pausada"], [data-gif-estado="quieta"]) .gif-pausa-icono {
  width: 0; height: 0; border: 0; border-left: 8px solid currentColor; border-block: 5px solid transparent;
}

/* ---- Rótulos: una palabra por paso, en tinta sobre una tira de papel */
.gif-rotulos { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.gif-rotulo {
  position: absolute; left: 4%; bottom: 5%; display: grid; justify-items: start; opacity: 0;
  padding: 0 .12em; color: var(--tinta);
  background: linear-gradient(var(--fondo), var(--fondo)) 0 100% / 100% .86em no-repeat;
  font-family: var(--letra); font-size: clamp(28px, 5.2vw, 84px); font-weight: 300;
  letter-spacing: -0.045em; line-height: .9; text-transform: uppercase;
}
.gif-rotulo small {
  justify-self: start; margin-bottom: 4px; padding: 2px 6px; background: var(--fondo);
  font-size: 12px; font-weight: 500; letter-spacing: .16em; font-variant-numeric: tabular-nums;
}
/* El Cuaderno y la Lección: la palabra en el hueco de la derecha, lejos del lápiz y del cursor */
.gif[data-gif="cuaderno"] .gif-rotulo { left: auto; right: 7%; bottom: 9%; justify-items: end; }
.gif[data-gif="cuaderno"] .gif-rotulo small,
.gif[data-gif="videotutoriales"] .gif-rotulo small { justify-self: end; }
.gif-rotulo-derecha { left: auto; right: 4%; justify-items: end; }
.gif-rotulo-derecha small { justify-self: end; }
.gif[data-gif="videotutoriales"] .gif-rotulo { left: auto; right: 5%; bottom: auto; top: 13%; justify-items: end; }
.gif[data-gif="teselador"] .gif-rotulo { bottom: 12%; }
@media (max-width: 560px) { .gif-rotulo { font-size: 28px; } .gif-rotulo small { font-size: 10px; } }
@media (forced-colors: active) { .gif-rotulos, .gif-marco::after { display: none; } }

/* ---- Piezas comunes dentro de los SVG */
.g-ventana { fill: var(--fondo); stroke: var(--linea); }
.g-linea { stroke: var(--linea); stroke-width: 1; fill: none; }
.g-mesa { fill: var(--mesa); }
.g-hoja { fill: #fff; }
.g-sombra { fill: #000; opacity: .07; }
.g-t { fill: var(--tinta); font-family: var(--letra); font-size: 9px; }
.g-t5 { font-weight: 500; }
.g-s { fill: var(--secundario); font-family: var(--letra); font-size: 8px; }
.cifras { font-variant-numeric: tabular-nums; }
.g-icono { fill: none; stroke: var(--tinta); stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.g-plano { fill: none; stroke: #141414; stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; }
.g-fino { fill: none; stroke: #141414; stroke-width: .7; stroke-linecap: round; }
.g-pespunte { fill: none; stroke: #141414; stroke-width: .6; stroke-dasharray: 2 1.6; }
.g-cota { fill: none; stroke: #6d6d6a; stroke-width: .6; }
.g-cota-t { fill: #6d6d6a; font: 300 7px var(--letra); font-variant-numeric: tabular-nums; }
.g-acento { stroke: var(--acento); fill: none; }
.g-acento-relleno { fill: var(--acento); }
.g-seleccion { fill: color-mix(in srgb, var(--acento) 14%, transparent); stroke: var(--acento); stroke-width: 1; }
.g-boton-tinta { fill: var(--boton); }
.g-boton-tinta-t { fill: var(--boton-texto); font: 500 8.5px var(--letra); }
.g-cursor { fill: #141414; stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
.g-boton-hoja { fill: #fff; stroke: #141414; stroke-width: .7; }
.g-tablet { fill: #0a0a0a; }
@media (prefers-color-scheme: dark) { .g-sombra { opacity: .3; } }
