:root {
  --night: #0c1c17;
  --pine: #10231d;
  --pine-light: #1b3a30;
  --pine-line: #2c5445;
  --cream: #f8f1e1;
  --paper: #fffaf0;
  --ink: #2b2620;
  --ink-soft: #6f6556;
  --gold: #e3b75a;
  --gold-soft: #f2d186;
  --berry: #a51f3a;
  --mist: #b9cbc1;
  --display: 'Fraunces', Georgia, serif;
  --hand: 'Caveat', 'Segoe Script', cursive;
  --body: 'Nunito Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: var(--body);
  background:
    radial-gradient(ellipse 70% 480px at 50% 300px, #24493c 0%, transparent 100%),
    linear-gradient(var(--pine), var(--night) 900px);
  background-repeat: no-repeat;
  background-color: var(--night);
}

#snow {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.page {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 16px 72px;
}

/* ------------------------------------------------------------ Le cadeau */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: min(86vh, 760px);
  justify-content: center;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.1;
  text-wrap: balance;
}

.gift {
  position: relative;
  width: min(68vw, 320px);
  aspect-ratio: 1;
  margin: 20px 0 8px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 24px;
  -webkit-tap-highlight-color: transparent;
}

.gift:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 6px; }
.gift svg { position: relative; display: block; width: 100%; height: 100%; overflow: visible; }

.gift-shadow { fill: rgba(0, 0, 0, 0.35); }

.gift-glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 209, 134, 0.42), transparent 68%);
  opacity: 0;
  transition: opacity 0.4s;
}

.gift-lid, .gift-box { transform-box: fill-box; transform-origin: 50% 100%; }
.gift-light { opacity: 0; }

/* Un cadeau attend d'être ouvert */
.gift.is-ready .gift-glow { opacity: 1; animation: pulse 2.6s ease-in-out infinite; }
.gift.is-ready svg { animation: float 3.4s ease-in-out infinite; }
.gift.is-ready:hover .gift-lid { transform: translateY(-8px) rotate(-3deg); }
.gift-lid { transition: transform 0.25s ease; }

/* Rien à ouvrir pour le moment */
.gift.is-waiting { cursor: default; }
.gift.is-waiting svg { filter: saturate(0.72) brightness(0.86); }
.gift.is-refused svg { animation: refuse 0.45s ease; }

/* Ouverture */
.gift.is-opening { cursor: default; }
.gift.is-opening svg { animation: shake 0.6s ease-in-out; }
.gift.is-opening .gift-lid {
  transition: transform 0.6s 0.55s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.45s 0.8s;
  transform: translateY(-120px) rotate(-22deg);
  opacity: 0;
}
.gift.is-opening .gift-light { opacity: 1; transition: opacity 0.2s 0.55s; }
.gift.is-opening .gift-glow {
  opacity: 1;
  transition: transform 0.8s 0.55s ease-out, opacity 0.2s;
  transform: scale(2.4);
}

@keyframes float { 50% { transform: translateY(-7px); } }
@keyframes pulse { 50% { transform: scale(1.1); } }
@keyframes shake {
  20% { transform: rotate(-4deg); }
  40% { transform: rotate(4deg); }
  60% { transform: rotate(-3deg); }
  80% { transform: rotate(2deg); }
}
@keyframes refuse {
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.status-title {
  margin: 4px 0 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 2.3rem);
  line-height: 1.15;
  color: var(--gold-soft);
  text-wrap: balance;
}

.status {
  margin: 6px 0 0;
  min-height: 1.5em;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}

/* --------------------------------------------------------- La collection */

.collection { margin-top: 32px; }

.collection-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding-bottom: 12px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--pine-line);
}

.collection-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.6rem;
}

.collection-head p {
  margin: 0;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cards > li { display: contents; }

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 6.4;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  border-radius: 4px;
}

button.card { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
button.card:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 4px; }

/* Carte déjà découverte : un polaroid légèrement de travers */
.polaroid {
  display: flex;
  flex-direction: column;
  padding: 9px 9px 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.card.polaroid { transform: rotate(var(--tilt, 0deg)); }
button.card.polaroid:hover { transform: rotate(0deg) translateY(-5px) scale(1.03); }

.polaroid-photo {
  position: relative;
  flex: 1;
  min-height: 0;
  background: linear-gradient(150deg, #e9dfc8, #d9cba9);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 2.2rem;
}

/* En absolu : une photo très haute ne doit pas déformer la carte. */
.polaroid-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.polaroid-day {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.polaroid-title {
  margin: 0;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Dos de carte : les jours pas encore découverts */
.card-back {
  display: grid;
  place-items: center;
  background: var(--pine-light);
  border: 1px solid var(--pine-line);
  color: var(--mist);
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 8px, transparent 8px 16px);
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid var(--pine-line);
  border-radius: 2px;
}

.card-number {
  font-family: var(--display);
  font-size: 2.5rem;
  line-height: 1;
}

.card-note {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 16px;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.25;
}

.card-locked { opacity: 0.62; }

/* Disponible, pas encore ouverte */
.card-ready {
  background-color: var(--berry);
  border-color: var(--gold);
  color: var(--cream);
  box-shadow: 0 0 22px rgba(227, 183, 90, 0.35);
}
.card-ready::before { border-color: var(--gold); }
.card-ready .card-number { color: var(--gold-soft); }
button.card-ready:hover { transform: translateY(-5px) scale(1.03); }

/* --------------------------------------------------------- La révélation */

.reveal {
  width: min(100% - 32px, 430px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}

.reveal[open] { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.reveal::backdrop { background: rgba(5, 12, 10, 0.82); backdrop-filter: blur(3px); }

.polaroid-large {
  width: 100%;
  min-height: 0;
  padding: 14px 14px 20px;
  overflow-y: auto;
  transform: rotate(-1deg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

/* Le texte long fait défiler la carte, il ne doit écraser ni le titre ni la photo. */
.polaroid-large > * { flex-shrink: 0; }

.reveal[open] .polaroid-large { animation: arrive 0.65s cubic-bezier(0.2, 1.25, 0.4, 1); }

@keyframes arrive {
  from { opacity: 0; transform: translateY(60px) scale(0.55) rotate(6deg); }
}

.polaroid-large .polaroid-photo {
  flex: none;
  aspect-ratio: 1;
  max-height: 52dvh;
  width: 100%;
  font-size: 4.5rem;
}

.polaroid-large .polaroid-photo img { object-fit: contain; background: #efe7d4; }
.polaroid-large .polaroid-day { margin-top: 14px; font-size: 0.75rem; }

.polaroid-large .polaroid-title {
  margin-top: 2px;
  font-size: 2.3rem;
  white-space: normal;
}

.reveal-message {
  margin: 8px 0 0;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.reveal-message:empty { display: none; }

.reveal-close {
  flex: none;
  padding: 11px 26px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--pine);
  color: var(--gold-soft);
  font: 700 1rem var(--body);
  cursor: pointer;
}
.reveal-close:hover { background: var(--pine-light); }
.reveal-close:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }

@media (max-width: 480px) {
  .page { padding-top: 28px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  #snow { display: none; }
}
