/*
 * App shell and auth layout.
 * From 760px: navy sidebar (240px). Below 760px: navy top bar and a tab bar at the bottom.
 */

/* --- logo (SVG, aspect ratio 4:1; full colour, also on navy) --------------------------- */
.sa-logo {
  display: block;
  width: auto;
  height: 32px;
}

.sa-topbar .sa-logo {
  height: 28px;
}


/* --- app shell ----------------------------------------------------------------------- */
.sa-shell {
  min-height: 100vh;
}

.sa-main {
  padding: var(--sa-space-6);
  max-width: 1200px;
}

.sa-page-header {
  display: grid;
  gap: var(--sa-space-1);
  margin-bottom: var(--sa-space-5);
}

.sa-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sa-sidebar-width);
  display: flex;
  flex-direction: column;
  gap: var(--sa-space-5);
  padding: var(--sa-space-5) 0;
  background: var(--sa-brand-primary);
  color: var(--sa-on-primary);
  overflow-y: auto;
}

.sa-sidebar__brand {
  padding: 0 var(--sa-space-5);
  text-decoration: none;
}

.sa-sidebar__nav {
  flex: 1;
}

.sa-nav {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--sa-space-1);
}

.sa-nav__link {
  display: flex;
  align-items: center;
  gap: var(--sa-space-3);
  min-height: var(--sa-control-height);
  padding: 0 var(--sa-space-5);
  border-left: 3px solid transparent;
  font: var(--sa-text-nav);
  color: var(--sa-on-primary);
  text-decoration: none;
  opacity: 0.85;
}

.sa-nav__link:hover {
  background: var(--sa-brand-primary-hover);
  opacity: 1;
}

.sa-nav__link[aria-current="page"] {
  border-left-color: var(--sa-brand-accent);
  background: var(--sa-brand-primary-hover);
  opacity: 1;
}

.sa-sidebar__account {
  display: grid;
  gap: var(--sa-space-2);
  padding: var(--sa-space-4) var(--sa-space-5) 0;
  border-top: 1px solid var(--sa-brand-primary-hover);
}

.sa-sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--sa-space-3);
  font: var(--sa-text-body-strong);
}

/* Top bar and tab bar exist only on small screens. */
.sa-topbar,
.sa-tabbar {
  display: none;
}

@media (min-width: 760px) {
  .sa-shell {
    padding-left: var(--sa-sidebar-width);
  }
}

@media (max-width: 759.98px) {
  .sa-sidebar {
    display: none;
  }

  .sa-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sa-space-3);
    min-height: var(--sa-topbar-height);
    padding: 0 var(--sa-space-4);
    padding-top: env(safe-area-inset-top);
    background: var(--sa-brand-primary);
    color: var(--sa-on-primary);
  }

  .sa-topbar__brand {
    text-decoration: none;
  }

  .sa-main {
    padding: var(--sa-space-5) var(--sa-space-4);
    /* Room for the tab bar, plus the iPhone home indicator. */
    padding-bottom: calc(var(--sa-tabbar-height) + var(--sa-space-5) + env(safe-area-inset-bottom));
  }

  .sa-tabbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    display: block;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--sa-color-surface);
    border-top: 1px solid var(--sa-color-line);
  }

  .sa-tabbar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
  }

  .sa-tabbar__list > li {
    flex: 1;
    min-width: 0;
  }

  .sa-tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--sa-tabbar-height);
    padding: var(--sa-space-1);
    border-top: 3px solid transparent;
    font: var(--sa-text-small);
    font-family: var(--sa-font-heading);
    font-weight: 500;
    color: var(--sa-ink-muted);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    list-style: none;
  }

  .sa-tabbar__link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sa-tabbar__link[aria-current="page"] {
    border-top-color: var(--sa-brand-accent);
    color: var(--sa-ink);
  }

  /* "More" opens upwards, above the tab bar. */
  .sa-menu--more > .sa-menu__panel {
    position: fixed;
    top: auto;
    right: var(--sa-space-2);
    bottom: calc(var(--sa-tabbar-height) + env(safe-area-inset-bottom) + var(--sa-space-2));
    left: var(--sa-space-2);
  }
}

/* --- menus (<details>), no JavaScript ----------------------------------------------- */
.sa-menu {
  position: relative;
}

.sa-menu > summary {
  list-style: none;
}

.sa-menu > summary::-webkit-details-marker {
  display: none;
}

.sa-menu__toggle {
  display: flex;
  align-items: center;
  gap: var(--sa-space-2);
  min-height: var(--sa-control-height);
  padding: 0 var(--sa-space-2);
  border-radius: var(--sa-radius-md);
  font: var(--sa-text-nav);
  cursor: pointer;
}

