/* Night-sky page for a Fire tablet. Type stays large, targets stay tall,
   and the gold ring marks the one orbit she can move. */

:root {
  --sky: #102033;
  --sky-deep: #070d16;
  --cream: #f6f1e6;
  --cream-dim: #d9d0c0;
  --gold: #f0d78c;
  --gold-deep: #c9a15b;
  --ink: #1c140c;
  --pad: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--sky-deep);
  color: var(--cream);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding:
    calc(10px + env(safe-area-inset-top))
    calc(var(--pad) + env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    calc(var(--pad) + env(safe-area-inset-left));
  gap: 8px;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.who {
  display: grid;
  gap: 0;
}

h1 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.age {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  font-weight: 700;
}

.date {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
}

.birthday {
  flex-basis: 100%;
  margin: 0;
  text-align: right;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  font-weight: 700;
  color: var(--gold);
}

.month-name {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 750;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--gold);
}

.day-label {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  color: var(--cream);
}

.month-name.pop {
  animation: pop 480ms ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.lesson {
  display: grid;
  gap: 2px;
}

.lesson p {
  margin: 0;
  font-size: clamp(1.05rem, 2.1vw, 1.3rem);
  line-height: 1.35;
  color: var(--cream);
}

.lesson .pace {
  font-size: clamp(0.92rem, 1.8vw, 1.1rem);
  color: var(--cream-dim);
}

.sky {
  position: relative;
  min-height: 0;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 42%, #1a314c 0%, var(--sky) 46%, var(--sky-deep) 100%);
  box-shadow: inset 0 0 0 1px rgba(240, 215, 140, 0.16);
}

#orrery {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#orrery:active {
  cursor: grabbing;
}

.tag {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(7, 13, 22, 0.72);
  color: var(--cream);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: nowrap;
}

.tag-earth {
  z-index: 3;
  color: var(--gold);
  font-size: 1.15rem;
}

.is-close .tag {
  font-size: 1.55rem;
  padding: 6px 14px;
}

.is-close .tag-earth {
  font-size: 1.9rem;
}

#all[aria-pressed="true"] {
  box-shadow: inset 0 0 0 3px var(--gold-deep);
}

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

.wish {
  position: absolute;
  z-index: 4;
  left: 4%;
  right: 4%;
  top: 4%;
  height: min(52%, calc(100% - 200px));
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
}

.wish[hidden] {
  display: none !important;
}

.wish.is-on {
  animation: wish-life 9s ease forwards;
}

.wish.is-on.is-still {
  animation: wish-life-still 9s ease forwards;
}

