/* ════════════════════════════════════════════════════════════
   bestgirlfriendaward.com — for Celeste
   Palette: peony-derived pinks, rosewood text, gilded details
   Type: Cinzel (engraved caps) · Parisienne (calligraphy) · Lora (body)
   ════════════════════════════════════════════════════════════ */

:root {
  --petal: #F9E3E8;
  --blush: #F2B8C6;
  --peony: #D5527C;
  --peony-deep: #B23A5E;
  --rosewood: #7C2D43;
  --gold: #C9A24B;
  --paper: #FFFAF5;
  --cream: #FAEFE4;
  --gold-line: rgba(201, 162, 75, 0.5);
  --gold-faint: rgba(201, 162, 75, 0.32);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: 'Lora', Georgia, serif;
  color: var(--rosewood);
  background:
    radial-gradient(1100px 700px at 88% -5%, rgba(242, 184, 198, 0.55), transparent 60%),
    radial-gradient(900px 600px at -8% 28%, rgba(255, 250, 245, 0.7), transparent 55%),
    radial-gradient(1000px 800px at 110% 80%, rgba(242, 184, 198, 0.35), transparent 60%),
    var(--petal);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--blush); color: var(--rosewood); }

img { max-width: 100%; display: block; }

/* corner peonies may bleed past the edge; clip without creating a scrollbar */
body { overflow-x: clip; }

/* ─────────────────────────────────────────────
   Peony corner sprays (artwork defined in index.html defs)
   The cluster is drawn for a bottom-left corner; the other
   corners are mirrors/rotations via --flip.
   ───────────────────────────────────────────── */

.peony-cluster {
  position: absolute;
  z-index: -1; /* behind each act's text; the acts isolate their stacking */
  pointer-events: none;
  --flip: rotate(0deg);
  transform: var(--flip);
  filter: drop-shadow(0 6px 14px rgba(124, 45, 67, 0.16));
}

/* flips use the default center origin so the box stays put in its corner */
.pc-bl { bottom: -10px; left: -10px; }
.pc-tr { top: -10px; right: -10px; --flip: rotate(180deg); }
.pc-tl { top: -10px; left: -10px; --flip: scaleY(-1); }
.pc-br { bottom: -10px; right: -10px; --flip: scaleX(-1); }

.ceremony .peony-cluster { width: clamp(110px, 24vw, 185px); opacity: 0.9; }
.reveal .peony-cluster { width: clamp(118px, 28vw, 260px); }
.certificate .peony-cluster { width: clamp(82px, 20vw, 165px); }

/* Scroll is locked until the envelope is opened (JS only) */
html.js body:not(.opened) { overflow: hidden; }

/* ─────────────────────────────────────────────
   Drifting peony petals (spawned by script.js)
   ───────────────────────────────────────────── */

.petal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

.petal {
  position: absolute;
  top: -6vh;
  left: var(--x);
  width: var(--size);
  opacity: var(--o);
  animation: petal-fall var(--dur) linear var(--delay) var(--count, 1) both;
}

.petal svg {
  width: 100%;
  height: auto;
  animation: petal-sway var(--sway-dur) ease-in-out var(--delay) infinite alternate;
}

@keyframes petal-fall {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(var(--drift), 114vh, 0); }
}

@keyframes petal-sway {
  from { transform: translateX(calc(var(--amp) * -1)) rotate(var(--rot-a)); }
  to   { transform: translateX(var(--amp)) rotate(var(--rot-b)); }
}

/* ─────────────────────────────────────────────
   ACT I · The sealed envelope (fixed overlay)
   ───────────────────────────────────────────── */

.ceremony {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4.5vh, 36px);
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(1100px 700px at 88% -5%, rgba(242, 184, 198, 0.55), transparent 60%),
    radial-gradient(900px 600px at -8% 28%, rgba(255, 250, 245, 0.7), transparent 55%),
    radial-gradient(1000px 800px at 110% 80%, rgba(242, 184, 198, 0.35), transparent 60%),
    var(--petal);
}

/* No JS: skip the overlay, show the page */
html:not(.js) .ceremony { display: none; }

body.opened .ceremony {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
}

.eyebrow {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(124, 45, 67, 0.6);
}

.ceremony-sub {
  font-style: italic;
  font-size: clamp(1.05rem, 4vw, 1.3rem);
  line-height: 1.7;
}

.hint {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(124, 45, 67, 0.55);
  animation: hint-pulse 2.8s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* The envelope */

.envelope {
  position: relative;
  width: min(78vw, 340px);
  aspect-ratio: 17 / 11;
  border: none;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 22px 30px rgba(124, 45, 67, 0.22));
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s ease;
}

.envelope:hover { transform: translateY(-3px); }

.envelope:focus-visible {
  outline: 2px solid var(--peony);
  outline-offset: 10px;
  border-radius: 12px;
}

.envelope > span { display: block; }

.env-back {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #F3E5D5;
  border-radius: 8px;
}

.env-letter {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 7%;
  bottom: 7%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #FFFDFA;
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(124, 45, 67, 0.08);
}

