/**
 * cover.css — the closed card (front of the print design).
 * Two doors hold identical copies of the artwork so the card can open
 * like a folded invitation. Geometry follows the V2 front artwork.
 */

@layer cover {
  .cover {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: hidden;
  }

  /* ── Doors ─────────────────────────────────────────────────────── */

  .cover__doors {
    position: absolute;
    inset: 0;
    display: flex;
  }

  .cover__door {
    position: relative;
    width: 50%;
    height: 100%;
    overflow: hidden;
    background: var(--paper);
    transition: transform 1.55s var(--ease-doors);
    will-change: transform;
  }

  .cover__door--left {
    box-shadow: inset -1px 0 rgb(120 72 30 / 10%);
  }

  .cover__door--right {
    box-shadow: inset 1px 0 rgb(120 72 30 / 10%);
  }

  .cover__door::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 22%;
    pointer-events: none;
  }

  .cover__door--left::after {
    right: 0;
    background: linear-gradient(to left, rgb(120 72 30 / 9%), transparent);
  }

  .cover__door--right::after {
    left: 0;
    background: linear-gradient(to right, rgb(120 72 30 / 9%), transparent);
  }

  .cover__doors::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: linear-gradient(
      to bottom,
      transparent,
      rgb(120 72 30 / 16%) 18%,
      rgb(120 72 30 / 16%) 82%,
      transparent
    );
    box-shadow: 1px 0 0 rgb(255 255 255 / 40%);
    pointer-events: none;
  }

  .cover__door-inner {
    position: absolute;
    top: 0;
    width: 100vw;
    height: 100%;
  }

  .cover__door--left .cover__door-inner {
    left: 0;
  }

  .cover__door--right .cover__door-inner {
    right: 0;
  }

  .cover__shade {
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    height: 34%;
    background: linear-gradient(
      to top,
      var(--paper) 18%,
      rgb(253 246 234 / 82%) 52%,
      transparent 100%
    );
    pointer-events: none;
  }

  /* ── Artwork ───────────────────────────────────────────────────── */

  .cover__art {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: calc(var(--safe-top) + 7vh) 0 calc(var(--safe-bottom) + 12.5rem);
    padding: calc(var(--safe-top) + 6svh) 0 calc(var(--safe-bottom) + 12.5rem);
  }

  .cover__top {
    padding-inline: var(--gutter);
    text-align: center;
  }

  .cover__kicker {
    font-family: var(--font-display);
    font-size: clamp(0.92rem, 3.9vw, 1.16rem);
    letter-spacing: 0.17em;
    line-height: 1.4;
    text-transform: uppercase;
    color: var(--ink);
  }

  .cover__kicker--sub {
    margin-top: 0.25rem;
    font-size: clamp(0.76rem, 3.3vw, 0.98rem);
    letter-spacing: 0.2em;
    color: var(--ink-soft);
  }

  .cover__stage {
    position: relative;
    container-type: inline-size;
    width: min(88vw, 27.5rem);
    aspect-ratio: 1000 / 869;
    margin: auto auto 0;
  }

  .cover__stage::before {
    content: "";
    position: absolute;
    inset: 6% 8% 8%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(238 125 31 / 9%), transparent 76%);
    filter: blur(12px);
    pointer-events: none;
  }

  .cover__wreath,
  .cover__lily {
    position: absolute;
    inset: 0;
    width: 100%;
    height: auto;
  }

  .cover__wreath {
    --cover-grow: 40%;
    -webkit-mask-image: radial-gradient(
      circle at 23.8% 75.3%,
      #000 var(--cover-grow),
      rgb(0 0 0 / 0%) calc(var(--cover-grow) + 13%)
    );
    mask-image: radial-gradient(
      circle at 23.8% 75.3%,
      #000 var(--cover-grow),
      rgb(0 0 0 / 0%) calc(var(--cover-grow) + 13%)
    );
  }

  .cover__lily {
    transform-origin: 23.8% 75.3%;
  }

  .cover__monogram {
    position: absolute;
    top: -19%;
    left: 33.5%;
    width: 39%;
    height: auto;
  }

  .cover__names {
    position: absolute;
    top: 44%;
    left: 26%;
    width: 48%;
    font-family: var(--font-display);
    font-size: max(0.95rem, 4.7vw);
    font-size: max(0.95rem, 5.3cqw);
    font-weight: 500;
    letter-spacing: 0.06em;
    line-height: 1.14;
    text-transform: uppercase;
    text-align: center;
    color: var(--ink);
  }

  .cover__name {
    display: block;
    white-space: nowrap;
  }

  .cover__name--last {
    text-align: right;
  }

  .cover__name:first-child {
    text-align: left;
  }

  .cover__amp {
    display: block;
    margin-block: 0.42em 0.3em;
    font-size: 0.72em;
    font-weight: 400;
    color: var(--accent-deep);
    text-align: center;
  }

  /* ── Personalised footer / call to action ──────────────────────── */

  .cover__ui {
    position: absolute;
    right: 0;
    bottom: calc(var(--safe-bottom) + 1.4rem);
    left: 0;
    z-index: 2;
    padding-inline: var(--gutter);
    text-align: center;
    transition:
      opacity 0.35s var(--ease-out),
      transform 0.5s var(--ease-out);
  }

  .cover__date {
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .cover__pipe {
    margin-inline: 0.45rem;
    color: var(--accent);
  }

  .cover__greeting {
    display: flex;
    flex-direction: column;
    gap: 0.16rem;
    margin-top: 0.8rem;
  }

  .cover__greeting-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--ink-mute);
  }

  .cover__guest {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-family: var(--font-display);
    font-size: clamp(1rem, 4.6vw, 1.3rem);
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--accent-deep);
  }

  .cover__ui .btn--open {
    min-width: 12.5rem;
    margin-top: 1.1rem;
  }

  .cover__hint {
    margin-top: 0.7rem;
    font-size: 0.64rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
    animation: hint-pulse 2.8s var(--ease-in-out) infinite;
  }

  /* ── Opening ───────────────────────────────────────────────────── */

  .cover.is-opening .cover__ui {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
  }

  .cover.is-opening .cover__shade {
    opacity: 0;
    transition: opacity 0.5s var(--ease-out);
  }

  .cover.is-opening .cover__door--left {
    transform: translateX(-101%);
  }

  .cover.is-opening .cover__door--right {
    transform: translateX(101%);
  }

  .cover.is-opening .cover__doors::after {
    opacity: 0;
    transition: opacity 0.6s var(--ease-out);
  }

  /* ── Entrance choreography (front-of-card animation) ───────────── */

  .cover__kicker,
  .cover__monogram,
  .cover__lily,
  .cover__date,
  .cover__greeting,
  .cover__ui .btn--open,
  .cover__hint {
    opacity: 0;
  }

  .cover__lily {
    transform: scale(0.84) rotate(-2deg);
  }

  .cover__monogram {
    transform: translateY(1.1rem) scale(0.96);
  }

  .cover__names .char {
    opacity: 0;
    transform: translateY(0.55em) rotate(2deg);
  }

  .cover.is-intro .cover__kicker {
    animation: cover-fade-up 1.1s var(--ease-out) 0.25s both;
  }

  .cover.is-intro .cover__kicker--sub {
    animation-delay: 0.42s;
  }

  .cover.is-intro .cover__lily {
    animation: lily-bloom 1.6s var(--ease-out) 0.1s both;
  }

  .cover.is-intro .cover__wreath {
    animation: wreath-grow 2.5s var(--ease-out) 0.55s both;
  }

  .cover.is-intro .cover__monogram {
    animation:
      cover-mono-in 1.4s var(--ease-out) 1.15s both,
      float-soft 7s var(--ease-in-out) 2.6s infinite;
  }

  .cover.is-intro .cover__names .char {
    animation: char-rise 0.9s var(--ease-out) both;
    animation-delay: calc(1.5s + var(--i, 0) * 42ms);
  }

  .cover.is-intro .cover__date {
    animation: cover-fade-up 0.9s var(--ease-out) 0.55s both;
  }

  .cover.is-intro .cover__greeting {
    animation: cover-fade-up 0.9s var(--ease-out) 0.7s both;
  }

  .cover.is-intro .cover__ui .btn--open {
    animation: cover-fade-up 0.9s var(--ease-out) 0.85s both;
  }

  .cover.is-intro .cover__hint {
    animation:
      cover-fade-up 0.9s var(--ease-out) 1.1s both,
      hint-pulse 2.8s var(--ease-in-out) 2s infinite;
  }

  @keyframes wreath-grow {
    from {
      --cover-grow: 12%;
    }
    to {
      --cover-grow: 150%;
    }
  }

  @keyframes lily-bloom {
    from {
      opacity: 0;
      transform: scale(0.84) rotate(-2deg);
    }
    55% {
      opacity: 1;
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes cover-mono-in {
    from {
      opacity: 0;
      transform: translateY(1.1rem) scale(0.96);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes cover-fade-up {
    from {
      opacity: 0;
      transform: translateY(0.7rem);
      filter: blur(3px);
    }
    to {
      opacity: 1;
      transform: none;
      filter: none;
    }
  }

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

  @keyframes float-soft {
    0%,
    100% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(-0.35rem);
    }
  }

  /* Hide the invitation until the card is opened (JS only). */
  .js body:not(.is-open) {
    overflow: hidden;
  }

  .js body:not(.is-open) .invitation {
    opacity: 0;
    transform: scale(1.015);
  }

  .js .invitation {
    transition:
      opacity 1s var(--ease-out) 0.12s,
      transform 1.3s var(--ease-out) 0.12s;
  }

  /* ── Wide screens: frame the narrow card composition ───────────── */

  @media (min-width: 64rem) {
    .cover__stage {
      width: min(72vw, 26rem);
    }

    .cover__door-inner::before {
      content: "";
      position: absolute;
      top: 12%;
      width: 13rem;
      height: 76%;
      background: url("../../assets/sprig.webp") no-repeat center / contain;
      opacity: 0.16;
      pointer-events: none;
    }

    .cover__door--left .cover__door-inner::before {
      left: 5vw;
      rotate: -6deg;
    }

    .cover__door--right .cover__door-inner::before {
      right: 5vw;
      rotate: 6deg;
      scale: -1 1;
    }
  }

  /* ── Short viewports (landscape phones) ─────────────────────────── */

  @media (max-height: 680px) and (min-width: 34rem) {
    .cover__art {
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr;
      align-items: center;
      padding: calc(var(--safe-top) + 1.2rem) 4vw calc(var(--safe-bottom) + 1rem);
    }

    .cover__top {
      grid-column: 2;
      grid-row: 1;
      align-self: start;
      padding-top: 4vh;
      text-align: center;
    }

    .cover__stage {
      grid-column: 1;
      grid-row: 1;
      width: min(38vw, 17rem);
      margin: 0 auto;
    }

    .cover__ui {
      right: 4vw;
      bottom: calc(var(--safe-bottom) + 1.4rem);
      left: 54%;
    }

    .cover__ui .btn--open {
      min-width: 10.5rem;
    }

    .cover__hint {
      display: none;
    }
  }
}
