@import url('./fonts.css');

/* ─────────────────────────────────────────────────────────────────────────────
   Design system Meeting Hub — encre, papier, vert, jaune.
   Les jetons de marque (--brand, --warm, --ink) ne bougent pas d'un thème à
   l'autre : ce sont les rôles (--bg, --surface, --accent) qui se réassignent.
   Un thème sombre n'est pas une marque différente.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  --brand: #0c7c59;
  --brand-strong: #095e43;
  --warm: #f4b942;
  --ink: #10221b;
  --paper: #fbfaf7;

  --bg: var(--paper);
  --surface: #ffffff;
  --surface-sunken: #f4f2ec;
  --text: var(--ink);
  --muted: #3a473f;
  --muted-2: #6e6e66;
  --faint: #9a9a92;
  --line: #edebe3;
  --line-strong: #e2e0d6;

  --tile-bg: #dde1e8;
  --tile-placeholder: linear-gradient(150deg, #e9ecf1, #dde1e8);
  --tile-letterbox: #10221b;

  --accent: var(--brand);
  --accent-hover: var(--brand-strong);
  --accent-soft: #e7f0ea;
  --on-accent: #ffffff;
  --warm-soft: #fdf1d8;
  --on-warm: var(--ink);
  --danger: #e11d2e;
  --danger-hover: #c2172a;
  --good: #16a34a;
  --warn: #d97706;

  --glass: rgb(251 250 247 / 0.76);
  --glass-strong: rgb(251 250 247 / 0.9);
  --glass-blur: blur(12px) saturate(130%);

  /* Les bandeaux pleins de l'accueil : du blanc s'y pose, quel que soit le
     thème. Déclarés ici, ils traversent le shadow DOM — que `:host-context`
     ne franchit pas dans tous les navigateurs. */
  --band: var(--brand);
  --band-deep: var(--ink);
  --on-band: #ffffff;
  --on-band-soft: rgb(255 255 255 / 0.78);
  --on-band-faint: rgb(255 255 255 / 0.5);
  --on-band-fill: rgb(255 255 255 / 0.08);
  --on-band-line: rgb(255 255 255 / 0.14);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  /* Les blocs du design system sont presque carrés : 4 px, pas 16. */
  --radius-card: 4px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgb(16 34 27 / 0.04), 0 1px 3px rgb(16 34 27 / 0.06);
  --shadow-md: 0 2px 6px rgb(16 34 27 / 0.05), 0 8px 20px rgb(16 34 27 / 0.08);
  --shadow-lg: 0 24px 60px rgb(16 34 27 / 0.16);

  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);

  --panel-width: 340px;
  --gap: 12px;

  --font-ui: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, 'Courier New', monospace;

  --font-scale: 1;
  --fs-xs: calc(11.5px * var(--font-scale));
  --fs-sm: calc(12.5px * var(--font-scale));
  --fs-md: calc(13.5px * var(--font-scale));
  --fs-lg: calc(15px * var(--font-scale));
  --fs-xl: calc(17px * var(--font-scale));
  --fs-2xl: calc(23px * var(--font-scale));
  --fs-3xl: calc(34px * var(--font-scale));
  --fs-4xl: calc(52px * var(--font-scale));
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    color-scheme: dark;

    --bg: #0b1512;
    --surface: #12201b;
    --surface-sunken: #182922;
    --text: #eaf2ed;
    --muted: #a9bcb2;
    --muted-2: #8fa098;
    --faint: #78877f;
    --line: rgb(255 255 255 / 0.1);
    --line-strong: rgb(255 255 255 / 0.18);

    /* Le vert de marque n'a pas le contraste requis sur fond sombre : c'est le
       rôle « accent » qui s'éclaircit, la marque reste elle-même. */
    --accent: #3fbf8f;
    --accent-hover: #5fd3a6;
    --accent-soft: rgb(63 191 143 / 0.16);
    --on-accent: #06130e;
    --warm-soft: rgb(244 185 66 / 0.16);
    --danger: #e5484d;
    --danger-hover: #f3595e;
    --good: #3dd68c;
    --warn: #f0a35e;

    --glass: rgb(11 21 18 / 0.74);
    --glass-strong: rgb(11 21 18 / 0.9);
    --band: #0a6349;
    --band-deep: #071310;

    --tile-bg: #1a2b24;
    --tile-placeholder: linear-gradient(150deg, #1e3129, #16241e);
    --tile-letterbox: #060e0b;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
    --shadow-md: 0 2px 6px rgb(0 0 0 / 0.4), 0 8px 20px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.5);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0b1512;
  --surface: #12201b;
  --surface-sunken: #182922;
  --text: #eaf2ed;
  --muted: #a9bcb2;
  --muted-2: #8fa098;
  --faint: #78877f;
  --line: rgb(255 255 255 / 0.1);
  --line-strong: rgb(255 255 255 / 0.18);

  --accent: #3fbf8f;
  --accent-hover: #5fd3a6;
  --accent-soft: rgb(63 191 143 / 0.16);
  --on-accent: #06130e;
  --warm-soft: rgb(244 185 66 / 0.16);
  --danger: #e5484d;
  --danger-hover: #f3595e;
  --good: #3dd68c;
  --warn: #f0a35e;

  --glass: rgb(11 21 18 / 0.74);
  --glass-strong: rgb(11 21 18 / 0.9);

  --band: #0a6349;
  --band-deep: #071310;

  --tile-bg: #1a2b24;
  --tile-placeholder: linear-gradient(150deg, #1e3129, #16241e);
  --tile-letterbox: #060e0b;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4), 0 1px 3px rgb(0 0 0 / 0.3);
  --shadow-md: 0 2px 6px rgb(0 0 0 / 0.4), 0 8px 20px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.5);
}

