/* Galerie « Colo 2026 » — épurée, inspirée d'ondonnedesnouvelles :
   fond clair, accent turquoise unique, coins arrondis, ombres douces. */
:root {
  --accent: #3a99d8;
  --accent-dark: #2f86c2;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #222222;
  --muted: #8a9199;
  --line: #e7eaee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, .06);
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, .12);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* --- Boutons --- */
.btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  padding: .8rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  padding: .4rem .5rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--accent);
}
.icon-btn:hover { background: rgba(58, 153, 216, .1); }

/* --- Connexion --- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.6rem;
  width: min(360px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.login-logo { border-radius: 20px; align-self: center; }
.login-card h1 { margin: .2rem 0 0; font-size: 1.5rem; }
.login-card p { margin: 0; font-size: .95rem; }
.login-card input {
  font: inherit;
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58, 153, 216, .18); }
.error { color: #e05a4b; font-weight: 700; font-size: .9rem; margin: 0; }

/* --- Barre supérieure --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  padding-top: max(.7rem, env(safe-area-inset-top));
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 900; color: var(--accent); font-size: 1.15rem; }
.pill {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: .72rem;
  padding: .15rem .55rem;
  border-radius: 999px;
}

/* --- Fil des publications --- */
.feed { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.pub { margin-bottom: 1.8rem; }
.pub-head { margin: 0 .2rem .6rem; }
.pub-date { font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: capitalize; }
.pub-title { margin: .1rem 0 0; font-size: 1.05rem; font-weight: 800; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #e9edf1;
  cursor: pointer;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s;
}
.tile img.loading { opacity: 0; }
.tile.seen img { opacity: .78; }

/* Pastille « non vu » */
.tile.unseen::after {
  content: "";
  position: absolute;
  top: 7px; right: 7px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #fff;
}

/* Tuile vidéo : superposition « play » (pas de poster côté API) */
.tile.video::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #4aa8e4, #3a99d8);
}
.tile.video .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2rem;
}
.tile.video .play::after {
  content: "▶";
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  background: rgba(255, 255, 255, .22);
  border-radius: 50%;
  padding-left: 4px;
}

.empty, .footer { text-align: center; padding: 2rem 1rem; }
.footer { font-size: .8rem; }

/* --- Visionneuse plein écran --- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(10, 12, 14, .96);
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-stage {
  max-width: 100vw;
  max-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-stage img,
.viewer-stage video {
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
}
.viewer-close, .viewer-nav {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.viewer-close {
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 42px; height: 42px;
  font-size: 1.1rem;
}
.viewer-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  font-size: 1.8rem;
  line-height: 1;
}
.viewer-prev { left: 10px; }
.viewer-next { right: 10px; }
.viewer-caption {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-size: .85rem;
  opacity: .85;
  padding: 0 3.5rem;
  pointer-events: none;
}
@media (hover: none) {
  /* Sur mobile, on navigue au swipe : on allège les flèches. */
  .viewer-nav { opacity: .5; }
}

/* --- Onglets Toutes / Mes enfants --- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  gap: .4rem;
  padding: .5rem 1rem;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  justify-content: center;
}
.tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 800;
  color: var(--muted);
  padding: .4rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.tab .heart { color: #e05a7a; font-size: .9em; }
.tab.is-active { background: var(--accent); color: #fff; }
.tab.is-active .heart { color: #fff; }
.tab-count {
  font-size: .72rem;
  background: rgba(0, 0, 0, .12);
  border-radius: 999px;
  padding: 0 .4rem;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, .28); }

/* --- Bouton « mes enfants » sur une tuile --- */
.flag-btn {
  position: absolute;
  bottom: 6px; left: 6px;
  z-index: 2;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(2px);
  transition: transform .1s;
}
.flag-btn:hover { transform: scale(1.1); }
.flag-btn.on { color: #ff5a7a; background: rgba(255, 255, 255, .9); }

/* --- Bouton « mes enfants » dans la visionneuse --- */
.viewer-flag {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  z-index: 21;
  width: 42px; height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.viewer-flag.on { color: #ff5a7a; background: rgba(255, 255, 255, .92); }

/* --- Panneau Réglages (feuille) --- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(10, 12, 14, .5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) { .sheet { align-items: center; } }
.sheet-panel {
  background: var(--card);
  width: min(460px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.2rem 1.3rem calc(1.3rem + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) { .sheet-panel { border-radius: var(--radius); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; color: var(--accent); }
.setting { padding: .9rem 0; border-top: 1px solid var(--line); }
.setting h3 { margin: 0 0 .2rem; font-size: 1rem; }
.small { font-size: .85rem; }
.setting p.small { margin: .1rem 0 .6rem; }
.field-row { display: flex; gap: .5rem; align-items: center; }
.field-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg);
  color: var(--text);
}
.field-row input:focus { border-color: var(--accent); }
.btn.small { padding: .55rem .9rem; font-size: .9rem; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn.ghost:hover { background: rgba(58, 153, 216, .1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn {
  margin-top: .6rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* --- Choix segmenté (fréquence des notifications) --- */
.segmented { display: flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  color: var(--text);
  padding: .55rem .3rem;
  cursor: pointer;
}
.seg + .seg { border-left: 1.5px solid var(--line); }
.seg.is-active { background: var(--accent); color: #fff; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #14171a; --card: #1e2226; --text: #e8eaed; --muted: #9aa2ab; --line: #2c3238; }
  .topbar, .tabs { background: rgba(20, 23, 26, .9); }
  .tile { background: #2a2f34; }
  .tab-count { background: rgba(255, 255, 255, .14); }
}
