/* ---- Sealed cover ---- */
.cover { display: none; }
html.intro { overflow: hidden; }
html.intro .cover {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  background: var(--paper) url("../art/paper.webp") repeat;
  background-size: 400px 400px;
}
/* The card's double rule, as the edge of the cover. */
.cover::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1.5px solid rgb(138 102 66 / .5);
  outline: 1.5px solid rgb(138 102 66 / .32);
  outline-offset: -6px;
  box-shadow: inset 1px 1px 0 var(--emboss-light), -1px -1px 0 var(--emboss-light);
  pointer-events: none;
}

.seal { grid-row: 2; position: relative; display: grid; justify-items: center; gap: 1.5rem; padding: 1rem; border: 0; background: none; color: var(--brown); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.seal svg { display: block; width: min(56vw, 13.5rem); height: auto; overflow: visible; filter: drop-shadow(0 7px 8px rgb(74 47 29 / .3)); transition: transform .25s ease; }
.seal:hover svg { transform: scale(1.03); }
.seal:active svg { transform: scale(.97); }
.seal:focus-visible { outline: none; }
.seal:focus-visible .seal-label { text-decoration: underline; text-underline-offset: .3em; }
.seal-text { font-family: var(--display); font-weight: 500; font-size: 39px; text-anchor: middle; fill: #e9dcc0; }
.seal-text-shade { fill: #2f2515; fill-opacity: .6; }
.seal-label { font-size: 1.125rem; letter-spacing: .08em; }
.skip { grid-row: 3; align-self: end; margin-bottom: max(2.25rem, env(safe-area-inset-bottom)); padding: .75rem 1.25rem; border: 0; background: none; font: inherit; font-size: 1rem; text-decoration: underline; cursor: pointer; z-index: 1; }

/* Opening: the wax breaks, then the cover lifts away. Only transform and opacity move. */
.seal-half { transition: transform .7s cubic-bezier(.4, 0, .2, 1) .1s, opacity .6s ease .35s; transform-origin: 100px 100px; }
.opening .seal-half-left { transform: translate(-30px, 6px) rotate(-9deg); opacity: 0; }
.opening .seal-half-right { transform: translate(30px, 10px) rotate(9deg); opacity: 0; }
.seal-label, .skip { transition: opacity .25s ease; }
.opening .seal-label, .opening .skip { opacity: 0; }
html.intro .cover.opening { opacity: 0; transition: opacity .7s ease .55s; pointer-events: none; }

/* ---- Lines that draw themselves ---- */
html.motion .frame g.shade, html.motion .frame g.face, html.motion .frame g.light { stroke-dasharray: 1; }
html.motion .frame-top path, html.motion .frame-sides path, html.motion .frame-bottom path { stroke-dashoffset: 1; }
html.motion .relief, html.motion .groove { stroke-dasharray: 1; }
html.motion .frame .fleuron { stroke-dashoffset: 1; fill-opacity: 0; }

/* The arch grows out from the top ornament (its paths end there, so the dash runs backwards). */
html.motion.play .frame-top g path { animation: draw-back 1.5s cubic-bezier(.45, 0, .25, 1) .25s forwards; }
html.motion.play .frame-sides path { animation: draw 1.4s ease-out 1.55s forwards; }
html.motion.play .frame-top .fleuron { animation: draw 1.4s ease-in-out forwards, fill-in .9s ease .8s forwards; }
html.motion .frame-bottom.seen path { animation: draw 1.4s ease-in-out forwards; }
html.motion .frame-bottom.seen .fleuron { animation: draw 1.4s ease-in-out forwards, fill-in .9s ease .8s forwards; }

/* Dashed from -1 to 0 reveals a line from its far end. */
@keyframes draw-back { from { stroke-dashoffset: -1; } to { stroke-dashoffset: 0; } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fill-in { to { fill-opacity: 1; } }

/* ---- Reveals ---- */
/* Held back from the first paint, so nothing flashes before it is revealed. */
html.motion:not(.watching) .content > * { opacity: 0; }
html.motion .reveal:not(.frame-bottom) { opacity: 0; transform: translateY(14px); }
html.motion .reveal.seen:not(.frame-bottom) {
  opacity: 1;
  transform: none;
  transition: opacity .9s ease var(--delay, 0ms), transform .9s cubic-bezier(.2, .7, .2, 1) var(--delay, 0ms);
}
/* The Bismillah only fades. Its lettering is never moved or redrawn. */
html.motion .bismillah.reveal { transform: none; }

/* ---- Countdown ---- */
.countdown { margin-top: 1.75rem; }
.countdown dl { display: flex; justify-content: center; gap: clamp(.35rem, 2.5cqw, 1rem); }
.countdown dl[hidden] { display: none; }
.countdown dl div { min-width: 3.6rem; display: flex; flex-direction: column; align-items: center; }
.countdown dd { font-family: var(--display); font-weight: 500; font-size: clamp(1.9rem, 8cqw, 2.6rem); line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; color: var(--brown); }
.countdown dt { font-size: .95rem; }
.countdown .countdown-done { font-size: 1.25rem; color: var(--brown); }

/* ---- Petals ---- */
.petals { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.petal { position: absolute; top: 0; border-radius: 80% 15% 75% 20%; opacity: 0; will-change: transform, opacity; }
.petal-0 { background: linear-gradient(135deg, #f3ded5, #dcb5a6); }
.petal-1 { background: linear-gradient(135deg, #fffaf0, #e4d0ae); }
.petal-2 { background: linear-gradient(135deg, #ead9c6, #c8a98a); }

/* A safety net in case the setting changes while the page is open. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; transition-delay: 0ms !important; }
  .petals { display: none; }
}
