/* Prototype — esthétique volontairement neutre, inspirée de l'app Appareil photo d'iOS.
   Les couleurs et la typographie sont réunies ici pour être changées facilement. */
:root {
  --bg: #000;
  --fg: #fff;
  --dim: rgba(255, 255, 255, .55);
  --line: rgba(255, 255, 255, .14);
  --accent: #ffd60a;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.3 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
button:disabled { opacity: .35; cursor: default; }
a { color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.screen.is-active { display: flex; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(32px); } }

/* ---------- 1. Mot de passe ---------- */

#screen-login { overflow-y: auto; }
.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(var(--top) + 56px) 20px calc(var(--bottom) + 24px);
}
.login-title { font-size: 34px; font-weight: 700; }
.login-sub { margin-bottom: 12px; color: var(--dim); }
.login-input {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  outline: none;
  background: #1c1c1e;
  color: var(--fg);
  font: inherit;
  font-size: 22px; /* 16px minimum, sinon iOS zoome sur le champ */
  -webkit-user-select: text;
  user-select: text;
}
.login-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.login-error { min-height: 20px; font-size: 15px; color: #ff453a; }
.login-btn {
  padding: 14px;
  border-radius: 12px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
}
.login.is-wrong .login-input { animation: shake .35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ---------- 2. Appareil photo ---------- */

.cam-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(var(--top) + 48px);
  padding: var(--top) 16px 0;
  font-size: 15px;
}
.cam-user {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-weight: 600;
}
.cam-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cam-user svg { flex: none; }
.cam-info {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.cam-gps { color: rgba(255, 255, 255, .25); transition: color .3s; }
.cam-gps.is-on { color: var(--accent); }

.cam-view {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
/* Cadre 3:4 comme sur iPhone ; la photo enregistrée correspond exactement à ce cadre */
.cam-frame {
  position: relative;
  width: min(100cqw, 75cqh);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #111;
}
@media (orientation: landscape) {
  .cam-frame { width: min(100cqw, 133.33cqh); aspect-ratio: 4 / 3; }
}
.cam-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  font-size: 15px;
  color: var(--dim);
}
.cam-msg button { color: var(--accent); }
.cam-blink {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
.cam-blink.is-on { animation: blink .3s ease-out; }
@keyframes blink { from { opacity: 1; } to { opacity: 0; } }

.cam-bottom {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--bottom) + 128px);
  padding: 0 32px var(--bottom);
}
.cam-thumb {
  justify-self: start;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  background: #1c1c1e;
}
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cam-shutter {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 4px solid #fff;
  padding: 4px;
}
.cam-shutter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  transition: transform .12s;
}
.cam-shutter:active span { transform: scale(.88); }
.cam-import {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}

/* ---------- 3. Mots-clés ---------- */

#screen-tags { z-index: 10; overflow: hidden; }
#screen-tags.is-active { animation: fade-in .25s ease-out; }
.tags-bg {
  position: absolute;
  inset: -60px;
  background: center / cover no-repeat;
  filter: blur(30px) saturate(1.2);
}
.tags-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .4);
}
.tags-head {
  position: relative;
  flex: none;
  padding: calc(var(--top) + 16px) 20px 4px;
  text-align: center;
  font-size: 15px;
  color: rgba(255, 255, 255, .75);
}
.tags-list {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
}
.tags-words {
  margin-block: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 8px;
}
.tag {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08);
  font-size: 24px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tag[aria-pressed="true"] {
  background: #fff;
  border-color: #fff;
  color: #000;
}
.tags-bar {
  position: relative;
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 20px calc(var(--bottom) + 16px);
}
.tags-bar button { justify-self: start; }
.tags-bar .tags-use { justify-self: end; color: var(--accent); font-weight: 600; }
.tags-count { font-size: 15px; color: var(--dim); }

/* ---------- Accès enseignant·e ---------- */

.adm-head {
  flex: none;
  padding: calc(var(--top) + 10px) 16px 12px;
}
.adm-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}
.adm-bar button { color: var(--accent); }
.adm-title { font-size: 34px; font-weight: 700; }
.adm-sub { font-size: 15px; color: var(--dim); }
.adm-filters {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
}
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 600px) {
  .chips { flex-wrap: wrap; overflow: visible; }
}
.chip {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  font-size: 15px;
  white-space: nowrap;
}
.chip span {
  font-size: 13px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.chip[aria-pressed="true"] span { color: rgba(0, 0, 0, .55); }

/* ---------- Galerie ---------- */

#screen-gallery { z-index: 20; }
#screen-gallery.is-active { animation: rise .25s ease-out; }
.gal-head {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--top) + 10px) 16px 12px;
  text-align: center;
}
.gal-head h2 { font-size: 17px; font-weight: 600; }
.gal-head p { font-size: 13px; color: var(--dim); }
.gal-close { justify-self: end; color: var(--accent); font-weight: 600; }
.gal-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;
  gap: 2px;
  padding-bottom: var(--bottom);
}
@media (min-width: 600px) {
  .gal-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
.gal-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #1c1c1e;
}
.gal-item img { width: 100%; height: 100%; object-fit: cover; }
.gal-item.is-pending::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.gal-empty {
  grid-column: 1 / -1;
  padding: 64px 20px;
  text-align: center;
  color: var(--dim);
}

/* ---------- Photo en grand ---------- */

#screen-viewer { z-index: 30; }
#screen-viewer.is-active { animation: fade-in .2s ease-out; }
.viewer-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  padding: calc(var(--top) + 10px) 16px 10px;
}
.viewer-head button { color: var(--accent); }
.viewer-head .viewer-delete { color: #ff453a; }
.viewer-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}
.viewer-meta {
  flex: none;
  padding: 16px 20px calc(var(--bottom) + 20px);
  font-size: 15px;
  color: var(--dim);
}
.viewer-tags {
  margin-bottom: 4px;
  font-size: 20px;
  color: var(--fg);
}
