/* ============================================================
   Caxellu 2.0 — «brutalismo suave»
   Herencia PlayPresta: miel #FFD23F, magenta #F35BD3 (solo
   celebración), morado nocturno #1C0F21, Archivo Black (títulos)
   + Space Grotesk (todo lo demás). Suavizado: fondo crema-cera,
   sombras duras pequeñas solo en botones, sin mayúsculas gritonas.
   ============================================================ */

/* Tipografíes sirvíes dende'l propiu hosting. Los dos subconxuntos
   cubren el llatín básicu y estendíu ensin depender de Google Fonts. */
@font-face {
  font-family: 'Archivo Black';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/archivo-black-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-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Archivo Black';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/archivo-black-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-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@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;
}

:root {
  --miel: #FFD23F;
  --miel-fuerte: #E8B70D;
  --magenta: #F35BD3;
  --tinta: #241329;

  /* Modo claro: papel de cera cálido */
  --fondu: #FBF4E1;
  --superficie: #FFFCF2;
  --testu: #2A1B30;
  --testu-nidiu: #7A6A55;
  --borde: #E6D9B8;
  --celda: #F3E7C6;
  --sombra: #2A1B30;
}

html[data-theme="dark"] {
  /* Modo oscuro: la noche PlayPresta; el panal s'allume en miel */
  --fondu: #1C0F21;
  --superficie: #241329;
  --testu: #FBF3FA;
  --testu-nidiu: #9D8AA0;
  --borde: #3E2A44;
  --celda: #2E1B34;
  /* Nel mou escuru la sombra negra nun se ve: úsase miel,
     como los hard shadows de PlayPresta sobre fondu nocturnu. */
  --sombra: #FFD23F;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--fondu);
  color: var(--testu);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  transition: background-color .25s, color .25s;
}

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

:focus-visible {
  outline: 3px solid var(--miel-fuerte);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Cabecera ---------- */

.cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px 4px;
}

/* Los dos llaterales tienen el mesmu anchu flexible: asina la marca
   queda centrada de verdá anque les aiciones ocupen más espaciu. */
.marca-playpresta {
  flex: 1 1 0;
  display: flex;
  justify-content: flex-start;
  min-width: 0;
}

.pp-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Archivo Black', 'Space Grotesk', system-ui, sans-serif;
  font-size: 20px;
  line-height: 1;
  color: var(--tinta);
  background: var(--miel);
  border: 2px solid var(--testu);
  border-radius: 10px;
  padding: 7px 9px;
  box-shadow: 2px 2px 0 var(--sombra);
  transition: transform .08s, box-shadow .08s;
}

.marca-playpresta:hover .pp-mini { transform: translateY(-1px); }
.marca-playpresta:active .pp-mini {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 transparent;
}

.marca-caxellu {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--testu);
  line-height: 1;
  text-decoration: none;
}

.nombre-caxellu {
  font-family: 'Archivo Black', 'Space Grotesk', system-ui, sans-serif;
  font-size: clamp(30px, 5.5vw, 40px);
  letter-spacing: -.055em;
}

.abeya-marca {
  display: block;
  width: 46px;
  line-height: 0;
}

.abeya-caxellu {
  display: block;
  width: 100%;
  height: auto;
}

.abeya-oscura { display: none; }
html[data-theme="dark"] .abeya-clara { display: none; }
html[data-theme="dark"] .abeya-oscura { display: block; }

.acciones { flex: 1 1 0; display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 430px) {
  .cabecera { gap: 6px; padding-inline: 10px; }
  .pp-mini { font-size: 18px; padding: 6px 8px; }
  .nombre-caxellu { font-size: 27px; }
  .abeya-marca { width: 38px; }
  .acciones { gap: 4px; }
  button.icono { padding: 7px 9px; }
}

/* ---------- Botones ---------- */

button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--testu);
  background: var(--superficie);
  border: 2px solid var(--testu);
  border-radius: 10px;
  padding: 9px 18px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--sombra);
  transition: transform .08s, box-shadow .08s, background-color .15s;
}

button:hover { background: var(--celda); }

button:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--sombra);
}

button.principal {
  background: var(--miel);
  color: var(--tinta);
  border-color: var(--tinta);
  font-weight: 700;
}
button.principal:hover { background: var(--miel-fuerte); }

/* Nel mou escuru, el botón miel lleva sombra magenta (pareya
   miel↔magenta de PlayPresta) pa que nun se funda col so fondu. */
html[data-theme="dark"] button.principal { box-shadow: 2px 2px 0 var(--magenta); }
html[data-theme="dark"] button.principal:active { box-shadow: 0 0 0 transparent; }

button.icono {
  padding: 9px 11px;
  display: inline-flex;
  align-items: center;
}

/* ---------- Zona de juego ---------- */

