/* Everborn 4-surface shell (Today · People · Calendar · Settings).
   A nav/routing layer over the existing panels — see surface-shell.js.
   Retires the old flat 12-item tab rail (desktop) and the old 5-slot bottom nav
   (nav-shell.js) whenever body.eb-surfaces is set, and provides the new rail,
   bottom nav, and per-surface sub-switcher. Everborn tokens from styles.css. */

/* ── Retire the old flat navs (they still EXIST, hidden, for proxy-clicking) ── */
body.eb-surfaces nav.tabs { display: none !important; }
body.eb-surfaces .eb-bottomnav,
body.eb-surfaces .eb-bn-more-sheet,
body.eb-surfaces .eb-more-backdrop { display: none !important; }

/* Hidden panels stay hidden; the real .tab buttons are visually gone but present. */
body.eb-surfaces main .import-toolbar { }  /* imports UI is portaled into Settings */

/* Default-hide the new chrome; the media queries below turn on the right one. */
.eb-rail, .eb-surfnav, .eb-more-sheet2, .eb-more-backdrop2 { display: none; }
.eb-subbar[hidden] { display: none !important; }

/* ── Per-surface sub-switcher (both desktop + mobile) ─────────────────────── */
.eb-subbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 0 14px; padding: 0;
}
.eb-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--eb-off, #F5F5F0); border: 1px solid var(--eb-stone, #DEDFD8);
  border-radius: 999px;
}
.eb-seg-item {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 15px; border-radius: 999px;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--eb-slate, #6E7268);
  white-space: nowrap; font-family: inherit;
}
.eb-seg-item:hover { color: var(--eb-ink, #16211B); }
.eb-seg-item.on {
  background: var(--brand-primary, #1E6B4A); color: var(--brand-on-primary, #fff);
  font-weight: 600; box-shadow: 0 1px 2px rgba(15,51,39,.18);
}
.eb-subactions { display: inline-flex; gap: 8px; }
.eb-subbtn {
  border: 1px solid var(--brand-primary, #1E6B4A); background: #fff;
  color: var(--brand-primary, #1E6B4A); cursor: pointer;
  padding: 7px 14px; border-radius: 999px; font: inherit; font-weight: 600;
  white-space: nowrap; font-family: inherit;
}
.eb-subbtn:hover { background: rgba(30,107,74,.06); }
.eb-subbtn.on {
  background: var(--brand-primary, #1E6B4A); color: var(--brand-on-primary, #fff);
}

/* ── Desktop (≥761px): a 4-item left rail; sub-switcher sits atop <main> ───── */
@media (min-width: 761px) {
  body.eb-surfaces .eb-rail {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: var(--eb-topbar-h, 60px); left: 0; bottom: 0;
    width: 186px; z-index: 18;
    /* Dark rail derived from the tenant brand: on the Everborn default this is the
       historical deep evergreen; on other tenants it becomes their brand-dark. */
    background: linear-gradient(180deg, var(--brand-surface), var(--brand-surface-2));
    border-right: 1px solid rgba(0,0,0,.12);
    padding: 16px 12px; overflow-y: auto;
  }
  body.eb-surfaces .eb-rail-item {
    display: flex; align-items: center; gap: 11px;
    text-align: left; border: 0; border-radius: 10px; background: transparent;
    /* Light tint of the brand for idle text (legible on the dark brand surface). */
    color: color-mix(in srgb, var(--brand-primary), #fff 72%);
    padding: 11px 12px; font: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer; font-family: inherit; border-left: 2px solid transparent;
  }
  body.eb-surfaces .eb-rail-item .ic { font-size: 15px; width: 18px; text-align: center; }
  body.eb-surfaces .eb-rail-item:hover {
    background: color-mix(in srgb, var(--brand-accent), transparent 90%);
    color: color-mix(in srgb, var(--brand-accent), #fff 62%);
  }
  body.eb-surfaces .eb-rail-item.on {
    background: color-mix(in srgb, var(--brand-accent), transparent 84%);
    color: color-mix(in srgb, var(--brand-accent), #fff 62%); font-weight: 600;
    border-left: 2px solid var(--brand-accent, #D4A62A);
  }
  body.eb-surfaces main { margin-left: 186px; }
}

/* ── Mobile (≤760px): a 4-item bottom nav + More overflow ─────────────────── */
@media (max-width: 760px) {
  body.eb-surfaces main { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  body.eb-surfaces .eb-surfnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--eb-stone, #DEDFD8);
    justify-content: space-around; align-items: stretch;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(16,33,27,.06);
  }
  body.eb-surfaces .eb-surfnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font: inherit; font-size: 10px; font-weight: 500; color: var(--eb-slate, #6E7268);
    cursor: pointer; background: none; border: 0; padding: 3px 0; font-family: inherit;
  }
  body.eb-surfaces .eb-surfnav-item[hidden] { display: none; }
  body.eb-surfaces .eb-surfnav-item .ic { font-size: 16px; line-height: 1; }
  body.eb-surfaces .eb-surfnav-item.on { color: var(--eb-green, #1E6B4A); font-weight: 600; }

  body.eb-surfaces .eb-more-backdrop2.on {
    display: block; position: fixed; inset: 0; z-index: 41; background: rgba(16,33,27,.25);
  }
  body.eb-surfaces .eb-more-sheet2.on {
    display: block; position: fixed; left: 0; right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 42;
    background: #fff; border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(16,33,27,.16);
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    max-height: 60vh; overflow-y: auto;
  }
  body.eb-surfaces .eb-more-item2 {
    display: block; width: 100%; text-align: left; font: inherit; font-size: 14px;
    padding: 12px 10px; border: 0; border-bottom: 1px solid var(--eb-off, #F5F5F0);
    background: none; color: var(--eb-ink, #16211B); font-family: inherit; cursor: pointer;
  }
  body.eb-surfaces .eb-more-item2:last-child { border-bottom: 0; }

  /* Sub-switcher scrolls horizontally on narrow screens (compact, no wrap sprawl). */
  body.eb-surfaces .eb-subbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-bottom: 12px; padding-bottom: 2px;
  }
  body.eb-surfaces .eb-seg { flex: 0 0 auto; }
  body.eb-surfaces .eb-subactions { flex: 0 0 auto; }
}