:root[data-theme='dark'] #banner {
  background: #2a1f10;
  border-color: rgb(240 163 94 / 0.3);
  color: #f0c08a;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] #banner {
    background: #2a1f10;
    border-color: rgb(240 163 94 / 0.3);
    color: #f0c08a;
  }
}

:root[data-contrast='high'],
:root[data-contrast='high'] * {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-sunken: #f2f2f2;
  --text: #000000;
  --muted: #2a2a2a;
  --muted-2: #2a2a2a;
  --faint: #3a3a3a;
  --line: #000000;
  --line-strong: #000000;
  --accent: #054a34;
  --accent-hover: #033a26;
  --accent-soft: #d9e9e1;
  --on-accent: #ffffff;
  --warm: #8a5a00;
  --warm-soft: #f6e6c4;
  --on-warm: #ffffff;
  --danger: #a1000f;
  --good: #036b2f;
  --warn: #7a4300;
  --glass: rgb(255 255 255 / 0.96);
  --glass-strong: #ffffff;
  --glass-blur: none;
  --shadow-sm: 0 0 0 1px #000;
  --shadow-md: 0 0 0 1px #000;
  --shadow-lg: 0 0 0 2px #000;
}

@media (prefers-contrast: more) {
  :root[data-contrast='auto'] {
    --muted: #26302b;
    --muted-2: #26302b;
    --faint: #3a473f;
    --line: rgb(0 0 0 / 0.55);
    --line-strong: rgb(0 0 0 / 0.7);
  }
}

@media (forced-colors: active) {
  :root {
    --glass: Canvas;
    --glass-strong: Canvas;
    --glass-blur: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;

  overscroll-behavior: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 70;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 600 var(--fs-md) var(--font-ui);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: top 0.14s var(--ease);
}

.skip:focus {
  top: 12px;
}

#banner {
  margin: 10px 16px 0;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  border: 1px solid rgb(217 119 6 / 0.22);
  color: #92400e;
  font-size: var(--fs-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

#banner[hidden] {
  display: none;
}

lobby-view,
admin-view,
green-room {
  flex: 1;
  overflow-y: auto;
}

green-room[hidden] {
  display: none;
}

#call {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 12px 16px 14px;
}

#call[hidden] {
  display: none;
}

#topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

#topbar .meeting {
  min-width: 0;
}

#topbar h1 {
  margin: 0;
  font: 600 var(--fs-lg) / 1.3 var(--font-ui);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topbar p {
  margin: 0;
  color: var(--muted);
  font: 400 var(--fs-sm) / 1.3 var(--font-ui);
}

.meeting-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

#elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font: 500 var(--fs-sm) var(--font-ui);
}

#lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 var(--fs-xs) var(--font-ui);
}

#lock-badge[hidden] {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

#copy-link,
#copy-host {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: min(320px, 40vw);
  padding: 8px 14px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--muted);
  font: 500 var(--fs-sm) var(--font-ui);
  cursor: pointer;
  transition:
    background 0.14s var(--ease),
    color 0.14s var(--ease);
}

#copy-link:hover,
#copy-host:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#copy-host {
  color: var(--accent);
  border-color: var(--accent-soft);
}

#copy-host[hidden] {
  display: none;
}

#copy-link .glyph,
#copy-host .glyph {
  display: inline-flex;
  color: var(--accent);
  flex: none;
}

#copy-link .url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#stage {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  min-width: 0;
  display: flex;
}

peer-grid {
  flex: 1;
  min-height: 0;
  min-width: 0;
}

#side {
  display: none;
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
}

#call.with-panel {
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
}

#call.with-panel #side {
  display: flex;
}

#side > * {
  flex: 1;
  min-height: 0;
}

#side > [hidden] {
  display: none;
}

#backdrop {
  display: none;
}

control-bar {
  position: relative;
  z-index: 6;
  grid-column: 1 / -1;
  grid-row: 3;
  min-width: 0;
}

#quality-dot {
  display: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #b6bcc7;
  flex: none;
}

#quality-dot[data-level='3'] {
  background: var(--good);
}

#quality-dot[data-level='2'] {
  background: var(--warn);
}

#quality-dot[data-level='1'] {
  background: var(--danger);
}

#self {
  position: absolute;
  right: 26px;
  bottom: 84px;
  width: clamp(140px, 16vw, 220px);
  z-index: 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition:
    right 0.18s var(--ease),
    width 0.18s var(--ease);
}

#call.with-panel #self {
  right: calc(var(--panel-width) + 26px);
}

#self.collapsed {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

#self.collapsed video-tile {
  display: none;
}

#self-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgb(16 24 40 / 0.2);
}

#self.collapsed #self-toggle {
  inset: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

@media (max-width: 860px) {
  #call {
    padding: 8px 10px 10px;
    gap: 8px;
  }

  #topbar {
    padding: 9px 12px;
  }

  #copy-link .url,
  #copy-host .label {
    display: none;
  }

  #copy-link,
  #copy-host {
    padding: 8px 10px;
  }

  #self {
    right: 12px;
    bottom: 74px;
    width: 104px;
  }

  #quality-dot {
    display: inline-block;
  }

  #call.with-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  #call.with-panel #side {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    height: min(72dvh, 560px);
    padding: 0 8px 8px;
  }

  #call.with-panel #side > * {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
  }

  #call.with-panel #backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    border: 0;
    padding: 0;
    background: rgb(16 24 40 / 0.35);
  }

  #call.with-panel #self,
  #call.with-menu #self {
    display: none;
  }
}

.left {
  display: grid;
  place-content: center;
  gap: 14px;
  height: 100dvh;
  padding: 24px;
  text-align: center;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
}

.left h1 {
  margin: 0;
  font: 600 var(--fs-2xl) var(--font-ui);
}

.left a {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
