/* The astronomical clock is a single engraved dial. Its size drives its typography. */
#clock-panel {
  --clock-ink: #fff0cf;
  --clock-gold: #e6c987;
  --clock-diameter: min(89vw, 48rem, 55svh);
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--clock-ink);
  color-scheme: dark;
  text-align: center;
  overflow: hidden;
  background: #071c2a;
}
#clock-panel .clock-cosmos {
  z-index: -2;
  position: absolute;
  inset: 0;
  background-image: linear-gradient(180deg, #0717288e 0%, #071c2a28 40%, #04152128 65%, #041321e0 100%),
    url("./assets/night.webp"), radial-gradient(ellipse at 50% 36%, #225063, #071c2c 70%);
  background-size: cover;
  background-position: center 65%;
  pointer-events: none;
}
#clock-panel .clock-content {
  display: flex;
  flex-flow: column;
  align-items: center;
  width: 100%;
  padding: max(77px, 10svh, env(safe-area-inset-top)) 14px max(30px, 4.7svh, env(safe-area-inset-bottom));
}
#clock-panel .clock-heading {
  display: grid;
  justify-items: center;
  margin: 0 0 min(2.8svh, 24px);
  color: inherit;
  text-shadow: 0 2px 20px #0a1524;
}
#clock-panel .clock-label,
#clock-panel .clock-major-label,
#clock-panel .clock-minor small,
#clock-panel .clock-rim-type,
#clock-panel .clock-date {
  font-family: var(--label, Arial, sans-serif);
  font-weight: 500;
  text-transform: uppercase;
}
#clock-panel .clock-label,
#clock-panel .clock-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 0;
  color: #f1dba8;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .19em;
}
#clock-panel .clock-label::before,
#clock-panel .clock-label::after {
  content: "";
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d9b778);
}
#clock-panel .clock-label::after { transform: rotate(180deg); }
#clock-panel .clock-heading h2 {
  margin: 9px 0 0;
  color: #fff3d8;
  font: normal clamp(43px, 6.8vw, 84px)/1.02 Letter, Georgia, serif;
  letter-spacing: -.056em;
}
#clock-panel .clock-heading h2 em { color: #f0d397; font-weight: inherit; }
#clock-panel .clock-instrument {
  position: relative;
  width: var(--clock-diameter);
  aspect-ratio: 1;
  flex: none;
  container-type: inline-size;
  align-self: center;
}
#clock-panel .clock-chart { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#clock-panel .clock-rim-type { font-size: 9.2px; letter-spacing: 3.6px; }
#clock-panel .clock-count { display: grid; justify-items: center; }
#clock-panel .clock-display {
  position: absolute;
  top: 32%;
  left: 16%;
  right: 16%;
  bottom: 22%;
  display: grid;
  place-items: center;
  color: var(--clock-ink);
  text-shadow: 0 1px 14px #0a141d;
  font-family: Letter, Georgia, serif;
}
#clock-panel .clock-major {
  display: block;
  font-size: calc(var(--clock-diameter) * .227);
  font-size: 22.7cqw;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -.055em;
  line-height: .82;
  padding-right: .052em;
}
#clock-panel .clock-major-label {
  display: block;
  margin-top: .55em;
  color: #f3d59e;
  font-size: max(9px, 2.35cqw);
  letter-spacing: .27em;
  line-height: 1.15;
}
#clock-panel .clock-rule {
  display: flex;
  align-items: center;
  width: 72%;
  gap: 5px;
  margin: 3.2cqw 0 2.3cqw;
}
#clock-panel .clock-rule::before,
#clock-panel .clock-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d6b47d);
}
#clock-panel .clock-rule::after { transform: rotate(180deg); }
#clock-panel .clock-rule i { width: 4px; height: 4px; background: #ebce94; transform: rotate(45deg); }
#clock-panel .clock-minor-row { display: flex; gap: 4.3cqw; justify-content: center; }
#clock-panel .clock-minor { position: relative; display: grid; gap: .55cqw; min-width: 8.5cqw; }
#clock-panel .clock-minor > span {
  font-variant-numeric: tabular-nums lining-nums;
  display: block;
  font-size: 6.7cqw;
  line-height: 1;
}
#clock-panel .clock-minor small { font-size: max(7px, 1.62cqw); letter-spacing: .12em; color: #e6cfaa; }
#clock-panel .clock-minor + .clock-minor::before {
  position: absolute;
  top: 30%;
  left: -2.25cqw;
  content: "";
  width: 2px;
  height: 2px;
  transform: rotate(45deg);
  background: #b99a63;
}
#clock-panel .clock-date { margin: min(2svh, 18px) 0 0; font-size: clamp(10px, 1vw, 12px); }
#clock-panel .clock-date span { width: 3px; height: 3px; transform: rotate(45deg); background: currentColor; }
#clock-panel .clock-next {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 7px 11px;
  margin-top: min(2.3svh, 25px);
  color: #fff2d9;
  font: italic clamp(17px, 1.5vw, 21px)/1.2 Letter, Georgia, serif;
  text-decoration: none;
}
#clock-panel .clock-next span { color: #e5c587; font: 15px Arial, sans-serif; }
#clock-panel .clock-next:focus-visible { outline: 2px solid #e4c48c; outline-offset: 2px; }
#clock-panel .clock-message { display: grid; align-content: center; gap: 1cqw; }
#clock-panel .clock-message span { font-size: 9.6cqw; line-height: .96; letter-spacing: -.055em; }
#clock-panel .clock-message em { font-size: 4.2cqw; color: #e8cb8e; }
#clock-panel .clock-message[hidden], #clock-panel .clock-count[hidden] { display: none; }