@keyframes wish-life {
  0% { opacity: 0; }
  7% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes wish-life-still {
  0% { opacity: 0; }
  8% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.wish-card {
  position: relative;
  z-index: 1;
  max-width: min(920px, 100%);
  padding: 1.15rem 1.6rem 1.3rem;
  border-radius: 28px;
  background:
    radial-gradient(120% 90% at 50% 0%, #1a314c 0%, #102033 46%, #070d16 100%);
  border: 1px solid rgba(255, 246, 212, 0.38);
  box-shadow:
    0 0 0 4px rgba(7, 13, 22, 0.7),
    0 0 0 5px rgba(255, 246, 212, 0.3),
    0 0 36px rgba(240, 180, 60, 0.26),
    0 18px 40px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.wish-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 22px;
  pointer-events: none;
  border: 1px solid rgba(255, 246, 212, 0.18);
  background:
    radial-gradient(circle at 8% 18%, #fff6d4 0 1.4px, transparent 2px),
    radial-gradient(circle at 92% 22%, #ffe9a8 0 1.2px, transparent 1.9px),
    radial-gradient(circle at 14% 84%, #ffe9a8 0 1.1px, transparent 1.8px),
    radial-gradient(circle at 88% 80%, #fff6d4 0 1.3px, transparent 2px),
    radial-gradient(circle at 50% 6%, #fff6d4 0 1.2px, transparent 1.9px),
    radial-gradient(circle at 50% 94%, #ffe9a8 0 1.1px, transparent 1.8px);
}

.wish.is-on .wish-card {
  animation: wish-card-in 900ms ease-out both;
}

.wish.is-still .wish-card {
  animation: none;
  transform: none;
}

@keyframes wish-card-in {
  0% { opacity: 0; transform: scale(0.86); }
  100% { opacity: 1; transform: scale(1); }
}

.wish-words {
  position: relative;
  z-index: 1;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.18em 0.34em;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: clamp(2.4rem, 7.6vw, 5rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: 0.02em;
  color: #fff6d4;
  text-align: center;
  text-shadow:
    0 0 28px rgba(240, 180, 60, 0.38),
    0 2px 0 rgba(28, 20, 12, 0.28);
}

.wish-line {
  position: relative;
  z-index: 1;
  margin: 0.4em 0 0;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: clamp(1.15rem, 3.2vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff6d4;
  text-align: center;
  text-shadow: 0 0 18px rgba(240, 180, 60, 0.3);
  opacity: 0;
}

.wish.is-on .wish-line {
  animation: wish-word 720ms ease forwards;
  animation-delay: 1100ms;
}

.wish.is-still .wish-line {
  animation: none;
  opacity: 1;
  transform: none;
}

.wish-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.28em);
}

.wish.is-on .wish-word {
  animation: wish-word 720ms ease forwards;
}

.wish.is-on .wish-word:nth-child(1) { animation-delay: 160ms; }
.wish.is-on .wish-word:nth-child(2) { animation-delay: 480ms; }
.wish.is-on .wish-word:nth-child(3) { animation-delay: 860ms; }

.wish.is-still .wish-word {
  animation: none;
  opacity: 1;
  transform: none;
}

@keyframes wish-word {
  0% { opacity: 0; transform: translateY(0.28em); }
  100% { opacity: 1; transform: translateY(0); }
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-bit {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 9px;
  height: 9px;
  margin: -4px 0 0 -4px;
  border-radius: 2px;
  background: var(--bit, var(--gold));
  opacity: 0;
  animation: wish-bit 2.5s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

.confetti-bit.dot {
  border-radius: 50%;
  width: 8px;
  height: 8px;
}

.confetti-bit.star {
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 0;
  clip-path: polygon(
    50% 0%,
    62% 34%,
    100% 36%,
    70% 58%,
    80% 96%,
    50% 74%,
    20% 96%,
    30% 58%,
    0% 36%,
    38% 34%
  );
}

@keyframes wish-bit {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.35);
  }
  14% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--spin)) scale(1);
  }
}

.dock {
  position: absolute;
  z-index: 5;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  border-radius: 22px;
  background: rgba(7, 13, 22, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.fact {
  margin: 0;
  min-height: 1.4em;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 700;
  color: var(--gold);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  margin: 0;
  flex: 1;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.3;
  color: var(--cream-dim);
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  padding: 0 18px;
  font-size: 1.05rem;
  font-weight: 750;
  font-weight: 700;
  cursor: pointer;
}

button:focus-visible,
.planet:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

button:active,
.planet:active {
  transform: scale(0.98);
}

.planets {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scroll-snap-type: x proximity;
}

.planet {
  flex: 1 1 0;
  scroll-snap-align: start;
  min-width: 0;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 8px 7px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: var(--bead, #d9d0c0);
  color: var(--bead-ink, var(--ink));
}

.planet .num {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.75;
}

.planet .pname {
  font-size: clamp(0.72rem, 1.4vw, 0.95rem);
  font-weight: 700;
  line-height: 1.1;
}

.planet.home {
  box-shadow: inset 0 0 0 2px var(--gold-deep);
}

.planet[aria-pressed="true"] {
  border-color: var(--gold);
}

@media (min-width: 1100px) {
  .lesson {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
}

@media (max-width: 720px) {
  .planet {
    flex: 0 0 auto;
    min-width: 76px;
  }
}

@media (max-height: 700px) {
  .app {
    gap: 4px;
    padding-top: calc(6px + env(safe-area-inset-top));
  }

  .dock {
    gap: 6px;
    padding: 8px 10px 8px;
  }

  .planet,
  button {
    min-height: 46px;
  }

  .lesson p {
    font-size: 1.02rem;
  }
}

@media (max-width: 640px) {
  .top {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .controls {
    flex-wrap: wrap;
  }

  .hint {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .month-name.pop {
    animation: none;
  }

  button:active,
  .planet:active {
    transform: none;
  }

  .wish-word,
  .wish.is-on .wish-word,
  .wish.is-on .wish-card,
  .wish-line,
  .wish.is-on .wish-line {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .confetti-bit {
    display: none;
  }
}
