/*
 * shell.css — Habillage du shell applicatif (masthead + topbar) dans la DA
 * bento. Mobile-first : le masthead est une grille compacte par défaut, puis
 * s'élargit sur tablette et desktop.
 */

#topbar-slot {
  width: 100%;
  max-width: var(--max-w-content);
  margin-inline: auto;
  padding: 10px var(--pad-page-x) 0;
  min-width: 0;
}

/* ---- Masthead ---- */
.shell-masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand actions"
    "site live"
    "nav nav";
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg, 14px);
  box-shadow: var(--shadow-1);
  min-width: 0;
}

/* ---- Marque ---- */
.shell-brand {
  grid-area: brand;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--tx);
  text-decoration: none;
}
.shell-brand svg {
  display: block;
  flex: 0 0 auto;
}
.shell-brand-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tx);
  font-family: var(--font-ui, 'Outfit'), system-ui, sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

/* ---- Mini-nav ---- */
.shell-nav {
  grid-area: nav;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 14px;
}
.shell-nav::-webkit-scrollbar {
  display: none;
}
.shell-nav-item {
  appearance: none;
  min-width: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  overflow: hidden;
  color: var(--tx2);
  background: transparent;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--font-ui, 'Outfit'), system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background 0.14s ease, color 0.14s ease;
}
.shell-nav-item:hover {
  color: var(--tx);
  background: var(--bg4);
}
.shell-nav-item:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}
.shell-nav-item.is-active {
  color: #fff;
  background: var(--ac);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}
.shell-nav-item.is-active:hover {
  color: #fff;
  filter: brightness(1.04);
}

/* ---- Outils ---- */
.shell-tools {
  display: contents;
}
.shell-site-group {
  grid-area: site;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.shell-site-select {
  min-width: 0;
  width: 100%;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 7px 10px;
  color: var(--tx);
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--font-mono, 'DM Mono'), monospace;
  font-size: 12px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.shell-site-select:hover {
  border-color: var(--ac3);
  background: var(--bg4);
}
.shell-site-select:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}
.shell-site-select svg {
  color: var(--tx3);
  flex: 0 0 auto;
}
.shell-site-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.shell-site-add {
  appearance: none;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ac);
  background: var(--ac2);
  border: 1px solid var(--ac3);
  border-radius: 11px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.14s ease, filter 0.14s ease;
}
.shell-site-add:hover {
  filter: brightness(0.98);
  background: var(--ac3);
}
.shell-site-add:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

/* Pastille live */
.shell-live {
  grid-area: live;
  min-width: 0;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 10px;
  color: var(--tx2);
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 999px;
  font-family: var(--font-mono, 'DM Mono'), monospace;
  font-size: 11.5px;
  white-space: nowrap;
}
.shell-live-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--tx3);
}
.shell-live.is-live .shell-live-dot {
  background: var(--ok);
  animation: shell-live-pulse 1.8s ease-out infinite;
}
@keyframes shell-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 196, 161, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(79, 196, 161, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 196, 161, 0); }
}

/* Actions */
.shell-actions {
  grid-area: actions;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.shell-lang {
  appearance: none;
  -webkit-appearance: none;
  width: 58px;
  height: 36px;
  padding: 7px 24px 7px 10px;
  color: var(--tx);
  background-color: var(--bg3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23808697' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  border: 1px solid var(--bd);
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--font-ui, 'Outfit'), system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.shell-lang:focus-visible {
  outline: none;
  border-color: var(--ac);
  box-shadow: var(--shadow-focus);
}
.shell-icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tx2);
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 11px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.shell-icon-btn:hover {
  color: var(--ac);
  border-color: var(--ac3);
  background: var(--ac2);
}
.shell-icon-btn:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

/* ---- Barre de contrôles (période / comparaison) sous le masthead ---- */
:root[data-theme='editorial'] .topbar-controls,
.topbar-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--bd);
}
.topbar-controls--inline {
  margin-top: 4px;
  margin-bottom: var(--space-5);
  padding-top: 0;
  border-top: 0;
}
.topbar-controls--inline .topbar-controls-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Très petits écrans : priorité aux commandes, pas au wordmark ni au texte live. */
@media (max-width: 430px) {
  #topbar-slot {
    padding-inline: var(--space-3);
  }
  .shell-masthead {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "site site"
      "live live"
      "nav nav";
    gap: 8px;
    padding: 8px;
  }
  .shell-brand-name,
  .shell-live-label {
    display: none;
  }
  .shell-live {
    justify-content: flex-start;
    height: 30px;
    padding-inline: 10px;
  }
  .shell-nav-item {
    min-height: 36px;
    padding-inline: 10px;
    font-size: 12px;
  }
}

/* Mobile paysage : tout tient sur deux lignes stables. */
@media (max-width: 767.98px) and (orientation: landscape) {
  .shell-masthead {
    grid-template-columns: auto minmax(180px, 1fr) auto;
    grid-template-areas:
      "brand site actions"
      "nav nav live";
  }
  .shell-live-label {
    display: none;
  }
  .shell-live {
    justify-self: end;
    width: auto;
    min-width: 42px;
  }
}

@media (min-width: 700px) {
  .shell-masthead {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand tools"
      "nav nav";
    gap: 12px;
    padding: 12px;
  }
  .shell-tools {
    grid-area: tools;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
  }
  .shell-site-group {
    flex: 1 1 220px;
    max-width: 320px;
  }
  .shell-live {
    flex: 0 0 auto;
  }
  .shell-actions {
    flex: 0 0 auto;
  }
  .shell-nav {
    grid-auto-columns: minmax(132px, 1fr);
  }
}

@media (min-width: 901px) {
  #topbar-slot {
    padding-top: 14px;
  }
  .shell-masthead {
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-areas: "brand nav tools";
    gap: 18px;
    padding: 14px 18px;
    border-radius: var(--radius-xl, 20px);
  }
  .shell-nav {
    width: auto;
    max-width: min(52vw, 620px);
    grid-auto-columns: auto;
    overflow: visible;
    border-radius: 999px;
  }
  .shell-nav-item {
    min-height: 32px;
    padding: 7px 16px;
    border-radius: 999px;
    font-weight: 500;
  }
  .shell-tools {
    gap: 12px;
  }
  .shell-site-group {
    flex: 0 1 260px;
  }
  .shell-site-select {
    max-width: 220px;
  }
  .shell-lang {
    width: 62px;
  }
}
