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

html, body {
  width: 600px;
  height: 600px;
  background: #000;          /* additive display: black = transparent */
  color: #fff;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.hidden { display: none !important; }

/* ===================== BRAND / HEADER ===================== */
.yt-mark {
  display: inline-block;
  width: 38px;
  height: 27px;
  background: #ff0033;
  border-radius: 7px;
  position: relative;
  flex: none;
}
.yt-mark::after {
  content: "";
  position: absolute;
  top: 50%; left: 52%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
}

.header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  margin-top: 16px;
  flex: none;
}
.header-title {
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn {
  width: 56px;
  height: 56px;
  font-size: 26px;
  background: #1c1e21;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  flex: none;
}

/* ===================== CONTENT / LISTS ===================== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  gap: 12px;
}

/* ===================== FOCUS STATE ===================== */
.focusable {
  outline: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  opacity: .9;
}
.focusable:focus {
  opacity: 1;
  transform: scale(1.02);
  box-shadow: 0 0 0 3px #00e5ff, 0 0 16px rgba(0,229,255,.6);
}

/* ===================== MENU ITEMS ===================== */
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 88px;
  padding: 0 20px;
  background: #1c1e21;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 20px;
  text-align: left;
  cursor: pointer;
  flex: none;
}
.menu-icon { font-size: 26px; flex: none; }
.menu-label { flex: 1; font-weight: 600; }
.menu-arrow { font-size: 28px; color: #b0b3b8; }
.menu-logout { background: #2a1416; }
.menu-logout .menu-label { color: #ff6b6b; }

/* ===================== VIDEO / PLAYLIST CARDS (gallery) ===================== */
.vcard {
  display: block;
  width: 100%;
  background: #1c1e21;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  color: #fff;
  text-align: left;
  cursor: pointer;
  padding: 0 0 10px;
}
.vcard-thumb {
  position: relative;
  display: block;
  width: 100%;
  height: 160px;           /* fixed box — deterministic, no ratio maths */
  background: #000;
  font-size: 0;
}
.vcard-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;       /* fill the fixed box, crop overflow */
}
.vcard-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  margin: 8px 10px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vcard-meta {
  display: block;
  font-size: 12px;
  color: #b0b3b8;
  margin: 4px 10px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vcard-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

/* ===================== CHANNEL RAIL (subscriptions carousel) ===================== */
.channel-rail {
  flex: none;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 8px 10px;
  scroll-snap-type: x proximity;
}
.chan-chip {
  flex: none;
  width: 84px;
  padding: 6px 2px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  scroll-snap-align: start;
}
.chan-av {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  background: #2a2d31;
  flex: none;
}
.chan-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chan-av-all {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.chan-chip.active .chan-av { box-shadow: 0 0 0 3px #ff0033; }
.chan-name {
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  max-width: 84px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* keep the loading/empty overlay below the rail on this screen */
#subscriptions .state { top: 196px; }

/* ===================== AUTH / KEYPAD ===================== */
.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 16px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.brand-name { font-size: 28px; font-weight: 700; }
.auth-hint { font-size: 15px; color: #b0b3b8; text-align: center; line-height: 1.45; margin-bottom: 8px; }
.auth-url { color: #00e5ff; font-weight: 600; }

.code-display {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}
.code-cell {
  width: 52px;
  height: 64px;
  background: #1c1e21;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: #fff;
}
.code-cell.filled { background: #2a2d31; box-shadow: inset 0 0 0 2px #ff0033; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 10px;
  margin-top: 6px;
}
.key {
  height: 64px;
  background: #1c1e21;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
}
.key-go { background: #ff0033; }
.key-alt { background: #2a2d31; }
.auth-status { margin-top: 12px; font-size: 14px; min-height: 18px; color: #ff6b6b; text-align: center; }
.auth-status.ok { color: #4ade80; }

/* ===================== PLAYER ===================== */
.player-frame {
  flex: 1;
  margin: 8px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.player-frame iframe { width: 100%; height: 100%; border: 0; }

.player-controls {
  flex: none;
  display: flex;
  gap: 6px;
  width: 100%;
  padding: 8px 6px 12px;
}
.pc-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 76px;
  background: #2a2d31;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pc-btn.pc-text { font-size: 24px; font-weight: 700; }

/* CSS-based fullscreen (no native Fullscreen API — it traps the D-pad in the
   YouTube iframe on the glasses). The video fills the 600x600 screen. */
.pc-exit {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, .6);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
#player.expanded .header,
#player.expanded .player-controls { display: none; }
#player.expanded .player-frame {
  position: absolute;
  inset: 0;
  margin: 0;
  border-radius: 0;
  z-index: 4;
}
/* Fullscreen = fully immersive: the exit button stays in the DOM (and keeps key
   focus out of the YouTube iframe) but is invisible until a swipe-up reveals it. */
#player.expanded .pc-exit {
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
#player.expanded.controls-shown .pc-exit {
  opacity: 1;
  pointer-events: auto;
}

/* ===================== SEARCH ===================== */
.search-query {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: #1c1e21;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-query:empty::before {
  content: "Rechercher…";
  color: #777;
  font-weight: 400;
}
.search-keyboard {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 8px;
  align-content: start;
}
.sk-key {
  height: 52px;
  background: #1c1e21;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
}
.sk-key.sk-wide { grid-column: span 2; }
.sk-key.sk-go { background: #ff0033; }
.sk-key.sk-alt { background: #2a2d31; }

/* ===================== NOTE / INFO ===================== */
.note {
  background: #2a2410;
  color: #f5d76e;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 14px;
  margin: 4px 8px 0;
  border-radius: 10px;
  flex: none;
}
.info-text {
  font-size: 16px;
  line-height: 1.5;
  color: #e4e6eb;
  background: #1c1e21;
  padding: 16px;
  border-radius: 12px;
}

/* ===================== STATES ===================== */
.state {
  position: absolute;
  inset: 80px 8px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #b0b3b8;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #2a2d31;
  border-top-color: #ff0033;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOAST ===================== */
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1c1e21;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 520px;
  text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #3a1416; }
.toast.success { background: #14331f; }
