:root {
  --gold: #f2ca7a;
  --gold-deep: #a87a2c;
  --cream: #f5e9dc;
  --ink: #3d3024;
  --glass: rgba(255, 250, 242, .58);
  --hair: rgba(184, 138, 58, .45);
  --display: "Cormorant Garamond", Georgia, serif;
  --script: "Pinyon Script", cursive;
  --body: Lora, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: #e9dcc4 url(../img/bg.webp) center / cover fixed;
  font-family: var(--body); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.bar, .kicker, main { position: relative; }
.sr-only, .is3d .flat { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar: the name in gold script, and the sound toggle */
.bar { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  margin: 0; white-space: nowrap; /* one line, with room for the two buttons beside it on a phone */
  font: 400 clamp(1.6rem, 7.2vw, 3.4rem)/1.1 var(--script);
  color: var(--gold);
  text-shadow: 0 0 6px #fff, 0 0 18px rgba(255,255,255,.9), 0 1px 3px rgba(120,80,20,.6);
}
/* gold foil: a slow light moving through the letters (the glow becomes a filter, since a
   text-shadow would paint over gradient-clipped text) */
.is3d .bar .brand {
  background: linear-gradient(100deg, #c9963c 25%, #fbe9b4 45%, #d9aa52 55%, #c9963c 75%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
  filter: drop-shadow(0 0 5px #fff) drop-shadow(0 1px 2px rgba(120,80,20,.45));
  animation: shimmer 9s ease-in-out infinite;
}
.sound {
  flex: none; width: 44px; height: 44px; border-radius: 50%; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--hair); background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(120, 85, 30, .12);
}
.sound i { width: 2px; height: 16px; border-radius: 1px; background: var(--gold-deep); transform: scaleY(.22); transition: transform .4s; }
.sound[aria-pressed="true"] i { animation: eq 1.1s ease-in-out infinite; }
.sound i:nth-child(2) { animation-delay: -.3s; }
.sound i:nth-child(3) { animation-delay: -.6s; }
.sound i:nth-child(4) { animation-delay: -.85s; }
@keyframes eq { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
.sound:focus-visible, .enter:focus-visible, nav a:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

.kicker {
  margin: 0; position: absolute; left: 0; right: 0; top: calc(max(16px, env(safe-area-inset-top)) + clamp(64px, 10svh, 96px));
  text-align: center; font: 600 clamp(.8rem, 2.6vw, 1rem)/1 var(--display);
  letter-spacing: .42em; text-indent: .42em; text-transform: uppercase; color: #7a5a30;
  text-shadow: 0 0 12px rgba(255,255,255,.9);
}
.kicker::before, .kicker::after {
  content: ''; display: inline-block; width: clamp(28px, 8vw, 64px); height: 1px; margin: 0 1.1em; vertical-align: middle;
  background: linear-gradient(90deg, transparent, var(--gold-deep));
}
.kicker::after { transform: scaleX(-1); }
html:not(.is3d) .kicker { display: none; } /* it sits above the 3D portrait; the flat page has no room for it */

main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; max-width: 720px; }
.flat { display: flex; flex-direction: column; align-items: center; }
.portrait { width: min(78vw, 46svh, 420px); height: auto; margin-bottom: -6%; }
.scroll { width: min(92vw, 480px); height: auto; }

/* glass buttons with a gold hairline */
nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; margin-top: 20px; }
nav a {
  flex: 1 1 150px; min-height: 52px; padding: 12px 22px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 999px; border: 1px solid var(--hair);
  background: var(--glass); -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
  color: var(--ink); text-decoration: none;
  font: 600 1.2rem/1 var(--display); letter-spacing: .03em;
  box-shadow: 0 10px 30px rgba(120, 85, 30, .14), inset 0 1px 0 rgba(255,255,255,.7);
  transition: background .4s, box-shadow .4s, border-color .4s, translate .5s cubic-bezier(.2,.8,.2,1);
}
nav a:hover { background: rgba(255,255,255,.85); border-color: var(--gold-deep); box-shadow: 0 0 30px rgba(255,214,130,.9), inset 0 1px 0 #fff; }
@media (min-width: 700px) { nav { flex-wrap: nowrap; } }

/* the home dock: three cards, each with a hand-drawn gold icon and its date */
.dock { flex-wrap: nowrap; gap: 8px; max-width: 520px; margin-top: 12px; }
.dock a {
  flex: 1 1 0; min-width: 0; min-height: 0; flex-direction: column; gap: 3px; padding: 8px 6px 7px; border-radius: 16px;
  font-size: clamp(.82rem, 3vw, 1rem);
}
.dock svg { width: 18px; height: 18px; fill: none; stroke: var(--gold-deep); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.dock a:hover svg { transform: translateY(-2px) scale(1.08); }
.dock .label { text-wrap: balance; line-height: 1.1; }
.dock .sub { font: 600 clamp(.5rem, 1.7vw, .6rem)/1 var(--display); letter-spacing: .16em; color: #8a6a3a; white-space: nowrap; }
.is3d .dock a { opacity: 0; transform: translateY(14px); transition: opacity 1.2s, transform 1.2s cubic-bezier(.2,.8,.2,1), background .4s, box-shadow .4s, border-color .4s, translate .5s cubic-bezier(.2,.8,.2,1); }
.is3d.ready .dock a { opacity: 1; transform: none; }
.is3d.ready .dock a:nth-child(2) { transition-delay: .12s, .12s, 0s, 0s, 0s, 0s; }
.is3d.ready .dock a:nth-child(3) { transition-delay: .24s, .24s, 0s, 0s, 0s, 0s; }

/* 3D mode: the scene draws the portrait; everything else rises in once the gates open */
.is3d main { justify-content: flex-end; }
.is3d .brand, .is3d .kicker, .is3d nav, .is3d .credit { opacity: 0; transform: translateY(16px); transition: opacity 1.4s, transform 1.4s; }
.is3d nav, .is3d .credit { pointer-events: none; } /* no invisible taps during the intro */
.is3d.ready .brand, .is3d.ready .kicker, .is3d.ready nav, .is3d.ready .credit { opacity: 1; transform: none; pointer-events: auto; }
.sound { position: relative; z-index: 7; } /* stays usable above the entrance curtain */
.is3d .song-open { opacity: 0; pointer-events: none; transition: opacity 1.4s; }
.is3d.ready .song-open { opacity: 1; pointer-events: auto; }

/* the hymn: the ♪ button (a gold ring fills as it plays) and A Chanchin's cover (a gold line
   runs along its foot); --p is the progress, 0 to 1, kept current by song.js */
.tools { display: flex; gap: 10px; }
.song-open {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--hair); background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(120, 85, 30, .12);
}
.song-open svg { width: 20px; height: 20px; fill: none; stroke: var(--gold-deep); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.song-open::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%; opacity: 0; transition: opacity .6s;
  background: conic-gradient(var(--gold-deep) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
}
.song-open[aria-pressed="true"] { box-shadow: 0 0 22px rgba(242,202,122,.85); }
.song-open[aria-pressed="true"]::after { opacity: 1; }
.song-open:focus-visible, .song-cover:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }
.song { position: relative; aspect-ratio: 16 / 9; border-radius: 20px; overflow: hidden; border: 1px solid var(--hair); box-shadow: 0 30px 80px rgba(80, 55, 20, .3); }
.song::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p, 0) * 100%); pointer-events: none;
  background: linear-gradient(90deg, #e9c983, #c3923d); box-shadow: 0 0 12px rgba(242,202,122,.95);
}
.song-cover {
  position: absolute; inset: 0; width: 100%; padding: 24px; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 14px); text-align: center;
  background: linear-gradient(rgba(255,248,235,.12), rgba(70,45,15,.38)), url(../img/bg.webp) center 38% / cover;
  color: #fff;
}
.song-kicker { font: 600 .78rem/1 var(--display); letter-spacing: .45em; text-indent: .45em; text-transform: uppercase; color: #fff8e6; text-shadow: 0 1px 8px rgba(90,60,20,.7); }
.song-title { font: italic 500 clamp(1.25rem, 4.2vw, 2.3rem)/1.2 var(--display); color: #fff; text-shadow: 0 2px 18px rgba(80,50,15,.8); }
.song-play {
  display: grid; place-items: center; width: clamp(56px, 12vw, 76px); aspect-ratio: 1; border-radius: 50%;
  background: rgba(255,255,255,.92); box-shadow: 0 0 0 10px rgba(255,255,255,.22), 0 12px 40px rgba(80,50,15,.45);
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
}
.song-play svg { width: 42%; fill: var(--gold-deep); margin-left: 8%; }
.song-play .i-pause { display: none; }
.song-cover[aria-pressed="true"] .i-play { display: none; }
.song-cover[aria-pressed="true"] .i-pause { display: block; }
.song-cover[aria-pressed="true"] .song-play svg { margin-left: 0; }
.song-cover[aria-pressed="true"] .song-play { animation: pulse 2.6s ease-out infinite; }
.song-cover:hover .song-play { transform: scale(1.07); }
.song-credit { font: 600 .68rem/1 var(--display); letter-spacing: .22em; text-indent: .22em; text-transform: uppercase; color: #fff8e6; text-shadow: 0 1px 6px rgba(80,50,15,.7); }

/* the entrance: her name over frosted heaven, a loading line, then Enter */
.curtain { display: none; }
.is3d:not(.returning) .curtain {
  position: fixed; inset: 0; z-index: 5; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(255,252,246,.55), rgba(240,228,210,.7));
  -webkit-backdrop-filter: blur(22px) saturate(1.1); backdrop-filter: blur(22px) saturate(1.1);
  transition: opacity 1.6s ease, backdrop-filter 1.6s ease, -webkit-backdrop-filter 1.6s ease;
}
.curtain.gone { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); pointer-events: none; }
.curtain-kicker { margin: 0 0 14px; font: 600 .85rem/1 var(--display); letter-spacing: .5em; text-indent: .5em; text-transform: uppercase; color: #8a6a3a; animation: rise 1.4s ease 2.2s both; }
/* her name writes itself in, left to right, like ink from a nib */
@property --ink { syntax: '<percentage>'; inherits: false; initial-value: 115%; }
.curtain-name {
  margin: 0; font: 400 clamp(3.2rem, 15vw, 7rem)/1.15 var(--script);
  background: linear-gradient(100deg, #b8862f 20%, #f7e3a8 40%, #c99a45 55%, #b8862f 80%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255,255,255,.8));
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--ink) - 14%), transparent var(--ink));
  mask-image: linear-gradient(90deg, #000 calc(var(--ink) - 14%), transparent var(--ink));
  animation: ink 2.4s cubic-bezier(.45,.05,.3,1) .3s both, shimmer 4.5s ease-in-out 2.7s infinite;
}
@keyframes ink { from { --ink: 0%; } to { --ink: 115%; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.curtain-dates { margin: 6px 0 34px; font: 500 1.1rem/1 var(--display); letter-spacing: .3em; text-indent: .3em; color: #7a5a30; animation: rise 1.4s ease 2.4s both; }
.curtain-bar { position: relative; width: 160px; height: 1px; background: rgba(168,122,44,.25); overflow: hidden; transition: opacity .8s; }
.curtain-bar span { position: absolute; inset: 0; background: var(--gold-deep); transform-origin: left; transform: scaleX(0); transition: transform .5s; }
.enter {
  margin-top: -1px; min-width: 170px; min-height: 52px; padding: 14px 34px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--gold-deep); background: rgba(255,255,255,.45); color: var(--ink);
  font: 600 1rem/1 var(--display); letter-spacing: .45em; text-indent: .45em; text-transform: uppercase;
  opacity: 0; transform: translateY(10px); transition: opacity 1s, transform 1s, background .4s, box-shadow .4s;
  box-shadow: 0 0 0 0 rgba(242,202,122,.6);
}
.curtain.loaded .curtain-bar { opacity: 0; }
.curtain.loaded .enter { opacity: 1; transform: none; animation: pulse 2.6s ease-out 1s infinite; }
.enter:hover { background: #fff; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,202,122,.7); } 100% { box-shadow: 0 0 0 22px rgba(242,202,122,0); } }

.veil { position: fixed; inset: 0; z-index: 6; background: #fffaf0; opacity: 0; pointer-events: none; transition: opacity 1.3s ease-in; }
.leaving .veil { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .curtain-name, .curtain-kicker, .curtain-dates, .is3d .bar .brand, .sound[aria-pressed="true"] i, .curtain.loaded .enter { animation: none; }
}

/* credit to the maker */
.credit { max-width: 34em; margin: 12px auto 0; padding: 0 8px; text-align: center; font: 500 .8rem/1.4 var(--display); letter-spacing: .04em; color: #6d5130; text-shadow: 0 0 10px rgba(255,255,255,.9); }
.credit a { color: var(--gold-deep); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.credit a:hover, .credit a:focus-visible { border-bottom-color: var(--gold-deep); outline: none; }

/* small phones: tighter dock, shorter cards */
@media (max-width: 400px) {
  body { padding-inline: 12px; }
  .dock { gap: 6px; }
  .dock a { padding: 7px 3px 6px; border-radius: 14px; }
  .dock .sub { letter-spacing: .08em; }
  .song-cover { padding: 14px; }
  .song { aspect-ratio: 4 / 3; }
}
/* short screens (phones on their side, small laptops): drop the decoration, shrink the art */
@media (max-height: 560px) {
  .kicker { display: none; }
  .portrait { width: min(78vw, 38svh, 420px); }
  .scroll { width: min(92vw, 300px); }
  nav { margin-top: 10px; }
  .credit { margin-top: 10px; }
  .curtain-dates { margin-bottom: 18px; }
  .curtain-name { font-size: clamp(2.6rem, 12svh, 5rem); }
  .hero { padding-block: 90px 40px; }
  .cue { margin-top: 24px; height: 48px; }
}
