/* Mur de souvenirs — une nuit d'été sous une guirlande de guinguette */

/* Polices hébergées sur le serveur (licence OFL, voir fonts/LICENSE-OFL.txt) */
@font-face { font-family: "Bagel Fat One"; src: url("/fonts/bagel-fat-one.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/fonts/atkinson-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --night: #0f2a22;
  --leaf: #17392f;
  --leaf-2: #22493d;
  --paper: #f4ead6;
  --muted: #a9bdb2;
  --amber: #ffc46b;
  --rose: #f49ac1;
  --sky: #8fd3f4;
  --mint: #a6e3b8;
  --peach: #ffb38a;
  --danger: #ff9b8a;

  --font-display: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

  --gutter: clamp(16px, 4vw, 32px);
  --garland-h: 118px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 420px at 50% 0, rgba(255, 196, 107, 0.13), transparent 70%),
    var(--night);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img, video { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 6px; }

/* ------------------------------------------------------------ guirlande */
.garland {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  height: var(--garland-h);
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}
.garland .wire { fill: none; stroke: #061510; stroke-width: 2.2; stroke-linecap: round; }
.garland .socket { fill: #0a1d17; }
.garland .glass { opacity: 0.32; transition: opacity 0.5s ease; }
.garland .halo { opacity: 0; transition: opacity 0.6s ease; transform-box: fill-box; transform-origin: center; }
.garland .bulb.on .glass { opacity: 1; }
.garland .halo.on { opacity: var(--halo, 0.55); }

.c-amber { fill: var(--amber); }
.c-rose  { fill: var(--rose); }
.c-sky   { fill: var(--sky); }
.c-mint  { fill: var(--mint); }
.c-peach { fill: var(--peach); }

/* scintillement léger, chaque ampoule à son rythme */
@media (prefers-reduced-motion: no-preference) {
  body:not(.closed) .garland .halo.on {
    animation: twinkle var(--tw, 4s) ease-in-out var(--twd, 0s) infinite;
  }
  .garland .halo.pulse {
    animation: pulse 1.1s ease-out 1 !important;
  }
}
@keyframes twinkle {
  0%, 100% { opacity: var(--halo, 0.55); }
  50% { opacity: calc(var(--halo, 0.55) * 0.62); }
}
@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  35% { opacity: 1; transform: scale(1.9); }
  100% { opacity: var(--halo, 0.55); transform: scale(1); }
}

/* ------------------------------------------------------------ page */
.page {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(var(--garland-h) + 28px) var(--gutter) 0;
}

.hero { padding-bottom: 40px; }
.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.75rem, 12.5vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-shadow: 0 0 34px rgba(255, 196, 107, 0.35);
  overflow-wrap: anywhere;
}
.subtitle {
  margin: 18px 0 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 1.125rem;
}

/* vidéo de l'anniversaire */
.featured { margin: 28px 0 0; }
.featured video {
  width: 100%;
  max-height: 72vh;
  background: #061510;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(255, 196, 107, 0.25), 0 0 40px rgba(255, 196, 107, 0.16);
}
.featured figcaption { margin-top: 12px; }
.featured-credit { margin: 0; font-weight: 700; }
.featured-credit a { color: var(--amber); text-underline-offset: 3px; }
.featured-note { margin: 4px 0 0; color: var(--muted); font-style: italic; max-width: 36em; }

.countdown { margin-top: 32px; }
.countdown-lead { margin: 0 0 6px; color: var(--muted); }
.countdown-units {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, max-content));
  gap: 0 clamp(18px, 6vw, 40px);
}
.unit { display: flex; flex-direction: column; }
.unit b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 12vw, 4rem);
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px rgba(255, 196, 107, 0.45);
}
.unit small { margin-top: 4px; color: var(--muted); font-size: 0.95rem; }
.countdown.soon .unit b { color: var(--peach); }

.closed-note {
  margin: 28px 0 0;
  padding: 16px 18px;
  border-left: 3px solid var(--amber);
  background: rgba(255, 196, 107, 0.07);
  border-radius: 0 10px 10px 0;
  max-width: 36em;
}

/* ------------------------------------------------------------ sections */
.block { padding: 36px 0 8px; border-top: 1px solid var(--leaf-2); }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.block-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  line-height: 1.05;
}
.count { color: var(--muted); white-space: nowrap; }

.empty {
  margin: 8px 0 24px;
  padding: 22px 18px;
  border: 1.5px dashed var(--leaf-2);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------ boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-light {
  background: var(--amber);
  color: #2a1a00;
  box-shadow: 0 0 0 0 rgba(255, 196, 107, 0);
}
.btn-light:hover { box-shadow: 0 0 26px 2px rgba(255, 196, 107, 0.35); }
.btn-light:active { transform: scale(0.97); }
.btn[disabled], .btn.busy { opacity: 0.6; pointer-events: none; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ------------------------------------------------------------ envoi */
.uploader { margin-bottom: 22px; }
.uploader .btn { width: 100%; font-size: 1.0625rem; }
.who-am-i { margin: 12px 0 0; color: var(--muted); font-size: 0.95rem; }
.who-am-i strong { color: var(--paper); }

.progress { margin-top: 14px; }
.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--leaf);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--amber);
  box-shadow: 0 0 14px rgba(255, 196, 107, 0.7);
  transition: width 0.2s linear;
}
.progress-text { display: block; margin-top: 6px; color: var(--muted); font-size: 0.95rem; }

/* ------------------------------------------------------------ galerie */
.gallery {
  columns: 2 150px;
  column-gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 640px) { .gallery { columns: 3 180px; column-gap: 12px; } }

