/* ═══════════════════════════════════════
   WOBAZI — The app dock (phones) and the header apps row (desktop), 2026-11-21
   public/css/app-dock.css, loaded on every page (views/partials/head.ejs, app/index.html)
   Markup: public/js/app-dock.js (dock) · views/partials/nav-menu.ejs (.nav-apps)
═══════════════════════════════════════ */
:root { --dock-h: calc(58px + env(safe-area-inset-bottom, 0px)); }

/* ── Desktop: the apps in the header, small orbs with a tiny label ── */
.nav-apps { display: none; }
@media (min-width: 900px) {
  .nav-apps { display: flex; align-items: center; gap: 2px; margin-right: 6px; }
  .nav-apps .dock-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px; width: 60px; padding: 3px 0 2px; border-radius: 10px;
    text-decoration: none; color: var(--m7, #a0a0b8);
  }
  .nav-apps .dock-item:focus-visible { background: var(--w06); color: var(--text, #f0f0ff); outline: none; }
  @media (hover: hover) { .nav-apps .dock-item:hover { background: var(--w06); color: var(--text, #f0f0ff); outline: none; } }
  .nav-apps .wz-orb { --orb-size: 26px !important; }
  .nav-apps .wz-orb::after { display: none; }
  .nav-apps .dock-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 600; line-height: 1.1; }
  .nav-apps .dock-item.active .dock-lbl { color: var(--gold, #f0c040); }
  .nav-apps .dock-item.active .wz-orb { box-shadow: 0 0 0 2px var(--gold, #f0c040); }
}
@media (min-width: 900px) and (max-width: 1080px) {
  .nav-apps .dock-item { width: 50px; }
  .nav-apps .dock-lbl { font-size: 9px; }
}

/* ── Phones: the dock on every page ── */
.app-dock { display: none; }
@media (max-width: 767px) {
  .app-dock, .app-dock.hide {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    display: flex !important; align-items: stretch; gap: 0;
    padding: 6px 2px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg-card, #13132a) 88%, var(--gold, #f0c040) 12%);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border-top: 1px solid color-mix(in srgb, var(--gold, #f0c040) 38%, var(--w08));
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
    touch-action: none;
  }
  .dock-item {
    flex: 1 1 0; min-width: 0; min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 2px 0; border-radius: 12px; text-decoration: none; color: var(--m7, #a0a0b8); -webkit-tap-highlight-color: transparent;
  }
  .app-dock .wz-orb { --orb-size: 28px !important; transition: transform 0.14s ease-out; }
  .app-dock .wz-orb::after { display: none; }
  .dock-item:active .wz-orb { transform: scale(0.92); }
  .dock-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8.5px; font-weight: 600; line-height: 1.1; letter-spacing: -0.1px; }
  .dock-item.active .dock-lbl { color: var(--gold, #f0c040); }
  .dock-item.active .wz-orb { box-shadow: 0 0 0 2px var(--gold, #f0c040), 0 0 12px color-mix(in srgb, var(--ln-accent, #f0c040) 70%, transparent); }
  .dock-item:focus-visible { outline: 2px solid var(--gold, #f0c040); outline-offset: -2px; }

  /* Room for it at the bottom of the site pages (the app shell's scroll areas already leave it). */
  html.has-dock body:not(.app-shell) { padding-bottom: var(--dock-h); }
  html.has-dock #input { padding-bottom: calc(var(--dock-h) + 12px); }
  /* The Oracle drawer and the Aura / Face layers stop above it, so it stays on screen there too. */
  html.has-dock .aura-layer { bottom: var(--dock-h) !important; }
  html.has-dock .oracle-drawer { bottom: var(--dock-h) !important; height: auto !important; }
  html.has-dock .oracle-drawer-backdrop { bottom: var(--dock-h); }
}

/* 2026-11-21: bigger icons, more room between icon and label, and sideways scroll when they don't all fit. */
:root { --dock-h: calc(70px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 767px) {
  .app-dock, .app-dock.hide { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-left: 4px; padding-right: 4px; touch-action: pan-x; }
  .app-dock::-webkit-scrollbar { display: none; }
  .app-dock .dock-item { flex: 1 0 64px; min-height: 56px; gap: 6px; padding: 4px 2px; }
  .app-dock .wz-orb { --orb-size: 34px !important; }
  .app-dock .dock-lbl { font-size: 10px; letter-spacing: 0; }
}
@media (max-width: 767px) {
  .app-dock .dock-item { flex: 1 0 auto; min-width: 62px; padding: 4px 7px; }
  .app-dock .dock-lbl { max-width: none; overflow: visible; text-overflow: clip; }
}

/* Site pages: hang the dock from the visible area's bottom (public/js/app-dock.js --pvv-*), not from the
   layout viewport's, which iOS Chrome can leave stale after switching apps. The app shell pins body itself. */
@media (max-width: 767px) {
  html.has-dock body:not(.app-shell) .app-dock { top: calc(var(--pvv-top, 0px) + var(--pvv-h, 100dvh)); bottom: auto; transform: translateY(-100%); }
}

/* Phones, 2026-11-21: the logo keeps its size on the site pages (home, Learn, Master Alice …) and is
   smaller inside the app (the app shell's screens and the Aura / Face layers). */
@media (max-width: 767px) {
  body.app-shell .nav-logo, body.app-shell .aura-logo { height: 18px !important; width: auto !important; }
}

/* Desktop header, 2026-11-21: icons only; the name shows in a small label under the icon on hover or keyboard focus. */
@media (min-width: 900px) {
  .nav-apps { gap: 4px; }
  .nav-apps .dock-item, .nav-apps .dock-item[class] { position: relative; width: auto; padding: 5px; border-radius: 10px; }
  .nav-apps .wz-orb { --orb-size: 30px !important; }
  .nav-apps .dock-lbl {
    position: absolute; top: calc(100% + 6px); left: 50%; z-index: 20; max-width: none; overflow: visible;
    padding: 4px 8px; border-radius: 6px; font-size: 11px; color: var(--text, #f0f0ff);
    background: rgba(10, 10, 22, 0.95); border: 1px solid var(--w12); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    opacity: 0; transform: translate(-50%, -3px); pointer-events: none; transition: opacity 0.12s, transform 0.12s;
  }
  .nav-apps .dock-item:focus-visible .dock-lbl { opacity: 1; transform: translate(-50%, 0); }
  @media (hover: hover) { .nav-apps .dock-item:hover .dock-lbl { opacity: 1; transform: translate(-50%, 0); } }
  .nav-apps .dock-item.active .dock-lbl { color: var(--gold, #f0c040); }
}

/* ═══════════════════════════════════════
   The five-item main nav (2026-11-23, NAV_V2=true; config/suite.js NAV, public/js/app-dock.js renderNav)
   The phone bar (< 768px) only: icon + label, labels at 11px or more and never cut (a locale that doesn't
   fit gets a nav.short.* label instead). The desktop header keeps the apps row + the 3×3 launcher (2026-11-24).
═══════════════════════════════════════ */
.nm-item {
  color: var(--m7, #a0a0b8); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nm-item.active, .nm-item.active .nm-lbl { color: var(--gold, #f0c040); }
.nm-lbl { font-weight: 600; white-space: nowrap; }
.nm-item:focus-visible { outline: 2px solid var(--gold, #f0c040); outline-offset: -2px; border-radius: 10px; }

@media (max-width: 767px) {
  .app-dock.nav-v2, .app-dock.nav-v2.hide { overflow: hidden; touch-action: none; padding-left: 2px; padding-right: 2px; }
  .app-dock.nav-v2 .nm-item {
    flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 4px 1px; border-radius: 12px;
  }
  .app-dock.nav-v2 .wz-orb { --orb-size: 32px !important; transition: transform 0.14s ease-out; }
  .app-dock.nav-v2 .wz-orb::after { display: none; }
  .app-dock.nav-v2 .nm-item:active .wz-orb { transform: scale(0.92); }
  /* Active: the old dock's gold ring round the icon, and a gold label. */
  .app-dock.nav-v2 .nm-item.active .wz-orb { box-shadow: 0 0 0 2px var(--gold, #f0c040), 0 0 12px rgba(240, 192, 64, 0.45); }
  .app-dock.nav-v2 .nm-lbl { font-size: 11px; line-height: 1.15; letter-spacing: 0; max-width: 100%; text-align: center; }
}

/* The Oracle, a floating button on every app (not on the Oracle's own pages). Above the phone bar;
   bottom right on desktop. Hidden while the Oracle drawer or the Aura / Face layer is open. */
.oracle-fab {
  position: fixed; z-index: 950; right: 16px; bottom: calc(var(--dock-h, 0px) + 14px);
  display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 18px;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.oracle-fab .wz-orb { --orb-size: 52px !important; }
.oracle-fab:focus-visible { outline: 2px solid var(--gold, #f0c040); outline-offset: 3px; }
@media (min-width: 768px) { .oracle-fab { right: 24px; bottom: 24px; } }
html.has-dock body:not(.app-shell) .oracle-fab { bottom: calc(var(--dock-h, 0px) + 14px); }
@media (min-width: 768px) { html.has-dock body:not(.app-shell) .oracle-fab { bottom: 24px; } }
.oracle-drawer:not(.hide) ~ .oracle-fab, .aura-layer ~ .oracle-fab, body.launcher-open .oracle-fab { display: none; }
