/* El comparador de cortina, compartit per les investigacions que el fan
   servir: Torrelles des de l'aire i el 22 de juliol de 1936.

   La figura ha de ser silenciosa: una capsa quadrada, dos anys petits a
   les cantonades i una guia vertical. El que ha de cridar l'atenció és
   el terreny, no el control. L'any de cada cantonada és, a més, el
   desplegable que el canvia, i a la cantonada de baix hi ha la lupa.

   L'estat de la cortina viu en una sola variable, --tall, que mou
   alhora el retall de la imatge de dalt i la guia. Si algun dia se'n
   canvia una, s'han de canviar totes dues.

   Els temps: 220 ms per obrir i 140 ms per tancar, amb la corba
   invertida, que és com es mou una cosa que torna pel mateix camí per on
   ha vingut. Res no rebota: això no és un gest amb inèrcia, és un menú.  */

/* ============================================================
   1. El marc i les dues imatges
   ============================================================ */

.vol-comp { margin: clamp(28px, 4vw, 44px) 0; }

.vol-marc {
  --tall: 50%;
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: var(--paper-2);
  box-shadow: var(--ombra-curta);
  touch-action: pan-y;               /* el dit ha de poder continuar llegint */
  cursor: ew-resize;
}

.vol-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* La de la dreta es retalla just on hi ha la guia. */
.vol-b { clip-path: inset(0 0 0 var(--tall)); }

.vol-nansa {
  position: absolute;
  z-index: 2;
  top: 0; bottom: 0;
  left: var(--tall);
  width: 2px;
  margin-left: -1px;
  background: light-dark(rgba(252,252,250,.9), rgba(255,255,255,.75));
  box-shadow: 0 0 0 1px light-dark(rgba(29,29,27,.28), rgba(0,0,0,.6));
  pointer-events: none;
}
.vol-nansa-rodona {
  position: absolute;
  top: 50%; left: 50%;
  width: 38px; height: 38px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--vidre-2);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 1px light-dark(rgba(29,29,27,.18), rgba(255,255,255,.22)), var(--ombra-curta);
}
/* Les dues fletxetes de la rodona, dibuixades amb vores. */
.vol-nansa-rodona::before,
.vol-nansa-rodona::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 0; height: 0;
  border: 5px solid transparent;
  transform: translateY(-50%);
}
.vol-nansa-rodona::before { left: 7px;  border-right-color: var(--ink-2); }
.vol-nansa-rodona::after  { right: 7px; border-left-color:  var(--ink-2); }

/* El range ocupa tot el marc i és invisible: el que es veu és la guia.
   Així la cortina té teclat i lector de pantalla sense inventar res. */
.vol-cursor {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%; height: 100%;
  margin: 0;
  appearance: none; -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-y;
}
.vol-cursor::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 44px; height: 100vh;
  opacity: 0;
  cursor: ew-resize;
}
.vol-cursor::-moz-range-thumb {
  width: 44px; height: 100vh;
  border: 0; opacity: 0;
  cursor: ew-resize;
}
.vol-cursor:focus { outline: none; }
.vol-marc:has(.vol-cursor:focus-visible) .vol-nansa-rodona {
  box-shadow: 0 0 0 3px var(--foix), var(--ombra-curta);
}

/* El peu: la frase primer i el crèdit a sota, en gris petit. Mai a la
   mateixa línia, que llavors sembla que el crèdit formi part del text. */
