/* ============================================================
   features.css — Estilos de los componentes de la fase
   "instrumento premium amigable": hub de Inicio, insights,
   resumen semanal, zonas 3×3, HUD (palabra de presencia, botón
   de modo, chips de zona/recurrencia, herramienta de fotos),
   llamada espectral, consentimiento de foto, coach-marks y
   ajustes ampliados (estado del sensor).

   Regla: TODA capa superpuesta (call-layer, photo-ask, coach)
   nace oculta y sólo aparece con .is-open. Todo SVG inline
   tiene tamaño acotado: nunca hereda el ancho del contenedor.
   ============================================================ */

/* ---------- Corrección de layout: las pantallas con scroll ----------
   .screen es un flex-column; los hijos con overflow:hidden (.panel)
   se encogían en lugar de empujar el scroll y recortaban su contenido.
   La Terminal se excluye: su .chat-log sí debe flexionar. */
.screen:not(.term-screen):not(.screen--flush) > * { flex: 0 0 auto; }

/* ---------- Seguridad global de iconos ---------- */
.hub-ico svg,
.insight-glyph svg,
.hud-mode-btn svg,
.presence-word svg,
.call-ring svg,
.coach-tip svg { width: 22px; height: 22px; flex: 0 0 auto; }

/* ============================================================
   INICIO · panel héroe
   ============================================================ */
.panel--hero {
  background:
    radial-gradient(120% 90% at 0% 0%, var(--accent-dim), transparent 55%),
    var(--bg-panel);
  border-color: var(--line-hard);
  box-shadow: var(--shadow-panel), var(--glow-accent);
}
.panel--hero .sigil { flex: 0 0 auto; }
.panel--hero .sigil svg { width: 100%; height: 100%; display: block; }
.panel--hero h3 {
  font-size: var(--fs-lg);
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--txt-hi);
  line-height: 1.25;
}
.panel--hero .btn--hero { justify-content: center; }
.panel--hero .btn span[id^="ico-"] { display: inline-flex; }
.panel--hero .btn span[id^="ico-"] svg { width: 17px; height: 17px; }

/* ============================================================
   INICIO · resumen semanal
   ============================================================ */
.weekly-text {
  font-size: var(--fs-sm);
  color: var(--txt);
  line-height: 1.55;
  margin: 0 0 var(--s3);
}
.weekly-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.weekly-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s3) var(--s2);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--bg-inset);
  text-align: center;
}
.weekly-cell b {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--txt-hi);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.weekly-cell:first-child b { color: var(--neon-cyan); }
.weekly-cell:nth-child(2) b { color: var(--neon-violet); }
.weekly-cell:nth-child(3) b { color: var(--neon-amber); }
.weekly-cell i {
  font-style: normal;
  font-size: var(--fs-nano);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt-ghost);
}
.weekly-hot {
  margin: var(--s3) 0 0;
  font-size: var(--fs-xs);
  color: var(--txt-lo);
}
.weekly-hot b { color: var(--neon-amber); font-weight: 600; }

/* ============================================================
   INICIO · tarjetas de insight
   ============================================================ */
.insight-list { display: flex; flex-direction: column; gap: var(--s2); }
.insight-list .empty { padding: var(--s4) var(--s3); }
.insight {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  width: 100%;
  padding: var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--bg-inset);
  text-align: left;
  color: inherit;
  transition: all var(--t-fast) var(--ease);
}
button.insight:hover { border-color: var(--line); }
button.insight:active { transform: scale(0.99); }
.insight-glyph {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.95;
}
.insight-glyph svg { width: 18px; height: 18px; }
.insight-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.insight-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--txt-hi);
  line-height: 1.3;
}
.insight-text {
  font-size: var(--fs-xs);
  color: var(--txt-lo);
  line-height: 1.5;
}
.insight--consolidate { border-color: rgba(167, 139, 250, 0.35); background: rgba(167, 139, 250, 0.07); }
.insight--consolidate::after {
  content: "›";
  align-self: center;
  font-size: var(--fs-lg);
  color: var(--neon-violet);
  padding-left: var(--s1);
}

/* ============================================================
   INICIO · hub de accesos rápidos
   ============================================================ */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s2);
  margin-bottom: var(--s4);
}
.hub-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 78px;
  padding: var(--s3) var(--s2);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--txt-lo);
  font-size: var(--fs-nano);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all var(--t-fast) var(--ease);
}
.hub-tile:hover { border-color: var(--line); color: var(--txt); }
.hub-tile:active { transform: scale(0.97); }
.hub-ico {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--accent-dim);
  color: var(--accent);
}
.hub-ico svg { width: 18px; height: 18px; }
.hub-tile[data-hub="entities"] .hub-ico { color: var(--neon-violet); background: var(--violet-dim); }
.hub-tile[data-hub="sessions"] .hub-ico { color: var(--neon-amber); background: var(--amber-dim); }
.hub-tile[data-hub="settings"] .hub-ico { color: var(--txt-lo); background: rgba(148, 163, 184, 0.1); }