.xuegu {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 32px;
  text-align: center;
}

.mensax {
  min-height: 1.5em;
  margin: 6px 0 0;
  font-weight: 700;
  opacity: 0;
  transition: opacity .4s;
}
.mensax.amosar { opacity: 1; }
.mensax.ensin-transicion { transition: none; }
.mensax.correcta { color: #1C7C3C; }
html[data-theme="dark"] .mensax.correcta { color: #7BE29B; }
.mensax.cortia {
  color: var(--tinta);
  background: var(--magenta);
  display: inline-block;
  padding: 2px 14px;
  border-radius: 8px;
  border: 2px solid var(--tinta);
  box-shadow: 3px 3px 0 var(--sombra);
}

.entrada {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  min-height: 1.3em;
  margin: 8px 0 4px;
  overflow-wrap: anywhere;
}
#cursor { color: var(--miel-fuerte); animation: parpaguéu 1.2s step-end infinite; }
@keyframes parpaguéu { 50% { opacity: 0; } }

/* ---------- Panal ---------- */

.panal-zona { margin: 4px 0 26px; }

.panal {
  --celda-anchu: 96px;
  --celda-altu: calc(var(--celda-anchu) * 1.09);
  --pasu-x: calc(var(--celda-anchu) + 6px);        /* anchu + separación */
  --pasu-y: calc(var(--celda-altu) * .75 + 5px);   /* solapamientu vertical del panal */
  position: relative;
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: calc(var(--celda-anchu) * 3 + 12px);
  height: calc(var(--celda-altu) + var(--pasu-y) * 2);
}

.panal li { display: contents; }

.hex {
  position: absolute;
  width: var(--celda-anchu);
  height: var(--celda-altu);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--celda);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--testu);
  font-family: 'Archivo Black', 'Space Grotesk', sans-serif;
  font-size: 30px;
  text-transform: lowercase;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: transform .08s, background-color .15s, filter .15s;
}
/* Filas del panal: 2 arriba, 3 en medio (la obligatoria en el centro), 2 abajo.
   Los botones .hex son hijos únicos de su <li>, así que la fila se decide
   por la posición del <li>, no del botón. */
.panal li:nth-child(1) .hex { left: calc(var(--pasu-x) * .5);  top: 0; }
.panal li:nth-child(2) .hex { left: calc(var(--pasu-x) * 1.5); top: 0; }
.panal li:nth-child(3) .hex { left: 0;                         top: var(--pasu-y); }
.panal li:nth-child(4) .hex { left: var(--pasu-x);             top: var(--pasu-y); }
.panal li:nth-child(5) .hex { left: calc(var(--pasu-x) * 2);   top: var(--pasu-y); }
.panal li:nth-child(6) .hex { left: calc(var(--pasu-x) * .5);  top: calc(var(--pasu-y) * 2); }
.panal li:nth-child(7) .hex { left: calc(var(--pasu-x) * 1.5); top: calc(var(--pasu-y) * 2); }

.hex:hover { filter: brightness(1.05); }
.hex:active { transform: scale(.93); }

.hex.centru {
  background: var(--miel);
  color: var(--tinta);
}
.hex.centru:hover { background: var(--miel-fuerte); }

.hex:focus-visible {
  outline: none;
  filter: drop-shadow(0 0 0 transparent) brightness(1.12);
  background: var(--miel-fuerte);
}

.botonera {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

/* ---------- Collecha (marcador + palabras) ---------- */

.collecha {
  background: var(--superficie);
  border: 2px solid var(--borde);
  border-radius: 14px;
  padding: 16px 18px 18px;
  text-align: left;
}

.collecha-resume { margin: 0 0 10px; }
#score-inline { color: var(--testu-nidiu); }

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 15px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2px solid var(--borde);
  background: var(--fondu);
  box-shadow: none;
}
.chip:hover { border-color: var(--miel-fuerte); background: var(--celda); }

.chip.pangrama {
  border-color: var(--magenta);
  background: var(--magenta);
  color: var(--tinta);
  font-weight: 700;
}

.chip .ok-icon { width: 13px; height: 13px; margin-right: 5px; }

.collecha-aida {
  color: var(--testu-nidiu);
  font-size: 14px;
  margin: 10px 0 0;
}

.collecha-acciones {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Popover de definiciones ---------- */

.popover {
  /* fixed + z-index penriba de los modales: el popover tien de vese
     tamién dientro del solucionariu (que ye z-index 50). */
  position: fixed;
  z-index: 60;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  background: var(--superficie);
  color: var(--testu);
  border: 2px solid var(--testu);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--sombra);
  padding: 12px 14px;
  text-align: left;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}
