/*
  The shell: a rail on iPad and wider (from md, 768px), a bottom tab bar on the phone, a sticky 56px top bar and the
  page column. Rail and tab bar are drawn from one list (Layout/NavMenu.cs). Ported from CampaignManager.
*/
@layer shell {
  .en-shell { min-height: 100dvh; }

  .en-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100dvh;
    padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  }

  @media (width >= 48rem) {
    .en-main {
      margin-left: var(--rail-width);
      padding-bottom: 0;
    }
  }

  /* ── Rail ── icon with an always visible 11px label, as in iPadOS: there is no hover on a tablet. */
  .en-rail {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--rail-width);
    flex-direction: column;
    background: var(--primary-50);
    border-right: 1px solid var(--border);
  }

  @media (width >= 48rem) {
    .en-rail { display: flex; }
  }

  .en-rail-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
  }

  .en-rail-logo img { width: 34px; height: 34px; }

  .en-rail-nav {
    flex: 1;
    min-height: 0;
    padding: 6px 4px;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .en-rail-footer {
    flex-shrink: 0;
    padding: 6px 4px;
    border-top: 1px solid var(--border);
  }

  .en-rail-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 4px 2px;
    margin-bottom: 2px;
    text-align: center;
    white-space: nowrap;
    text-decoration: none;
    color: var(--primary-500);
    border-radius: 0.5rem;
    transition: background-color 120ms ease, color 120ms ease;
  }

  button.en-rail-item {
    width: 100%;
    background: none;
    border: none;
  }

  .en-rail-item:hover { background: var(--primary-100); color: var(--primary-800); }
  .en-rail-item.active { background: var(--accent-50); color: var(--accent-700); }
  .en-rail-item i { font-size: 18px; }

  .en-rail-label {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.15;
  }

  .en-rail-item.active .en-rail-label { font-weight: 600; }

  /* Count on the shoulder of an icon (cards due). */
  .en-nav-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: var(--white);
    background: var(--accent-600);
    border: 1px solid var(--primary-50);
    border-radius: 99px;
  }

  /* ── Phone tab bar ── */
  .en-tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    display: flex;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--primary-50);
    border-top: 1px solid var(--border);
  }

  @media (width >= 48rem) {
    .en-tabbar { display: none; }
  }

  .en-tabbar-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 4px 2px;
    font-size: 11px;
    color: var(--primary-500);
    text-decoration: none;
  }

  .en-tabbar-item i { font-size: 1.15rem; }
  .en-tabbar-item.active { color: var(--accent-600); font-weight: 600; }
  .en-tabbar-item .en-nav-badge { top: 2px; }

  /* ── Top bar ── 56px, sticky. Title on one line with an ellipsis; actions on the right, icon-only on phones. */
  .en-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    height: var(--topbar-height);
    padding: 0 12px;
    background: var(--page);
    border-bottom: 1px solid var(--border);
  }

  @media (width >= 40rem) {
    .en-topbar { padding: 0 20px; }
  }

  .en-topbar-back { flex-shrink: 0; }
  .en-topbar-heading { flex: 1; min-width: 0; }

  .en-topbar-title {
    overflow: hidden;
    font-size: 1rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .en-topbar-title:focus { outline: none; }

  .en-topbar-subtitle {
    overflow: hidden;
    font-size: 0.8125rem;
    line-height: 1.2;
    color: var(--primary-600);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .en-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* Phone: a top-bar button with an icon becomes a square; its label stays for screen readers. */
  @media (width < 48rem) {
    .en-topbar-actions .en-btn:has(> i) {
      width: var(--tap-sm);
      padding: 0;
      gap: 0;
    }

    .en-topbar-actions .en-btn:has(> i) > span {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }

  /* The page column below the top bar. A container, so layouts follow the column width, not the window. */
  .en-page {
    container: page / inline-size;
    width: 100%;
    max-width: 72rem;
    padding: 1rem 0.75rem 1.5rem;
  }

  @media (width >= 40rem) {
    .en-page { padding: 1.25rem 1.25rem 2rem; }
  }

  /* A page that reads better narrow: forms, the review card. */
  .en-page-narrow {
    max-width: 46rem;
    margin-inline: auto;
  }

  /* Pages without the shell (sign-in). */
  .en-bare {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 1rem;
  }
}
