/* Convite de casamento — Lucas & Emily
   Cores e materiais vêm do convite em PDF: papel em relevo, selo de cera azul,
   aquarela do local, tinta verde-oliva e filetes dourados. */

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/eb-garamond-italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f0eae2;      /* fundo do papel em relevo */
  --flap: #f1eee7;       /* aba da capa */
  --card: #f7f4ed;       /* papel da aquarela */
  --olive: #535c3a;      /* nomes, data, horários */
  --ink: #4b5436;        /* texto corrido */
  --olive-soft: #646b46; /* ícones de relógio e local */
  --gold: #a98a4e;       /* filetes */
  --wax: 144 174 196;    /* azul do selo (r g b) */

  --serif: "EB Garamond", Garamond, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --gutter: clamp(12px, 3.2vw, 32px);

  color-scheme: only light;
}

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.55;
  color: var(--ink);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

/* O papel em relevo fica parado atrás do convite, como uma mesa. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  background: var(--paper) url("assets/papel.webp") center / cover no-repeat;
}

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

/* ——— Página ——— */

.page {
  padding:
    max(clamp(12px, 5vh, 56px), env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(4.5rem, calc(env(safe-area-inset-bottom) + 3rem))
    max(var(--gutter), env(safe-area-inset-left));
  transform-origin: 50% 0;
  transition: transform 1.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ——— Cartão do convite ——— */

.card {
  max-width: 38rem;
  margin: 0 auto;
  overflow: hidden;
  background: var(--card);
  border-radius: clamp(14px, 2.6vw, 22px);
  box-shadow:
    0 1px 2px rgb(83 72 52 / 0.08),
    0 24px 48px -28px rgb(83 72 52 / 0.45);
}

.card__art {
  width: 100%;
  height: auto;
  -webkit-mask-image: linear-gradient(to bottom, #000 86%, transparent);
  mask-image: linear-gradient(to bottom, #000 86%, transparent);
}

.card__body {
  padding: 0.5rem clamp(20px, 6.5vw, 56px) calc(clamp(84px, 22vw, 112px) * 0.48 + 1.5rem);
  text-align: center;
}

.names {
  margin: 0;
  font-size: clamp(2.4rem, 1.4rem + 5vw, 3.1rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.005em;
  color: var(--olive);
}

.names:focus {
  outline: none;
}

.names__part {
  display: block;
}

.names__amp {
  display: block;
  margin: 0.08em 0 0.04em;
  font-size: 0.6em;
  line-height: 1.1;
}

.blessing {
  max-width: 34em;
  margin: 1.25rem auto 0;
  text-wrap: pretty;
}

.br-wide,
.br-cols {
  display: none;
}

/* Horários e endereço: um embaixo do outro no celular, lado a lado nas telas maiores. */
.details {
  display: grid;
  justify-content: center;
  gap: 1.15rem;
  margin: 1.9rem auto 0;
  text-align: left;
}

.details__rule {
  display: block;
  height: 1px;
  background: var(--gold);
  opacity: 0.75;
}

.detail {
  display: grid;
  grid-template-columns: 2.6rem auto;
  column-gap: 0.95rem;
  align-items: start;
}

.detail__icon {
  width: 2.6rem;
  height: 2.6rem;
  color: var(--olive-soft);
}

.schedule {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  column-gap: 0.4em;
  margin: 0;
  font-size: 1.22em;
  line-height: 1.3;
  color: var(--olive);
}

.schedule dt {
  font-weight: 500;
}

.schedule dd {
  margin: 0;
}

.schedule .schedule__note {
  grid-column: 2;
  margin-top: 0.1em;
  font-size: 0.74em;
  color: var(--ink);
}

.place {
  padding-top: 0.15em;
  font-style: normal;
  font-size: 1.08em;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.date {
  margin: 2rem 0 0;
  font-size: clamp(1.5rem, 1.05rem + 2.2vw, 2rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--olive);
  text-wrap: balance;
}

/* Adicionar à agenda: botão discreto preso à data, com o filete dourado do cartão */
.calendar {
  margin: 0.8rem 0 0;
}

.calendar__summary {
  display: inline-block;
  border-radius: 999px;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.calendar__summary::-webkit-details-marker {
  display: none;
}

.calendar__button {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0.45em 1.15em 0.4em;
  border: 1px solid rgb(169 138 78 / 0.75);
  border-radius: 999px;
  font-size: 0.98em;
  font-weight: 500;
  line-height: 1.2;
  color: var(--olive);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease;
}

.calendar__button svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

.calendar[open] .calendar__button,
.calendar__summary:active .calendar__button,
a.calendar__button:active {
  background: rgb(169 138 78 / 0.14);
}

.calendar__options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
}

.calendar__option {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4em 1.05em;
  border-radius: 999px;
  background: rgb(169 138 78 / 0.13);
  font-size: 0.95em;
  font-weight: 500;
  line-height: 1.2;
  color: var(--olive);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease;
}

.calendar__option:active {
  background: rgb(169 138 78 / 0.24);
}

.calendar__summary:focus-visible,
a.calendar__button:focus-visible,
.calendar__option:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 3px;
}

@media (hover: hover) {
  .calendar__summary:hover .calendar__button,
  a.calendar__button:hover {
    background: rgb(169 138 78 / 0.1);
  }

  .calendar__option:hover {
    background: rgb(169 138 78 / 0.2);
  }
}

.rule {
  width: min(82%, 26rem);
  height: 1px;
  margin: 1.1rem auto 0.9rem;
  border: 0;
  background: var(--gold);
}

.deadline {
  margin: 0;
  font-size: 1.05em;
}

.ornament {
  width: min(78%, 19rem);
  height: auto;
  margin: 1.6rem auto 0;
}

/* Selo que fecha o cartão, como no PDF */
.closing-seal {
  position: relative;
  width: clamp(84px, 22vw, 112px);
  height: auto;
  margin: calc(clamp(84px, 22vw, 112px) * -0.48) auto 0;
  filter: drop-shadow(0 5px 7px rgb(45 60 75 / 0.24));
}

/* ——— Links ——— */

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem clamp(0.5rem, 3vw, 1.5rem);
  max-width: 30rem;
  margin: clamp(1.25rem, 4vw, 2rem) auto 0;
  padding: 0;
  list-style: none;
}

.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  height: 100%;
  padding: 1.25rem 0.5rem 1.1rem;
  border-radius: 1.25rem;
  color: var(--olive);
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.action__icon {
  width: auto;
  height: 4.25rem;
}

.action__icon[src$=".svg"] {
  filter: drop-shadow(2px 3px 2px rgb(40 30 20 / 0.28));
}

.action__label {
  font-size: 1.2em;
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
}

.action:active {
  transform: scale(0.97);
  background: rgb(255 255 255 / 0.5);
}

.action:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

@media (hover: hover) {
  .action:hover {
    background: rgb(255 255 255 / 0.45);
  }
}

/* ——— Celulares bem estreitos ——— */

@media (max-width: 359px) {
  .detail {
    grid-template-columns: 2.2rem auto;
    column-gap: 0.7rem;
  }

  .detail__icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  .schedule {
    font-size: 1.14em;
  }
}

/* ——— Telas maiores ——— */

@media (min-width: 46rem) {
  .card {
    max-width: 46rem;
  }

  .names {
    font-size: 2.95rem;
  }

  .names__part,
  .names__amp {
    display: inline;
  }

  .names__amp {
    margin: 0 0.05em;
  }

  .br-wide {
    display: inline;
  }
}

/* Horário e endereço lado a lado, separados por um filete, como no PDF */
@media (min-width: 50rem) {
  .card__body {
    padding-inline: 3rem;
  }

  .details {
    grid-template-columns: auto 1px auto;
    column-gap: 1.6rem;
  }

  .details__rule {
    width: 1px;
    height: auto;
  }

  .schedule {
    font-size: 1.12em;
    white-space: nowrap;
  }

  .place {
    font-size: 1em;
  }

  .br-cols {
    display: inline;
  }
}

/* ——— Envelope (capa) ———
   Como na capa do PDF: a aba creme, dobrada à esquerda, está colada pelo selo de cera
   no papel em relevo, que por sua vez está dobrado à direita sobre o convite.
   Ao tocar no selo, a aba creme descola levando o selo inteiro e abre para a esquerda;
   em seguida o papel em relevo abre para a direita e mostra o convite. */

.envelope {
  display: none;
}

html.is-sealed,
html.is-opening {
  overflow: hidden;
}

.is-sealed .envelope,
.is-opening .envelope {
  --seam: 56.5%;  /* borda da aba, onde fica o selo */
  --hinge: 2.6%;  /* dobra da aba */
  --seal-y: 42%;
  --seal: clamp(112px, min(31vw, 30vh), 200px);

  display: block;
  position: fixed;
  inset: 0;
  z-index: 10;
}

.is-opening .envelope {
  pointer-events: none;
}

.envelope__paper {
  position: absolute;
  inset: 0;
  perspective: max(1500px, 250vw);
}

/* Papel em relevo, dobrado na borda direita */
.sheet {
  position: absolute;
  inset: 0;
  transform-origin: 100% 50%;
  transform-style: preserve-3d;
}

.sheet__front,
.sheet__back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.sheet__front {
  background: var(--paper) url("assets/papel.webp") center / cover no-repeat;
}

.sheet__front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(60 50 40);
  opacity: 0;
}

/* Verso do papel, que aparece enquanto ele abre */
.sheet__back {
  background:
    linear-gradient(to right, rgb(70 58 44 / 0.12), rgb(70 58 44 / 0) 40%),
    #efebe3;
  transform: rotateY(180deg);
}

/* Sombra que a aba fechada faz no envelope */
.envelope__shade {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--seam);
  width: clamp(28px, 9vw, 96px);
  background: linear-gradient(to right, rgb(70 58 44 / 0.16), rgb(70 58 44 / 0.05) 45%, rgb(70 58 44 / 0));
}

.flap {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--hinge);
  width: calc(var(--seam) - var(--hinge));
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}

.flap__front,
.flap__back {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.flap__front {
  background: var(--flap);
}

/* A luz cai sobre a aba enquanto ela se levanta */
.flap__front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(60 50 40);
  opacity: 0;
}

/* Lado de dentro da aba, que aparece depois que ela passa da metade do giro */
.flap__back {
  background:
    linear-gradient(to left, rgb(70 58 44 / 0.12), rgb(70 58 44 / 0) 40%),
    #ebe5da;
  transform: rotateY(180deg);
}

.seal {
  position: absolute;
  top: var(--seal-y);
  left: 100%;
  width: var(--seal);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transform: translate(-50%, -50%) translateZ(1px);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.seal img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 10px rgb(45 60 75 / 0.28));
  transition: transform 0.25s ease, filter 0.25s ease;
}