/* ============================================================
   RADAR · historial por zona
   ============================================================ */
.zone-list { display: flex; flex-direction: column; gap: var(--s2); }
.zone-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.2fr) 2fr auto;
  align-items: center;
  gap: var(--s3);
  padding: 8px 0;
  border-bottom: 1px dashed rgba(140, 170, 200, 0.08);
}
.zone-row:last-child { border-bottom: 0; }
.zone-name { font-size: var(--fs-xs); color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-name .ghost { font-size: var(--fs-nano); }
.zone-bar {
  display: block;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.zone-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-amber));
  border-radius: var(--r-pill);
  transition: width var(--t-mid) var(--ease);
}
.zone-num { font-size: var(--fs-xs); color: var(--txt-hi); white-space: nowrap; }

/* ============================================================
   HUD · cuadrícula 3×3 de zonas (heatmap histórico)
   ============================================================ */
.zone-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}
.zone-grid.hidden { display: none; }
.zone-cell {
  --heat: 0;
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(251, 191, 36, calc(var(--heat) * 0.22));
  transition: background var(--t-slow) var(--ease);
}
.zone-cell b {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(241, 245, 249, 0.42);
  font-family: var(--font-mono);
  opacity: 0;
}
.zone-cell[data-expert="1"] b { opacity: 1; }

/* ============================================================
   HUD · palabra de presencia, chips y botón de modo
   ============================================================ */
.presence-word {
  display: inline-block;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent);
  text-shadow: 0 0 14px var(--accent-dim);
  transition: color var(--t-mid) var(--ease);
  white-space: nowrap;
}
body[data-ui="simple"] .presence-box { min-width: 136px; }
body[data-ui="simple"] .presence-k { display: none; }

.hud-chip--zone {
  color: var(--neon-cyan);
  border-color: rgba(34, 211, 238, 0.42);
  animation: chip-in var(--t-mid) var(--ease);
}
.hud-chip--rec-anom {
  color: var(--neon-violet);
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.12);
  font-weight: 600;
  animation: chip-in var(--t-mid) var(--ease);
}
.hud-chip.hidden { display: none; }
@keyframes chip-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

.hud-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  min-height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: rgba(5, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--txt-lo);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: all var(--t-fast) var(--ease);
}
.hud-mode-btn svg { width: 13px; height: 13px; }
.hud-mode-btn:active { transform: scale(0.96); }
body[data-ui="expert"] .hud-mode-btn { color: var(--neon-violet); border-color: rgba(167, 139, 250, 0.45); }
body[data-ui="simple"] .hud-mode-btn { color: var(--neon-cyan); border-color: rgba(34, 211, 238, 0.4); }

/* Herramienta de fotos: PREGUNTA / FOTOS SÍ / FOTOS NO */
.tool--photos.is-on { color: var(--neon-green); border-color: var(--neon-green); background: var(--green-dim); box-shadow: none; }
.tool--photos.is-off { color: var(--txt-ghost); border-color: var(--line-soft); text-decoration: line-through; }

/* ============================================================
   BOTONES nuevos
   ============================================================ */
