/* style.css — lecteur public video.k-prod.fr
   Palette neutre grise, accent vert clair pour les actions interactives. */

@import url('fonts.css');

:root {
  --bg: #f2f3f2;
  --surface: #ffffff;
  --surface-2: #e7e9e7;
  --text: #1a1c1b;
  --text-dim: #686d6a;
  --accent: #45b372;
  --accent-contrast: #ffffff;
  --border: #dadcda;
  --shadow: 0 12px 32px -16px rgba(20, 20, 20, 0.2);
  --radius: 14px;
  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg: #17181a;
  --surface: #212224;
  --surface-2: #2a2c2e;
  --text: #eceeed;
  --text-dim: #9ba09e;
  --accent: #5fd38d;
  --accent-contrast: #0c1f14;
  --border: #34373a;
  --shadow: 0 12px 32px -16px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

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

/* ── Layout général ─────────────────────────────────────────────────── */

.kv-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 48px) 16px 64px;
}

.kv-topbar {
  width: 100%;
  max-width: 980px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.kv-wrap {
  width: 100%;
  max-width: 980px;
}

body.kv-fullwidth .kv-wrap,
body.kv-fullwidth .kv-topbar {
  max-width: none;
}

/* Sur mobile, le lecteur reste toujours pleine largeur, indépendamment
   de la préférence ci-dessus (peu de marge à gagner avec un cadre étroit). */
@media (max-width: 700px) {
  .kv-wrap,
  .kv-topbar {
    max-width: none;
  }
}

/* ── Conteneur vidéo ────────────────────────────────────────────────── */

.kv-video-shell {
  position: relative;
  width: 100%;
  max-height: 88vh;
  margin: 0 auto;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  /* aspect-ratio posé en inline-style par player.php selon la source */
}

.kv-video-shell video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 88vh;
  object-fit: contain;
  background: #000;
}

.kv-psv-container {
  width: 100%;
  height: 100%;
}

.kv-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  aspect-ratio: 16/9;
  width: 100%;
  background: var(--surface-2);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-body);
}

.kv-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: kv-spin 0.9s linear infinite;
}
@keyframes kv-spin { to { transform: rotate(360deg); } }

/* ── Méta (titre / description) ─────────────────────────────────────── */

.kv-meta { margin-top: 22px; }

.kv-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  margin: 0 0 6px;
  line-height: 1.25;
}

.kv-description {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0 0 18px;
  max-width: 720px;
}
.kv-description a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}
.kv-description a:hover { text-decoration-color: currentColor; }

/* ── Barre d'actions ─────────────────────────────────────────────────── */

.kv-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.kv-btn:hover { border-color: var(--accent); }
.kv-btn:active { transform: scale(0.97); }
.kv-btn svg { width: 16px; height: 16px; flex: none; }

.kv-select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 30px 8px 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23686d6a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
html[data-theme="dark"] .kv-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ba09e'/%3E%3C/svg%3E");
}

.kv-spacer { flex: 1; }

.kv-icon-only { padding: 8px; }
.kv-icon-only svg { margin: 0; }
.kv-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--accent);
}

.kv-codec-badge {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
  position: relative;
}
.kv-codec-badge[data-tooltip] { cursor: help; }
.kv-codec-badge[data-tooltip]:hover::after,
.kv-codec-badge[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: normal;
  white-space: normal;
  line-height: 1.4;
  box-shadow: var(--shadow);
  z-index: 30;
  pointer-events: none;
}

.kv-download-option {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: 8px;
}
.kv-download-option:last-child { margin-bottom: 0; }
.kv-download-option:hover { background: var(--border); }

/* ── Mise en scène vidéo : ambilight + coins arrondis optionnels ─────── */

.kv-stage { position: relative; }

.kv-ambilight {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  z-index: 0;
  filter: blur(46px) saturate(1.5) brightness(0.85);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.kv-stage.kv-ambilight-on .kv-ambilight { opacity: 0.85; }

.kv-stage .kv-video-shell { position: relative; z-index: 1; }

/* Bouton "coins arrondis" désactivé : la vidéo (et son cadre d'attente) perd son arrondi. */
.kv-stage.kv-square .kv-video-shell,
.kv-stage.kv-square .kv-waiting { border-radius: 0; }

/* ── Popover de partage ─────────────────────────────────────────────── */

.kv-popover-anchor { position: relative; }

.kv-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 20;
  display: none;
}
.kv-popover.kv-open { display: block; }

.kv-popover label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kv-popover .kv-row { display: flex; gap: 6px; margin-bottom: 14px; }
.kv-popover .kv-row:last-child { margin-bottom: 0; }

.kv-share-customize { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.kv-customize-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kv-field-sm {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
}

.kv-field {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
textarea.kv-field { resize: none; height: 64px; font-family: monospace; font-size: 0.72rem; }

.kv-copy {
  flex: none;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
}
.kv-copy.kv-copied { background: #4c9a5b; }

/* ── Footer discret ──────────────────────────────────────────────────── */

.kv-footer {
  margin-top: auto;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ── Mode embed (iframe) : pas de chrome autour de la vidéo ─────────── */

body.kv-embed .kv-page { padding: 0; }
body.kv-embed .kv-meta,
body.kv-embed .kv-topbar,
body.kv-embed .kv-footer,
body.kv-embed .kv-ambilight { display: none; }
body.kv-embed .kv-video-shell { max-height: 100vh; border-radius: 0; box-shadow: none; }
body.kv-embed .kv-wrap,
body.kv-embed .kv-stage { max-width: none; }

/* ── États d'erreur / page introuvable ──────────────────────────────── */

.kv-error-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.kv-error-shell h1 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1.4rem;
  margin: 0;
}

/* ── Page d'accueil publique (/) ──────────────────────────────────────
   "video.k-prod.fr" sert de marque/repère (grand titre), le vrai titre
   de la vidéo apparaît juste dessous, plus discret. */

.kv-home-brand { margin-bottom: 2px; }
.kv-home-video-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.kv-home-more { margin-top: 36px; }

.kv-home-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.kv-home-tab {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.kv-home-tab-active { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }

/* Grille responsive : s'adapte automatiquement du mobile (1-2 colonnes)
   au desktop (plusieurs colonnes), même principe que la zone VIP. */
.kv-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.kv-home-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}
.kv-home-thumb {
  aspect-ratio: 16/9;
  background: var(--surface-2);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-bottom: 6px;
}
.kv-home-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kv-home-card:hover .kv-home-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.kv-home-badge-360 {
  position: absolute;
  top: 6px; right: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20,18,12,0.72);
  color: #fff;
}
.kv-home-card-title {
  font-size: 0.82rem;
  font-weight: 500;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
