/* =====================================================================
   layout.css — one header/nav system (responsive + hamburger) and shared
   page-layout primitives. Consumes tokens.css. Loaded after base.css.
   ===================================================================== */

/* ── App header (rendered by js/shared/header.js) ─────────────── */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.appbar__left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.appbar__logo {
  font-size: 15px; font-weight: 800; letter-spacing: 3px;
  text-transform: uppercase; color: var(--primary); text-decoration: none; white-space: nowrap;
}
/* Logo lockup for the app bar, the landing nav and the login card: the
   speech-bubble mark (the favicon art) before the CRISIS wordmark. The mark is
   decorative, so the wordmark text stays the link's accessible name. */
.appbar__logo,
.site-logo,
.login-logo { display: inline-flex; align-items: center; gap: 8px; }
.appbar__logo::before,
.site-logo::before,
.login-logo::before {
  content: "";
  flex: none;
  width: 26px;
  height: 26px;
  background: url("/favicon.svg?v=3") center / contain no-repeat;
}
.appbar__sep { width: 1px; height: 24px; background: var(--border); flex: none; }
/* Breadcrumb: parent page link › page title (rendered by header.js). */
.appbar__crumb {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 4px 6px; margin: 0 -6px;
  border-radius: 6px;
  font-size: 13px; color: var(--text-muted); text-decoration: none; white-space: nowrap;
}
.appbar__crumb:hover { color: var(--text); background: var(--surface2); }
.appbar__crumb:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.appbar__crumb-icon { display: none; font-size: 20px; }
.appbar__crumb--solo .appbar__crumb-icon { display: inline-block; }
.appbar__crumb-sep { flex: none; margin: 0 -6px; font-size: 18px; color: var(--text-muted); }
.appbar__title {
  font-size: 14px; font-weight: 600; color: var(--text); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;   /* lets the ellipsis kick in before the right side is pushed off */
}
.appbar__right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.appbar__panel { display: flex; align-items: center; gap: 18px; }
.appbar__nav { display: flex; align-items: center; gap: 4px; }
.appbar__link {
  font-size: 13px; padding: 6px 12px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.appbar__link:hover { background: var(--surface2); color: var(--text); }
.appbar__link.is-active { background: var(--accent); color: #fff; }
.appbar__userbox { display: flex; align-items: center; gap: 12px; }
.appbar__burger {
  display: none;
  width: 42px; height: 42px; flex: none;
  align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer;
}
.appbar__burger:hover { background: var(--surface2); }
.appbar__burger .material-icons { font-size: 24px; line-height: 1; }

@media (max-width: 768px) {
  .appbar { padding: 0 16px; }
  .appbar__burger { display: inline-flex; }

  /* Nav + account menu collapse into a styled dropdown below the bar, with
     the account menu shown inline (no nested dropdown). Logo (left) and the
     hamburger (right) stay in the top row. */
  .appbar__panel {
    position: absolute;
    top: 100%; left: 0; right: 0;
    z-index: 90;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 16px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
  }
  .appbar--open .appbar__panel { display: flex; }
  .appbar__nav { flex-direction: column; align-items: stretch; gap: 2px; }
  .appbar__link { padding: 11px 12px; }
  .appbar__panel .appbar__sep { display: none; }
  .appbar__userbox {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .appbar__userbox:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
  /* The account menu shows inline in the panel (no nested dropdown). */
  .appbar__panel .account-menu__btn { display: none; }
  .appbar__panel .account-menu__panel {
    position: static;
    display: flex;
    min-width: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
  }
  .appbar__panel .account-menu__head { padding: 6px 12px 10px; }
  .appbar__panel .account-menu__item,
  .appbar__panel .account-menu__row { padding: 8px 12px; }
}

/* Phones: the breadcrumb's parent link collapses to a back-arrow button; its
   label stays as the link's accessible name. */
@media (max-width: 640px) {
  .appbar__crumb:not(.appbar__crumb--solo) {
    justify-content: center;
    width: 40px; height: 40px; padding: 0; margin: 0 -6px;
  }
  .appbar__crumb:not(.appbar__crumb--solo) .appbar__crumb-icon { display: inline-block; }
  .appbar__crumb:not(.appbar__crumb--solo) .appbar__crumb-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .appbar__crumb-sep { display: none; }
}

/* ── Account menu (js/shared/account-menu.js) ─────────────────
   The username opens a dropdown with the role, the dashboards, the theme
   toggle and sign-out. Used by the app header and the landing-page nav. */
.account-menu { position: relative; }
.account-menu__btn {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 34px; padding: 4px 6px 4px 12px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit; cursor: pointer;
}
.account-menu__btn:hover { background: var(--surface2); }
.account-menu__btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.account-menu__user { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.account-menu__caret { font-size: 20px; color: var(--text-muted); transition: transform 0.15s ease; }
.account-menu__btn[aria-expanded="true"] .account-menu__caret { transform: rotate(180deg); }
.account-menu__panel {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
}
.account-menu.is-open .account-menu__panel { display: flex; }
.account-menu__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px 10px;
}
.account-menu__name {
  font-size: 14px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-menu__group {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.account-menu__group[hidden] { display: none; }
.account-menu__item,
.account-menu__row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 38px; padding: 6px 10px;
  border: 0; border-radius: 8px; background: none;
  color: var(--text-muted); font: inherit; font-size: 13px;
  text-align: left; text-decoration: none; cursor: pointer;
}
/* The theme row is a <label> so the whole row toggles the switch; undo the
   global form-label look (uppercase, tracking, margin) from app.css. */
.account-menu__row { margin: 0; text-transform: none; letter-spacing: normal; }
.account-menu__item:hover,
.account-menu__row:hover { background: var(--surface2); color: var(--text); }
.account-menu__item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.account-menu__item .material-icons,
.account-menu__row .material-icons { font-size: 18px; }
.account-menu__label { flex: 1 1 auto; }
.account-menu__item[aria-current="page"] { color: var(--text); font-weight: 600; }
.account-menu__check { color: var(--accent); }
.account-menu__signout:hover { color: var(--danger); }
.account-menu__theme-slot { display: inline-flex; align-items: center; }
@media (max-width: 768px) {
  .account-menu__item,
  .account-menu__row { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .account-menu__caret { transition: none; }
}

/* ── Page containers ──────────────────────────────────────────── */
.container { max-width: 1000px; margin: 0 auto; padding: 40px 28px; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 48px 28px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 40px; }
.page-subtitle.compact { margin-bottom: 0; }

@media (max-width: 768px) {
  .container, .container-wide { padding: 24px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
