:root {
  color-scheme: light;
  --ink: #493849;
  --edge: #948099;
  --paper: #f2e8f1;
  background: #e3d7e4;
  color: var(--ink);
  font-family: "Baskerville", Georgia, serif;
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 0%, #f7eff6, #e1d2e3 78%);
}

.invitation {
  position: relative;
  width: min(100%, 29rem);
  margin-inline: auto;
  box-shadow: 0 14px 75px #48284f30;
}

.sheet {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #e7dce7;
  isolation: isolate;
}

.letter {
  display: block;
  width: 100%;
  height: 100%;
}

.portrait-card {
  position: absolute;
  inset: 0;
}

.portrait-card, .ayah-sheet {
  background: #ebe1ed url("art/stationery.jpg") center / cover no-repeat;
  container-type: inline-size;
}

.portrait-picture {
  position: absolute;
  inset: 15.8% 14.5% 26%;
  display: block;
  padding: 6px;
  border: 1px solid #a28aa4b5;
  border-radius: 48% 48% 23% 23% / 23% 23% 14% 14%;
  background: linear-gradient(145deg, #fff7fc, #c4abc6);
  box-shadow: 0 4px 24px #5137582b, 0 0 0 4px #faf0f8b0;
  overflow: hidden;
}

.portrait-picture img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: var(--portrait-position, 50% 45%);
}

.portrait-names {
  color: #493849;
  position: absolute;
  inset: auto 9% 12.5%;
  margin: 0;
  text-align: center;
  font-family: "Snell Roundhand", "Apple Chancery", Georgia, serif;
  font-size: clamp(1.5rem, 10.3cqw, 3.1rem);
  font-style: italic;
}

.portrait-names span { font-size: 0.72em; }

.seal-layer {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  pointer-events: none;
  background: #c8b7ca;
}

.seal-layer.is-ready { background: transparent; }
.seal-layer.is-ready #cover-photo { visibility: hidden; }
.inner[open] + .seal-layer { display: none; }
.invitation:has(.inner:not([open])) #swipe-note { visibility: hidden; }

#cover-photo, #scratch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scratch {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

#instruction {
  position: absolute;
  margin: 0 auto;
  top: min(112cqw, 30rem);
  left: 8%;
  right: 8%;
  width: max-content;
  max-width: 84%;
  padding: 0.45rem 0.85rem;
  border-radius: 30px;
  background: #f7edf5eb;
  color: #463346;
  text-align: center;
  font: 1rem/1.35 "Baskerville", Georgia, serif;
  box-shadow: 0 2px 12px #51375824;
}

.seal-layer.is-scratching #instruction { opacity: 0; }
.invitation { container-type: inline-size; }
#open {
  position: absolute;
  z-index: 5;
  top: min(138cqw, 37rem);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 84%;
  min-height: 48px;
  list-style: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: #93739545;
}
#open::-webkit-details-marker { display: none; }
.inner[open] > #open { display: none; }

.paper-button, .swipe-note {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid #8e748e;
  border-radius: 30px;
  background: #f9f0f7;
  color: #483348;
  font: 1rem/1.2 "Baskerville", Georgia, serif;
  text-decoration: none;
  box-shadow: 0 3px 13px #56345925;
  cursor: pointer;
}

.paper-button:focus-visible, .swipe-note:focus-visible {
  outline: 2px solid #5b3660;
  outline-offset: 4px;
}

.swipe-note {
  position: absolute;
  bottom: 3.9%;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 1.5rem);
  width: max-content;
  min-height: 40px;
  border-color: transparent;
  background: #f9f0f7d9;
}

.end {
  display: grid;
  justify-items: center;
  padding: 0.65rem 1rem max(1rem, env(safe-area-inset-bottom));
  background: #e7dce7;
}
.end:has(button[hidden]) { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 650px) {
  .invitation {
    width: min(100%, 29rem);
    margin-block: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
}
.ayah-copy {
  position: absolute;
  top: 50%;
  inset-inline: 18%;
  transform: translateY(-50%);
  text-align: center;
}

.ayah {
  margin: 0;
  color: #48364a;
  font-family: "Geeza Pro", "Noto Naskh Arabic", "Traditional Arabic", Arial, sans-serif;
  font-size: clamp(1.2rem, 5.4cqw, 1.8rem);
  line-height: 2.15;
  font-weight: 400;
}

.ayah-reference {
  margin: 1.3rem 0 0;
  color: #655067;
  font-family: "Geeza Pro", Arial, sans-serif;
  font-size: 0.95rem;
}
