/* ==========================================================================
   simul — design system v3
   Direction claire/creme, glassmorphism chaud, Newsreader + Manrope.
   Tous les selecteurs restent identiques (app.js/capture.js en dependent).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,400;0,500;1,400;1,500&family=Manrope:wght@400;500;600;700&display=swap');

:root{
  --bg:        #f8f5ed;
  --bg-alt:    #f2ede2;
  --bg-card:   #efe8d8;
  --surface:   #fefcf8;
  --ink:       #2a2420;
  --ink-dim:   #928a83;
  --border:    #e4ddd0;

  /* accent mesure sur les vraies captures : aubergine sombre */
  --accent:      #28042a;
  --accent-dark: #28042a;
  --accent-soft: rgba(40,4,42,.10);

  /* alias conserves pour compatibilite avec les regles existantes */
  --violet: var(--accent);
  --bleu:   var(--accent);
  --vert:   var(--accent-dark);
  --gradient:      var(--accent);
  --gradient-soft: var(--accent-soft);

  --danger:    oklch(58% 0.13 25);

  --display: 'Newsreader', Georgia, serif;
  --sans:    'Manrope', -apple-system, 'Segoe UI', sans-serif;
  --mono:    'Manrope', -apple-system, sans-serif;

  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 12px 32px oklch(30% 0.02 60 / .12);

  --glass-bg: oklch(99% 0.005 85 / .55);
  --glass-border: oklch(100% 0 0 / .6);
}

*{ box-sizing: border-box; }

html,body{
  margin:0; padding:0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3{
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -.005em;
  margin: 0;
}

.eyebrow{
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--ink-dim);
}

