@import url('https://fonts.googleapis.com/css2?family=Bangers&display=swap');

:root {
  --bg: #101214;
  --bg-elevated: #17191d;
  --text: #ececec;
  --text-dim: #9a9a9a;
  --accent: #e8b04b;
  --border: #26282c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/* Empêche le menu "Enregistrer l'image" au appui long sur iOS/Android */
img, video {
  -webkit-touch-callout: none;
}

.topbar {
  padding: 16px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-family: 'Bangers', cursive;
  font-size: 3rem;
  letter-spacing: 0.06em;
  color: #2f6fed;
  -webkit-text-stroke: 1.5px #0d2c8f;
  text-shadow:
    2px 2px 0 #0d2c8f,
    4px 4px 0 rgba(13, 44, 143, 0.4);
  transform: rotate(-2deg);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 8px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

section { margin-bottom: 40px; }

section h2 {
  font-size: 1.1rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.video-section h2 {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Animation de chargement bleue, centrée, en boucle sur 15s ---------- */

.page-loading-banner {
  display: flex;
  justify-content: center;
  padding: 0 24px;
  margin: 0 0 24px;
}

.page-loading-bar {
  width: 100%;
  max-width: 480px;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}

.page-loading-bar-fill {
  height: 100%;
  width: 0%;
  margin: 0 auto;
  border-radius: 999px;
  background: #2f6fed;
  animation: page-bar-fill 40s linear infinite;
}

@keyframes page-bar-fill {
  0%   { width: 0%; }
  50%  { width: 100%; }
  100% { width: 0%; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  position: relative;
}

.tile img, .tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: auto;
}

.tile img.lightbox-trigger {
  cursor: zoom-in;
  transition: transform 0.25s ease;
}

.tile img.lightbox-trigger:hover {
  transform: scale(1.04);
}

/* Grille vidéo : une vidéo par ligne, en pleine largeur (100% au lieu
   de la grille photo en colonnes ~30%). */
.video-grid {
  grid-template-columns: 1fr;
  gap: 0;
}

/* Format portrait : les vidéos sont filmées à la verticale (téléphone),
   donc le lecteur est plus haut que large pour ne rien couper. */
.video-grid .tile {
  aspect-ratio: 9 / 16;
  max-width: 480px;
  margin: 0 auto;
}

/* Le lecteur vidéo prend une bordure bleue et perd ses coins arrondis
   en bas, pour se fondre avec la barre de smileys collée dessous. */
.video-tile {
  border: 2px solid #2f6fed;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

/* Espace normal entre chaque bloc vidéo (plus de ligne bleue entre elles). */
.video-item:not(:last-child) {
  margin-bottom: 28px;
}

/* Barre de smileys transparente, directement collée sous la vidéo,
   avec la même largeur que le lecteur et une bordure bleue qui
   prolonge celle-ci — comme si elle faisait partie du lecteur. */
.video-reactions-bar {
  max-width: 480px;
  margin: 0 auto;
  background: transparent;
  border: 2px solid #2f6fed;
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 10px 12px;
}

.video-reactions-bar .reactions {
  gap: 4px 6px;
}

.video-reactions-bar .reaction-btn {
  color: var(--text);
  text-shadow: none;
}

/* Écran d'attente affiché tant que la vidéo n'a pas assez de
   données en mémoire tampon pour être lancée sans blocage. */
.video-tile {
  position: relative;
}

.video-tile video {
  visibility: hidden;
  object-fit: contain;
  background: #000;
}

.video-tile.video-ready video {
  visibility: visible;
}

.video-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  transition: opacity 0.3s ease;
}

.video-tile.video-ready .video-loading {
  opacity: 0;
  pointer-events: none;
}

.video-loading-spinner {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: #2f6fed;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: video-spin 1s linear infinite;
}

.video-loading-text {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #2f6fed;
  /* Contre-rotation pour que le texte reste toujours lisible pendant
     que l'anneau autour de lui tourne. */
  animation: video-spin-reverse 1s linear infinite;
}

@keyframes video-spin {
  to { transform: rotate(360deg); }
}

@keyframes video-spin-reverse {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  cursor: zoom-out;
  /* Désactive le pincer-zoomer natif du téléphone sur toute la lightbox :
     c'est le JS (lightbox.js) qui gère le zoom, uniquement sur la photo,
     pour que les smileys gardent toujours la même taille. */
  touch-action: none;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: block;
  touch-action: none;
  transform-origin: center center;
  will-change: transform;
  position: relative;
  z-index: 1;
}

.lightbox-content {
  position: relative;
  display: inline-flex;
}

.lightbox-reactions {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
}

.lightbox-reactions .reaction-btn {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 1.3rem;
  gap: 8px;
  white-space: nowrap;
}

.lightbox-reactions .reaction-emoji {
  font-size: 48px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.35);
  border: none;
  color: rgba(255, 255, 255, 0.55);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.lightbox-nav.hidden {
  display: none;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

/* Mobile : la photo laisse de la place en bas de l'écran pour la
   bande de smileys, qui est toujours affichée en dessous de la photo
   (jamais par-dessus), que la photo soit zoomée ou non. */
@media (max-width: 700px) {
  .lightbox img {
    max-height: 78vh;
  }

  .lightbox-reactions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    transform: none;
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    gap: 3vw;
    z-index: 1002;
    isolation: isolate;
  }

  .lightbox-reactions .reaction-btn {
    background: none;
    padding: 1.6vw 2.4vw;
    font-size: 3vw;
    gap: 1.2vw;
  }

  .lightbox-reactions .reaction-emoji {
    font-size: 6vw;
  }

  .lightbox-nav {
    width: 34px;
    height: 34px;
    font-size: 1.4rem;
    top: 42%;
  }

  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
}

.tile-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
  z-index: 2;
}

.view-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.65rem;
  font-weight: 400;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.view-badge .eye-icon {
  width: 11px;
  height: 11px;
  color: rgba(255, 255, 255, 0.55);
}

.tile-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
  z-index: 2;
}

.reactions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  gap: 2px 4px;
}

.reaction-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 3px;
  cursor: pointer;
  color: #fff;
  font-size: 0.7rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  flex: 1;
}

