/* ─────────────────────────────────────────────
   Tour Budget CMS — App Shell
   The one piece of chrome shared by every page. See client/js/shell.js.

   Typographic note: labels use DM Mono in the register of a spec sheet —
   uppercase, letter-spaced, small. Money and data elsewhere in the app should
   likewise carry tabular figures; `.tnum` below is the shared utility for that.
───────────────────────────────────────────── */

/* A floating island, not an edge-to-edge bar (Jim's foureditors.io reference):
   inset from the top and sides, hairline border all round, page content
   scrolling underneath the gap. Sticky with top = the gap it keeps. */
.shell-topbar {
  position: sticky;
  top: var(--topbar-gap);
  z-index: 900;
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: var(--topbar-h);
  padding: 0 14px;
  width: calc(100% - 2 * var(--topbar-gap));
  max-width: 1240px;   /* deliberately narrower than the content column (Jim) */
  margin: var(--topbar-gap) auto var(--topbar-gap-below);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
}

/* The glass lives on a pseudo, NOT the bar itself: backdrop-filter makes an
   element the containing block for position:fixed descendants, which
   re-based the dropdown menus' viewport coordinates onto the bar and threw
   them to the far right on wide screens. On ::before it blurs identically
   but affects no descendants. */
.shell-topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
}

/* ── Wordmark ── */
.shell-brand {
  display: flex;
  align-items: center;
  padding-right: 16px;
  margin-right: 6px;
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
/* the dense tour bar keeps its dividers; the global island stays clean */
body.in-tour .shell-brand { border-right: 1px solid var(--border); }
.shell-brand span { color: var(--accent); }
.shell-brand:hover span { color: var(--accent2); }

/* ── Nav ── */
.shell-nav {
  display: flex;
  align-items: stretch;
  /* centered in the island, like the reference; `safe` keeps the first links
     reachable when the bar overflows and scrolls */
  justify-content: safe center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.shell-nav::-webkit-scrollbar { display: none; }

.shell-group { position: relative; display: flex; }

.shell-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  margin: 8px 0;
  border: 0;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 9px;
  transition: color 0.12s, background 0.12s;
}
.shell-link:hover { color: var(--text); background: var(--accent-subtle); }
.shell-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.shell-link[aria-current="page"],
.shell-trigger.is-active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.shell-caret {
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.7;
}

/* ── Collapsed global menu ──
   When the inline links overflow the bar, shell.js measures and flips the nav
   to `.collapsed`: every inline link hides and one "Menu" trigger shows,
   holding the whole navigation with section labels. Measurement-based, not a
   breakpoint — the menu's width varies by role. */
.shell-collapse { display: none; }
.shell-nav.collapsed > .shell-link,
.shell-nav.collapsed > .stage,
.shell-nav.collapsed > .shell-group:not(.shell-collapse) { display: none; }
.shell-nav.collapsed .shell-collapse { display: flex; }
.shell-menu-sec {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 11px 3px;
}

/* ── Dropdown ──
   position: FIXED, not absolute. .shell-nav needs overflow-x:auto so the nav can
   scroll on narrow screens, but CSS cannot have overflow visible on one axis and
   auto on the other — overflow-y computes to auto as well, which clipped an
   absolutely-positioned menu to the 52px nav box. The menu was rendered but
   invisible and unclickable. Fixed positioning escapes the ancestor's clipping;
   shell.js sets left/top from the trigger's rect each time it opens. */
.shell-menu {
  position: fixed;
  min-width: 190px;
  padding: 6px;
  display: none;
  flex-direction: column;
  /* SOLID, unlike the glassy bar: a menu floats over page content and its
     items must stay readable — nothing may show through (Jim, 2026-07-28). */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  z-index: 950;
}
.shell-menu .shell-item { border-radius: 6px; }
.shell-group.open .shell-menu { display: flex; }

.shell-item {
  padding: 8px 11px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  border-left: 2px solid transparent;
}
.shell-item:hover { background: var(--accent-subtle); color: var(--accent); }
.shell-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-item[aria-current="page"] {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
}

/* ── Right cluster ── */
.shell-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  margin-left: 6px;
}
body.in-tour .shell-right { border-left: 1px solid var(--border); }

