/* ============ Fondo vivo ============ */

.sea {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.tide {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 120%, rgb(23 158 147 / 0.28), transparent 60%),
    linear-gradient(180deg, var(--abyss) 0%, var(--deep) 55%, var(--sea) 100%);
}

.tide i {
  position: absolute;
  width: 80vmax;
  height: 80vmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(64 224 208 / 0.16), transparent);
  will-change: transform;
}

.tide i:nth-child(1) {
  left: -30vmax;
  top: -25vmax;
  animation: drift-a 38s var(--ease-in-out) infinite alternate;
}

.tide i:nth-child(2) {
  right: -35vmax;
  top: 10vmax;
  background: radial-gradient(closest-side, rgb(23 158 147 / 0.22), transparent);
  animation: drift-b 46s var(--ease-in-out) infinite alternate;
}

.tide i:nth-child(3) {
  left: 0;
  bottom: -45vmax;
  background: radial-gradient(closest-side, rgb(143 245 234 / 0.1), transparent);
  animation: drift-c 54s var(--ease-in-out) infinite alternate;
}

@keyframes drift-a { to { transform: translate3d(18vmax, 12vmax, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-16vmax, 14vmax, 0) scale(0.9); } }
@keyframes drift-c { to { transform: translate3d(12vmax, -10vmax, 0) scale(1.1); } }

/* ============ Esqueleto ============ */

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-x: hidden;
}

.topbar,
.stage,
.foot {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}

@media (min-width: 720px) {
  .topbar { padding: 28px 32px 0; }
}

.mark {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 24px;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  padding: 8px 6px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: color 300ms ease;
}

.mark b {
  font-weight: 400;
  color: var(--turq);
  margin: 0 0.12em;
}

/* ============ Campana ============ */

.bell {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass);
  box-shadow: var(--inner-light), 0 0 0 1px var(--hairline);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: var(--ink);
  transition: transform 160ms var(--ease-out), box-shadow 300ms ease;
}

.bell:active { transform: scale(0.94); }

@media (hover: hover) {
  .bell:hover { box-shadow: var(--inner-light), 0 0 0 1px var(--hairline-strong), 0 0 24px -4px rgb(64 224 208 / 0.4); }
}

.bell-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: 50% 8%;
}

.bell.has-unread::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--turq);
  animation: halo 2.6s var(--ease-out) infinite;
  pointer-events: none;
}

@keyframes halo {
  0% { transform: scale(1); opacity: 0.7; }
  70%, 100% { transform: scale(1.65); opacity: 0; }
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--coral);
  color: #2a0d08;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 3px var(--abyss);
}

/* ============ Escenario ============ */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px 24px;
  gap: clamp(28px, 6vh, 56px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dedication {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(19px, 5vw, 24px);
  line-height: 1.2;
  color: var(--ink-2);
}

.dedication time { color: var(--turq); }

.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(46px, 12.5vw, 116px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.title .line {
  display: block;
  overflow: hidden;
  padding: 0.04em 0.08em 0.1em;
}

.title .line > * { display: inline-block; }

.title em {
  font-style: italic;
  color: var(--turq-hi);
  text-shadow: 0 0 36px rgb(64 224 208 / 0.45);
  padding-right: 0.06em;
}

/* ============ Cuenta atrás ============ */

.countdown {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(10px, 3.4vw, 40px);
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.digits {
  display: flex;
  font-family: var(--font-display);
  font-size: clamp(50px, 15.5vw, 150px);
  line-height: 1;
  color: var(--ink);
}

.unit[data-unit='seconds'] .digits {
  color: var(--turq-hi);
  text-shadow: 0 0 28px rgb(64 224 208 / 0.5);
}

.slot {
  position: relative;
  display: block;
  width: 0.54em;
  height: 1.08em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.slot > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  will-change: transform;
}

.label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============ Contadores (tocar para cambiar) ============ */

.meters {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 22px 20px 14px;
  border-radius: var(--r-lg);
  text-align: center;
  background: rgb(64 224 208 / 0.035);
  box-shadow: var(--inner-light), 0 0 0 1px var(--hairline);
  transition: transform 160ms var(--ease-out), background-color 300ms ease, box-shadow 300ms ease;
}

.meters:active { transform: scale(0.98); }

@media (hover: hover) {
  .meters:hover {
    background: rgb(64 224 208 / 0.06);
    box-shadow: var(--inner-light), 0 0 0 1px var(--hairline-strong);
  }
}

.meter-stack { display: grid; }

/* Todos apilados en la misma celda: la tarjeta mide lo que el más alto y nunca salta. */
.meter {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  visibility: hidden;
  opacity: 0;
}

.meter.is-active,
.meter.is-leaving {
  visibility: visible;
  opacity: 1;
}

.meter-caption {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  line-height: 1.25;
  color: var(--ink-3);
}

.meter-note {
  margin-top: -6px;
  font-size: 11px;
  color: var(--ink-4);
}

.meter-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 16px;
}

.meter-dots {
  display: flex;
  gap: 6px;
}

.meter-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-4);
  transition: background-color 300ms ease, transform 300ms var(--ease-out);
}

