/* GUS, el perro guía · Web provisional
   Paleta y tipografía según la guía de estilo:
   https://gus-guia-estil.accesibilidadprimero.com/ */

@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --nit: #172b46;      /* Blau nit / Azul noche */
  --crema: #fff8e8;    /* Crema càlid */
  --guia: #2457a7;     /* Blau guia */
  --taronja: #f28c45;  /* Taronja aventura */
  --verd: #386447;     /* Verd parc */
  --groc: #f2c44e;     /* Groc sol */

  --font-display: "Fredoka", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-text: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fade: 1600ms;
  --radius: 1.5rem;
  --gutter: clamp(1rem, 3vw, 2.5rem);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--nit);
  color: var(--crema);
  font-family: var(--font-text);
  font-size: 1.125rem;   /* 18 px, criterio de lectura de la guía */
  line-height: 1.5;
}

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

a { color: var(--crema); text-decoration: underline; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.12em; }

:focus-visible {
  outline: 3px solid var(--groc);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

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

/* Salta al contenido */
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--crema);
  color: var(--nit);
  font-weight: 700;
  border-radius: 0.75rem;
}
.skip-link:focus { top: var(--gutter); }

/* ---------- Fondo con fundidos ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #000;                 /* bandas negras: la imagen mantiene su formato */
}
.backdrop img.still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
  opacity: 0;
  transition: opacity var(--fade) ease-in-out;
}
.backdrop img.still.is-active { opacity: 1; }

/* ---------- Cabecera: idiomas ---------- */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  padding: var(--gutter);
}
.lang ul {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--nit);
  border-radius: 999px;
}
.lang li { display: flex; align-items: center; }
.lang a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.75rem;
  letter-spacing: 0.04em;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}
.lang a:hover { text-decoration: underline; }
.lang a[aria-current="page"] {
  background: var(--crema);
  color: var(--nit);
}

/* ---------- Contenido ---------- */
.layout {
  position: relative;
  z-index: 1;
  padding: 0 var(--gutter) var(--gutter);
}

.card {
  position: relative;
  z-index: 1;                       /* por encima de los fotogramas de fondo */
  width: 100%;
  max-width: 36rem;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: var(--nit);           /* fondo sólido: 13,5:1 con el crema */
  border-radius: var(--radius);
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.35);
}

/* Ocultar la tarjeta para ver la imagen completa (botón de ojo) */
.card { transition: opacity 300ms ease, visibility 0s linear 0s; }
.card.is-hidden { opacity: 0; visibility: hidden; transition: opacity 300ms ease, visibility 0s linear 300ms; }

.title { margin: 0; }
.title img { width: min(100%, 26rem); }

.release {
  display: inline-block;
  margin: 1.25rem 0 0;
  padding: 0.45rem 1.1rem 0.5rem;
  background: var(--groc);          /* Blau nit sobre Groc sol: 8,69:1 */
  color: var(--nit);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  line-height: 1.15;
  border-radius: 0.75rem;
  transform: rotate(-2deg);
}

.synopsis h2 {
  margin: 2rem 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem);
  line-height: 1.2;
  color: var(--taronja);            /* Taronja sobre Blau nit: 5,86:1 */
}
.synopsis p { margin: 0 0 1em; max-width: 65ch; }
.synopsis p:last-child { margin-bottom: 0; }

.credit {
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid rgb(255 248 232 / 0.25);
  font-size: 1rem;
}

/* ---------- Control del pase ---------- */
.controls {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 2;
  display: flex;
  gap: 0.5rem;
}
.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--nit);
  color: var(--crema);
  border: 2px solid var(--crema);
  border-radius: 999px;
  cursor: pointer;
}
.control-btn:hover { background: var(--guia); }
.control-btn[hidden] { display: none; }
.control-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.control-btn svg.fill { width: 1.125rem; height: 1.125rem; fill: currentColor; stroke: none; }
.control-btn svg[hidden] { display: none; }

/* ---------- Escritorio: tarjeta a la izquierda, imagen visible ---------- */
@media (min-width: 60rem) {
  body { display: grid; grid-template-rows: auto 1fr; }
  .layout { display: flex; align-items: flex-end; }
}

/* ---------- Móvil: la imagen asoma arriba ---------- */
.loop-clone, .swipe-hint { display: none; }

/* ---------- Móvil y tablet vertical: una sola pantalla con carrusel horizontal en bucle ---------- */
@media (max-width: 59.99rem) {
  /* Idiomas flotando arriba a la derecha */
  .site-header { position: absolute; top: 0; right: 0; z-index: 3; padding: 1rem; }
  .card-toggle { display: none; }

  /* La pantalla entera es una tira horizontal: tarjeta + fotogramas + copia para el bucle */
  .layout {
    display: flex;
    gap: 4px;
    height: 100vh;
    height: 100svh;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    background: #000;
  }
  .layout::-webkit-scrollbar { display: none; }
  .layout:focus-visible { outline-offset: -4px; }

  .card,
  .card.loop-clone {
    flex: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 85vw;
    max-width: 34rem;
    height: 100%;
    margin: 0;
    padding: 4.5rem 1.5rem 1.5rem;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;                 /* con la letra muy ampliada, el texto se puede desplazar */
  }
  .card.is-hidden { opacity: 1; visibility: visible; }
  .title img { width: min(100%, 17rem); }
  .release { margin-top: 1rem; font-size: 1.5rem; align-self: flex-start; }
  .synopsis h2, .synopsis .h2-like {
    margin: 1.5rem 0 0.5rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.375rem;
    line-height: 1.2;
    color: var(--taronja);
  }
  .synopsis p:not(.h2-like) { font-size: 1.0625rem; }
  .swipe-hint {
    display: block;
    margin: 1.25rem 0 0;
    font-weight: 700;
    font-size: 1rem;
  }
  .swipe-hint span { display: inline-block; margin-left: 0.25rem; }

  /* Los fotogramas, a toda la altura, uno detrás de otro */
  .backdrop {
    position: static;
    flex: none;
    display: flex;
    gap: 4px;
    height: 100%;
    background: none;
  }
  .backdrop img.still,
  .backdrop img.loop-clone {
    display: block;
    position: static;
    flex: none;
    width: auto;
    height: 100%;
    max-width: none;
    opacity: 1;
    object-fit: cover;
    transition: none;
  }
}

@media (max-width: 59.99rem) and (prefers-reduced-motion: no-preference) {
  .swipe-hint span { animation: nudge 1.6s ease-in-out 3; }
  @keyframes nudge { 50% { transform: translateX(6px); } }
}
}

/* Movimiento reducido: sin fundidos automáticos (el JS tampoco arranca solo) */
@media (prefers-reduced-motion: reduce) {
  :root { --fade: 0ms; }
  .release { transform: none; }
}

/* Modo de alto contraste forzado (Windows) */
@media (forced-colors: active) {
  .card, .lang ul, .release, .control-btn { border: 2px solid CanvasText; }
}
@media (forced-colors: active) and (min-width: 60rem) {
  .backdrop { display: none; }
}