/* ── Avatar + user menu ──
   The whole right cluster is one circular initials button (Jim: the toggle +
   name + sign-out row ate too much bar). Its 1px ring is the reference's
   warm→cool gradient: surface fill clipped to padding-box, gradient clipped
   to border-box, plus a faint warm glow. */
.shell-avatar {
  align-self: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(var(--surface2), var(--surface2)) padding-box,
    linear-gradient(120deg, var(--accent), rgba(90,130,210,0.85)) border-box;
  border: 1px solid transparent;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 15%, transparent);
  transition: box-shadow 0.15s;
}
.shell-avatar:hover,
.shell-group.open .shell-avatar {
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 40%, transparent);
}
.shell-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell-user-menu { min-width: 210px; }
.sum-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 11px 9px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}
.sum-name { font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; }
.sum-mail {
  font-family: 'DM Mono', monospace; font-size: 10.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Section label inside the user menu (Admin block) */
.sum-section {
  font-family: 'DM Mono', monospace; font-size: 9.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 8px 11px 3px; border-top: 1px solid var(--border-subtle); margin-top: 4px;
}
/* .shell-item is styled for anchors; menu buttons need the resets */
button.shell-item {
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text);
  border-left: 2px solid transparent;
}
.sum-signout:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.sum-divider { border-top: 1px solid var(--border-subtle); margin: 4px 0; }

.shell-topbar .theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  padding: 4px 7px;
  line-height: 1;
  font-size: 13px;
}
.shell-topbar .theme-toggle:hover { border-color: var(--accent); }

/* ── Tour context: the stage bar replaces the global menu in the same slot ──
   Once you are inside a tour, day-to-day navigation IS the tour flow. The
   global menu returns on My Dashboard and other non-tour pages. */
.shell-tour-label {
  display: flex; align-items: center; gap: 6px; margin-right: 4px; padding: 0 10px 0 4px;
  font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); text-decoration: none;
  white-space: nowrap; max-width: 280px; overflow: hidden;
  background: none; border: 0; cursor: pointer; margin: 8px 4px 8px 0;
  border-radius: 9px; transition: color 0.12s, background 0.12s;
}
/* Ellipsis lives on the band-name span — on the flex button itself it does
   nothing and the label hard-clips mid-character. Tour name (b) never clips. */
.shell-tour-label .stl-band-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.shell-tour-label b, .shell-tour-label .shell-caret { flex: none; }
.shell-tour-label:hover { color: var(--accent); background: var(--accent-subtle); }
.shell-tour-label:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-tour-label b { color: var(--text); font-weight: 500; }

