/* 567 Dance! — mapa del ritmo. Fondo café casi negro, paneles cálidos y un
 * color por instrumento, el mismo en su ícono y en sus golpes. */

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --fondo: #120d0a;
  --panel: #1d1713;
  --celda: #2b231d;
  --apagado: #3a302a;
  --texto: #f6eee6;
  --tenue: #9a8e84;
  --linea: rgba(255, 255, 255, 0.06);
  --banda: rgba(255, 255, 255, 0.07);
  --naranja: #ff8a1f;
  --naranja-suave: rgba(255, 138, 31, 0.14);

  --clave: #ff8a1f;
  --guiro: #ffc93c;
  --bongo: #ff5d73;
  --campana: #3ddba0;
  --bajo: #7c8cff;
  --voz: #f6eee6;

  --etiqueta: 94px;
  --hueco: 5px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body { overscroll-behavior: none; }
body.con-panel { overflow: hidden; }

button, select, a { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--naranja); outline-offset: 2px; }

.sprite { position: absolute; }
.ic { width: 24px; height: 24px; flex: none; display: block; }

/* --- marco --- */

.app {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.redondo,
.icono-boton {
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  background: none;
  padding: 0;
}
.redondo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--tenue);
}
.redondo .ic { width: 22px; height: 22px; }
.icono-boton { width: 40px; height: 40px; border-radius: 50%; color: var(--tenue); }

/* --- aviso para instalar --- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
}
.banner-emoji {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: var(--naranja-suave);
  font-size: 24px;
}
.banner-textos { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.banner-textos strong { font-size: 14px; }
.banner-textos span { font-size: 12px; line-height: 1.3; color: var(--tenue); }
.banner-instalar {
  border: 0;
  background: none;
  padding: 6px 4px;
  color: var(--naranja);
  font-weight: 700;
}
.banner .icono-boton { width: 32px; height: 32px; }
.banner .icono-boton .ic { width: 20px; height: 20px; }

/* --- cabecera y título --- */

.barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 0 20px;
}
.marca { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 0 20px;
}
.titulo h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.etiqueta-clave {
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--naranja-suave);
  color: var(--naranja);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.pastilla {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  margin-left: auto;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 16px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pastilla .ic { width: 18px; height: 18px; color: var(--tenue); }
.pastilla[aria-expanded='true'] { background: var(--celda); }

/* --- mapa del ritmo --- */

.zona {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 12px 0;
}

.mapa {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto;
  padding: 10px 12px 12px;
  border-radius: 24px;
  background: var(--panel);
  scrollbar-width: none;
}

.cabezal {
  position: absolute;
  top: 6px;
  left: 0;
  width: 0;
  border-radius: 12px;
  background: var(--banda);
  opacity: 0;
  pointer-events: none;
}
.cabezal.visible { opacity: 1; }

.fila {
  display: grid;
  grid-template-columns: var(--etiqueta) 1fr;
  grid-template-rows: minmax(0, 1fr);
  flex: 0 1 84px;     /* se encogen hasta 58 px antes de que el mapa tenga que desplazarse */
  min-height: 58px;
  max-height: 84px;
  padding: 8px 0;
  border-top: 1px solid var(--linea);
}
.fila.encabezado {
  flex: 0 0 34px;
  min-height: 34px;
  padding: 0;
  border-top: 0;
  align-items: center;
}
.fila[data-grupo='clave'] { --c: var(--clave); }
.fila[data-grupo='guiro'] { --c: var(--guiro); }
.fila[data-grupo='bongo'] { --c: var(--bongo); }
.fila[data-grupo='campana'] { --c: var(--campana); }
.fila[data-grupo='bajo'] { --c: var(--bajo); }
.fila[data-grupo='voz'] { --c: var(--voz); }
/* Cada toque sube el volumen: se puede tocar rápido sin que el teléfono haga
 * zoom ni seleccione texto. En los instrumentos toda la fila es el control. */
.fila[data-grupo] { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.fila[data-grupo]:not([data-grupo='voz']) { cursor: pointer; }

.celdas {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  column-gap: var(--hueco);
}
.num {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--tenue);
}
.num.ahora { color: var(--naranja); }

.etiqueta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  border-radius: 10px;
  cursor: pointer;
}
.nombre {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 0;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.nombre .ic { width: 18px; height: 18px; color: var(--c); }
.nombre span { overflow: hidden; text-overflow: ellipsis; }

.nivel {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding-left: 24px;
  touch-action: none;
}
.nivel i { width: 7px; height: 3px; border-radius: 2px; background: var(--apagado); }
.nivel i.on { background: var(--c); }

.par { display: grid; grid-template-columns: 1fr 1fr; column-gap: 2px; }
.par i { border-radius: 4px; background: var(--celda); }
.par i.largo { background: var(--c); }
/* Golpe corto: una franja en el centro de la celda. */
.par i.corto { background: linear-gradient(to bottom, var(--celda) 28%, var(--c) 28% 72%, var(--celda) 72%); }

.conteo {
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--apagado);
  border-radius: 8px;
  background: none;
}
.conteo[aria-pressed='true'] { background: var(--voz); border-color: var(--voz); }
.conteo[aria-pressed='true']::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fondo);
}