.btn--ok {
  background: linear-gradient(180deg, var(--green-dim), rgba(0, 0, 0, 0.3));
  border-color: var(--neon-green);
  color: var(--neon-green);
  font-weight: 600;
  box-shadow: 0 0 16px var(--green-dim), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ============================================================
   LLAMADA ESPECTRAL (capa a pantalla completa)
   ============================================================ */
.call-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-call);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: radial-gradient(circle at 50% 35%, rgba(167, 139, 250, 0.16), rgba(6, 5, 12, 0.94) 70%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.call-layer.is-open { display: flex; animation: screen-in var(--t-mid) var(--ease); }
.call-card {
  width: 100%;
  max-width: 380px;
  padding: var(--s5) var(--s4) var(--s4);
  border-radius: var(--r-xl);
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow-panel), var(--glow-violet);
  text-align: center;
}
.call-ring {
  width: 96px;
  height: 96px;
  margin: 0 auto var(--s4);
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(167, 139, 250, 0.55);
  color: var(--neon-violet);
  position: relative;
  animation: call-pulse 1.6s ease-in-out infinite;
}
.call-ring::before,
.call-ring::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(167, 139, 250, 0.35);
  animation: call-wave 1.6s ease-out infinite;
}
.call-ring::after { animation-delay: 0.6s; }
.call-ring svg { width: 40px; height: 40px; }
@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(167, 139, 250, 0); }
}
@keyframes call-wave {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(1.5); opacity: 0; }
}
.call-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--txt-hi);
  line-height: 1.2;
}
.call-sub {
  margin: var(--s2) 0 0;
  font-size: var(--fs-sm);
  color: var(--txt-lo);
  line-height: 1.5;
}
.call-reasons {
  list-style: none;
  margin: var(--s3) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s2);
}
.call-reasons:empty { display: none; }
.call-reasons li {
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: var(--violet-dim);
  color: #eddcff;
  font-size: var(--fs-nano);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.call-layer .btn--primary {
  --accent: var(--neon-violet);
  --accent-dim: var(--violet-dim);
  border-color: var(--neon-violet);
  color: var(--neon-violet);
}

/* ============================================================
   CONSENTIMIENTO DE FOTO (hoja inferior con cuenta atrás)
   ============================================================ */
.photo-ask {
  position: fixed;
  inset: 0;
  z-index: var(--z-call);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: var(--s3);
  padding-bottom: calc(var(--s3) + var(--safe-b));
  background: rgba(6, 7, 11, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.photo-ask.is-open { display: flex; animation: screen-in var(--t-mid) var(--ease); }
.photo-ask-card {
  width: 100%;
  max-width: 420px;
  padding: var(--s4);
  border-radius: var(--r-xl);
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow-panel), 0 0 30px var(--green-dim);
  text-align: center;
  animation: sheet-up var(--t-mid) var(--ease);
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.photo-ask-count {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--s3);
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--neon-green);
  color: var(--neon-green);
  font-size: var(--fs-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 18px var(--green-dim);
  animation: count-tick 1s ease-in-out infinite;
}
@keyframes count-tick {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.photo-ask-card h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--txt-hi);
}
.photo-ask-card .ghost { margin: var(--s1) 0 0; font-size: var(--fs-sm); }
.photo-ask-card .ghost:empty { display: none; }
.photo-ask-note {
  margin: var(--s2) 0 0;
  font-size: var(--fs-nano);
  color: var(--txt-ghost);
  line-height: 1.5;
}

/* Modal rápido de fotos (long-press) */
#photo-mode-options .btn.btn--primary { --accent: var(--neon-green); --accent-dim: var(--green-dim); border-color: var(--neon-green); color: var(--neon-green); }

/* ============================================================
   COACH-MARKS (primera sesión)
   ============================================================ */
.coach-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  pointer-events: none;
}
.coach-layer.is-open { display: block; pointer-events: auto; animation: screen-in var(--t-mid) var(--ease); }
.coach-hole {
  position: fixed;
  border-radius: var(--r-md);
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 0 9999px rgba(4, 5, 9, 0.8), var(--glow-cyan);
  pointer-events: none;
}
.coach-tip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 360px);
  padding: var(--s4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-hard);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow-panel);
  color: var(--txt);
}
.coach-tip b { display: block; font-size: var(--fs-md); color: var(--txt-hi); margin-bottom: var(--s1); }
.coach-tip p { font-size: var(--fs-sm); line-height: 1.55; color: var(--txt-lo); margin: 0; }
.coach-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s3); }
.coach-count {
  position: absolute;
  top: var(--s3);
  right: var(--s4);
  font-size: var(--fs-nano);
  letter-spacing: 0.1em;
  color: var(--txt-ghost);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   AJUSTES · notas, separadores y estado del sensor
   ============================================================ */
.panel-note {
  margin: 0 0 var(--s3);
  font-size: var(--fs-xs);
  color: var(--txt-lo);
  line-height: 1.55;
}
.field-sep {
  align-self: center;
  padding: 0 var(--s2);
  font-size: var(--fs-xs);
  color: var(--txt-ghost);
}
.quiet-row { display: flex; align-items: center; gap: var(--s1); }
.quiet-row .input { flex: 1; min-width: 0; }
input[type="time"].input { color-scheme: dark; font-variant-numeric: tabular-nums; }

.sensor-rows { display: flex; flex-direction: column; }
.sensor-rows .kv { align-items: center; }
.sensor-rows .kv-v { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-nano); letter-spacing: 0.08em; text-transform: uppercase; }
.sensor-rows .kv-v::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ---------- Ajustes en modo simple: hint de modo ---------- */
#s-mode-hint, #s-sensor-summary { margin-top: var(--s2); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 380px) {
  .hub-grid { grid-template-columns: repeat(2, 1fr); }
  .weekly-cell b { font-size: var(--fs-lg); }
  .zone-row { grid-template-columns: minmax(80px, 1fr) 1.4fr auto; gap: var(--s2); }
}
@media (min-width: 720px) {
  .hub-tile { min-height: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  .call-ring, .call-ring::before, .call-ring::after, .photo-ask-count { animation: none; }
}