.reaction-emoji {
  font-size: 22px;
  line-height: 1;
  filter: grayscale(85%) opacity(0.75);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.reaction-count {
  color: var(--text-dim);
  text-shadow: none;
}

.reaction-btn.active .reaction-emoji {
  filter: none;
  transform: scale(1.2);
}

.reaction-btn:active .reaction-emoji {
  transform: scale(1.3);
}

/* Couche invisible par-dessus les images pour bloquer le glisser-déposer natif du navigateur */
.tile.protected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
}

.empty code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---------- Livre d'or ---------- */

#guestbook {
  max-width: 700px;
  margin: 0 auto;
}

.guestbook-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.guestbook-input,
.guestbook-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

.guestbook-textarea {
  resize: vertical;
  min-height: 70px;
}

.guestbook-input:focus,
.guestbook-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.guestbook-submit {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  padding: 9px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.guestbook-submit:hover {
  opacity: 0.9;
}

.guestbook-submit:disabled {
  opacity: 0.5;
  cursor: default;
}

.guestbook-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.guestbook-error {
  margin: 0;
  color: #e06060;
  font-size: 0.8rem;
}

.guestbook-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guestbook-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px 0;
}

.guestbook-message {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

/* Discret : adresse IP, petite et estompée, juste au-dessus du pseudo */
.guestbook-ip {
  display: block;
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.55;
  margin-bottom: 2px;
}

.guestbook-message-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 4px;
}

.guestbook-pseudo {
  font-weight: 600;
  font-size: 0.9rem;
}

.guestbook-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.guestbook-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-line;
}

/* ---------- Footer ---------- */

.sitefooter {
  max-width: 700px;
  margin: 40px auto 0;
  padding: 32px 24px 48px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.share-box {
  margin-bottom: 28px;
}

.share-title {
  color: var(--text);
  font-size: 1rem;
  margin: 0 0 16px;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  padding: 14px 22px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: transform 0.15s ease, background 0.15s ease;
}

.share-btn:hover {
  transform: translateY(-2px);
}

.share-btn svg {
  width: 44px;
  height: 44px;
}

.share-whatsapp svg { color: #25D366; }
.share-telegram svg { color: #29A9EB; }

.visitor-box {
  display: inline-block;
  margin: 0 auto 24px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.bottom-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.bottom-row .visitor-box {
  margin: 0;
}

.visit-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 64px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 2.2rem;
  font-weight: 700;
  color: #45484f;
}

.visitor-title {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.visitor-line {
  margin: 2px 0;
  font-size: 0.85rem;
  color: var(--text);
}

.visitor-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 50%;
  background: rgba(62, 207, 107, 0.15);
  color: #3ecf6b;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
