/*
  Hub d'accueil — ciel étoilé doux.
  Deux écrans (#gate puis #hub) au-dessus d'un canvas d'étoiles (#sky).
  Le cadeau de la lettre s'ouvre puis tombe : classes .is-opening puis .is-falling posées par hub.js.
*/

:root {
  --night-1: #0b1026;
  --night-2: #1a1442;
  --night-3: #2d1b52;
  --ink: #f6f1ff;
  --ink-dim: rgba(246, 241, 255, .72);
  --gold: #ffd59e;
  --rose: #ff8fab;
  --glass: rgba(255, 255, 255, .06);
  --glass-edge: rgba(255, 255, 255, .14);
  --radius: 22px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; }

html, body { min-height: 100%; }

body {
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(255, 143, 171, .18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 10%, rgba(120, 100, 255, .18), transparent 70%),
    linear-gradient(180deg, var(--night-1), var(--night-2) 55%, var(--night-3));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

main { position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; }

.screen {
  width: min(100%, 980px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  animation: appear 1.2s var(--ease-out) both;
}
.screen[hidden] { display: none; }
.screen.leaving { animation: vanish .7s ease forwards; }

.kicker {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

h1 {
  font: 400 clamp(2.1rem, 8vw, 3.6rem)/1.1 "Fraunces", serif;
  letter-spacing: -.01em;
}
.name {
  display: inline-block;
  font: 400 1.35em/1 "Pinyon Script", cursive;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 213, 158, .45);
  padding: 0 .08em;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Écran du code ---------- */

.hint { font: italic 400 1.05rem/1.4 "Fraunces", serif; color: var(--ink-dim); max-width: 30ch; }

.gate-form { display: flex; gap: 10px; margin-top: 8px; width: min(100%, 340px); }
.gate-form input {
  flex: 1;
  min-width: 0;
  padding: .85em 1.1em;
  border-radius: 999px;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  color: var(--ink);
  font: 500 1.1rem/1 "Inter", sans-serif;
  letter-spacing: .3em;
  text-align: center;
  outline: none;
  transition: border-color .3s ease, box-shadow .3s ease;
}
.gate-form input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255, 213, 158, .15); }
.gate-form button, .feedback-button {
  padding: .85em 1.4em;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  color: #2a1640;
  font: 600 .95rem/1 "Inter", sans-serif;
  cursor: pointer;
  transition: transform .2s ease, filter .2s ease;
}
.gate-form button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.gate-form button:active { transform: translateY(1px); }
.gate-form button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.feedback { min-height: 1.4em; color: var(--rose); font-size: .95rem; }
#gate.is-shaking .gate-form { animation: shake .45s ease; }

/* ---------- Hub : les cartes ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 28px);
  width: 100%;
  margin-top: 26px;
}

.card {
  --bob-delay: 0s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 18px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: inherit;
  text-decoration: none;
  animation: bob 6s ease-in-out var(--bob-delay) infinite;
  transition: border-color .3s ease, background .3s ease, box-shadow .3s ease;
}
.card:nth-child(2) { --bob-delay: -2s; }
.card:nth-child(3) { --bob-delay: -4s; }
.card:hover, .card:focus-visible {
  border-color: rgba(255, 213, 158, .5);
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), 0 0 40px rgba(255, 213, 158, .12);
  outline: none;
}

.icon { position: relative; display: block; width: 112px; height: 112px; }
.icon svg { display: block; width: 100%; height: 100%; overflow: visible; }

.card-title { font: 600 1.25rem/1.2 "Fraunces", serif; }
.card-text { font-size: .92rem; color: var(--ink-dim); }

.badge {
  position: absolute;
  top: 12px; right: 12px;
  padding: .3em .7em;
  border-radius: 999px;
  background: var(--rose);
  color: #2a1640;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  animation: pulse 2.4s ease-in-out infinite;
}

/* Icône planète-chat : l'anneau tourne doucement au survol */
.icon--planet svg { transition: transform .6s var(--ease-out); }
.card:hover .icon--planet svg { transform: rotate(-8deg) scale(1.05); }

/* Icône terminal : curseur clignotant */
.terminal-text { font: 700 30px/1 ui-monospace, "SFMono-Regular", Menlo, monospace; fill: #7ee0a1; }
.icon--terminal .cursor { animation: blink 1s steps(1) infinite; }

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

.gift-box, .gift-lid, .gift-heart { position: absolute; inset: 0; display: block; }
.gift-lid { transform-origin: 50% 40%; }
.card--gift:hover .gift-lid { animation: wiggle .6s ease-in-out; }

.gift-heart {
  inset: 34% 30% 30%;
  opacity: 0;
  transform: translateY(20px) scale(.4);
  filter: drop-shadow(0 0 12px rgba(255, 122, 147, .8));
}

.card--gift.is-opening { animation-play-state: paused; z-index: 5; }
.card--gift.is-opening .gift-lid { animation: lid-off .7s var(--ease-out) forwards; }
.card--gift.is-opening .gift-heart { animation: heart-rise 1.1s .25s var(--ease-out) forwards; }
.card--gift.is-falling .gift-box { animation: fall 1s cubic-bezier(.55, 0, 1, .45) forwards; }
.card--gift.is-falling .gift-lid { animation: lid-off .7s var(--ease-out) forwards, fall-lid 1.1s .05s cubic-bezier(.55, 0, 1, .45) forwards; }

@keyframes lid-off {
  to { transform: translate(-18px, -46px) rotate(-28deg); }
}
@keyframes fall {
  from { transform: none; }
  to { transform: translateY(120vh) rotate(22deg); }
}
@keyframes fall-lid {
  from { transform: translate(-18px, -46px) rotate(-28deg); }
  to { transform: translate(-60px, 120vh) rotate(-140deg); }
}
@keyframes heart-rise {
  60% { opacity: 1; transform: translateY(-34px) scale(1.25); }
  to { opacity: 1; transform: translateY(-28px) scale(1.1); }
}

/* ---------- Animations communes ---------- */

@keyframes appear { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }
@keyframes vanish { to { opacity: 0; transform: translateY(-10px); filter: blur(6px); } }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 143, 171, 0); transform: scale(1.06); } }
@keyframes wiggle {
  25% { transform: rotate(-6deg) translateY(-3px); }
  75% { transform: rotate(5deg) translateY(-2px); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ---------- Téléphone : cartes empilées ---------- */

@media (max-width: 680px) {
  .cards { grid-template-columns: 1fr; max-width: 360px; margin-top: 18px; }
  .card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 16px;
    row-gap: 2px;
    padding: 16px 18px;
    text-align: left;
  }
  .card .icon { grid-row: 1 / span 2; width: 76px; height: 76px; }
  .card-title { align-self: end; }
  .card-text { align-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
