/* Our color palette, all in one place.
   Change a color here and it changes everywhere. */
:root {
  --space: #0f1a33;      /* deep navy background */
  --card: #1a2747;       /* slightly lighter navy for cards and buttons */
  --text: #e8ecf5;       /* soft white, gentler than pure white */
  --soft: #9fb0d0;       /* muted blue for smaller text */
  --glow: #7fb2ff;       /* soft blue highlight */
  --done: #74d3a0;       /* calm green for the Done button */
  --dot: #2c3b60;        /* empty progress dots */
}

/* Anything marked "hidden" stays hidden, no matter what */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--space);
  /* A few faint, still stars. No twinkling, so it stays calm. */
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.35) 1px, transparent 2px),
    radial-gradient(circle at 82% 12%, rgba(255,255,255,0.25) 1px, transparent 2px),
    radial-gradient(circle at 68% 78%, rgba(255,255,255,0.30) 1px, transparent 2px),
    radial-gradient(circle at 25% 85%, rgba(255,255,255,0.20) 1px, transparent 2px),
    radial-gradient(circle at 90% 50%, rgba(255,255,255,0.25) 1px, transparent 2px);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px;
  /* Keep clear of the clock/battery bar and the bottom swipe bar */
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

/* Each screen stacks its parts in a column, centered */
section {
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

h1 {
  font-size: 44px;
  margin: 0;
}

p {
  margin: 0;
}

.big-emoji {
  font-size: 120px;
  line-height: 1;
}

#greeting,
#finish-message {
  font-size: 28px;
  color: var(--soft);
}

/* ---------- Buttons (shared) ---------- */
button {
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;          /* no accidental double-tap zoom */
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 4px solid var(--glow);
  outline-offset: 4px;
}

/* ---------- Home screen ---------- */
.mission-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.mission-button {
  font-size: 72px;
  background: var(--card);
  border: 4px solid transparent;
  border-radius: 28px;
  padding: 24px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mission-button span {
  font-size: 26px;
  font-weight: 600;
}

/* The mission that fits the time of day gets a soft glow */
.mission-button.suggested {
  border-color: var(--glow);
  box-shadow: 0 0 24px rgba(127, 178, 255, 0.35);
}

/* ---------- Step screen ---------- */
.top-bar {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr 64px;  /* home | dots | empty space */
  align-items: center;
}

#progress-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dot);
}

.dot.done    { background: var(--done); }
.dot.current { background: var(--glow); transform: scale(1.3); }

.step-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--card);
  border-radius: 32px;
  padding: 32px 16px;
}

#step-emoji {
  font-size: 160px;
  line-height: 1.1;
}

#step-text {
  /* 40px on a tablet, a little smaller on a narrow phone */
  font-size: clamp(32px, 9vw, 40px);
  font-weight: 600;
  margin-top: 16px;
}

#step-extra {
  font-size: 30px;
  font-weight: 600;
  color: var(--glow);
  margin-top: 16px;
}

.done-button {
  width: 100%;
  min-height: 96px;
  font-size: 36px;
  font-weight: 700;
  background: var(--done);
  color: var(--space);
  border: none;
  border-radius: 28px;
}

.done-button:active {
  transform: scale(0.97);
}

.small-button {
  background: transparent;
  border: 2px solid var(--dot);
  color: var(--soft);
  font-size: 22px;
  border-radius: 16px;
  padding: 12px 20px;
  min-height: 56px;
}

/* ---------- Gear button (hold to open) ---------- */
.gear-button {
  align-self: flex-end;          /* sits in the bottom-right corner */
  font-size: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--dot);
  opacity: 0.6;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;   /* no pop-up menu on a long press */
  transition: box-shadow 200ms, opacity 200ms;
}

/* While a finger holds it, a ring slowly grows for 2 seconds */
.gear-button.holding {
  opacity: 1;
  box-shadow: 0 0 0 10px var(--glow);
  transition: box-shadow 2s linear, opacity 2s linear;
}