.env-letter-mark {
  font-family: 'Cinzel', serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--gold);
}

.env-letter-text {
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(124, 45, 67, 0.55);
}

.env-front {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(180deg, #F8ECDD 0%, var(--cream) 100%);
  /* V-cut meets the corners at the top so the letter never peeks out while sealed */
  clip-path: polygon(0 0, 50% 58%, 100% 0, 100% 100%, 0 100%);
  border-radius: 8px;
}

.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 58%;
  z-index: 5;
  transform-origin: top center;
}

.env-flap-face {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #F8EDE0, #F1E0CC);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 8px 8px 0 0;
}

.wax-seal {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -60%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 47% 53% 50% 50% / 52% 48% 55% 45%;
  background: radial-gradient(circle at 35% 30%, #D8688C, #B23A5E 55%, #93304C);
  box-shadow:
    0 3px 8px rgba(124, 45, 67, 0.35),
    inset 0 2px 3px rgba(255, 255, 255, 0.25),
    inset 0 -3px 5px rgba(0, 0, 0, 0.18);
}

.wax-letter {
  font-family: 'Cinzel', serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--petal);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
}

@media (prefers-reduced-motion: no-preference) {
  body:not(.opening) .wax-seal { animation: seal-pulse 2.6s ease-in-out infinite; }
}

@keyframes seal-pulse {
  0%, 100% { transform: translate(-50%, -60%) scale(1); }
  50% { transform: translate(-50%, -60%) scale(1.06); }
}

/* Opening sequence */

body.opening .wax-seal { animation: seal-pop 0.5s ease-out forwards; }

@keyframes seal-pop {
  40% { transform: translate(-50%, -60%) scale(1.18) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1.5) rotate(-12deg); opacity: 0; }
}

body.opening .env-flap { animation: flap-open 0.7s cubic-bezier(0.55, 0, 0.3, 1) 0.3s forwards; }

@keyframes flap-open {
  0%   { transform: rotateX(0deg); z-index: 5; }
  49%  { z-index: 5; }
  50%  { z-index: 2; }
  100% { transform: rotateX(180deg); z-index: 2; }
}

body.opening .env-letter { animation: letter-rise 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) 0.6s forwards; }

@keyframes letter-rise {
  to { transform: translateY(-56%); }
}

body.opening .hint { opacity: 0; transition: opacity 0.3s ease; animation: none; }

/* ─────────────────────────────────────────────
   ACT II · The reveal
   ───────────────────────────────────────────── */

.reveal {
  min-height: 100svh;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 26px);
  padding: 32px 20px 96px;
  text-align: center;
  background: radial-gradient(620px 420px at 50% 44%, rgba(255, 250, 245, 0.85), transparent 70%);
}

.reveal-line {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.78rem, 2.8vw, 1.05rem);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.dots span { animation: dot-pulse 1.6s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.22s; }
.dots span:nth-child(3) { animation-delay: 0.44s; }

@keyframes dot-pulse {
  0%, 100% { opacity: 0.25; }
  45% { opacity: 1; }
}

.laureate {
  font-family: 'Parisienne', cursive;
  font-weight: 400;
  font-size: clamp(4.4rem, 18vw, 9rem);
  line-height: 1.15;
  color: var(--peony-deep);
  padding: 0 0.3em;
}

.flourish {
  width: min(280px, 64vw);
  color: var(--gold);
}

.flourish-path {
  stroke-dasharray: 380;
  stroke-dashoffset: 0;
}

.scroll-cue {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-family: 'Cinzel', serif;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(124, 45, 67, 0.65);
  white-space: nowrap;
}

.scroll-cue:hover, .scroll-cue:focus-visible { color: var(--peony-deep); }

.cue-arrow { font-size: 0.9rem; }

@media (prefers-reduced-motion: no-preference) {
  .cue-arrow { animation: cue-bob 1.6s ease-in-out infinite alternate; }

  /* Staged entrance, choreographed off body.opened */
  html.js .reveal-line,
  html.js .laureate,
  html.js .flourish,
  html.js .scroll-cue { opacity: 0; }

  html.js body.opened .reveal-line { animation: fade-up 0.8s ease 0.35s both; }
  html.js body.opened .laureate { animation: bloom 1.1s cubic-bezier(0.16, 0.8, 0.3, 1) 1.45s both; }
  html.js body.opened .flourish { animation: fade-in 0.4s ease 2.15s both; }
  html.js body.opened .flourish-path { stroke-dashoffset: 380; animation: draw 1.2s ease 2.2s forwards; }
  /* cue-fade preserves the centering translateX while fading up */
  html.js body.opened .scroll-cue { animation: cue-fade 0.7s ease 3s both; }

  /* corner peonies bloom open alongside the name */
  html.js .reveal .peony-cluster { opacity: 0; }
  html.js body.opened .reveal .peony-cluster { animation: peony-bloom 1.1s cubic-bezier(0.18, 1.25, 0.4, 1) both; }
  html.js body.opened .reveal .pc-bl { animation-delay: 1.7s; }
  html.js body.opened .reveal .pc-tr { animation-delay: 1.95s; }
}

