/* Mirador — cuaderno a tinta sobre pizarra (la familia de skynex.es): viñetas de papel, tinta, coral, ámbar y verde
   fósforo. La ciudad es un <canvas> a pantalla completa; todo lo demás flota encima. */

@font-face { font-family: 'Patrick Hand'; src: url('/fuentes/patrick-hand.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cabin Sketch'; src: url('/fuentes/cabin-sketch.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Bangers'; src: url('/fuentes/bangers.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fuentes/jetbrains-mono.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  --papel: #F1E8D6;
  --papel2: #E3D7BF;
  --tinta: #1F1D2E;
  --tinta2: #4A465E;
  --coral: #E2674A;
  --coral-osc: #B8452B;
  --ambar: #F2A541;
  --matrix: #4DFF96;
  --violeta: #6B4FA0;
  --fondo: #1E2029;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
  --mano: 'Patrick Hand', 'Segoe Print', 'Comic Sans MS', system-ui, sans-serif;
  --boceto: 'Cabin Sketch', 'Patrick Hand', system-ui, sans-serif;
  --sombra: 5px 5px 0 rgba(0, 0, 0, 0.55);
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden;
  background: var(--fondo);
  color: var(--papel);
  font-family: var(--mano);
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ambar); outline-offset: 3px; }
code { font-family: var(--mono); font-size: 0.86em; background: rgba(31, 29, 46, 0.1); padding: 0 4px; }

#ciudad { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#ciudad.sobre { cursor: pointer; }
#ciudad.arrastrando { cursor: grabbing; }

.vineta {
  background: var(--papel);
  color: var(--tinta);
  border: 2.5px solid var(--tinta);
  box-shadow: var(--sombra);
}

/* ---- cabecera ---- */
.cabecera {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: max(14px, var(--sa-t)) max(16px, var(--sa-r)) 10px max(16px, var(--sa-l));
  pointer-events: none;
}
.cabecera > * { pointer-events: auto; }
.marca {
  display: inline-flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 16px 0 10px;
  border: 2.5px solid var(--tinta); background: var(--papel); color: var(--tinta); text-decoration: none;
  box-shadow: var(--sombra); transform: rotate(-0.8deg);
}
.marca-nombre { font-family: var(--boceto); font-size: 27px; line-height: 1; letter-spacing: 0.02em; }
.directo {
  margin: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 2px solid var(--matrix); background: #12131A; color: var(--matrix);
  font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase;
  text-shadow: 0 0 10px rgba(77, 255, 150, 0.5);
}
.directo .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--matrix); box-shadow: 0 0 8px var(--matrix); animation: latido 1.6s ease-in-out infinite; }
.directo.caido { border-color: var(--coral); color: var(--coral); text-shadow: none; }
.directo.caido .punto { background: var(--coral); box-shadow: none; animation: none; }
.hora { color: var(--papel); opacity: 0.85; text-shadow: none; letter-spacing: 0.04em; }
@keyframes latido { 50% { opacity: 0.25; transform: scale(0.75); } }

.botones { margin-left: auto; display: flex; gap: 8px; }
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px;
  border: 2.5px solid var(--tinta); background: var(--papel); color: var(--tinta); cursor: pointer;
  font-family: var(--mono); font-weight: 700; font-size: 13px; box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.boton:hover { background: var(--tinta); color: var(--papel); }
