/* components.css — iconos superiores y menú inferior "pill" con glass blur */

/* ---- Iconos superiores simétricos ---- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  z-index: 100;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--surface-glass);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  color: var(--text);
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease, transform .15s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---- Pantalla de Inicio ---- */
#screen-home { text-align: center; }
.home__title {
  font-size: clamp(calc(2.2rem - 2px), 8vw, calc(3rem - 2px));
  /* Centra el título en la franja entre el borde superior y los botones:
     se sube con margen negativo y se compensa abajo para no mover los tiempos. */
  margin-top: -34px;
  margin-bottom: calc(0.4em + 34px);
}

/* Botones rápidos de duración */
.quick-times {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 0 14px;
}
.chip {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 1;
  max-width: 60px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .15s ease;
}
.chip:active { transform: scale(0.96); }
.chip.is-active {
  background-color: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

/* Minutos personalizados (stepper mobile-friendly) */
.custom-min { margin-bottom: 6px; }
.custom-min .seg-label { display: block; }

.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stepper__btn {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;          /* sin retardo de doble toque */
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.stepper__btn:active {
  transform: scale(0.92);
  background-color: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

.stepper__field {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  border-radius: 14px;
  background-color: var(--surface);
}
.stepper__field input {
  width: 3.5ch;
  border: 0;
  background-color: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 2rem;
  text-align: right;
}
.stepper__field input:focus { outline: none; }
.stepper__field[data-invalid="true"] { outline: 1px solid var(--danger); }
.stepper__unit { opacity: .7; }

/* Oculta las flechas nativas del input number */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.error { color: var(--danger); font-size: .85rem; margin: 2px 0 8px; }

/* Filas de toggle */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px;
  border-top: 1px solid var(--border);
}

/* Bloque de opciones de sesión: separado de los tiempos por arriba */
.session-options { margin-top: 32px; }

/* Interruptor (switch) */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--surface);
  cursor: pointer;
  transition: background-color .2s ease;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--text);
  transition: transform .2s ease, background-color .2s ease;
}
.switch[aria-checked="true"] { background-color: var(--accent); }
.switch[aria-checked="true"]::after {
  transform: translateX(20px);
  background-color: var(--on-accent);
}

/* Panel de tonos */
.tones-panel {
  margin-top: 4px;
  padding: 8px 14px 14px;
  border-radius: 16px;
  background-color: var(--surface);
  text-align: left;
}
.seg-label { font-size: .85rem; opacity: .7; margin: 12px 2px 6px; }
.segmented { display: flex; gap: 6px; }
.seg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background-color: transparent;
  color: var(--text);
  font-size: .95rem;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.seg small { font-size: .72rem; opacity: .7; }
.seg.is-active {
  background-color: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}
.seg.is-active small { opacity: .85; }
.hint { font-size: .8rem; opacity: .7; margin: 12px 0 0; }