.meter-dots i.is-on {
  background: var(--turq);
  transform: scale(1.35);
}

.meter-hint {
  font-size: 11px;
  color: var(--ink-3);
}

/* · Año */

.year-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.year-age {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  color: var(--ink-3);
}

.year-age.is-next {
  font-style: italic;
  color: var(--turq);
}

.year-pct {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.year-pct small {
  font-size: 11px;
  margin-left: 2px;
  color: var(--ink-3);
}

.year-bar {
  position: relative;
  display: block;
  height: 2px;
  margin: 6px 0;
  border-radius: 2px;
  background: var(--ink-4);
}

.year-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--turq-lo), var(--turq-hi));
  box-shadow: 0 0 12px rgb(64 224 208 / 0.6);
}

.year-bar span::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--turq-hi);
  box-shadow: 0 0 14px 3px rgb(143 245 234 / 0.75);
}

/* · Semana */

.week {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.day-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.day-disc {
  position: relative;
  width: min(36px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
}

.day-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--turq-hi), var(--turq-lo));
  transform-origin: 50% 100%;
  transform: scaleY(0);
}

.day-num {
  position: relative;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.day.is-past .day-disc { box-shadow: none; }
.day.is-past .day-num { color: #022624; font-weight: 500; }

.day.is-today .day-label { color: var(--turq); }
.day.is-today .day-disc { box-shadow: inset 0 0 0 1px var(--turq), 0 0 16px -2px rgb(64 224 208 / 0.6); }
.day.is-today .day-fill { opacity: 0.45; }
.day.is-today .day-num { color: var(--ink); font-weight: 500; }

.day.is-last .day-disc { box-shadow: inset 0 0 0 1px var(--turq); }
.day.is-last .day-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  color: var(--turq-hi);
}
.day.is-last.is-past .day-num { color: #022624; }

/* · Noches */

.nights-num {
  font-family: var(--font-display);
  font-size: 64px;
  line-height: 0.9;
  color: var(--ink);
}

.moons {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 22px;
}

.moon svg {
  display: block;
  fill: var(--turq-hi);
  filter: drop-shadow(0 0 6px rgb(64 224 208 / 0.55));
}

.moon:nth-child(even) svg { transform: rotate(-14deg) scale(0.9); }

/* · Latidos */

.beats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.heart {
  flex: none;
  fill: var(--coral);
  filter: drop-shadow(0 0 10px rgb(255 154 139 / 0.5));
}

.meter[data-meter='beats'].is-active .heart {
  animation: heartbeat 800ms var(--ease-out) infinite;
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.2); }
  28% { transform: scale(1); }
  42% { transform: scale(1.1); }
  70%, 100% { transform: scale(1); }
}

.beats-num {
  font-family: var(--font-display);
  font-size: clamp(40px, 11vw, 56px);
  line-height: 1;
  color: var(--ink);
}

.beats-num .dig {
  display: inline-block;
  width: 0.54em;
  text-align: center;
}

.beats-num .sep { color: var(--ink-3); }

/* ============ Pie ============ */

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px 20px;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--ink-3);
}

.pulse {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--turq);
}

/* ============ Entrada ============ */

[data-i='0'] { --i: 0; }
[data-i='1'] { --i: 1; }
[data-i='2'] { --i: 2; }
[data-i='3'] { --i: 3; }
[data-i='4'] { --i: 4; }
[data-i='5'] { --i: 5; }

.reveal {
  opacity: 0;
  animation: rise 1100ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 120ms + 200ms);
}

.reveal-up {
  transform: translateY(110%);
  animation: lift 1200ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 120ms + 200ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes lift {
  to { transform: none; }
}

/* ============ Bandeja de mensajes ============ */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 8 10 / 0.6);
  opacity: 0;
  transition: opacity 320ms ease;
}

.scrim.is-open { opacity: 1; }

.inbox {
  position: fixed;
  z-index: 21;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--glass-strong);
  box-shadow: var(--inner-light), var(--halo);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  padding-bottom: var(--safe-b);
  transform: translateY(100%);
  transition: transform 480ms var(--ease-drawer);
  touch-action: pan-y;
}

.inbox.is-open { transform: none; }
.inbox.is-dragging { transition: none; }

.inbox-grip {
  width: 40px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: var(--ink-4);
}

.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px 24px;
  touch-action: none;
}

.inbox-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: 30px;
  line-height: 1;
}

.inbox-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  background: rgb(255 255 255 / 0.04);
  transition: transform 160ms var(--ease-out), background-color 200ms ease;
}

