/* ══════════════════════════════════════════════════════════════════════
   chrome.css — SITE CHROME: header, desktop dock nav, account bubble +
   dropdown, mobile bottom nav, fixed desktop footer.
   ──────────────────────────────────────────────────────────────────────
   Markup is injected by ui-kit.js (UI.mountHeader / UI.mountFooter) into
   the #siteHeader / #siteFooter slots so every page renders the SAME
   chrome and none can drift. Per-page differences are markup only: which
   nav item is .active, the page name in .header-title-nav, and whether the
   first dock slot is the account bubble (signed in) or Home (public).

   Breakpoint: 900px. Below = fixed header + bottom nav. Above = sticky
   header with the centred icon dock + fixed footer.
   Requires tokens.css.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  background: var(--header-grad);
  border-bottom: 3px solid var(--warn);
  padding: 0 20px;
  box-shadow: 0 4px 24px rgba(0,40,70,0.28);
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 60;
  overflow: hidden;
}
/* Soft radial wash over the gradient (gives the header its texture). */
.header::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-radial-gradient(ellipse at 20% 50%, rgba(99,220,230,0.07) 0 1px, transparent 2px 28px);
  transform: rotate(-9deg) scale(1.4);
}
.header-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 0; position: relative; z-index: 1;
}

/* Logo (image, white-inverted) with text fallback when the image is missing. */
.logo-wrap {
  display: flex; align-items: center; flex-shrink: 0; text-decoration: none;
  cursor: pointer; border-radius: 12px; padding: 4px; margin: -4px; transition: opacity .2s;
}
.logo-wrap:hover  { opacity: .82; }
.logo-wrap:active { opacity: .55; }
.logo-wrap img { height: 52px; filter: brightness(0) invert(1); }
.logo-fallback { display: none; flex-direction: column; line-height: 1; }
.logo-wrap img.hidden + .logo-fallback { display: flex; }
.logo-fallback-top  { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,0.65); }
.logo-fallback-main { font-size: 19px; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.logo-fallback-main span { color: var(--accent-lt); }

/* Brand title + page eyebrow (with a live pulse dot). */
.header-title-block { display: flex; flex-direction: column; justify-content: center; gap: 4px; margin-left: auto; text-align: right; }
.header-title-top { font-size: 15px; font-weight: 800; color: #fff; letter-spacing: -.01em; line-height: 1.1; white-space: nowrap; }
.header-title-nav {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .10em;
  color: rgba(255,255,255,0.60); white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0;
  animation: pulse-dot 2s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0    color-mix(in srgb, var(--ok) 50%, transparent); }
  70%  { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0    transparent; }
}

/* Mobile header right: small avatar chip (desktop uses the dock bubble). */
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  border-radius: 10px; padding: 4px; transition: background .15s;
}
.user-chip:hover { background: rgba(255,255,255,0.12); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-grad); color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.25);
}

/* ── Desktop dock (hidden on mobile) ───────────────────────────────── */
.header-dock { display: none; }

/* ── Mobile bottom nav ─────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: color-mix(in srgb, var(--brand) 97%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: stretch; height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; padding: 6px 4px; position: relative;
  color: rgba(255,255,255,0.38); transition: color .2s; text-decoration: none;
}
.nav-tab:hover  { color: rgba(255,255,255,0.65); }
.nav-tab.active { color: var(--accent-lt); }
.nav-tab.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 2px; border-radius: 0 0 3px 3px; background: var(--accent-lt);
}
.nav-tab svg { width: 20px; height: 20px; transition: transform .2s; }
.nav-tab.active svg { transform: scale(1.12); }
.nav-label { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 14px);
  width: 7px; height: 7px; background: var(--warn); border-radius: 50%;
  border: 1.5px solid var(--brand); display: none;
}
.nav-badge.is-on { display: block; }

/* Account dropdown is desktop-only chrome. */
@media (max-width: 899px) { .account-dropdown { display: none !important; } }

/* ── Footer (desktop only, fixed) ──────────────────────────────────── */
.site-footer { display: none; }