.vol-comp figcaption {
  margin-top: 10px;
  font-family: var(--sans);
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.vol-comp figcaption .credit {
  display: block;
  margin-top: 4px;
  font-size: .75rem;
  line-height: 1.45;
  color: var(--ink-3);
}

/* ============================================================
   2. L'any de cada cantonada, i el seu desplegable
   ============================================================ */

.vol-any {
  position: absolute;
  z-index: 3;
  top: 10px;
  font-family: var(--sans);
}
.vol-any-a { left: 10px; }
.vol-any-b { right: 10px; }

.vol-any-boto {
  display: flex; align-items: center; gap: 5px;
  appearance: none; border: 0;
  height: 26px;
  padding: 0 7px 0 10px;
  border-radius: 999px;
  background: light-dark(rgba(252,252,250,.82), rgba(28,28,30,.72));
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 .5px 0 light-dark(rgba(255,255,255,.9), rgba(255,255,255,.14)),
    0 0 0 .5px light-dark(rgba(29,29,27,.16), rgba(0,0,0,.5)),
    0 1px 2px light-dark(rgba(29,29,27,.12), rgba(0,0,0,.4));
  font: inherit;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .005em;          /* text petit: una mica d'aire entre lletres */
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 120ms cubic-bezier(.32,.72,0,1),
              background-color 140ms ease;
}
.vol-any-boto:active { transform: scale(.96); }
.vol-any-boto:focus-visible { outline: 2px solid var(--foix); outline-offset: 2px; }
.vol-any-obert .vol-any-boto {
  background: light-dark(rgba(252,252,250,.94), rgba(44,44,46,.86));
}

.vol-any-fletxa {
  color: var(--ink-3);
  transition: transform 220ms cubic-bezier(.32,.72,0,1);
}
.vol-any-obert .vol-any-fletxa { transform: rotate(180deg); }

/* El menú surt de la pastilla: l'origen de l'escala és la cantonada del
   botó, i quan es tanca hi torna. Enter i sortida pel mateix camí. */
.vol-menu {
  position: absolute;
  z-index: 4;
  top: calc(100% + 6px);
  min-width: 108px;
  padding: 5px;
  border-radius: 13px;
  background: light-dark(rgba(252,252,250,.78), rgba(28,28,30,.72));
  backdrop-filter: blur(2px) saturate(180%);
  -webkit-backdrop-filter: blur(2px) saturate(180%);
  box-shadow:
    inset 0 .5px 0 light-dark(rgba(255,255,255,.9), rgba(255,255,255,.12)),
    0 0 0 .5px light-dark(rgba(29,29,27,.14), rgba(0,0,0,.55)),
    0 12px 28px -12px light-dark(rgba(29,29,27,.45), rgba(0,0,0,.75));
  opacity: 0;
  visibility: hidden;
  transform: scale(.88) translateY(-6px);
  transform-origin: top left;
  transition:
    opacity 140ms cubic-bezier(.4,0,.6,1),
    transform 140ms cubic-bezier(.4,0,.6,1),
    backdrop-filter 140ms cubic-bezier(.4,0,.6,1),
    visibility 0s linear 140ms;
}
.vol-any-b .vol-menu { right: 0; transform-origin: top right; }
.vol-any-a .vol-menu { left: 0; }
.vol-menu.vol-menu-amunt {
  top: auto;
  bottom: calc(100% + 6px);
  transform: scale(.88) translateY(6px);
  transform-origin: bottom left;
}
.vol-any-b .vol-menu.vol-menu-amunt { transform-origin: bottom right; }

.vol-any-obert .vol-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  transition:
    opacity 220ms cubic-bezier(.32,.72,0,1),
    transform 220ms cubic-bezier(.32,.72,0,1),
    backdrop-filter 220ms cubic-bezier(.32,.72,0,1),
    visibility 0s;
}