.tile {
  break-inside: avoid;
  margin: 0 0 12px;
  position: relative;
}
.tile-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--leaf);
  border-radius: 6px;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.tile img, .tile video {
  width: 100%;
  height: auto;
  background: var(--leaf);
  object-fit: cover;
}
.tile.is-video video { aspect-ratio: 9 / 12; }
.tile.new .tile-btn { box-shadow: 0 0 0 2px var(--amber), 0 0 24px rgba(255, 196, 107, 0.45); transition: box-shadow 2.5s ease; }

.play {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 52px; height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(15, 42, 34, 0.72);
  border: 2px solid rgba(244, 234, 214, 0.85);
  pointer-events: none;
}
.play::after {
  content: "";
  position: absolute;
  left: 19px; top: 14px;
  border-style: solid;
  border-width: 11px 0 11px 17px;
  border-color: transparent transparent transparent var(--paper);
}
.tile figcaption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px 0;
  font-size: 0.875rem;
  line-height: 1.3;
}
.tile figcaption .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile figcaption time { color: var(--muted); white-space: nowrap; }

/* couleurs des prénoms, comme les ampoules */
.t-amber { color: var(--amber); }
.t-rose  { color: var(--rose); }
.t-sky   { color: var(--sky); }
.t-mint  { color: var(--mint); }
.t-peach { color: var(--peach); }

/* ------------------------------------------------------------ discussion */
.messages {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg {
  max-width: 82%;
  align-self: flex-start;
  margin-top: 10px;
}
.msg.cont { margin-top: 0; }
.msg.cont .msg-meta { display: none; }
.msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 0 3px 4px;
  font-size: 0.875rem;
}
.msg-meta .who { font-weight: 700; }
.msg-meta time { color: var(--muted); }
.msg-text {
  margin: 0;
  padding: 9px 14px;
  background: var(--leaf);
  border-radius: 4px 18px 18px 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.cont .msg-text { border-radius: 18px; }
.msg.mine { align-self: flex-end; }
.msg.mine .msg-meta { justify-content: flex-end; margin: 0 4px 3px 0; }
.msg.mine .msg-text { background: var(--leaf-2); border-radius: 18px 4px 18px 18px; }
.msg.mine.cont .msg-text { border-radius: 18px; }
.msg.new .msg-text { animation: arrive 0.35s ease-out; }
@keyframes arrive { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msg.new .msg-text { animation: none; } }

.composer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin: 0 calc(var(--gutter) * -1);
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(15, 42, 34, 0), var(--night) 30%);
}
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 16px;
  border: 1.5px solid var(--leaf-2);
  border-radius: 24px;
  background: var(--leaf);
  resize: none;
  line-height: 1.35;
}
.composer textarea::placeholder { color: var(--muted); opacity: 0.8; }
.composer textarea:focus-visible { outline: none; border-color: var(--amber); }

.page-end { height: 40px; }

/* ------------------------------------------------------------ vitrine */
body.closed .uploader,
body.closed .composer,
body.closed #countdown { display: none !important; }

/* ------------------------------------------------------------ porte d'entrée */
.gate {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: calc(var(--garland-h) + clamp(32px, 12vh, 120px)) var(--gutter) 24px;
  overflow-y: auto;
}
.gate-card {
  width: 100%;
  max-width: 420px;
}
.gate-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 9vw, 2.7rem);
  line-height: 1;
  text-shadow: 0 0 30px rgba(255, 196, 107, 0.3);
}
.gate-card p { margin: 0 0 18px; color: var(--muted); }
.gate-card input {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border: 1.5px solid var(--leaf-2);
  border-radius: 14px;
  background: var(--leaf);
  font-size: 1.25rem;
}
.gate-card input:focus-visible { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 196, 107, 0.25); }
.gate-card .btn { width: 100%; margin-top: 6px; }
.form-error { min-height: 1.5em; margin: 8px 0 4px !important; color: var(--danger) !important; font-size: 0.95rem; }

/* ------------------------------------------------------------ visionneuse */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(4, 14, 11, 0.96);
  display: grid;
  grid-template-rows: 1fr auto;
}
.lb-stage {
  grid-row: 1;
  display: grid;
  place-items: center;
  padding: 56px 8px 8px;
  min-height: 0;
  touch-action: pan-y;
}
.lb-stage img, .lb-stage video {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  border-radius: 4px;
}
.lb-footer {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  font-size: 0.95rem;
}
.lb-caption { color: var(--muted); }
.lb-caption .who { font-weight: 700; }
.lb-download { color: var(--amber); font-weight: 700; text-underline-offset: 3px; }
.lb-btn {
  position: absolute;
  z-index: 1;
  width: 48px; height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 57, 47, 0.85);
  cursor: pointer;
}
.lb-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--paper); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lb-close { top: 10px; right: 10px; }
.lb-prev, .lb-next { top: 50%; margin-top: -40px; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--paper);
  color: var(--night);
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ------------------------------------------------------------ admin */
.admin .page { padding-top: calc(var(--garland-h) + 12px); }
.admin-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.admin-item { background: var(--leaf); border-radius: 8px; overflow: hidden; font-size: 0.875rem; }
.admin-item img, .admin-item video { width: 100%; aspect-ratio: 1; object-fit: cover; }
.admin-item .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); min-height: 36px; padding: 6px 12px; }
.btn-ghost { background: transparent; color: var(--paper); border: 1.5px solid var(--leaf-2); }
.admin-msgs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.admin-msgs li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; background: var(--leaf); border-radius: 10px; padding: 8px 12px; }
.admin-msgs p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--muted); margin: 0 0 18px; }
.stats b { color: var(--paper); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="datetime-local"] { min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--leaf-2); background: var(--leaf); }