/* ---------- Parent screen ---------- */
.parent-screen {
  justify-content: flex-start;
  text-align: left;
}

#parent-done-button {
  font-size: 26px;
  min-height: 72px;
}

.parent-screen h1 {
  font-size: 32px;
  align-self: flex-start;
}

.setting-card {
  width: 100%;
  box-sizing: border-box;
  background: var(--card);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-label {
  font-size: 24px;
  font-weight: 600;
}

.setting-help {
  width: 100%;
  font-size: 16px;
  color: var(--soft);
}

/* On/Off switch */
.switch {
  min-width: 96px;
  min-height: 56px;
  font-size: 22px;
  font-weight: 700;
  border-radius: 28px;
  border: 2px solid var(--dot);
  background: var(--space);
  color: var(--soft);
}

.switch[aria-pressed="true"] {
  background: var(--done);
  border-color: var(--done);
  color: var(--space);
}

/* Two weeks of day tiles, 7 across */
.week-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-tile {
  min-height: 72px;
  padding: 6px 0;
  border-radius: 14px;
  border: 2px solid var(--dot);
  background: var(--space);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  color: var(--soft);
}

.day-tile .day-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.day-tile.today {
  border-color: var(--glow);
}

.day-tile[aria-pressed="true"] {
  background: var(--glow);
  border-color: var(--glow);
  color: var(--space);
}

.day-tile[aria-pressed="true"] .day-number {
  color: var(--space);
}

/* ---------- Rocket scene (finish screen) ---------- */
.sky {
  position: relative;      /* so the rocket can be placed inside it */
  width: 100%;
  height: 360px;
  overflow: hidden;        /* the rocket disappears off the top edge */
}

.rocket {
  position: absolute;
  left: 50%;
  bottom: 36px;            /* sitting on the launch pad */
  font-size: 96px;
  line-height: 1;
  /* The 🚀 emoji leans sideways, so we turn it to point straight up */
  transform: translateX(-50%) rotate(-45deg);
}

.launch-pad {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 140px;
  height: 14px;
  margin-left: -70px;
  border-radius: 7px;
  background: var(--dot);
}

.smoke {
  position: absolute;
  left: 50%;
  bottom: 14px;
  font-size: 40px;
  opacity: 0;              /* invisible until it puffs */
  transform: translateX(-50%);
}

.finish-words {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
}

/* LAUNCH: a short pause on the pad, then a slow rise off the top.
   "ease-in" starts slow and speeds up, like a real rocket. */
.rocket.launching {
  animation: lift-off 3s ease-in 0.8s forwards;
}

@keyframes lift-off {
  from { transform: translate(-50%, 0) rotate(-45deg); }
  to   { transform: translate(-50%, -440px) rotate(-45deg); }
}

/* LANDING: comes down from above and slows gently onto the pad.
   "ease-out" starts faster and slows down at the end. */
.rocket.landing {
  animation: touch-down 3.5s ease-out forwards;
}

@keyframes touch-down {
  from { transform: translate(-50%, -440px) rotate(-45deg); }
  to   { transform: translate(-50%, 0) rotate(-45deg); }
}

/* Soft clouds of smoke: at the start of a launch, or the end of a landing */
.smoke.puff-launch  { animation: puff 2.4s ease-out 0.6s forwards; }
.smoke.puff-landing { animation: puff 2.4s ease-out 2.8s forwards; }

@keyframes puff {
  0%   { opacity: 0;   transform: translateX(-50%) scale(0.6); }
  30%  { opacity: 0.8; }
  100% { opacity: 0;   transform: translateX(-50%) scale(1.4); }
}

/* A gentle fade when a new step appears */
.fade-in {
  animation: fade-in 400ms ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* If the device is set to "reduce motion", skip the movement */
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .gear-button.holding { transition: none; }
  /* The rocket just sits on the pad, no flying or smoke */
  .rocket.launching,
  .rocket.landing,
  .smoke { animation: none !important; }
  .done-button:active { transform: none; }
}