/* Scene motion sleeps whenever a different chapter is in view. */
#clock-panel .clock-pointer, #clock-panel .clock-celestial-orbit { transform-origin: 240px 240px; }
#clock-panel .clock-celestial-orbit { animation: clock-orbit 88s linear infinite; }
#clock-panel .clock-sky-map { animation: clock-starlight 7s ease-in-out infinite alternate; }
#clock-panel .clock-pointer { transform: rotate(var(--clock-angle, 0deg)); }
#clock-panel .clock-comet { pointer-events: none; position: absolute; z-index: -1; width: 1px; height: 1px; }
#clock-panel .clock-comet i {
  display: block;
  width: clamp(65px, 13vw, 175px);
  height: 1px;
  transform-origin: right center;
  background: linear-gradient(90deg, transparent, #fae7b35c 65%, #fff6cf);
  opacity: 0;
  animation: clock-comet 14s cubic-bezier(.4,0,.8,1) infinite;
}
#clock-panel .clock-comet i::after {
  content: ""; position: absolute; right: 0; top: -1px;
  width: 3px; height: 3px; border-radius: 50%; box-shadow: 0 0 8px #f5dba2; background: #fff4d2;
}
#clock-panel .clock-comet-one { left: 10%; top: 7%; transform: rotate(35deg); }
#clock-panel .clock-comet-two { right: 27%; top: 14%; transform: rotate(141deg); }
#clock-panel .clock-comet-two i { animation-delay: -8s; animation-duration: 18s; }
#clock-panel .clock-content, #clock-panel .clock-chart { position: relative; }
#clock-panel.is-clock-visible .clock-chart { animation: clock-assemble 1.3s cubic-bezier(.2,.72,.25,1) both; }
#clock-panel.is-clock-visible .clock-engraving path { animation: clock-ink 1.7s .1s cubic-bezier(.2,.7,.15,1) both; }
#clock-panel.is-clock-visible .clock-display { animation: clock-read 1.15s .18s ease both; }
#clock-panel .clock-value-tick { animation: clock-tick .4s ease-out; }
#clock-panel:not(.is-clock-visible) * { animation-play-state: paused; }
@keyframes clock-assemble { from { opacity: 0; transform: scale(.92) rotate(-6deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes clock-ink { from { stroke-dasharray: 1 10; opacity: .15; } to { stroke-dasharray: 11 0; opacity: 1; } }
@keyframes clock-read { from { opacity: .01; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes clock-orbit { to { transform: rotate(360deg); } }
@keyframes clock-starlight { from { opacity: .5; } to { opacity: 1; } }
@keyframes clock-tick { from { opacity: .57; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
@keyframes clock-comet {
  0%, 70%, 100% { opacity: 0; transform: translateX(-70px) scaleX(.08); }
  72% { opacity: .82; transform: translateX(-20px) scaleX(.7); }
  77% { opacity: 0; transform: translateX(160px) scaleX(1.05); }
}
@media (min-aspect-ratio: 5/4) {
  #clock-panel .clock-cosmos {
    background-image: linear-gradient(180deg, #07172870, #05192638 56%, #041321d9), url("./assets/night-wide.webp"), radial-gradient(ellipse at 50% 36%, #225063, #071c2c 70%);
    background-position: center;
  }
}
@media (max-width: 700px) {
  #clock-panel { --clock-diameter: min(96vw, 59svh, 465px); }
  #clock-panel .clock-content { padding-left: 4px; padding-right: 4px; }
  #clock-panel .clock-next { margin-top: min(3.5svh, 27px); }
}
@media (max-height: 650px) and (min-width: 701px) {
  #clock-panel { --clock-diameter: min(53svh, 390px); }
  #clock-panel .clock-heading { margin-bottom: 8px; }
  #clock-panel .clock-heading h2 { font-size: 44px; }
  #clock-panel .clock-content { padding-top: 62px; padding-bottom: 14px; }
}
@media (max-height: 550px) and (orientation: landscape) {
  #clock-panel { --clock-diameter: min(66svh, 42vw); }
  #clock-panel .clock-content {
    width: min(810px, 100%); display: grid; grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto; align-content: center; align-items: center; justify-items: center;
    padding: 60px 6% 12px; column-gap: 4vw;
  }
  #clock-panel .clock-heading { align-self: end; margin: 0; }
  #clock-panel .clock-heading h2 { max-width: 7em; font-size: clamp(34px, 5vw, 55px); }
  #clock-panel .clock-instrument { grid-column: 2; grid-row: 1 / 4; }
  #clock-panel .clock-date { margin: 9px 0 0; }
  #clock-panel .clock-next { align-self: start; margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #clock-panel *, #clock-panel *::before, #clock-panel *::after { animation: none !important; transition: none !important; }
}