button{
  font-family: var(--sans);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible{
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

svg.icon{
  width: 17px; height: 17px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- shell ---------- */
#app{
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.view{ display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active{ display: flex; }

/* ---------- topbar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.topbar.topbar-titled{ padding: 12px 14px; }
.topbar-title{
  display:flex; flex-direction:column; align-items:center; gap:1px;
}
.topbar-title-main{
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.topbar-title-sub{
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-dim);
}
.topbar .brand{
  font-family: var(--display);
  font-style: italic;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--ink);
}
.brand.watermark{
  display:block;
  text-align:center;
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-dim);
  padding: 8px 0 4px;
  flex-shrink: 0;
}
.icon-btn{
  width: 36px; height:36px;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  transition: border-color .15s ease, transform .15s ease;
}
.icon-btn:active{ transform: scale(.92); }
.icon-btn:hover{ border-color: var(--accent); }

/* ---------- capture view ---------- */
.capture-stage{
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 12px 12px 10px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.capture-stage-full{ margin-top: 12px; }

#video-main, #video-pip{
  position: absolute;
  object-fit: cover;
  background: var(--bg-card);
}
#video-main{ inset: 0; width: 100%; height: 100%; transition: opacity .15s ease; }
#video-main.updating{ opacity: .55; }
#video-pip, #pip-canvas{
  width: 30%; aspect-ratio: 3/4;
  top: 14px; right: 14px;
  border-radius: 24px;
  border: 3px solid var(--surface);
  box-shadow: 0 8px 22px oklch(30% 0.02 60 / .2);
  z-index: 3;
}
#video-pip{ position: absolute; object-fit: cover; }
#pip-canvas{ position: absolute; object-fit: cover; background: var(--bg-card); }

.capture-badge{
  position:absolute; top:10px; left:10px; z-index:3;
  display:flex; align-items:center; gap:6px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink);
}
.capture-badge .dot{
  width:7px; height:7px; border-radius:50%;
  background: var(--accent);
}
.capture-badge.alt .dot{ background: var(--accent-dark); }

/* ---------- glass controls ---------- */
.capture-controls-row{
  display:flex;
  align-items:flex-end;
  justify-content: center;
  gap: 14px;
  margin: 0 14px calc(16px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.glass-controls{
  display:flex;
  flex-wrap: nowrap;
  justify-content:space-around;
  align-items:flex-start;
  gap: 6px;
  flex: 1;
  padding: 10px 8px;
  border-radius: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.glass-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:5px;
  width: 48px;
}
.glass-btn .circle{
  width:44px; height:44px;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.glass-btn:active .circle{ transform: scale(.92); }
.glass-btn .label{
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.glass-btn.active .circle{
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.glass-btn.active .label{ color: var(--ink); }
.glass-btn:disabled{ opacity: .5; }

.glass-btn.shutter-glass{ width: 60px; }
.glass-btn.shutter-glass .label{ display:none; }
.glass-btn.shutter-glass .circle{
  width:60px; height:60px;
  background: var(--accent);
  border: 4px solid var(--surface);
  box-shadow: 0 0 0 2px var(--accent), 0 10px 26px -6px oklch(30% 0.02 60 / .35);
  color: var(--surface);
}
.glass-btn.shutter-glass .circle svg{ fill: currentColor; }
.glass-btn.shutter-glass.recording .circle{
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ box-shadow: 0 0 0 2px var(--danger); }
  50%{ box-shadow: 0 0 0 6px oklch(58% 0.13 25 / .35); }
}

/* ---------- review / detail sheet ---------- */
.sheet{
  padding: 14px 16px calc(74px + env(safe-area-inset-bottom));
  display:flex; flex-direction:column; gap:12px;
  overflow-y: auto;
  min-height: 0;
}
.sheet-media{
  border-radius: var(--radius);
  overflow:hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  position: relative;
  max-height: 200px;
  display:flex; align-items:center; justify-content:center;
}
.sheet-media img, .sheet-media video{
  width:100%; max-height:200px; object-fit:cover; display:block;
}

.map-strip{
  position: relative;
  height: 90px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
}
.map-strip.status-only{
  height: auto;
  border: none;
  background: none;
  display:flex; justify-content:center;
}
.map-strip.status-only .pin{ display:none; }
.map-strip.status-only .meta{
  position: static;
}
.map-strip img{
  width:100%; height:100%; object-fit: cover;
}
.map-strip .pin{
  position:absolute; top:50%; left:50%;
  transform: translate(-50%,-100%);
  color: var(--accent-dark);
  width: 18px; height: 18px;
  z-index: 2;
}
.map-strip .meta{
  position:absolute; left:8px; right:8px; bottom:8px;
  display:flex; align-items:center; gap:8px;
  font-family: var(--sans); font-size: 12.5px;
  color: var(--ink);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  padding: 7px 12px; border-radius: 999px;
}

.field{
  display:flex; flex-direction:column; gap:6px;
}
.field label{
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display:flex; align-items:center; gap: 6px;
}
.field-row{ display:flex; gap:8px; align-items:center; }
.tag-input{
  flex: 1;
  display:flex; flex-wrap:wrap; gap:6px; align-items:center;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.tag-input input{
  flex:1; min-width: 80px;
  background: none; border:none; color: var(--ink);
  font-family: var(--sans); font-size: 13.5px;
  padding: 3px;
}
.tag-chip{
  display:flex; align-items:center; gap:5px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12.5px;
}
.tag-chip button{ display:flex; color: var(--accent-dark); opacity:.7; }
.tag-suggestions{
  display:flex; flex-wrap:wrap; gap:6px;
}
.tag-suggestions button{
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--ink-dim);
  font-family: var(--sans);
}
.btn-contacts{
  width: 38px; height:38px; flex-shrink:0;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-dim);
}
.btn-contacts:active{ transform: scale(.92); }

.action-row{ display:flex; gap: 10px; margin-top: auto; }
.btn{
  flex:1;
  display:flex; align-items:center; justify-content:center; gap:7px;
  padding: 13px 14px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
}
.btn-primary{
  background: var(--accent);
  color: var(--surface);
}
.btn-ghost{
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
}
.btn:active{ transform: scale(.97); }

/* ---------- gallery ---------- */
.gallery-header{
  padding: 2px 16px 10px;
  display:flex; flex-direction:column; gap:2px;
  flex-shrink: 0;
}
.gallery-grid{
  flex:1;
  padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  overflow-y:auto;
  min-height: 0;
}
.souvenir-card{
  border-radius: 20px;
  overflow:hidden;
  aspect-ratio: 1;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.souvenir-card img, .souvenir-card video{
  width:100%; height:100%; object-fit: cover;
}
.souvenir-card .card-meta{
  position:absolute; left:0; right:0; bottom:0;
  padding: 8px 10px;
  background: linear-gradient(0deg, oklch(20% 0.02 60 / .55), transparent);
  font-family: var(--sans); font-size: 10px;
  color: oklch(96% 0.01 85 / .85);
}
.souvenir-card .card-meta .date{ color: oklch(99% 0 0); font-size:12.5px; font-weight: 500; }
.souvenir-card .kind-badge{
  position:absolute; top:8px; right:8px;
  width: 22px; height:22px; border-radius:50%;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  display:flex; align-items:center; justify-content:center;
  color: var(--ink);
}
.souvenir-card .kind-badge svg{ width:12px; height:12px; }

.empty-state{
  flex:1;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:12px; padding: 40px 32px;
  text-align:center;
  color: var(--ink-dim);
}
.empty-state svg{ width:36px; height:36px; color: var(--accent); }
.empty-state h3{ font-size: 17px; color: var(--ink); }
.empty-state p{ font-size: 13px; max-width: 220px; line-height: 1.5; }

/* ---------- carte / gallery-map ---------- */
.gallery-map{
  flex:1;
  position: relative;
  margin: 0 12px 12px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: none;
}
.gallery-map.active{ display:block; }
.gallery-map img{
  width:100%; height:100%; object-fit: cover;
  position: absolute; inset:0;
}
.map-pin-btn{
  position: absolute;
  transform: translate(-50%, -100%);
  display:flex; flex-direction:column; align-items:center;
  z-index: 2;
}
.map-pin-btn .pin-thumb{
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid var(--surface);
  box-shadow: 0 6px 16px oklch(30% 0.02 60 / .3);
  background: var(--bg-card);
}
.map-pin-btn .pin-thumb img{ position:static; width:100%; height:100%; object-fit:cover; }
.map-pin-btn .pin-tail{
  width: 2px; height: 8px;
  background: var(--surface);
}
.map-pin-btn .pin-count{
  position:absolute; top:-4px; right:-4px;
  min-width: 16px; height:16px; padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--sans); font-size: 9px; font-weight: 700;
  display:flex; align-items:center; justify-content:center;
}
.map-pin-btn:active .pin-thumb{ transform: scale(.9); }

/* ---------- location sheet ---------- */
.location-sheet-backdrop{
  position: fixed; inset:0;
  background: oklch(20% 0.02 60 / .25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.location-sheet-backdrop.show{ display:flex; }
.location-sheet{
  width: 100%; max-width: 480px;
  max-height: 78vh;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  display:flex; flex-direction:column; gap:14px;
  overflow-y:auto;
  box-shadow: 0 -8px 32px oklch(30% 0.02 60 / .18);
}
.location-sheet .grabber{
  width: 36px; height:4px; border-radius:999px;
  background: var(--border);
  margin: 0 auto 4px;
}
.location-sheet-hero{
  border-radius: 14px;
  overflow:hidden;
  max-height: 200px;
  border: 1px solid var(--border);
}
.location-sheet-hero img{ width:100%; max-height:200px; object-fit:cover; display:block; }
.location-sheet-meta{
  display:flex; align-items:center; justify-content:space-between;
}
.location-sheet-count{
  font-family: var(--sans); font-size: 12px; color: var(--ink-dim);
}
.location-mini-grid{
  display:grid; grid-template-columns: repeat(4, 1fr); gap:8px;
}
.location-mini-grid .mini-item{
  aspect-ratio: 1; border-radius: 10px; overflow:hidden;
  border: 1px solid var(--border);
}
.location-mini-grid .mini-item img,
.location-mini-grid .mini-item video{ width:100%; height:100%; object-fit:cover; }

/* ---------- toast ---------- */
.toast{
  position: fixed; left:50%; bottom: 20px;
  transform: translateX(-50%) translateY(10px);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  padding: 10px 16px;
  border-radius: 999px;
  font-family: var(--sans); font-size: 12.5px;
  color: var(--ink);
  opacity:0; pointer-events:none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
  display:flex; align-items:center; gap:7px;
  box-shadow: var(--shadow);
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

@media (min-width: 640px){
  .gallery-grid{ grid-template-columns: repeat(3, 1fr); }
}