/* ══════════════════════════════════════════════════════════════════════
   DESKTOP (≥ 900px)
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  .header { position: sticky; top: 0; padding: 0 36px; }
  .bottom-nav { display: none !important; }
  .header-right { display: none; }

  .header-inner {
    padding: 22px 0; gap: 0; min-height: 96px;
    display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  }
  .logo-wrap { justify-self: start; }
  .logo-wrap img { height: 72px; }
  .header-title-block { justify-self: center; margin-left: 0; text-align: left; gap: 5px; }
  .header-title-top { font-size: 22px; letter-spacing: -.02em; }
  .header-title-nav { justify-content: flex-start; font-size: 12px; letter-spacing: .12em; color: rgba(255,255,255,0.65); }

  /* Dock: icon buttons that grow on hover (neighbours grow a little too). */
  .header-dock { display: flex; align-items: center; gap: 0; padding: 0 8px; height: 92px; justify-self: center; overflow: visible; }
  .hdock-item {
    --sz: 58px; width: var(--sz); height: var(--sz); position: relative; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: width .28s cubic-bezier(.16,1,.3,1), height .28s cubic-bezier(.16,1,.3,1);
  }
  .hdock-item:hover                                 { --sz: 78px; }
  .hdock-item:has(+ .hdock-item:hover),
  .hdock-item:hover + .hdock-item                   { --sz: 68px; }
  .hdock-item:has(+ .hdock-item + .hdock-item:hover),
  .hdock-item:hover + .hdock-item + .hdock-item     { --sz: 63px; }
  .hdock-item.is-hidden { display: none; }
  .hdock-btn {
    width: 100%; height: 100%; background: none; border: none; text-decoration: none;
    display: flex; align-items: center; justify-content: center; position: relative;
    border-radius: 16px; color: rgba(255,255,255,0.75); transition: color .15s, background .15s;
  }
  .hdock-btn svg {
    width: calc(var(--sz) * 0.44); height: calc(var(--sz) * 0.44); pointer-events: none;
    transition: width .28s cubic-bezier(.16,1,.3,1), height .28s cubic-bezier(.16,1,.3,1);
  }
  .hdock-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }
  .hdock-btn.active { color: #fff; }
  .hdock-btn.active::after {
    content: ''; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.8);
  }
  @keyframes dock-pop { 0% { transform: scale(1); } 40% { transform: scale(.82); } 100% { transform: scale(1); } }
  .hdock-btn.popping { animation: dock-pop .22s cubic-bezier(.34,1.56,.64,1); }
  .hdock-tooltip {
    position: absolute; top: calc(100% + 5px); left: 50%;
    transform: translateX(-50%) translateY(-4px);
    color: rgba(255,255,255,0.85); font-size: 10px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .18s, transform .18s; z-index: 10; text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  }
  .hdock-btn:hover .hdock-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }
  .hdock-badge {
    position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; display: none;
    background: var(--warn); border-radius: 50%; border: 1.5px solid var(--brand);
  }
  .hdock-badge.is-on { display: block; }
  .hdock-sep { width: 1px; height: 22px; background: rgba(255,255,255,0.20); margin: 0 4px; flex-shrink: 0; }

  /* Account bubble (replaces Home when signed in). */
  .hdock-account-btn { padding: 0; }
  .hdock-account-initials {
    display: inline-flex; align-items: center; justify-content: center;
    width: calc(var(--sz) * 0.74); height: calc(var(--sz) * 0.74); border-radius: 50%;
    background: var(--brand-grad); color: #fff; font-weight: 800; font-size: calc(var(--sz) * 0.30);
    letter-spacing: -.02em; border: 2px solid rgba(255,255,255,0.28);
    box-shadow: 0 6px 14px rgba(0,0,0,0.18); transition: border-color .15s, box-shadow .15s; user-select: none;
  }
  .hdock-account-btn:hover { background: transparent; }
  .hdock-account-btn:hover .hdock-account-initials,
  .hdock-account-btn[aria-expanded="true"] .hdock-account-initials { border-color: rgba(255,255,255,0.78); box-shadow: 0 10px 22px rgba(0,0,0,0.26); }
  .hdock-account-btn.active::after { display: none; }

  /* Dropdown card anchored under the bubble (position set by JS). */
  .account-dropdown {
    position: fixed; width: 248px; padding: 6px; z-index: 200;
    border: 1px solid var(--border); border-radius: 14px;
    color: var(--text); background: rgba(255,255,255,0.98); box-shadow: 0 22px 55px rgba(3,33,48,0.24);
    opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: top center;
    transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  }
  .account-dropdown.open { opacity: 1; visibility: visible; transform: none; }
  .account-dropdown::before {
    content: ''; position: absolute; top: -8px; left: 50%; width: 14px; height: 14px; background: #fff;
    border-left: 1px solid var(--border); border-top: 1px solid var(--border);
    transform: translateX(-50%) rotate(45deg);
  }
  .account-dropdown-header { padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border-soft); }
  .account-dropdown-name { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .account-dropdown-upn  { margin-top: 3px; font-size: 11px; color: var(--accent); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .account-menu-item {
    width: 100%; min-height: 40px; border: 0; border-radius: 10px; padding: 10px 12px;
    display: flex; align-items: center; gap: 12px; background: transparent; color: var(--text);
    font-size: 14px; font-weight: 700; text-align: left; text-decoration: none;
  }
  .account-menu-item svg { width: 18px; height: 18px; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
  .account-menu-item:hover { background: var(--panel-2); }
  .account-menu-divider { height: 1px; margin: 5px 8px; background: var(--border-soft); }
  .account-menu-item.danger { color: var(--danger-ink); }
  .account-menu-item.danger:hover { background: var(--danger-08); }

  /* Footer */
  .site-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--brand); padding: 11px 36px;
    border-top: 1px solid rgba(255,255,255,0.07); box-shadow: 0 -2px 16px rgba(0,40,70,0.18);
    font-size: 12px; color: rgba(255,255,255,0.55);
  }
  .site-footer-left  { display: flex; align-items: center; gap: 10px; }
  .site-footer-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
  .footer-logo-text  { font-weight: 800; font-size: 13px; color: var(--accent-lt); letter-spacing: .06em; }
  .footer-divider    { opacity: .3; }
  .footer-poc        { color: rgba(255,255,255,0.6); display: flex; align-items: center; gap: 4px; }
  .footer-poc svg    { width: 12px; height: 12px; }
  .footer-link       { color: var(--accent-lt); text-decoration: none; transition: color .15s; }
  .footer-link:hover { color: #fff; text-decoration: underline; }
  .footer-version    { color: rgba(255,255,255,0.7); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
}