/* Un instrumento silenciado se queda a la vista, apagado. */
.fila.silencio .celdas { opacity: 0.3; }
.fila.silencio .nombre { color: var(--tenue); }
.fila.silencio .nombre .ic { color: var(--tenue); }

/* Los golpes de un instrumento se ven tan fuertes como suenan: al 25, 50, 75 o
 * 100 % de color, y casi apagados en silencio. Así cada toque se nota en toda la
 * fila, no solo en las barras. */
.fila:not([data-grupo='voz']) .celdas {
  opacity: calc(0.2 + 0.8 * var(--volumen, 1));
  transition: opacity 0.15s ease-out;
}

/* --- barra de tempo y reproducción --- */

.transporte {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px;
  padding: 14px 14px 14px 18px;
  border-radius: 28px;
  background: var(--panel);
}
.paso {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--celda);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.bpm {
  flex: 1;
  text-align: center;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.bpm b {
  display: block;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.bpm span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--tenue);
}
.play {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--naranja);
  color: var(--fondo);
}
.play .ic { width: 38px; height: 38px; }
.play .ic-pausa,
.play .girando { display: none; }
.play.sonando .ic-play { display: none; }
.play.sonando .ic-pausa { display: block; }
.play.preparando .ic { display: none; }
.play.preparando .girando {
  display: block;
  width: 26px;
  height: 26px;
  border: 2.5px solid rgba(18, 13, 10, 0.25);
  border-top-color: var(--fondo);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* --- avisos --- */

.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 112px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: #2b231d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  transform: translateX(-50%);
}
.aviso-accion {
  flex: none;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--naranja);
  font-weight: 700;
}

/* --- paneles: configuración y acerca --- */

.panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  background: var(--fondo);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.panel-barra {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 480px;
  height: 56px;
  margin: 0 auto;
}
.panel-barra .atras { position: absolute; left: 8px; color: var(--texto); }
.panel-barra h2 { margin: 0; font-size: 20px; font-weight: 700; }
.panel-cuerpo { max-width: 480px; margin: 0 auto; padding: 0 16px 48px; }

.panel h3 {
  margin: 24px 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--tenue);
}
.grupo { border-radius: 12px; background: var(--panel); overflow: hidden; }
.opcion {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}
.opcion + .opcion::before {
  content: '';
  position: absolute;
  top: 0;
  left: 68px;
  right: 0;
  height: 1px;
  background: var(--linea);
}
.opcion .texto { flex: 1; }
.opcion .flecha { color: var(--tenue); opacity: 0.6; }
.opcion-icono {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 8px;
  background: var(--naranja-suave);
  color: var(--naranja);
}
.opcion-icono .ic { width: 20px; height: 20px; }
.bandera {
  padding: 4px 8px;
  border-radius: 12px;
  background: var(--celda);
  font-size: 14px;
}
.punto { width: 10px; height: 10px; border-radius: 50%; background: var(--naranja); display: none; }
.con-punto .punto { display: block; }
.version { margin: 48px 0 0; text-align: center; font-size: 13px; color: var(--tenue); opacity: 0.6; }