.vol-opcio {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  height: 30px;
  padding: 0 10px 0 6px;
  appearance: none; border: 0; background: transparent;
  border-radius: 9px;
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.vol-opcio + .vol-opcio { margin-top: 1px; }
.vol-opcio:hover { background: light-dark(rgba(29,29,27,.07), rgba(255,255,255,.09)); }
.vol-opcio:focus-visible {
  outline: none;
  background: var(--foix);
  color: var(--sup);
}
.vol-opcio:focus-visible .vol-tick { color: var(--sup); }
.vol-opcio:active { background: light-dark(rgba(29,29,27,.12), rgba(255,255,255,.14)); }

/* El tick manté el seu lloc encara que no es vegi, perquè les xifres
   quedin alineades i el menú no balli en canviar d'any. */
.vol-tick { flex: 0 0 12px; color: var(--foix); opacity: 0; }
.vol-opcio[aria-checked="true"] { font-weight: 600; }
.vol-opcio[aria-checked="true"] .vol-tick { opacity: 1; }

/* ============================================================
   3. La lupa
   ============================================================ */

.vol-lupa-boto {
  position: absolute;
  z-index: 3;
  right: 10px; bottom: 10px;
  display: none;                     /* només on hi ha ratolí de debò */
  place-items: center;
  width: 30px; height: 30px;
  appearance: none; border: 0;
  border-radius: 999px;
  background: light-dark(rgba(252,252,250,.82), rgba(28,28,30,.72));
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    inset 0 .5px 0 light-dark(rgba(255,255,255,.9), rgba(255,255,255,.14)),
    0 0 0 .5px light-dark(rgba(29,29,27,.16), rgba(0,0,0,.5)),
    0 1px 2px light-dark(rgba(29,29,27,.12), rgba(0,0,0,.4));
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms cubic-bezier(.32,.72,0,1), background-color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .vol-lupa-boto { display: grid; }
}
.vol-lupa-boto:active { transform: scale(.94); }
.vol-lupa-boto:focus-visible { outline: 2px solid var(--foix); outline-offset: 2px; }
.vol-lupa-boto[aria-pressed="true"] {
  background: var(--foix);
  color: var(--sup);
}

/* La lent. Ensenya els píxels de debò de la fotografia, no una ampliació
   inventada: el factor surt de la mida original de la imatge. */
.vol-lent {
  position: absolute;
  z-index: 4;
  top: 0; left: 0;
  width: var(--lent, 190px);
  height: var(--lent, 190px);
  margin: calc(var(--lent, 190px) / -2) 0 0 calc(var(--lent, 190px) / -2);
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--lx, 0px), var(--ly, 0px)) scale(.9);
  transition: opacity 140ms ease, transform 140ms cubic-bezier(.32,.72,0,1);
  box-shadow:
    inset 0 0 0 1px light-dark(rgba(255,255,255,.75), rgba(255,255,255,.28)),
    0 10px 30px -8px rgba(0,0,0,.55);
}
.vol-marc.vol-amb-lent { cursor: none; }
.vol-marc.vol-lent-visible .vol-lent { opacity: 1; }
/* Mentre es mou no hi ha transició de posició: ha d'anar clavada al dit. */
.vol-marc.vol-lent-visible .vol-lent {
  transform: translate(var(--lx, 0px), var(--ly, 0px)) scale(1);
  transition: opacity 140ms ease, transform 140ms cubic-bezier(.32,.72,0,1);
}
.vol-marc.vol-lent-movent .vol-lent { transition: none; }

.vol-lent-capa {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  image-rendering: -webkit-optimize-contrast;
}
.vol-lent-b { clip-path: inset(0 0 0 var(--lent-tall, 50%)); }

/* La creueta del centre, perquè se sàpiga què s'està mirant. */
.vol-lent::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,.8), 0 0 0 2px rgba(0,0,0,.35);
}

/* ============================================================
   4. Els botons de lloc
   ============================================================ */

.vol-tria {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-2);
}
.vol-fila {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.vol-etiqueta {
  flex: 0 0 4.6em;
  font-family: var(--sans);
  font-size: .6875rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
}
.vol-botons { display: flex; flex-wrap: wrap; gap: 6px; }

.vol-boto {
  appearance: none;
  border: 1px solid var(--rule-2);
  background: var(--sup);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: var(--sans);
  font-size: .8125rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease,
              transform 120ms cubic-bezier(.32,.72,0,1);
}
.vol-boto:hover { border-color: var(--ink-3); color: var(--ink); }
.vol-boto:active { transform: scale(.97); }
.vol-boto[aria-pressed="true"] {
  background: var(--foix);
  border-color: var(--foix);
  color: var(--sup);
  font-weight: 600;
}

@media (max-width: 560px) {
  .vol-etiqueta { flex-basis: 100%; }
}

/* ============================================================
   5. Preferències del sistema
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .vol-any-boto, .vol-boto, .vol-lupa-boto, .vol-any-fletxa, .vol-opcio { transition: none; }
  .vol-menu, .vol-any-obert .vol-menu {
    transform: none;
    transition: opacity 120ms ease, visibility 0s linear 120ms;
  }
  .vol-any-obert .vol-menu { transition: opacity 120ms ease, visibility 0s; }
  .vol-lent { transition: opacity 120ms ease; transform: translate(var(--lx,0px), var(--ly,0px)); }
  .vol-marc.vol-lent-visible .vol-lent { transform: translate(var(--lx,0px), var(--ly,0px)); }
}

@media (prefers-reduced-transparency: reduce) {
  .vol-any-boto, .vol-menu, .vol-lupa-boto {
    background: light-dark(#FCFCFA, #1C1C1E);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .vol-any-boto, .vol-menu, .vol-lupa-boto {
    background: light-dark(#fff, #000);
    box-shadow: 0 0 0 1px var(--ink);
  }
}