/* Botón Iniciar */
.btn--start {
  display: block;
  width: 100%;
  margin-top: 36px;
  padding: 16px;
  font-size: 1.15rem;
  border-radius: 18px;
}
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Botón genérico ---- */
.btn {
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  background-color: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  cursor: pointer;
  transition: transform .15s ease, opacity .2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:hover { opacity: .92; }

/* ---- Campos de formulario (Configuración) ---- */
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

/* ---- Menú inferior "pill" (glass blur) ---- */
.pill {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: calc(100% - 32px);     /* margen lateral de 16px a cada lado */
  max-width: 520px;             /* no excederse en tablet/escritorio */
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background-color: var(--surface-glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: 0 10px 34px var(--shadow);
  z-index: 100;
}

.pill__item {
  flex: 1 1 0;                  /* reparte el ancho por igual entre los 4 */
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 6px;
  border: 0;
  border-radius: 999px;
  background-color: transparent;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  opacity: .7;
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease, opacity .25s ease;
}
.pill__item svg { width: 22px; height: 22px; }
.pill__item span { white-space: nowrap; }

.pill__item.is-active {
  background-color: var(--accent);
  color: var(--on-accent);
  opacity: 1;
}

/* Sombras blandas: elevan las superficies tipo tarjeta (clave en el tema claro;
   en oscuro quedan como un halo sutil). El valor sale de --shadow por tema. */
.icon-btn,
.chip,
.stepper__btn,
.stepper__field,
.tones-panel,
.btn--start,
.app-link,
.stat-card,
.entry {
  box-shadow: 0 2px 10px var(--shadow);
}

/* ---- Conocimiento ---- */
.learn__title { font-size: 1.05rem; margin: 24px 0 8px; }
.learn__title:first-child { margin-top: 8px; }
.learn__body { opacity: .9; line-height: 1.6; white-space: pre-line; }

/* ---- Otras aplicaciones ---- */
.app-links { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.app-link {
  display: block;
  padding: 14px 16px;
  border-radius: 14px;
  background-color: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.app-link--soon { cursor: default; }
.app-link__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-link__name { font-weight: 700; }
.app-link__badge {
  flex: none;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 999px;
  background-color: var(--surface-glass);
  border: 1px solid var(--border);
  opacity: .8;
}
.app-link__desc { font-size: .85rem; opacity: .7; margin-top: 2px; }

/* ---- Configuración: fondo ---- */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.bg-opt {
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  border: 2px solid transparent;
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, transform .12s ease;
}
.bg-opt:active { transform: scale(0.97); }
.bg-opt.is-active { border-color: var(--accent-ink); }
.bg-opt--none {
  display: grid;
  place-items: center;
  font-size: .8rem;
  padding: 4px;
  text-align: center;
}

/* ---- Configuración: datos ---- */
.settings__subtitle { font-size: 1rem; margin: 28px 0 12px; }
.settings__data { display: flex; gap: 10px; }
.settings__data .btn { flex: 1; }
.settings__status { margin-top: 12px; font-size: .9rem; opacity: .8; min-height: 1.2em; }
.settings__status.error { color: var(--danger); opacity: 1; }

/* ---- Estadísticas ---- */
.muted { opacity: .65; }
.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  padding: 18px 14px;
  border-radius: 16px;
  background-color: var(--surface);
  text-align: center;
}
.stat-card__num { font-weight: 700; font-size: 2rem; color: var(--accent-ink); }
.stat-card__label { font-size: .85rem; opacity: .75; margin-top: 4px; }

.stats__subtitle { font-size: 1rem; margin: 26px 0 12px; }
.mood-stats { display: flex; gap: 6px; }
.mood-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border-radius: 14px;
  background-color: var(--surface);
}
.mood-stat__emoji { font-size: 1.4rem; }
.mood-stat__num { font-weight: 700; }

/* ---- Diario ---- */
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.entry {
  padding: 14px;
  border-radius: 16px;
  background-color: var(--surface);
}
.entry__head { display: flex; align-items: center; gap: 12px; }
.entry__mood { font-size: 1.6rem; line-height: 1; flex: 0 0 auto; width: 1.6em; text-align: center; }
.entry__meta { flex: 1; min-width: 0; }
.entry__date { font-weight: 700; }
.entry__sub { font-size: .82rem; opacity: .7; margin-top: 2px; }
.entry__tools { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.entry__tool {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background-color: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .12s ease;
}
.entry__tool:active { transform: scale(0.92); }
.entry__tool svg { width: 18px; height: 18px; }
.entry__tool--danger { color: var(--danger); }
.entry__note { margin: 10px 0 0; white-space: pre-wrap; }

.entry__editor { margin-top: 12px; }
.entry__editor .mood--sm { margin-bottom: 10px; }
.entry__editor .note { margin-bottom: 10px; }
.entry__actions { display: flex; gap: 10px; }
.entry__actions .btn { flex: 1; }

/* ---- Pantalla de fin de sesión ---- */
.done {
  max-width: 360px;
  margin: 8vh auto 0;
  text-align: center;
}
.done__check {
  width: 72px;
  height: 72px;
  color: var(--accent-ink);
  margin-bottom: 8px;
}
.done__title { font-size: 1.9rem; }
.done__subtitle { opacity: .75; margin-bottom: 20px; }
.done__mood-prompt { font-size: .9rem; opacity: .7; margin-bottom: 10px; }

/* Selector de ánimo (emoji + etiqueta) */
.mood {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}
.mood__opt {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background-color: transparent;
  color: var(--text);
  font-size: .72rem;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .12s ease;
}
.mood__opt:active { transform: scale(0.95); }
.mood__emoji { font-size: 1.5rem; line-height: 1; }
.mood__opt.is-active {
  background-color: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

/* Nota del diario */
.note {
  width: 100%;
  padding: 12px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background-color: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}
.note:focus { outline: 1px solid var(--accent-ink); }

.done__save {
  display: block;
  width: 100%;
  margin-bottom: 14px;
}

.done__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.done__actions .btn { flex: 1; max-width: 170px; }

/* ---- Sesión (overlay inmersivo) ---- */
.session {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 44px;
  padding: 24px;
  background-color: var(--bg);
  overflow: hidden;
  opacity: 0;
  transition: opacity .4s ease;
}
.session.is-open { opacity: 1; }

/* Aurora de fondo que deriva muy lentamente */
.session::before {
  content: '';
  position: absolute;
  inset: -30%;
  z-index: -1;
  background:
    radial-gradient(40% 40% at 30% 30%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 70%);
  filter: blur(48px);
  animation: aurora-drift 40s ease-in-out infinite alternate;
}
@keyframes aurora-drift {
  from { transform: translate(-4%, -3%) scale(1); }
  to   { transform: translate(5%, 4%) scale(1.15); }
}

/* Recipiente que se vacía */
.session__stage {
  position: relative;
  width: min(72vw, 320px);
  aspect-ratio: 1 / 1;
}
.vessel { display: block; width: 100%; height: 100%; }
.vessel__ring { fill: none; stroke: var(--text); stroke-opacity: .25; stroke-width: 2; }
.water { fill: var(--accent-ink); fill-opacity: .9; }
.wave { animation: wave-drift 7s linear infinite; }
@keyframes wave-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-100px); }   /* una longitud de onda */
}

.session__readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}
.session__time {
  font-weight: 700;
  font-size: clamp(2.6rem, 13vw, 4.2rem);
  letter-spacing: .02em;
  color: var(--text);
}
.session__label {
  font-size: .9rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .8;
}

.session__stop {
  /* Relleno con el acento del tema (hereda bg/color de .btn) y separado de la esfera. */
  padding: 12px 30px;
  margin-top: 28px;
  box-shadow: 0 2px 10px var(--shadow);
}

/* Diálogo de confirmación */
.dialog {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, .45);
}
.dialog__box {
  width: 86%;
  max-width: 320px;
  padding: 24px;
  border-radius: 20px;
  background-color: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 20px 60px var(--shadow);
}
.dialog__title { font-size: 1.15rem; margin-bottom: 22px; }
.dialog__actions { display: flex; gap: 10px; }
.dialog__actions .btn { flex: 1; }
.btn--ghost {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--danger {
  background-color: var(--danger);
  color: var(--bg);
}

/* Diálogo de confirmación reutilizable (fijo, cubre toda la pantalla) */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: rgba(0, 0, 0, .45);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
  .wave, .session::before { animation: none; }
}