@keyframes peony-bloom {
  from { opacity: 0; transform: var(--flip) scale(0.55) rotate(-9deg); }
  to   { opacity: 1; transform: var(--flip) scale(1) rotate(0deg); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes cue-fade {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes bloom {
  from { opacity: 0; transform: scale(0.92) translateY(12px); filter: blur(7px); }
  to   { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

@keyframes cue-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(4px); }
}

/* ─────────────────────────────────────────────
   ACT III · The certificate
   ───────────────────────────────────────────── */

.cert-section {
  padding: clamp(16px, 5vw, 72px) 16px 56px;
}

.certificate {
  position: relative;
  isolation: isolate;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(40px, 9vw, 76px) clamp(22px, 7vw, 64px);
  text-align: center;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.49 0 0 0 0 0.18 0 0 0 0 0.26 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  box-shadow: 0 24px 60px rgba(124, 45, 67, 0.14);
}

/* inner gold rule — the certificate's double border */
.certificate::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid var(--gold-faint);
  border-radius: 1px;
  pointer-events: none;
}

.cert-eyebrow {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.72rem, 2.4vw, 0.85rem);
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  line-height: 2;
  color: rgba(124, 45, 67, 0.8);
}

.cert-confers {
  font-style: italic;
  font-size: 0.95rem;
  color: rgba(124, 45, 67, 0.72);
  margin-top: 26px;
}

.cert-name {
  font-family: 'Parisienne', cursive;
  font-size: clamp(3.2rem, 13vw, 5.4rem);
  line-height: 1.2;
  color: var(--peony-deep);
  margin-top: 4px;
}

.portrait { margin: 30px auto 0; }

.arch {
  display: inline-block;
  padding: 10px;
  border: 1px solid var(--gold-line);
  border-radius: 50% 50% 10px 10px / 38% 38% 10px 10px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(124, 45, 67, 0.16);
}

.arch img {
  width: min(290px, 64vw);
  height: auto; /* the width/height attributes otherwise pin height to 1600px */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 50% 50% 7px 7px / 38% 38% 7px 7px;
}

.portrait figcaption {
  font-style: italic;
  font-size: 0.82rem;
  line-height: 1.7;
  color: rgba(124, 45, 67, 0.62);
  margin-top: 16px;
}

.cert-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.55rem, 6.4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.3;
  margin-top: 10px;
}

.citation {
  font-size: clamp(0.98rem, 2.8vw, 1.07rem);
  line-height: 1.9;
  max-width: 50ch;
  margin: 34px auto 0;
  color: rgba(124, 45, 67, 0.92);
}

/* Categories won */

.categories { margin-top: 44px; }

.categories-head {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Cinzel', serif;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1.9;
  color: rgba(124, 45, 67, 0.55);
}

.categories-head::before,
.categories-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gold-faint);
}

.categories ul {
  list-style: none;
  display: grid;
  gap: 22px 36px;
  margin-top: 26px;
}

@media (min-width: 600px) {
  .categories ul { grid-template-columns: 1fr 1fr; }
}

.categories strong {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.categories em {
  display: block;
  font-size: 0.86rem;
  color: rgba(124, 45, 67, 0.68);
  margin-top: 5px;
}

/* Seal, date & signature */

.attestation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-top: 50px;
}

@media (min-width: 560px) {
  .attestation {
    flex-direction: row;
    justify-content: center;
    gap: 52px;
  }
}

.peony-seal {
  width: 82px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(124, 45, 67, 0.25));
}

.signature-block { text-align: center; }

.awarded-date {
  font-style: italic;
  font-size: 0.86rem;
  line-height: 1.75;
  color: rgba(124, 45, 67, 0.75);
}

.signature {
  font-family: 'Parisienne', cursive;
  font-size: 2.5rem;
  line-height: 1.3;
  color: var(--peony-deep);
  display: inline-block;
  min-width: 180px;
  margin-top: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gold-line);
}

.signature-title {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(124, 45, 67, 0.6);
  margin-top: 8px;
}

/* Fine print */

.fine-print {
  max-width: 720px;
  margin: 30px auto 0;
  text-align: center;
  font-style: italic;
  font-size: 0.76rem;
  line-height: 1.85;
  color: rgba(124, 45, 67, 0.55);
}

.fine-print-domain {
  font-family: 'Cinzel', serif;
  font-style: normal;
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(124, 45, 67, 0.45);
  margin-top: 14px;
}

/* Scroll-triggered entrances on the certificate */

@media (prefers-reduced-motion: no-preference) {
  html.js .rise {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.8s ease, transform 0.8s ease;
  }

  html.js .rise.in {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─────────────────────────────────────────────
   Reduced motion: everything visible, nothing moves
   ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .petal { display: none; }

  .hint,
  .dots span,
  .wax-seal,
  .cue-arrow { animation: none !important; }

  body.opened .ceremony { transition: none; }
}