.boton:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55); }
.boton.cuadrado { width: 42px; padding: 0; font-size: 20px; }
.boton[aria-pressed='true'] { background: var(--ambar); color: var(--tinta); }
.boton.cta { background: var(--coral); color: #fff; border-color: var(--tinta); }
.boton.cta:hover { background: var(--coral-osc); }
.solo-estrecho { display: none; }
.boton .ic-cerrar, :root.completa .boton .ic-abrir { display: none; }
:root.completa .boton .ic-cerrar { display: block; }

/* ---- hoy ---- */
.hoy {
  position: fixed; z-index: 2; left: max(16px, var(--sa-l)); bottom: max(16px, var(--sa-b));
  padding: 10px 16px 9px; transform: rotate(0.4deg); max-width: calc(100vw - 32px);
}
.hoy-titulo { position: absolute; top: -15px; left: 12px; margin: 0; padding: 0 10px; background: var(--tinta); color: var(--papel); font-family: var(--boceto); font-size: 19px; font-weight: 400; line-height: 26px; transform: rotate(-2deg); }
.cifras { display: flex; gap: 22px; margin: 4px 0 0; }
.cifras div { display: flex; flex-direction: column-reverse; }
.cifras dt { font-size: 15px; color: var(--tinta2); white-space: nowrap; }
.cifras dd { margin: 0; font-family: var(--boceto); font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.cifras dd.sube { animation: sube 0.6s ease; }
#c-l { color: var(--coral-osc); }
@keyframes sube { 30% { transform: translateY(-4px) scale(1.08); color: var(--coral); } }
.central { margin: 6px 0 0; padding-top: 6px; border-top: 1.5px dashed rgba(31, 29, 46, 0.35); font-family: var(--mono); font-size: 12px; color: var(--tinta2); }
.central b { color: var(--tinta); }

/* ---- diario ---- */
.diario {
  position: fixed; z-index: 2; top: 82px; right: max(16px, var(--sa-r)); bottom: max(16px, var(--sa-b)); width: 330px;
  display: flex; flex-direction: column; padding: 0; transform: rotate(-0.3deg);
}
.diario-cabeza {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px 10px; border: 0; border-bottom: 2px solid var(--tinta);
  background: transparent; text-align: left; cursor: default;
}
.diario-cabeza h2 { margin: 0; font-family: var(--boceto); font-weight: 400; font-size: 25px; line-height: 1; }
.diario-ultima { display: none; }
.diario-cabeza .flecha { display: none; margin-left: auto; transition: transform 0.2s ease; }
.diario-lista {
  list-style: none; margin: 0; padding: 6px 0 10px; overflow-y: auto; flex: 1;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.45;
  scrollbar-width: thin; scrollbar-color: var(--tinta2) transparent;
}
.diario-lista li { display: grid; grid-template-columns: auto 1fr; gap: 2px 9px; padding: 5px 16px; border-bottom: 1px dashed rgba(31, 29, 46, 0.16); animation: entra 0.3s ease; cursor: pointer; }
.diario-lista li:hover, .diario-lista li:focus-visible { background: rgba(242, 165, 65, 0.22); }
.diario-lista li.elegida { background: rgba(242, 165, 65, 0.4); }
.diario-lista li:focus-visible { outline-offset: -3px; }
.diario-lista .ip { grid-column: 2; font-size: 11.5px; color: var(--coral-osc); font-weight: 700; letter-spacing: 0.01em; }
.diario-lista .ip.persona { color: var(--tinta2); }
.diario-lista li::before { content: ''; grid-row: span 2; width: 8px; height: 8px; margin-top: 5px; border: 1.5px solid var(--tinta); border-radius: 50%; background: var(--papel2); }
.diario-lista li.t-p::before { background: var(--ambar); }
.diario-lista li.t-r::before { background: var(--violeta); }
.diario-lista li.t-l::before { background: var(--coral); }
.diario-lista li.t-e::before { background: #FF4D4D; }
.diario-lista li.t-s::before { background: var(--matrix); }
.diario-lista time { color: var(--tinta2); font-size: 11.5px; }
.diario-lista b { font-weight: 800; }
.diario-lista .ruta { color: var(--coral-osc); font-weight: 700; }
.diario-lista .robot { color: var(--violeta); font-weight: 700; }
.diario-lista .vacio { display: block; padding: 18px 16px; color: var(--tinta2); font-family: var(--mano); font-size: 17px; }
.diario-lista .vacio::before { display: none; }
@keyframes entra { from { opacity: 0; transform: translateY(-6px); } }

/* ---- ficha de un edificio ---- */
.ficha {
  position: fixed; z-index: 4; top: 82px; left: max(16px, var(--sa-l)); width: 320px; max-height: calc(100vh - 230px); overflow-y: auto;
  padding: 16px 18px 16px; transform: rotate(-0.5deg); animation: ficha 0.22s ease;
}
@keyframes ficha { from { opacity: 0; transform: translateY(8px) rotate(-0.5deg); } }
.ficha h2 { margin: 2px 0 6px; font-family: var(--boceto); font-weight: 400; font-size: 32px; line-height: 1.05; padding-right: 30px; }
.ficha-barrio { margin: 0; display: inline-block; padding: 1px 8px; border: 1.5px solid var(--tinta); font-family: var(--mono); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.ficha-texto { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.ficha-obras { margin: 0 0 10px; padding: 6px 10px; background: var(--ambar); border: 2px solid var(--tinta); font-size: 16px; }
.ficha-cifras { display: grid; grid-template-columns: 1fr auto; gap: 3px 14px; margin: 0 0 12px; padding: 10px 0 0; border-top: 1.5px dashed rgba(31, 29, 46, 0.35); font-size: 16px; }
.ficha-cifras dt { color: var(--tinta2); }
.ficha-cifras dd { margin: 0; text-align: right; font-family: var(--mono); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.ficha-acciones { margin: 0; }
.ficha-acciones:empty { display: none; }
.ficha-acciones .boton { text-decoration: none; }
/* ficha de un suceso (alguien, un robot, un ladrón…) */
.ficha .cuando { margin: 0 0 8px; font-family: var(--mono); font-size: 12px; color: var(--tinta2); }
.ficha .que { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.ficha .que .ruta { font-family: var(--mono); font-size: 0.85em; color: var(--coral-osc); font-weight: 700; word-break: break-all; }
.ficha .que .robot { color: var(--violeta); font-weight: 700; }
.ficha .explica { margin: 0 0 12px; padding: 8px 10px; background: rgba(31, 29, 46, 0.06); border-left: 4px solid var(--tinta); font-size: 16.5px; line-height: 1.3; }
.ficha .explica.t-l { border-color: var(--coral); }
.ficha .explica.t-r { border-color: var(--violeta); }
.ficha .explica.t-p { border-color: var(--ambar); }
.quien { margin: 0 0 10px; padding: 10px 12px 8px; border: 2px solid var(--tinta); background: #fff8ea; }
.quien-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ip-grande { font-family: var(--mono); font-weight: 800; font-size: 19px; letter-spacing: 0.01em; word-break: break-all; }
.quien .mini { min-height: 30px; padding: 0 9px; font-size: 11.5px; box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45); }
.quien .host { margin: 2px 0 6px; font-family: var(--mono); font-size: 12px; color: var(--tinta2); word-break: break-all; }
.quien dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 6px 0; font-size: 15px; }
.quien dt { color: var(--tinta2); }
.quien dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.quien .ua { font-size: 11.5px; line-height: 1.35; color: var(--tinta2); }
.quien h3 { margin: 10px 0 4px; font-family: var(--boceto); font-weight: 400; font-size: 19px; }
.quien .lista-rutas { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; }
.quien .lista-rutas li { padding: 1px 6px; border: 1.5px solid var(--coral); font-family: var(--mono); font-size: 11.5px; color: var(--coral-osc); word-break: break-all; }
.quien .enlaces { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.quien .enlaces a { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.solo-dueno { margin: 0 0 10px; font-size: 15px; color: var(--tinta2); }
.ficha-sub { margin: 4px 0 4px; font-family: var(--boceto); font-weight: 400; font-size: 19px; }
.ficha .mini-diario { margin: 0 -18px 12px; padding: 0; overflow: visible; border-top: 1.5px dashed rgba(31, 29, 46, 0.35); }
.ficha .mini-diario li { padding: 5px 18px; }
.ficha-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.cerrar {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 2px solid var(--tinta); background: var(--papel); color: var(--tinta);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.cerrar:hover { background: var(--tinta); color: var(--papel); }

/* ---- ¿qué es esto? ---- */
.ayuda {
  width: min(640px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px 26px 18px;
  font-size: 18.5px; line-height: 1.38;
}
.ayuda::backdrop { background: rgba(14, 13, 21, 0.72); }
.ayuda h2 { margin: 0 0 10px; font-family: var(--boceto); font-weight: 400; font-size: 34px; line-height: 1.05; padding-right: 40px; }
.ayuda h3 { margin: 16px 0 4px; font-family: var(--boceto); font-weight: 400; font-size: 24px; }
.ayuda p { margin: 0 0 10px; }
.leyenda { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 9px; }
.leyenda li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.leyenda li p { margin: 2px 0 0; }
.ico { width: 30px; height: 30px; border: 2px solid var(--tinta); background: var(--papel2) center / 70% no-repeat; }
.ico-persona { background-color: var(--ambar); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='5' r='3' fill='%23F1E8D6' stroke='%231F1D2E' stroke-width='1.5'/%3E%3Crect x='6.5' y='8.5' width='7' height='6' rx='2' fill='%23E2674A' stroke='%231F1D2E' stroke-width='1.5'/%3E%3Cpath d='M8 14.5 7 19M12 14.5 13 19' stroke='%231F1D2E' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico-arana { background-color: #D9CCEB; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 1v6M4 7l3 3-3 4M16 7l-3 3 3 4M3 11h4M13 11h4' stroke='%231F1D2E' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='10' cy='11' rx='3' ry='3.6' fill='%231F1D2E'/%3E%3C/svg%3E"); }
.ico-ladron { background-color: var(--coral); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='5' r='3' fill='%23F1E8D6' stroke='%231F1D2E' stroke-width='1.5'/%3E%3Crect x='7' y='4' width='6' height='1.6' fill='%231F1D2E'/%3E%3Crect x='6.5' y='8.5' width='7' height='6' rx='2' fill='%231F1D2E'/%3E%3Cpath d='M7 10.5h6M7 12.5h6' stroke='%23F1E8D6' stroke-width='1'/%3E%3Cpath d='M8 14.5 7 19M12 14.5 13 19' stroke='%231F1D2E' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico-ventana { background-color: var(--papel2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Crect x='3' y='3' width='14' height='14' fill='%23F1E8D6' stroke='%231F1D2E' stroke-width='1.5'/%3E%3Crect x='5' y='5' width='4' height='4' fill='%23F2A541'/%3E%3Crect x='11' y='5' width='4' height='4' fill='%233B3850'/%3E%3Crect x='5' y='11' width='4' height='4' fill='%233B3850'/%3E%3Crect x='11' y='11' width='4' height='4' fill='%23F2A541'/%3E%3C/svg%3E"); }
.ico-humo { background-color: var(--papel2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='7' cy='6' r='2.5' fill='%23CFC6B4' stroke='%231F1D2E'/%3E%3Ccircle cx='11' cy='3.5' r='2' fill='%23CFC6B4' stroke='%231F1D2E'/%3E%3Crect x='5' y='9' width='4' height='9' fill='%23F1E8D6' stroke='%231F1D2E' stroke-width='1.4'/%3E%3Crect x='5' y='12' width='4' height='1.6' fill='%23E2674A'/%3E%3C/svg%3E"); }
.ayuda-pie { margin-top: 14px; padding-top: 10px; border-top: 1.5px dashed rgba(31, 29, 46, 0.35); font-family: var(--mono); font-size: 12px; color: var(--tinta2); }

.estado {
  position: fixed; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 10px 16px;
  border: 2px solid var(--matrix); background: #12131A; color: var(--matrix); font-family: var(--mono); font-size: 13px; font-weight: 700;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
.estado.oculto { opacity: 0; visibility: hidden; }
.estado.aviso { top: auto; bottom: 120px; border-color: var(--coral); color: var(--coral); }

/* ---- pantallas medianas: el diario se estrecha ---- */
@media (max-width: 1180px) {
  .diario { width: 290px; }
  .cifras { gap: 16px; }
  .cifras dd { font-size: 29px; }
}

/* ---- móvil y tableta en vertical ---- */
@media (max-width: 759px) {
  body { font-size: 16px; }
  .cabecera { flex-wrap: wrap; gap: 8px; padding-top: max(10px, var(--sa-t)); }
  .marca { min-height: 42px; padding: 0 12px 0 8px; }
  .marca-nombre { font-size: 23px; }
  .directo { order: 3; min-height: 28px; font-size: 11px; padding: 0 9px; }
  .botones { gap: 6px; }
  .boton { min-height: 42px; padding: 0 10px; }
  .boton.cuadrado { width: 40px; }
  #b-menos, #b-mas { display: none; }
  .ficha { max-height: 72vh; }
  .solo-ancho { display: none; }
  .solo-estrecho { display: inline; }
  .boton.cta { width: 42px; padding: 0; font-family: var(--boceto); font-size: 22px; }

  .hoy {
    left: 10px; right: 10px; bottom: auto; top: calc(max(10px, var(--sa-t)) + 92px); padding: 6px 10px 6px; transform: none; max-width: none;
  }
  .hoy-titulo { display: none; }
  .cifras { justify-content: space-between; gap: 8px; margin: 0; }
  .cifras dt { font-size: 12.5px; }
  .cifras dd { font-size: 22px; }
  .central { display: none; }

  .diario {
    top: auto; left: 10px; right: 10px; bottom: max(10px, var(--sa-b)); width: auto; height: 96px; transform: none;
    transition: height 0.25s ease;
  }
  .diario.abierto { height: 62vh; }
  .diario-cabeza { cursor: pointer; padding: 8px 12px; min-height: 44px; }
  .diario-cabeza h2 { font-size: 19px; white-space: nowrap; }
  .diario-cabeza .flecha { display: block; }
  .diario.abierto .flecha { transform: rotate(180deg); }
  .diario-lista { font-size: 12px; padding-top: 2px; }
  .diario-lista li { padding: 4px 12px; }

  .ficha { top: auto; bottom: max(10px, var(--sa-b)); left: 10px; right: 10px; width: auto; max-height: 64vh; transform: none; }
  @keyframes ficha { from { opacity: 0; transform: translateY(14px); } }
  .ficha h2 { font-size: 28px; }
  .ayuda { padding: 18px 16px 14px; font-size: 17px; }
  .ayuda h2 { font-size: 28px; }
}

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