/**
 * [INPUT]: depends on CSS variables from web/styles/tokens.css
 * [OUTPUT]: provides Bécane floating top-left HUD (Header, GroupBar, ItemBar), condition popover, slide-over drawer, modal, and toast stack styles
 * [POS]: chrome and navigation stylesheet of web/styles/, paired with web/js/main.js
 * [PROTOCOL]: Update this header on change, then check GEMINI.md
 */

/* ==========================================================================
   App Shell & Floating Top-Left Architectural HUD
   ========================================================================== */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hud-shell {
  position: sticky;
  top: 0;
  z-index: var(--z-hud);
  padding: var(--hud-edge) var(--hud-edge) 8px;
  pointer-events: none;
}

.hud-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hud-gap);
  max-width: 1480px;
  margin: 0 auto;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.hud-bar {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  min-height: var(--hud-height);
  background: var(--bg-bar);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-bar);
  overflow: hidden;
  max-width: 100%;
}

.hud-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--hud-height);
  padding: 0 12px;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  position: relative;
}

.hud-cell + .hud-cell {
  border-left: 1px solid var(--hairline);
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--hud-height);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  border-radius: 0;
}

.hud-btn + .hud-btn,
.hud-cell + .hud-btn,
.hud-btn + .hud-cell {
  border-left: 1px solid var(--hairline);
}

.hud-btn.is-active {
  color: var(--ink);
  background: var(--bg-canvas);
}

.hud-btn .nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--index-ink);
  font-variant-numeric: tabular-nums;
}

.hud-btn.is-active .nav-count {
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .hud-btn:hover:not(:disabled) {
    color: var(--ink);
    background: var(--bg-hover);
  }
}

.hud-sep {
  width: 1px;
  height: 16px;
  background: var(--hairline);
  flex-shrink: 0;
}

/* Brand Mark */
.brand-mark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  display: inline-block;
  flex-shrink: 0;
}

.brand-word {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Status Dots & Live Spinner */
.key-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--index-ink);
}

.key-dot.is-ready {
  background: #16A34A;
}

.key-dot.is-missing {
  background: #D97706;
}

.hud-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--hairline-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: hud-spin 700ms linear infinite;
  flex-shrink: 0;
}

@keyframes hud-spin {
  to { transform: rotate(360deg); }
}

/* Transversal Micro-Thumbnails (24x24) in ItemBar */
.transversal-strip {
  display: inline-flex;
  align-items: center;
  height: var(--hud-height);
  padding: 0 6px;
  gap: 4px;
  border-left: 1px solid var(--hairline);
}

.transversal-item {
  width: 24px;
  height: 24px;
  border-radius: 2px;
  border: 1px solid var(--hairline);
  background: var(--bg-well);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  padding: 0;
}

.transversal-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.transversal-item.is-active {
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

/* Sync Alert Bar */
.hud-sync-banner {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-bar);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #FED7AA;
  font-size: 12px;
}

/* ==========================================================================
   Context Condition Popover (Today Weather / City / Date / Occasion)
   ========================================================================== */
.condition-popover {
  pointer-events: auto;
  margin-top: 2px;
  width: min(680px, calc(100vw - 32px));
  background: var(--bg-bar);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
  padding: 16px;
  display: grid;
  gap: 14px;
  box-shadow: 0 12px 32px rgba(10, 10, 10, 0.06);
  animation: fade-slide-in var(--dur-base) var(--ease-out);
}

.condition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.condition-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-bar);
  border: 1px solid var(--hairline);
  background: var(--bg-bar);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip-btn.is-active {
  background: var(--ink);
  color: var(--bg-bar);
  border-color: var(--ink);
}

.city-search-row {
  display: flex;
  gap: 6px;
}

.city-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-bar);
  overflow: hidden;
}

.city-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 12px;
  text-align: left;
  background: var(--bg-bar);
}

.city-option + .city-option {
  border-top: 1px solid var(--hairline);
}

/* ==========================================================================
   Main View Container
   ========================================================================== */
.view-shell {
  flex: 1;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px var(--hud-edge) 96px;
}

/* ==========================================================================
   Frosted Glass Slide-Over Drawer & Modal Layer
   ========================================================================== */
.drawer-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: flex;
  justify-content: flex-end;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in var(--dur-base) var(--ease-out);
}

.drawer-layer.is-modal {
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.drawer-panel {
  width: min(560px, 100vw);
  height: 100%;
  background: var(--bg-bar);
  border-left: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-slide-in var(--dur-base) var(--ease-out);
}

.drawer-panel.is-wide {
  width: min(760px, 100vw);
}

.drawer-layer.is-modal .drawer-panel {
  width: min(540px, 100%);
  height: auto;
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-panel);
  animation: fade-slide-in var(--dur-base) var(--ease-out);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

.drawer-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.drawer-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-bar);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--ink);
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--bg-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================================
   Toast Stack
   ========================================================================== */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}

.toast-item {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: var(--radius-bar);
  background: var(--ink);
  color: var(--bg-bar);
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.12);
  animation: fade-slide-in var(--dur-base) var(--ease-out);
}

.toast-item.is-err {
  background: var(--err);
}

.toast-item.is-ok {
  background: var(--ok);
}

/* ==========================================================================
   Mobile Bottom Floating Bar (<= 900px)
   ========================================================================== */
.mobile-bottom-hud {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --hud-edge: 12px;
  }

  .hud-group-bar-desktop {
    display: none;
  }

  .hud-bar {
    width: 100%;
    justify-content: space-between;
  }

  .hud-bar.is-compact {
    width: auto;
  }

  .condition-grid {
    grid-template-columns: 1fr;
  }

  .view-shell {
    padding-bottom: 128px;
  }

  .mobile-bottom-hud {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: var(--z-hud);
    background: var(--bg-bar);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-bar);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(10, 10, 10, 0.08);
  }

  .mobile-bottom-hud .hud-btn {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    height: 48px;
    padding: 0 4px;
    font-size: 11px;
  }

  .toast-stack {
    bottom: 72px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes drawer-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
