* { box-sizing: border-box; }

body {
  --lake-color: #3a4d6e;
  --orb-size: clamp(7.5rem, 18vh, 10.5rem);
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  color: #faf2eb;
  font-family: "Cormorant Garamond", Georgia, serif;
  background-color: var(--lake-color);
}

.background-status {
  display: none;
  position: absolute;
  inset: 0;
  width: calc(var(--orb-size) * .646);
  height: calc(var(--orb-size) * .646);
  margin: auto;
  pointer-events: none;
}

.background-status span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.background-status::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid transparent;
  border-top-color: #fff0e5;
  border-radius: 50%;
}

.background-status::after {
  content: "";
}

@media (prefers-reduced-motion: no-preference) {
  .background-status::before {
    animation: background-status-spin 1.8s linear infinite;
  }
}

@keyframes background-status-spin {
  to { transform: rotate(1turn); }
}

@media (scripting: enabled) {
  body[data-background-loading] > :is(.practice, .time-of-day, .secret) {
    visibility: hidden;
  }

  body[data-background-loading] > .background-status {
    display: grid;
    place-items: center;
    animation: background-status-delay 350ms step-end;
  }
}

@keyframes background-status-delay {
  from { opacity: 0; }
}

.landscape {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.landscape::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(#101b2b25, #101b2b42);
}

.landscape img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body[data-time-of-day="morning"] {
  --lake-color: #79889e;
  --landscape-width: 197.1svh;
  --landscape-offset: 4svh;
}

body[data-time-of-day="day"] {
  --lake-color: #568cae;
  --landscape-width: 201.6svh;
  --landscape-offset: calc(2svh + 3px);
}

body[data-time-of-day="evening"] {
  --lake-color: #64403b;
  --landscape-width: 208svh;
  --landscape-offset: calc(7svh - 4px);
}

body[data-time-of-day="night"] {
  --lake-color: #14253c;
}

/* Keep the ridge just below the sun, including on portrait screens. */
body:is([data-time-of-day="morning"], [data-time-of-day="day"], [data-time-of-day="evening"]) .landscape img {
  top: calc(50% + var(--landscape-offset));
  left: 50%;
  width: max(100%, var(--landscape-width));
  height: auto;
  transform: translate(-50%, -50%);
}

.time-of-day {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  left: max(1rem, env(safe-area-inset-left));
}

.time-of-day label {
  display: block;
  margin-bottom: .25rem;
  font-size: 1rem;
  font-weight: 600;
  text-shadow: 0 1px 4px #101c2a, 0 0 8px #101c2a;
}

.time-of-day select {
  appearance: none;
  min-height: 44px;
  padding: .4rem 2rem .4rem .75rem;
  border: 1px solid #fde3d449;
  border-radius: .65rem;
  background: #182635;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.time-of-day button {
  position: fixed;
  z-index: 1;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  display: block;
  min-height: 44px;
  padding: .4rem .75rem;
  border: 1px solid #fde3d449;
  border-radius: .65rem;
  background: #182635;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.time-of-day button:disabled {
  cursor: wait;
  opacity: .65;
}

.time-of-day::after {
  content: "";
  position: absolute;
  top: 2.65rem;
  right: .85rem;
  width: .4rem;
  height: .4rem;
  border-right: 1px solid;
  border-bottom: 1px solid;
  transform: rotate(45deg);
  pointer-events: none;
}

.practice { position: relative; }

.orb, summary {
  cursor: pointer;
  touch-action: manipulation;
}

.orb:focus-visible, summary:focus-visible, .time-of-day :is(select, button):focus-visible {
  outline: 2px solid #ffe0c8;
  outline-offset: 4px;
}

.orb {
  width: var(--orb-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  background: #19243630;
  border-radius: 50%;
  border: 1px solid #ffded44d;
  box-shadow: inset 0 0 24px #ffd5bc16;
}

.core, .background-status {
  border: 1px solid #ffdfcc80;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 43%, #f9c9b478, #dd9e8d46 50%, #e1bbba21 74%);
  box-shadow: 0 0 30px #f5b5a342, inset 0 0 16px #ffd4be36;
}

.core {
  width: 76%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: scale(.85);
  transition: transform 650ms ease-in-out;
}

.core span, .background-status::after {
  width: .45rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffe5d8;
  box-shadow: 0 0 16px 4px #ffcab7aa;
}

.practice[data-phase="in"] .core { transform: scale(1.23); transition-duration: 4s; }
.practice[data-phase="out"] .core { transition-duration: 6s; }

#phase {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin: .9rem 0 0;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 6px #0b1423;
}

.secret {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: max(clamp(1rem, 16vw, 14rem), env(safe-area-inset-right));
}

.secret summary {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  list-style: none;
  border-radius: 50%;
  color: #fff4e8;
  text-shadow: 0 0 7px #ffe2d2, 0 0 18px #ffc5a4;
}

.secret summary::-webkit-details-marker { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .landscape { animation: landscape-appear 240ms ease-out; }

  body:not([data-background-loading]) .practice {
    animation: circle-reveal .85s cubic-bezier(.2, .65, .3, 1) both;
  }

  body:not([data-background-loading]) .secret summary {
    animation: star-reveal .65s ease-out both;
  }

  .secret[open] summary span {
    animation: star-glow 1.2s ease-out;
  }
}

@keyframes landscape-appear {
  from { opacity: 0; }
}

@keyframes circle-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes star-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes star-glow {
  35% {
    transform: scale(1.35);
    text-shadow: 0 0 9px #fff4e8, 0 0 22px #ffc5a4, 0 0 38px #ffc5a4;
  }
}

.secret p {
  position: absolute;
  right: 0;
  top: 100%;
  width: max-content;
  max-width: min(18rem, 75vw);
  margin: .5rem 0 0;
  padding: .9rem 1.15rem;
  border: 1px solid #fde3d449;
  border-radius: 1rem;
  background: #182635;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.2;
}

@media (prefers-reduced-motion: reduce) {
  .practice[data-phase] .core { transition: none; transform: scale(.85); }
}