.sa-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--sa-space-1));
  z-index: 20;
  min-width: 220px;
  display: grid;
  gap: var(--sa-space-2);
  padding: var(--sa-space-3);
  border: 1px solid var(--sa-color-line);
  border-radius: var(--sa-radius-lg);
  background: var(--sa-color-surface);
  box-shadow: var(--sa-shadow-card);
  color: var(--sa-ink);
}

/* The panel sits on white: the navy focus ring applies again. */
.sa-menu__panel :focus-visible {
  outline-color: var(--sa-focus-ring);
}

.sa-menu__user {
  font: var(--sa-text-body-strong);
}

.sa-menu__list {
  list-style: none;
  padding: 0;
  display: grid;
}

.sa-menu__link {
  display: flex;
  align-items: center;
  gap: var(--sa-space-3);
  min-height: var(--sa-control-height);
  padding: 0 var(--sa-space-2);
  border-radius: var(--sa-radius-md);
  font: var(--sa-text-nav);
  color: var(--sa-ink);
  text-decoration: none;
}

.sa-menu__link[aria-current="page"] {
  background: var(--sa-color-surface-muted);
}

/* --- auth layout (login, 2FA, error) ------------------------------------------------ */
.sa-auth__layout {
  display: grid;
  grid-template-columns: 5fr 6fr;
  min-height: 100vh;
}

.sa-auth__panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--sa-space-6);
  padding: var(--sa-space-7);
  background: var(--sa-brand-primary);
  color: var(--sa-on-primary);
}

/* Large decorative {••}, cut off by the panel edge. */
.sa-auth__panel::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -100px;
  width: 520px;
  height: 410px;
  background: url("../brand/icon/syntall-icon-gold.svg") no-repeat center / contain;
  opacity: 0.07;
  pointer-events: none;
}

.sa-auth__logo .sa-logo {
  height: 48px;
}

.sa-auth__pitch {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--sa-space-4);
  max-width: 460px;
  margin-block: auto;
}

.sa-auth__eyebrow {
  font: var(--sa-text-eyebrow);
  letter-spacing: var(--sa-text-eyebrow-spacing);
  text-transform: uppercase;
  color: var(--sa-brand-accent);
}

.sa-auth__headline {
  font: var(--sa-text-hero);
  color: var(--sa-on-primary);
}

.sa-auth__lead {
  font: var(--sa-text-lead);
  color: var(--sa-on-primary-muted);
}

.sa-auth__footnote {
  position: relative;
  z-index: 1;
  font: var(--sa-text-small);
  color: var(--sa-color-slate-300);
}

.sa-auth__main {
  display: grid;
  place-items: center;
  padding: var(--sa-space-7) var(--sa-space-5);
  padding-bottom: calc(var(--sa-space-7) + env(safe-area-inset-bottom));
  background: var(--sa-color-surface-subtle);
}

.sa-auth__form {
  display: grid;
  gap: var(--sa-space-4);
  width: 100%;
  max-width: 380px;
}

.sa-auth__form h1 {
  font: var(--sa-text-auth-title);
}

.sa-auth__form .sa-button {
  width: 100%;
}

/* On the auth pages the primary button is gold with navy text; elsewhere it stays navy. */
.sa-auth .sa-button--primary {
  background: var(--sa-brand-accent);
  color: var(--sa-on-accent);
}

.sa-auth .sa-button--primary:hover {
  background: var(--sa-brand-accent-hover);
}

@media (max-width: 759.98px) {
  .sa-auth__layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sa-auth__panel {
    align-items: center;
    gap: var(--sa-space-4);
    padding: var(--sa-space-5) var(--sa-space-4);
    padding-top: calc(var(--sa-space-5) + env(safe-area-inset-top));
    text-align: center;
  }

  .sa-auth__panel::after,
  .sa-auth__lead,
  .sa-auth__footnote {
    display: none;
  }

  .sa-auth__logo .sa-logo {
    height: 36px;
  }

  .sa-auth__pitch {
    gap: var(--sa-space-2);
    margin-block: 0;
  }

  .sa-auth__headline {
    font: var(--sa-text-hero-mobile);
  }

  .sa-auth__main {
    place-items: start stretch;
    padding: var(--sa-space-5) var(--sa-space-4);
    padding-bottom: calc(var(--sa-space-5) + env(safe-area-inset-bottom));
  }

  .sa-auth__form {
    max-width: none;
  }
}