.seal:active img {
  transform: scale(0.95);
}

.seal:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 8px;
}

/* Um halo discreto convida a tocar no selo */
.seal::before {
  content: "";
  position: absolute;
  inset: 9%;
  z-index: -1;
  border-radius: 50%;
  animation: halo 2.8s ease-out 1.2s infinite;
}

@keyframes halo {
  0% {
    box-shadow: 0 0 0 0 rgb(var(--wax) / 0.55);
  }
  75%,
  100% {
    box-shadow: 0 0 0 clamp(14px, 4vw, 26px) rgb(var(--wax) / 0);
  }
}

.envelope__hint {
  position: absolute;
  top: calc(var(--seal-y) + var(--seal) * 0.5 + 1.1rem);
  left: var(--seam);
  margin: 0;
  font-size: 1.05rem;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--olive);
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.25s ease;
}

.hint-click {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .hint-touch {
    display: none;
  }

  .hint-click {
    display: inline;
  }
}

/* ——— Abertura ——— */

.is-opening .envelope__hint {
  opacity: 0;
}

/* A sombra some quando a aba deixa de encostar no envelope */
.is-opening .envelope__shade {
  animation: fade-out 0.3s ease forwards;
}

/* O selo sai inteiro, preso na aba */
.is-opening .seal::before {
  animation: none;
}