/* The switcher menu: every tour the user can see, current one marked. */
.shell-tour-menu { min-width: 260px; max-height: 60vh; overflow-y: auto; }
.shell-tour-item { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.sti-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sti-state {
  flex: none; font-family: 'DM Mono', monospace; font-size: 8.5px;
  letter-spacing: 0.09em; text-transform: uppercase; padding: 2px 6px;
}
.sti-final { background: color-mix(in srgb, var(--rag-green) 15%, transparent); color: var(--rag-green); }
.sti-draft { background: var(--surface2); color: var(--muted); }
.sti-band {
  font-family: 'DM Mono', monospace; font-size: 8.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.shell-tour-item:hover .sti-band { color: inherit; }
.sti-name { font-size: 13px; }

/* Twelve stages (Breaks + Merch joined the spine, 2026-08-04) no longer fit
   the 1240px island — in tour context the bar widens to the content column
   and the stages tighten a touch. The global menu keeps the narrower island
   (Jim's original choice). */
body.in-tour .shell-topbar { max-width: var(--content-w); }

.shell-nav .stage {
  flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center;
  gap: 2px; padding: 5px 9px; margin: 8px 0; border: 0; background: none;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  text-decoration: none; min-width: 0;
  border-radius: 9px; transition: color 0.12s, background 0.12s;
}
.shell-nav .stage:hover { background: var(--accent-subtle); }
.shell-nav .stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shell-nav .stage.active { background: var(--accent-subtle); }
.shell-nav .stage.active .st-name,
.shell-nav .stage.active .st-val { color: var(--accent); }
.shell-nav .stage.disabled { cursor: not-allowed; opacity: 0.5; }
.shell-nav .stage.disabled:hover { background: none; }
.shell-nav .st-name { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); white-space: nowrap; line-height: 1.15; }
.shell-nav .st-val  { font-family: 'DM Mono', monospace; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1; }
/* flex: none — the meter is the one child with no intrinsic size, so when the
   floating pill runs a fraction short it is what flex collapses to 0px. */
.shell-nav .st-meter { height: 2px; flex: none; background: var(--surface2); min-width: 42px; }
.shell-nav .st-meter > i { display: block; height: 100%; }
.shell-nav .sm-ok > i   { background: var(--rag-green); }
.shell-nav .sm-warn > i { background: var(--rag-amber); }
.shell-nav .sm-crit > i { background: var(--rag-red); }
.shell-nav .sm-idle > i { background: var(--muted); opacity: 0.45; }

/* ── Page headers sit below the shell ──
   Pages keep their own header for page-specific actions; the shell removes the
   duplicated wordmark / back-link / theme toggle from them. A page header that
   was stuck to the top must now stick below the shell instead.

   Scoped to a DIRECT child so it cannot reach headers nested inside panels.
   The topbar floats (top = --topbar-gap), so stuck headers sit below
   h + gap, plus the small below-gap so they never kiss the island. */
body.has-shell > header { top: calc(var(--topbar-h) + var(--topbar-gap) + var(--topbar-gap-below)); }

/* Pages style the bare `nav` element as a sticky full-height sidebar. The shell
   uses a div, so it is unaffected — but those sidebars must now start below the
   shell rather than under a 56px page header. */
body.has-shell nav { top: calc(var(--topbar-h) + var(--topbar-gap) + var(--topbar-gap-below) + 56px); }

/* Tabular figures — money and any column of digits should line up.
   Applied here as a shared utility so pages can opt in without redefining it. */
.tnum,
td.num, th.num,
.money, .amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

@media (max-width: 860px) {
  :root { --topbar-gap: 6px; }
  .shell-topbar { border-radius: 12px; padding: 0 8px; }
  .shell-brand { padding-right: 10px; margin-right: 2px; font-size: 14px; }
  .shell-link { padding: 0 9px; font-size: 12.5px; }
  /* Stage bar returns to compact sizes where width is scarce — the desktop
     bump matches the global menu, but small screens need the density. */
  .shell-nav .st-name { font-size: 8px; }
  .shell-nav .st-val  { font-size: 10.5px; }
  .shell-nav .stage   { padding: 6px 8px; margin: 6px 0; }
  .shell-tour-label   { font-size: 10px; max-width: 200px; }
  /* Phones: the band name yields entirely (tour name is the identity) so the
     collapsed Menu trigger keeps room in the bar. */
  .shell-tour-label .stl-band-name { display: none; }
  .shell-nav .shell-collapse { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  .shell-link { transition: none; }
}

/* ── Shared new-tour modal (js/newTour.js) ──────────────────────────────────
   newTour.js injects its markup on ANY shell page; these styles must live
   with the shell, not copied per page — tours.html shipped without them and
   the dialog rendered unstyled in page flow (Cancel "did nothing" because
   .open had no meaning). Scoped under .modal-back so pages with their own
   modal systems (base.css .modal-overlay family) are untouched. */
.modal-back {
  display: none; position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-back.open { display: flex; }
.modal-back .modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
  background-image: linear-gradient(90deg, var(--accent), transparent 72%);
  background-size: 100% 2px; background-repeat: no-repeat;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 0;
}
.modal-back .modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-back .modal-head h3 { margin: 0; font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 700; }
.modal-back .modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-back .modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-back .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-back .note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.modal-back .err { color: var(--danger); font-size: 12.5px; min-height: 16px; }
.modal-back .cand-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.modal-back .cand { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.modal-back .cand:last-child { border-bottom: 0; }
.modal-back .cand:hover { background: var(--accent-subtle); }
.modal-back .cand input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex: none; }
.modal-back .cand-date { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.modal-back .cand-venue { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-back .quick { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-back .quick a { font-family: 'DM Mono', monospace; font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); padding: 3px 9px; text-decoration: none; border-radius: 5px; }
.modal-back .quick a:hover { border-color: var(--accent); color: var(--accent); }
.modal-back .task-del { background: none; border: 0; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 2px; }
.modal-back .task-del:hover { color: var(--danger); }
