﻿/* §6 Cover and opening + §9 music button */
.cover {
  --vh: 1vh;
  --envw: min(84vw, 340px, calc(66 * var(--vh)));
  --seal: min(26vw, 96px);
  position: fixed; inset: 0; height: 100vh; z-index: 100; overflow: hidden;
  background: var(--night-grad); color: var(--gold-light);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
@supports (height: 1svh) { .cover { --vh: 1svh; height: 100svh; } }
.cover[hidden] { display: none !important; }

.cv-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.cv-lattice, .cv-vignette, .cv-dust, .cv-dots, .cv-veil { position: absolute; inset: 0; pointer-events: none; }
.cv-lattice { inset: -24px 0 0; background: var(--lattice) 0 0 / 48px 48px; opacity: .06; }
.cover.is-idle .cv-lattice { animation: cv-drift 40s ease-in-out infinite alternate; }
@keyframes cv-drift { to { transform: translateY(-24px); } }
.cv-vignette { background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(5, 7, 15, .85)); }
.cv-dust { width: 100%; height: 100%; }
.cv-dots { display: none; }
.cv-dots i { position: absolute; left: var(--x); top: var(--y); width: var(--s, 3px); height: var(--s, 3px); border-radius: 50%; background: var(--gold-glint); opacity: var(--o, .45); }
html.is-reduced .cv-dots { display: block; }
html.is-reduced .cv-dust { display: none; }
.cv-veil { z-index: 30; background: #05070F; animation: cv-veil .6s 3s forwards; }
@keyframes cv-veil { to { opacity: 0; visibility: hidden; } }

/* text column */
.cv-top { position: absolute; z-index: 2; top: calc(7 * var(--vh)); inset-inline: 0; display: grid; justify-items: center; pointer-events: none; }
.cv-kicker { display: flex; align-items: center; gap: 10px; font: 500 13px/1.6 var(--f-body); color: var(--gold); word-spacing: .2em; }
.cv-hl { position: relative; width: 28px; height: 1px; }
.cv-hl::after { content: ''; position: absolute; top: -2px; width: 5px; height: 5px; background: currentColor; transform: rotate(45deg); }
.cv-hl.r { background: linear-gradient(to right, currentColor, rgba(201, 164, 106, .3)); }
.cv-hl.r::after { right: -4px; }
.cv-hl.l { background: linear-gradient(to left, currentColor, rgba(201, 164, 106, .3)); }
.cv-hl.l::after { left: -4px; }
.cv-names { font-size: clamp(52px, 15vw, 96px); line-height: 1.7; padding: .25em .2em; margin-block: -.1em -.25em; white-space: nowrap; opacity: 0; }
.cv-and { font-size: .6em; }
.cv-names.is-ready { opacity: 1; }
html:not(.is-reduced) .cv-names:not(.ink-done) {
  -webkit-mask-image: linear-gradient(to left, #000 40%, transparent 60%); mask-image: linear-gradient(to left, #000 40%, transparent 60%);
  -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 0 0; mask-position: 0 0;
}
.cv-names.is-inked { animation: ink-sweep 900ms var(--e-write) both; }
html.is-reduced .cv-names { transition: opacity .3s ease; }
.cv-date { font: 400 13px/1.6 var(--f-body); color: var(--gold-light); opacity: .75; }

/* stage + envelope (O3) */
.cv-stage {
  position: absolute; z-index: 3; width: var(--envw); aspect-ratio: 3 / 2;
  left: calc(50% - var(--envw) / 2); top: calc(58 * var(--vh) - var(--envw) / 3);
  perspective: 1100px;
}
.cv-par, .cv-float { position: absolute; inset: 0; }
.cv-par { transform: rotateX(6deg); }
.cover.is-idle .cv-float { animation: cv-float 4.5s ease-in-out infinite alternate; }
@keyframes cv-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }
.cv-rays {
  position: absolute; left: 50%; top: 10%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 230, 179, .2) 0 5deg, transparent 5deg 17deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 8%, transparent 70%); mask-image: radial-gradient(closest-side, #000 8%, transparent 70%);
  opacity: 0; pointer-events: none;
}
.cv-shadow { position: absolute; left: 6%; right: 6%; top: 94%; height: 16%; background: radial-gradient(closest-side, rgba(0, 0, 0, .6), transparent); pointer-events: none; }
.cv-env { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border-radius: 6px; }
.cv-env:focus-visible { outline-offset: 8px; }
.cv-env > * { position: absolute; display: block; }
.cv-back { inset: 0; width: 100%; height: 100%; z-index: 2; }
.cv-glow {
  z-index: 3; left: 50%; top: 18%; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax; border-radius: 50%;
  background: radial-gradient(circle, #FFF6DF 0%, #FFE6B3 22%, rgba(201, 164, 106, .45) 48%, transparent 70%);
  opacity: 0; pointer-events: none;
}
.cv-card {
  z-index: 5; left: 4%; top: 7%; width: 92%; height: 86%; border-radius: 3px; opacity: 0;
  background: var(--paper); display: flex !important; flex-direction: column; align-items: center; padding-top: 5%;
}
.cv-card::before, .cv-card::after { content: ''; position: absolute; border: 1px solid rgba(156, 122, 67, .55); inset: 5px; border-radius: 2px; }
.cv-card::after { inset: 8px; border-width: .5px; }
.cv-card-shin { height: 34px; width: 24px; fill: var(--gold-deep); }
.cv-card-names { font-size: 22px; line-height: 1.7; white-space: nowrap; }
.cv-pocket { inset: 0; z-index: 6; }
.cv-pocket svg { width: 100%; height: 100%; }
.cv-to {
  position: absolute; top: 84.5%; left: 12%; right: 12%;
  font: 500 19px/1.5 var(--f-letter); color: var(--gold-light); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cv-flap { left: 0; top: 0; width: 100%; height: 62%; z-index: 7; }
.cv-flip { position: absolute; inset: 0; transform-origin: 50% 0; transform-style: preserve-3d; transform: perspective(1100px) rotateX(0deg); }
.cv-face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.cv-face svg { width: 100%; height: 100%; }
.cv-gate { transform: rotateX(180deg); }

/* seal (O2) */
.cv-seal { z-index: 8; left: 50%; top: 62%; width: var(--seal); height: var(--seal); margin: calc(var(--seal) / -2) 0 0 calc(var(--seal) / -2); }
.cv-seal > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.cv-halo {
  inset: 6%; width: auto; height: auto; border-radius: 50%; border: 1px solid var(--gold); opacity: 0; pointer-events: none;
  /* fade the lower arc so the expanding ring stays ≥8px clear of the «إلى …» line below the seal */
  -webkit-mask-image: linear-gradient(#000 58%, transparent 76%); mask-image: linear-gradient(#000 58%, transparent 76%);
}
.cover.is-idle .cv-halo { animation: cv-halo 2.6s ease-out infinite; }
.cover.is-idle .cv-halo + .cv-halo { animation-delay: 1.3s; }
@keyframes cv-halo { from { transform: scale(1); opacity: .45; } to { transform: scale(1.7); opacity: 0; } }
.cv-crack { opacity: 0; }
.cv-glint-band { transform: translateX(-140px); }
.cover.is-idle .cv-glint-band { animation: cv-glint 5s ease-in-out 1s infinite; }
@keyframes cv-glint { 0% { transform: translateX(-140px); } 18%, 100% { transform: translateX(140px); } }
.cv-flash { inset: auto; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: radial-gradient(closest-side, var(--glow), rgba(255, 230, 179, 0)); opacity: 0; }

/* hint + music row */
.cv-hint { position: absolute; z-index: 4; top: calc(86 * var(--vh)); inset-inline: 0; margin-top: -.8em; text-align: center; font: 400 15px/1.6 var(--f-body); color: var(--gold-light); pointer-events: none; }
.cv-hint.is-breathe { animation: cv-breathe 2.2s ease-in-out infinite alternate; }
@keyframes cv-breathe { from { opacity: 1; } to { opacity: .55; } }
.cv-music {
  position: absolute; z-index: 4; bottom: calc(14px + env(safe-area-inset-bottom)); inset-inline: 0;
  display: flex; justify-content: center; align-items: center; gap: 6px; padding-inline: 16px;
  font: 400 12px/1.6 var(--f-body); color: var(--gold-light); opacity: .85;   /* ≥7:1 on the midnight ground */
}
.cv-spk { width: 14px; height: 14px; transform: scaleX(-1); flex: none; }
.cv-nomusic { min-height: 44px; padding: 0 4px; color: inherit; text-decoration: underline; text-underline-offset: 4px; }

/* pre-arrival: hidden under the veil until the arrival timeline animates them in */
.cover.cv-pre :is(.cv-kicker, .cv-date, .cv-stage, .cv-hint, .cv-music, .cv-dust, .cv-seal) { opacity: 0; }

/* flood disc (appended to body, outside the cover) */
.cv-flood { position: fixed; z-index: 110; border-radius: 50%; background: var(--flood); pointer-events: none; transform: scale(.02); will-change: transform, opacity; }

html.is-reduced .cover * { animation: none !important; }

/* ---------- §9 music button ---------- */
.mu {
  position: fixed; z-index: 50; bottom: calc(16px + env(safe-area-inset-bottom)); inset-inline-end: 16px;
  width: 52px; height: 52px; border-radius: 50%;
  transition: transform .35s var(--e-expo);
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 768px) { .mu { inset-inline-end: max(16px, calc(50vw - 220px + 16px)); } }
/* fixed over both ivory and midnight bands: light ring sandwiched in a dark halo reads on either */
.mu:focus-visible { outline-color: var(--focus-night); border-radius: 50%; box-shadow: 0 0 0 4px var(--night-900), 0 0 0 8px var(--night-900); }
.mu.is-pop { animation: mu-pop .5s var(--e-spring) backwards; }
.mu.is-pop::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--gold); animation: mu-halo .9s ease-out .2s both; pointer-events: none; }
@keyframes mu-pop { from { transform: scale(0); } }
@keyframes mu-halo { from { transform: scale(1); opacity: .6; } to { transform: scale(1.8); opacity: 0; } }
.mu.is-away { transform: translateY(80px); }
.mu.is-nudge { animation: mu-nudge .5s var(--e-spring) 2; }
@keyframes mu-nudge { 50% { transform: scale(1.14); } }
.mu-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.mu-disc {
  position: absolute; left: 7px; top: 7px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--night-900); display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding-bottom: 11px;
}
.mu-disc i { display: block; width: 2.5px; height: 10px; border-radius: 2px; background: var(--gold-light); transform-origin: 50% 100%; transform: scaleY(.35); transition: transform .3s ease; }
.mu-disc i:nth-child(2) { height: 16px; }
.mu-disc i:nth-child(3) { height: 12px; }
.mu-disc::after { content: ''; position: absolute; left: 6px; right: 6px; top: 50%; height: 1px; background: var(--gold); transform: rotate(45deg); transition: opacity .3s ease; }
.mu.is-playing .mu-disc::after { opacity: 0; }
.mu.is-playing .mu-disc i { transform: none; animation: mu-bar .9s ease-in-out infinite alternate; }
.mu.is-playing .mu-disc i:nth-child(2) { animation-delay: .2s; }
.mu.is-playing .mu-disc i:nth-child(3) { animation-delay: .4s; }
@keyframes mu-bar { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
.mu.is-playing .mu-ring { animation: mu-spin 14s linear infinite; }
@keyframes mu-spin { to { transform: rotate(360deg); } }
html.is-reduced .mu, html.is-reduced .mu * { animation: none !important; }
html.is-reduced .mu::before { display: none; }

/* ===== desktop ===== */
/* Full-screen midnight stage with a larger envelope + seal. Positions stay vh-driven so the
   arrival/opening timeline (which measures the stage at run time) works unchanged; the
   flood disc is sized in JS from max(innerWidth, innerHeight), glow/rays use vmax. */
@media (min-width: 1024px) {
  .cover {
    --envw: min(520px, 46vw, calc(62 * var(--vh)));
    --seal: calc(var(--envw) * .28);
  }
  .cv-top { top: calc(6 * var(--vh)); }
  .cv-kicker { font-size: 15px; gap: 14px; }
  .cv-hl { width: 44px; }
  .cv-names { font-size: min(128px, 9vw, calc(13.5 * var(--vh))); }
  .cv-date { font-size: 16px; }
  .cv-stage { top: calc(60 * var(--vh) - var(--envw) / 3); }
  .cv-card { padding-top: 6%; }
  .cv-card-shin { height: calc(var(--envw) * .1); width: calc(var(--envw) * .07); }
  .cv-card-names { font-size: calc(var(--envw) * .064); }
  .cv-to { font-size: calc(var(--envw) * .052); }
  .cv-flash { width: calc(var(--seal) * .58); height: calc(var(--seal) * .58); margin: calc(var(--seal) * -.29) 0 0 calc(var(--seal) * -.29); }
  .cv-hint { top: calc(89 * var(--vh)); font-size: 17px; }
  .cv-music { bottom: calc(18px + env(safe-area-inset-bottom)); font-size: 13px; }

  /* music button: bottom-left corner of the viewport (inline-end in RTL) */
  .mu { bottom: calc(24px + env(safe-area-inset-bottom)); inset-inline-end: 24px; width: 56px; height: 56px; }
  .mu-disc { left: 8px; top: 8px; width: 40px; height: 40px; }
}
@media (min-width: 1440px) {
  .cover { --envw: min(560px, 40vw, calc(62 * var(--vh))); }
  .mu { bottom: calc(32px + env(safe-area-inset-bottom)); inset-inline-end: 32px; }
}