.is-opening .seal img {
  transform: scale(1.04);
  filter: drop-shadow(0 14px 16px rgb(45 60 75 / 0.32));
}

.is-opening .flap {
  animation: flap-open 1s forwards;
}

.is-opening .flap__front::after {
  animation: flap-light 1s forwards;
}

/* A dobra da aba fica na borda esquerda; some no fim para não deixar um filete */
.is-opening .flap__back {
  animation: fade-late 1s forwards;
}

/* Depois que a aba creme passa da metade, o papel em relevo abre para a direita */
.is-opening .sheet {
  animation: sheet-open 0.8s cubic-bezier(0.5, 0, 0.3, 1) 0.5s forwards;
}

.is-opening .sheet__front::after {
  animation: flap-light 0.8s 0.5s forwards;
}

/* O convite aparece por baixo e chega um pouco mais perto */
.is-sealed .page {
  transform: scale(0.965);
}

.is-opening .page {
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.6s;
}

@keyframes flap-open {
  0% {
    transform: rotateY(0deg);
    animation-timing-function: cubic-bezier(0.3, 0, 0.4, 1);
  }
  /* a aba descola do envelope */
  20% {
    transform: rotateY(-14deg);
    animation-timing-function: cubic-bezier(0.45, 0, 0.25, 1);
  }
  100% {
    transform: rotateY(-178deg);
  }
}

@keyframes flap-light {
  50% {
    opacity: 0.14;
  }
  100% {
    opacity: 0.14;
  }
}

/* Só a parte visível do giro: um pouco além de ficar de perfil, já fora da tela */
@keyframes sheet-open {
  to {
    transform: rotateY(105deg);
  }
}

@keyframes fade-late {
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .seal::before {
    animation: none;
  }

  .page,
  .is-opening .page {
    transition: none;
  }

  .is-sealed .page {
    transform: none;
  }

  .is-opening .flap,
  .is-opening .flap__front::after,
  .is-opening .flap__back,
  .is-opening .sheet,
  .is-opening .sheet__front::after,
  .is-opening .envelope__shade {
    animation: none;
  }

  .is-opening .envelope {
    animation: fade-out 0.35s ease forwards;
  }
}