.inbox-close:active { transform: scale(0.92); }

.inbox-close svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.inbox-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 8px 16px;
}

.note {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 4px 10px;
  padding: 16px 16px;
  border-radius: var(--r-md);
  transition: background-color 600ms ease;
}

.note + .note { box-shadow: 0 -1px 0 var(--hairline); }

.note.is-unread { background: rgb(64 224 208 / 0.06); }

.note-dot {
  width: 7px;
  height: 7px;
  margin-top: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 600ms ease, box-shadow 600ms ease;
}

.note.is-unread .note-dot {
  background: var(--coral);
  box-shadow: 0 0 10px rgb(255 154 139 / 0.7);
}

.note-title {
  grid-column: 2;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.note-body {
  grid-column: 2;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note-time {
  grid-column: 2;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

.inbox-empty {
  padding: 28px 24px 48px;
  text-align: center;
  font-size: 15px;
  color: var(--ink-3);
}

.inbox-empty em {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--turq);
}

@media (min-width: 720px) {
  .scrim { background: transparent; }

  .inbox {
    left: auto;
    right: 32px;
    bottom: auto;
    top: calc(var(--safe-t) + 88px);
    width: 400px;
    max-height: min(560px, 75dvh);
    border-radius: 24px;
    padding-bottom: 0;
    transform-origin: calc(100% - 24px) 0;
    transform: translateY(-6px) scale(0.96);
    opacity: 0;
    transition: transform 220ms var(--ease-out), opacity 180ms ease;
  }

  .inbox.is-open {
    transform: none;
    opacity: 1;
  }

  .inbox-grip { display: none; }
  .inbox-head { padding-top: 20px; }
}

@media (hover: hover) {
  .inbox-close:hover { background: rgb(255 255 255 / 0.09); color: var(--ink); }
}

/* ============ Toast ============ */

.toasts {
  position: fixed;
  z-index: 30;
  top: calc(var(--safe-t) + 76px);
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 380px);
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px 14px 14px;
  border-radius: 22px;
  text-align: left;
  background: var(--glass-strong);
  box-shadow: var(--inner-light), 0 0 0 1px var(--hairline-strong), 0 20px 50px -18px rgb(0 0 0 / 0.8), 0 0 40px -10px rgb(64 224 208 / 0.35);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  transition: transform 160ms var(--ease-out);
}

.toast:active { transform: scale(0.98); }

.toast-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(64 224 208 / 0.14);
  color: var(--turq-hi);
}

.toast-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-kicker {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--turq);
}

.toast-title {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Susurros (easter eggs) ============ */

.whisper {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(var(--safe-b) + 72px);
  width: min(calc(100% - 32px), 460px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

/* Tarjeta de cristal oscuro: el mensaje se lee aunque caiga encima de la tarjeta de contadores. */
.whisper:not(:empty) {
  padding: 18px 22px 14px;
  border-radius: 24px;
  background: rgb(2 18 20 / 0.86);
  box-shadow: var(--inner-light), 0 0 0 1px var(--hairline-strong), 0 24px 60px -16px rgb(0 0 0 / 0.85);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.whisper-text {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.2;
  color: var(--ink);
  text-shadow: 0 0 24px rgb(64 224 208 / 0.55), 0 2px 12px rgb(0 0 0 / 0.6);
  text-wrap: balance;
}

.whisper-count {
  display: block;
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--turq);
}

/* ============ Puerta secreta ============ */

.gate-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 8 10 / 0.55);
}

.gate {
  position: fixed;
  z-index: 41;
  top: calc(var(--safe-t) + 88px);
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 340px);
  display: grid;
  gap: 12px;
  padding: 22px 20px 14px;
  border-radius: 24px;
  text-align: center;
  background: var(--glass-strong);
  box-shadow: var(--inner-light), var(--halo);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.gate-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 26px;
  line-height: 1.1;
}

.gate-input {
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  text-align: center;
  color: var(--ink);
  background: rgb(0 0 0 / 0.3);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: box-shadow 200ms ease;
}

.gate-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--turq), 0 0 0 4px rgb(64 224 208 / 0.12);
}

.gate-msg {
  min-height: 1.4em;
  font-size: 13px;
  color: var(--ink-3);
}

/* ============ Día del cumple ============ */

.is-birthday .countdown { display: none; }
.is-birthday .title { font-size: clamp(54px, 15vw, 140px); }

/* ============ Menos movimiento ============ */

@media (prefers-reduced-motion: reduce) {
  .tide i,
  .bell.has-unread::before,
  .meter[data-meter='beats'].is-active .heart {
    animation: none;
  }

  .reveal,
  .reveal-up {
    animation: fade 400ms ease forwards;
    transform: none;
  }

  @keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}
