/* Polho POC – charte reprise du prototype Figma 2022 : noir & blanc, gros titres, pilules grises. */
:root {
  --bg: #ffffff;
  --ink: #000000;
  --ink-2: #3a3a3a;
  --muted: #8a8a8a;
  --line: #e6e6e6;
  --pill: #d9d9d9;
  --pill-strong: #a9a9a9;
  --dark: #3a3a3a;
  --soft: #f5f5f5;
  --bubble-them: #8f8f8f;
  --bubble-me: #e9e9e9;
  --danger: #b3261e;
  --radius-pill: 999px;
  --tap: 48px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Roboto", "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overscroll-behavior: none; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--ink); }
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: var(--sat) var(--sar) 0 var(--sal);
  overflow: hidden;
}

/* ---------- Barres ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 6px; min-height: 60px; }
.topbar .grow { flex: 1; min-width: 0; }
.iconbtn { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 50%; }
.iconbtn:active { background: var(--soft); }
.iconbtn svg { width: 24px; height: 24px; }
.iconbtn.on { background: var(--ink); color: #fff; }
.iconbtn[disabled] { opacity: .3; }

.nav {
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 12px calc(8px + var(--sab)); border-top: 1px solid transparent; background: var(--bg);
}
.nav .iconbtn.active { color: var(--ink); }
.nav .iconbtn { color: var(--ink-2); }
.nav .iconbtn .dot { position: absolute; }
.nav .plus { width: 48px; height: 48px; border-radius: 14px; background: var(--ink); color: #fff; display: grid; place-items: center; }
.nav .plus svg { width: 26px; height: 26px; }

/* ---------- Bandeau anonyme ---------- */
.anon-banner { display: none; align-items: center; justify-content: center; gap: 8px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; padding: 6px 12px; }
.anon .anon-banner { display: flex; }
.anon-banner svg { width: 18px; height: 18px; }