.popover[hidden] { display: none; }
.popover h3 {
  margin: 0 24px 6px 0;
  font-family: 'Archivo Black', sans-serif;
  font-size: 17px;
  font-weight: 400;
}
.popover .tipu {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--tinta);
  background: var(--miel);
  border-radius: 6px;
  padding: 1px 8px;
  margin-bottom: 4px;
}
.popover p { margin: 4px 0; }
.popover .cargando, .popover .ensin { color: var(--testu-nidiu); }

#def-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 100px);
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding-right: 5px;
  scrollbar-gutter: stable;
}

/* En móvil la definición forma parte de la llista, xusto debaxo de
   la pallabra. Asina'l modal crez y tanto la definición como'l
   solucionariu pueden desplazase con naturalidá. */
@media (max-width: 700px) {
  .chips > li.def-abierta {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
  }

  .popover.popover-movil {
    position: relative;
    inset: auto;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 1;
    width: 100%;
    max-height: none;
    margin-top: 8px;
    box-shadow: 3px 3px 0 var(--sombra);
  }

  .popover.popover-movil #def-body {
    max-height: 45vh;
    max-height: min(45dvh, 360px);
    overflow-y: auto;
  }
}

.popover-zarrar {
  position: absolute;
  top: 6px; right: 6px;
  padding: 0 8px;
  font-size: 18px;
  line-height: 1.4;
  border-width: 0;
  box-shadow: none;
  background: transparent;
  color: var(--testu-nidiu);
}
.popover-zarrar:hover { color: var(--testu); background: transparent; }

/* ---------- Modales ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 8, 25, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  overflow-y: auto;
}
.modal[hidden] { display: none; }

.modal-caxa {
  position: relative;
  background: var(--superficie);
  color: var(--testu);
  border: 2px solid var(--testu);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--sombra);
  max-width: 560px;
  width: 100%;
  padding: 22px 24px;
  text-align: left;
}

.modal-caxa h2 {
  font-family: 'Archivo Black', sans-serif;
  font-weight: 400;
  font-size: 20px;
  margin: 18px 0 8px;
}

.saludu {
  text-align: center;
  background: var(--celda);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 6px 0 4px;
}

.modal-conteniu { padding-left: 20px; }
.modal-conteniu li { margin-bottom: 6px; }
.creitos p { margin: 4px 0; }

.modal-zarrar {
  position: absolute;
  top: 10px; right: 10px;
  padding: 2px 11px;
  font-size: 20px;
}

.modal-pie { text-align: center; margin-top: 18px; }

.lletres-ayeri strong { color: var(--miel-fuerte); font-family: 'Archivo Black', sans-serif; font-weight: 400; }
.chips-solucion .chip { cursor: pointer; }
.chip.atopada { border-color: #1C7C3C; }
html[data-theme="dark"] .chip.atopada { border-color: #7BE29B; }

/* ---------- Avisu pa instalar la PWA ---------- */

.install-avisu {
  position: fixed;
  z-index: 80;
  right: 16px;
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  width: min(520px, calc(100% - 32px));
  margin-inline: auto;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--superficie);
  color: var(--testu);
  border: 2px solid var(--testu);
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--sombra);
  padding: 14px 46px 14px 14px;
  text-align: left;
}
.install-avisu[hidden] { display: none; }
.install-iconu { flex: 0 0 auto; border-radius: 12px; }
.install-conteniu { min-width: 0; }
.install-conteniu strong {
  display: block;
  font-family: 'Archivo Black', sans-serif;
  font-size: 18px;
  font-weight: 400;
}
.install-conteniu p { margin: 3px 0 10px; }
.install-aida { font-size: 15px; }
.install-aiciones { display: flex; flex-wrap: wrap; gap: 8px; }
.install-aiciones button { padding: 8px 13px; }
.install-zarrar {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 1px 9px;
  border: 0;
  box-shadow: none;
  background: transparent;
  font-size: 22px;
}
.install-zarrar:hover { background: var(--celda); }

/* ---------- Pie ---------- */

.pie { text-align: center; padding: 8px 16px 28px; }
.banner img { width: min(380px, 80%); height: auto; border-radius: 10px; }

/* ---------- Responsive y preferencias ---------- */

/* Pantalles anches: los modales aprovechen l'espaciu y les llistes
   de normes van en dos columnes pa evitar tanto scroll. */
@media (min-width: 720px) {
  .modal-caxa { max-width: 780px; padding: 26px 32px; }
  ul.modal-conteniu { columns: 2; column-gap: 36px; }
  ul.modal-conteniu li { break-inside: avoid; }
}

@media (max-width: 420px) {
  .panal { --celda-anchu: 84px; }
  .entrada { font-size: 26px; }
  .botonera { gap: 8px; }
  button { padding: 9px 14px; }
  .install-avisu { right: 10px; left: 10px; width: calc(100% - 20px); }
  .install-iconu { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
