/* ==========================================================================
   ui.css — persistent chrome, buttons, calendar disclosure, share + footer
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reading progress hairline
   -------------------------------------------------------------------------- */

.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 2px;
  z-index: calc(var(--z-chrome) + 1);
  pointer-events: none;
  background: color-mix(in srgb, var(--chrome-ink) 8%, transparent);
}

.progress__fill {
  display: block;
  height: 100%;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   Chapter rail
   -------------------------------------------------------------------------- */

.procession-rail {
  position: fixed;
  left: 50%;
  bottom: calc(0.85rem + env(safe-area-inset-bottom));
  z-index: var(--z-rail);
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  color: var(--chrome-ink);
  background: color-mix(in srgb, var(--chrome-bg) 78%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(-50%);
  transition: color 1.2s var(--ease-soft);
}

.procession-rail a {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.26;
  transition: opacity 0.45s var(--ease-soft), transform 0.45s var(--ease-out);
}

.procession-rail a:hover,
.procession-rail a:focus-visible { opacity: 0.75; }

.procession-rail a[aria-current="true"] {
  opacity: 1;
  transform: scale(1.55);
}

@media (min-width: 900px) {
  .procession-rail {
    left: auto;
    right: 1.6rem;
    top: 50%;
    bottom: auto;
    flex-direction: column;
    gap: 1rem;
    padding: 0.85rem 0.45rem;
    transform: translateY(-50%);
  }
}

/* --------------------------------------------------------------------------
   Music toggle
   -------------------------------------------------------------------------- */

.music-toggle {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: var(--z-chrome);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--chrome-ink);
  background: var(--chrome-bg);
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition:
    color 1.2s var(--ease-soft),
    background-color 1.2s var(--ease-soft),
    border-color 0.4s var(--ease-soft),
    transform 0.4s var(--ease-out);
}

.music-toggle:hover { border-color: color-mix(in srgb, currentColor 52%, transparent); }
.music-toggle:active { transform: scale(0.94); }

.music-toggle .icon { width: 1.15rem; height: 1.15rem; }

.eq {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 15px;
}

.eq i {
  width: 2px;
  height: 4px;
  border-radius: 1px;
  background: currentColor;
  animation: eq-bounce 1.15s var(--ease-soft) infinite;
  animation-play-state: paused;
}

.eq i:nth-child(1) { animation-delay: -0.2s; }
.eq i:nth-child(2) { animation-delay: -0.55s; }
.eq i:nth-child(3) { animation-delay: -0.85s; }

@keyframes eq-bounce {
  0%, 100% { height: 4px; opacity: 0.55; }
  50%      { height: 15px; opacity: 1; }
}

.music-toggle[data-state="playing"] .eq { display: flex; }
.music-toggle[data-state="playing"] .eq i { animation-play-state: running; }
.music-toggle[data-state="playing"] .music-toggle__icon { display: none; }

.music-toggle[data-state="loading"] .music-toggle__icon { opacity: 0.35; }

.music-toggle[data-state="loading"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: currentColor;
  animation: spin 1.1s linear infinite;
}

.music-toggle[data-state="unavailable"] { opacity: 0.45; }
.music-toggle[data-state="unavailable"] .music-toggle__icon { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  .music-toggle {
    right: 1.6rem;
    bottom: calc(1.6rem + env(safe-area-inset-bottom));
  }
}

/* --------------------------------------------------------------------------
   Buttons and quiet links
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.78rem 1.15rem;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  line-height: 1;
  text-transform: uppercase;
  transition:
    background-color 0.4s var(--ease-soft),
    border-color 0.4s var(--ease-soft),
    color 0.4s var(--ease-soft);
}

.btn .icon { width: 0.9rem; height: 0.9rem; }

.btn:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
  border-color: color-mix(in srgb, currentColor 55%, transparent);
}

.link-quiet {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, currentColor 62%, transparent);
  border-bottom: 1px solid color-mix(in srgb, currentColor 26%, transparent);
  padding-bottom: 0.2rem;
  transition: color 0.35s var(--ease-soft), border-color 0.35s var(--ease-soft);
}

.link-quiet:hover {
  color: currentColor;
  border-color: currentColor;
}

/* --------------------------------------------------------------------------
   Calendar disclosure — works without JavaScript, upgrades to Google with it
   -------------------------------------------------------------------------- */

.cal { display: inline-block; }

.cal__summary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.78rem 1.15rem;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 999px;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.4s var(--ease-soft), border-color 0.4s var(--ease-soft);
}

.cal__summary::-webkit-details-marker { display: none; }
.cal__summary:hover { border-color: color-mix(in srgb, currentColor 55%, transparent); }
.cal__summary .icon { width: 0.9rem; height: 0.9rem; }

.cal__chev { transition: transform 0.35s var(--ease-out); opacity: 0.6; }
.cal[open] .cal__chev { transform: rotate(180deg); }

.cal__panel {
  display: grid;
  gap: 0.15rem;
  margin-top: 0.6rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  border-radius: 12px;
  background: var(--panel-bg, rgba(255, 253, 248, 0.72));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.cal__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  padding: 0.62rem 0.1rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

.cal__link:last-of-type { border-bottom: 0; }
.cal__link:hover { color: var(--scene-accent, var(--gold)); }
.cal__link span { opacity: 0.5; }

.cal__note {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
  opacity: 0.45;
  padding-top: 0.35rem;
}

/* --------------------------------------------------------------------------
   Share + toast
   -------------------------------------------------------------------------- */

.share {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in srgb, currentColor 70%, transparent);
  border-bottom: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  padding-bottom: 0.35rem;
  transition: color 0.35s var(--ease-soft), border-color 0.35s var(--ease-soft);
}

.share:hover { color: currentColor; border-color: currentColor; }
.share .icon { width: 0.9rem; height: 0.9rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.2rem + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-soft), transform 0.35s var(--ease-out);
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  position: relative;
  z-index: var(--z-content);
  padding: 2.5rem var(--gutter) calc(5.5rem + env(safe-area-inset-bottom));
  text-align: center;
  color: color-mix(in srgb, var(--cream) 55%, transparent);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-footer p + p { margin-top: 0.5rem; }
.site-footer__note {
  text-transform: none;
  letter-spacing: 0.03em;
  font-size: 0.66rem;
  opacity: 0.6;
}

/* No JavaScript: chrome that cannot work is removed. */
html:not(.js) .music-toggle,
html:not(.js) .progress { display: none; }

@media (prefers-reduced-motion: reduce) {
  .eq i { animation: none; height: 10px; }
}