/* ---------- Fil ---------- */
.feed { flex: 1; display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; min-height: 0; }
.card {
  position: absolute; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; padding: 0 16px;
  will-change: transform; touch-action: none; user-select: none; -webkit-user-select: none;
}
.card.behind { transform: scale(.96) translateY(10px); opacity: .55; pointer-events: none; }
.card.dragging { transition: none; }
.card.anim { transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .32s; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 0 4px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #d9d9d9; display: grid; place-items: center; font-size: 22px; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 17px; }
.meta { font-size: 13px; line-height: 1.35; min-width: 0; }
.meta .who { color: var(--ink); }
.meta .when { color: var(--muted); margin-left: 6px; }
.meta .heat { display: flex; align-items: center; gap: 4px; color: var(--ink-2); }
.meta .heat svg { width: 14px; height: 14px; }
.theme-tag { margin-left: auto; font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }

.q {
  font-weight: 800; letter-spacing: -.01em; text-align: center; line-height: 1.12;
  font-size: clamp(28px, 8.6vw, 46px);
  margin: 12px 8px 0; text-wrap: balance; overflow-wrap: anywhere;
}
.q.long { font-size: clamp(24px, 7vw, 38px); }
.q.xlong { font-size: clamp(21px, 6vw, 32px); }

.visual-row { flex: 1; min-height: 120px; display: flex; align-items: center; justify-content: center; position: relative; }
.visual { width: min(42vw, 190px, 26vh); aspect-ratio: 1; border-radius: 30%; background: var(--soft); display: grid; place-items: center; font-size: min(22vw, 100px, 14vh); line-height: 1; }
.rail { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; }
.rail .iconbtn svg { width: 22px; height: 22px; }

.stamp {
  position: absolute; top: 42%; padding: 8px 16px; border: 4px solid var(--ink); border-radius: 14px;
  font-weight: 900; font-size: 22px; text-transform: uppercase; letter-spacing: .03em; background: rgba(255,255,255,.9);
  opacity: 0; pointer-events: none; max-width: 52%; text-align: center; line-height: 1.1;
}
.stamp.left { left: 18px; transform: rotate(-14deg); }
.stamp.right { right: 18px; transform: rotate(14deg); }
.stamp.up { left: 50%; top: 24%; transform: translateX(-50%); border-style: dashed; color: var(--muted); border-color: var(--muted); }

.vote { padding: 8px 4px 0; }
.pill { display: flex; height: 96px; border-radius: var(--radius-pill); overflow: hidden; gap: 3px; background: var(--bg); }
.pill > button, .pill > div { flex: 1; background: var(--pill); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 14px; font-size: 18px; text-align: center; line-height: 1.15; min-width: 0; position: relative; }
.pill > button:active { background: var(--pill-strong); }
.pill.three { height: 84px; }
.pill.three > button, .pill.three > div { font-size: 16px; padding: 0 8px; }
.pill .lbl { overflow-wrap: anywhere; }
.pill .pct { font-size: 26px; font-weight: 800; margin-top: 4px; }
.pill .pct small { font-size: 15px; font-weight: 700; }
.pill .res { transition: flex-grow .6s cubic-bezier(.2,.8,.2,1); }
.pill .res.win { background: var(--pill-strong); }
.pill .res.mine .lbl::before { content: "✓ "; font-weight: 800; }
.pill .res.mine .lbl { font-weight: 600; }
.swipe-hint { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 0 0; min-height: 30px; }
.swipe-hint b { color: var(--ink-2); }

.after { display: flex; flex-direction: column; gap: 10px; padding: 12px 4px 0; }
.btn-dark { height: 60px; border-radius: var(--radius-pill); background: var(--dark); color: #fff; font-size: 19px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.btn-dark:active { background: #222; }
.btn-dark .count { border: 2px solid #fff; border-radius: 10px; font-size: 11px; font-weight: 700; min-width: 30px; height: 26px; padding: 0 5px; display: grid; place-items: center; }
.btn-ghost { height: 52px; border-radius: var(--radius-pill); border: 1.5px solid var(--line); font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); }
.btn-ghost:active { background: var(--soft); }
.btn-ghost svg { width: 20px; height: 20px; }
.note { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 8px; }
.ro-badge { display: inline-flex; gap: 6px; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-2); background: var(--soft); border-radius: 12px; padding: 10px 12px; text-align: center; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 24px; }
.empty h2 { font-size: 26px; margin: 0; font-weight: 800; }
.empty p { color: var(--muted); margin: 0; max-width: 320px; }

/* ---------- Débat ---------- */
.debate { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.debate-head { padding: 6px 16px 16px; position: relative; }
.debate-head .dq { font-size: 24px; font-weight: 800; text-align: center; margin: 4px 8px 16px; line-height: 1.2; text-wrap: balance; }
.debate-head .ghost { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; opacity: .06; pointer-events: none; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bars .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.bars .track { display: flex; gap: 3px; height: 6px; }
.bars .track span { background: var(--pill); border-radius: 3px; }
.bars .track span.win { background: var(--pill-strong); }
.bars .labels { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; gap: 8px; }
.bars .labels span:last-child { text-align: right; }
.thread { flex: 1; overflow-y: auto; background: #f7f7f7; padding: 12px 12px 18px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.thread .grip { width: 180px; height: 3px; background: #dcdcdc; border-radius: 2px; margin: 0 auto 10px; }
.faces { display: flex; justify-content: center; margin-bottom: 10px; }
.faces span { width: 20px; height: 20px; border-radius: 50%; background: #d0d0d0; border: 2px solid #f7f7f7; margin-left: -6px; display: grid; place-items: center; font-size: 10px; }
.faces span.n { background: #e9e9e9; font-weight: 700; font-size: 9px; }
.msg { display: flex; gap: 10px; align-items: flex-end; margin: 6px 0 14px; }
.msg .col { display: flex; flex-direction: column; gap: 4px; max-width: 76%; }
.msg .name { font-size: 11px; color: var(--muted); margin-left: 4px; }
.msg .bubble { background: var(--bubble-them); color: #fff; padding: 12px 18px; border-radius: 22px 22px 22px 6px; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: var(--bubble-me); color: var(--ink); border-radius: 22px 22px 6px 22px; }
.msg .more { align-self: center; color: var(--muted); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.msg .more svg { width: 18px; height: 18px; }
.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--sab)); background: #f7f7f7; }
.composer input { flex: 1; height: 54px; border-radius: 27px; border: 0; background: #e9e9e9; padding: 0 22px; outline: none; }
.composer button { width: 54px; height: 54px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.composer button svg { width: 22px; height: 22px; }
.composer .ro-badge { flex: 1; }

/* ---------- Formulaires / écrans ---------- */
.screen { flex: 1; overflow-y: auto; padding: 8px 20px calc(24px + var(--sab)); -webkit-overflow-scrolling: touch; }
.screen.center { display: flex; flex-direction: column; justify-content: safe center; }
.logo { font-weight: 900; font-size: 56px; letter-spacing: -.04em; text-align: center; margin: 0; }
.logo span { display: inline-block; transform: rotate(-8deg); }
.tagline { text-align: center; color: var(--ink-2); margin: 6px 0 28px; font-size: 17px; }
h1.h { font-size: 30px; font-weight: 800; margin: 12px 0 6px; letter-spacing: -.01em; }
p.sub { color: var(--muted); margin: 0 0 20px; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 6px; }
input.t, textarea.t, select.t { width: 100%; height: 54px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--bg); padding: 0 16px; outline: none; }
textarea.t { height: 96px; padding: 12px 16px; resize: none; }
input.t:focus, textarea.t:focus, select.t:focus { border-color: var(--ink); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { aspect-ratio: 1; border-radius: 50%; background: var(--soft); font-size: 26px; display: grid; place-items: center; border: 2px solid transparent; }
.avatars button.sel { border-color: var(--ink); background: #e9e9e9; }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: #000; }
.btn-main { width: 100%; height: 60px; border-radius: var(--radius-pill); background: var(--ink); color: #fff; font-size: 18px; font-weight: 600; margin-top: 18px; }
.btn-main[disabled] { opacity: .35; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { height: 44px; padding: 0 18px; border-radius: 22px; background: var(--soft); border: 1.5px solid var(--line); font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.chip.sel { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .lock { font-size: 11px; opacity: .7; }

.tuto { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 18px; }
.tuto .ill { width: 220px; height: 220px; border-radius: 40px; background: var(--soft); display: grid; place-items: center; position: relative; }
.tuto .ill svg { width: 120px; height: 120px; }
.tuto h2 { font-size: 28px; font-weight: 800; margin: 0; }
.tuto p { color: var(--ink-2); margin: 0; max-width: 340px; font-size: 17px; line-height: 1.45; }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--pill); }
.dots i.on { background: var(--ink); width: 22px; }
@keyframes swipeDemo { 0%,15% { transform: translateX(0) rotate(0) } 40% { transform: translateX(-46px) rotate(-10deg) } 55% { transform: translateX(0) rotate(0) } 80% { transform: translateX(46px) rotate(10deg) } 100% { transform: translateX(0) } }
.tuto .demo { animation: swipeDemo 3s ease-in-out infinite; }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 14px 2px; border-bottom: 1px solid var(--line); min-height: 56px; }
.li .grow { flex: 1; min-width: 0; }
.li .t1 { font-weight: 600; font-size: 15px; }
.li .t2 { font-size: 13px; color: var(--muted); margin-top: 2px; }
.li button.small { height: 36px; padding: 0 14px; border-radius: 18px; border: 1.5px solid var(--line); font-size: 13px; white-space: nowrap; }
.li button.small.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--pill); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--ink); }
.switch.on::after { transform: translateX(20px); }
.section-t { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 4px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.kpi { background: var(--soft); border-radius: 18px; padding: 14px; }
.kpi .v { font-size: 28px; font-weight: 800; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .chip { flex: none; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0 4px; }
.profile-head .avatar { width: 84px; height: 84px; font-size: 46px; }
.profile-head .n { font-size: 24px; font-weight: 800; }
.hist .q1 { font-weight: 600; font-size: 15px; }
.minibar { display: flex; height: 6px; gap: 2px; margin-top: 8px; }
.minibar span { background: var(--pill); border-radius: 3px; }
.minibar span.mine { background: var(--ink); }

/* ---------- Feuilles (bottom sheets) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(22px + var(--sab)); max-height: 86dvh; overflow-y: auto; animation: up .25s cubic-bezier(.2,.8,.2,1);
  max-width: 640px; margin: 0 auto;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--pill); margin: 0 auto 14px; }
.sheet h3 { font-size: 22px; margin: 0 0 8px; font-weight: 800; }
.sheet p { color: var(--ink-2); line-height: 1.5; }
@keyframes up { from { transform: translateY(100%) } }
@keyframes fade { from { opacity: 0 } }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--sab)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 88vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Deux volets : iPhone pliable déplié, tablette, ordinateur ---------- */
.side { display: none; }
@media (min-width: 720px) and (min-height: 520px) {
  .feed { gap: 0; }
  .stage { flex: 1 1 50%; max-width: 620px; }
  .side { display: flex; flex: 1 1 50%; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); }
  .side .placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 10px; padding: 32px; }
  .side .placeholder svg { width: 56px; height: 56px; opacity: .4; }
  .feed .after .btn-dark.debate-open { display: none; }
  .q { font-size: clamp(30px, 4.2vw, 48px); }
  .visual { width: min(24vw, 190px, 24vh); font-size: min(12vw, 100px, 13vh); }
  .screen { max-width: 720px; margin: 0 auto; width: 100%; }
  .nav { justify-content: center; gap: min(8vw, 72px); }
}
/* Écran pliable à deux segments (Viewport Segments API) : on aligne la séparation sur la charnière. */
@media (horizontal-viewport-segments: 2) {
  .stage { flex: 0 0 env(viewport-segment-width 0 0, 50%); max-width: none; }
  .side { flex: 1 1 auto; margin-left: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px)); }
}
/* Pliable déplié en mode « livre » vertical : la carte en haut, le débat en bas. */
@media (vertical-viewport-segments: 2) {
  .feed { flex-direction: column; }
  .stage { flex: 0 0 env(viewport-segment-height 0 0, 50%); }
  .side { display: flex; flex: 1; flex-direction: column; border-left: 0; border-top: 1px solid var(--line); margin-top: calc(env(viewport-segment-top 0 1, 0px) - env(viewport-segment-bottom 0 0, 0px)); }
}
/* Petits écrans (iPhone SE, écran extérieur d'un pliable) */
@media (max-height: 700px) {
  .pill { height: 78px; }
  .pill.three { height: 72px; }
  .btn-dark { height: 52px; }
  .q { font-size: clamp(24px, 7.4vw, 38px); margin-top: 6px; }
  .visual-row { min-height: 90px; }
  .swipe-hint { min-height: 22px; padding-top: 6px; }
}
@media (max-width: 340px) { .avatars { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { .card.anim, .pill .res { transition: none; } .tuto .demo { animation: none; } }