.acerca { display: flex; flex-direction: column; align-items: center; text-align: center; }
.logo { margin-top: 32px; border-radius: 24px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3); }
.acerca-nombre { margin: 24px 0 0; font-size: 24px; font-weight: 700; }
.insignia {
  margin: 12px 0 0;
  padding: 6px 16px;
  border: 1px solid rgba(255, 138, 31, 0.3);
  border-radius: 20px;
  background: var(--naranja-suave);
  color: var(--naranja);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.tarjeta {
  margin: 32px 0 0;
  padding: 24px;
  border-radius: 16px;
  background: var(--panel);
  color: var(--tenue);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-line;
}
.acerca h3 { margin-top: 40px; margin-bottom: 8px; font-size: 11px; opacity: 0.8; }
.persona { margin: 0; font-size: 18px; font-weight: 600; }
.acerca hr { width: 100%; margin: 32px 0 0; border: 0; border-top: 1px solid var(--linea); }
.enlace {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--naranja);
  font-weight: 500;
  text-decoration: none;
}
.enlace .ic { width: 16px; height: 16px; }
/* El crédito, al pie: texto secundario, sin la opacidad de .version para que se
 * lea bien. «apolar» va como su logotipo en apolar.co: Space Grotesk en negrita,
 * apretada, con el punto (•) al 74 % de su tamaño, y en el color del texto, no
 * en naranja. Junto al gris el color solo no bastaría (2,8:1): la letra de marca
 * es lo que lo señala como enlace, así que no lleva subrayado. Al pasar el ratón
 * se pone naranja; con el teclado, el anillo de :focus-visible de siempre. */
.autoria { margin: 48px 0 0; font-size: 13px; color: var(--tenue); }
.autoria a {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.085em;
  color: var(--texto);
  text-decoration: none;
}
.autoria-punto { font-size: 0.74em; }
@media (hover: hover) {
  .autoria a:hover { color: var(--naranja); }
}

/* --- hoja de instrucciones para iPhone --- */

.hoja {
  width: min(480px, 100vw);
  max-width: 100vw;
  margin: auto auto 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--panel);
  color: var(--texto);
}
.hoja::backdrop { background: rgba(0, 0, 0, 0.6); }
.hoja h2 { margin: 0 0 16px; font-size: 18px; }
.hoja ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.hoja li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.boton-principal {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: var(--naranja);
  color: var(--fondo);
  font-weight: 700;
}

/* --- menú de idiomas --- */

/* Un <dialog> modal que ui.js coloca junto al botón que lo abrió. El fondo
 * queda transparente: tocar fuera solo lo cierra. */
.menu {
  inset: auto;
  margin: 0;
  min-width: 212px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  border: 1px solid var(--linea);
  border-radius: 18px;
  background: var(--celda);
  color: var(--texto);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.menu::backdrop { background: none; }
.menu[open] { animation: desplegar 0.16s ease-out; transform-origin: top right; }
.menu.arriba { transform-origin: bottom right; }
@keyframes desplegar { from { opacity: 0; transform: scale(0.94); } }

.menu-titulo {
  margin: 0;
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tenue);
}
.menu-opciones { display: grid; gap: 2px; }
.menu-opciones:focus { outline: none; }
.menu-opcion {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}
.menu-opcion:focus-visible { outline-offset: -2px; }
.menu-opcion[aria-selected='true'] { background: var(--naranja-suave); color: var(--naranja); }
.menu-opcion .ic { width: 20px; height: 20px; visibility: hidden; }
.menu-opcion[aria-selected='true'] .ic { visibility: visible; }
.menu-bandera { font-size: 18px; line-height: 1; }
.menu-nombre { flex: 1; }
@media (hover: hover) {
  .menu-opcion[aria-selected='false']:hover { background: var(--banda); }
}

/* La flecha de quien abrió el menú apunta hacia arriba mientras está abierto. */
[aria-haspopup] .flecha { transition: transform 0.16s ease-out; }
[aria-haspopup][aria-expanded='true'] .flecha { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  .play.preparando .girando { animation-duration: 2.4s; }
  .menu[open] { animation: none; }
  [aria-haspopup] .flecha { transition: none; }
}
