/* Signed-in app shell: sidebar (drawer on phones), top bar, content area and the member tab bar.
   Loaded after marketing.css, so it may refine shared pieces such as buttons inside the shell. */
.app-body { min-height: 100vh; background: var(--canvas); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: var(--space-10) var(--space-16);
  font-weight: 600;
  color: var(--white);
  background: var(--ink);
  border-radius: var(--radius-sm);
}

.skip-link:focus { top: 12px; color: var(--white); }

/* ---------- Icons and icon buttons ---------- */
.icon { flex: none; display: block; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.icon-btn:hover { color: var(--ink); background: var(--lilac); }

/* ---------- Avatars ---------- */
.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--purple-deep);
  background: var(--lilac);
  border-radius: 50%;
}

.avatar--xs { width: 26px; height: 26px; font-size: var(--text-2xs); }
.avatar--sm { width: 34px; height: 34px; font-size: var(--text-sm); }
.avatar--lg { width: 52px; height: 52px; font-size: var(--text-2xl); }
.avatar--square { border-radius: var(--radius-sm); color: var(--white); background: var(--purple); }
.avatar--purple { color: var(--white); background: var(--purple); }
.avatar--yellow { color: var(--ink); background: var(--yellow); }
.avatar--ink { color: var(--white); background: var(--ink); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(86vw, var(--sidebar-width));
  background: var(--white);
  border-right: 1px solid var(--line-fine);
  transform: translateX(-100%);
  transition: transform var(--duration-base) ease;
  visibility: hidden;
}

.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-drawer); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgb(var(--ink-rgb) / .36);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) ease;
}

.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
.sidebar-open { overflow: hidden; }

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  min-height: 68px;
  padding: var(--space-12) var(--space-12) var(--space-12) var(--space-20);
}

.sidebar__home .logo__wordmark { font-size: var(--text-3xl); }

.sidebar__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
  min-height: 0;
  padding: var(--space-4) var(--space-12) var(--space-20);
  overflow-y: auto;
}

.sidebar__cta { gap: var(--space-8); margin: 0 var(--space-4); }
.sidebar__section { display: flex; flex-direction: column; gap: var(--space-2); }

.sidebar__heading {
  padding: var(--space-4) var(--space-12) var(--space-6);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--status-inactive);
}

.sidebar__form,
.sidebar__signout { display: block; margin: 0; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  width: 100%;
  min-height: 44px;
  padding: var(--space-8) var(--space-12);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.sidebar__link .icon { color: var(--text-muted); }
.sidebar__link:hover { color: var(--ink); background: var(--canvas); }
.sidebar__link:hover .icon { color: var(--ink); }
.sidebar__link--current,
.sidebar__link--current:hover { font-weight: 600; color: var(--purple-deep); background: var(--lilac); }
.sidebar__link--current .icon,
.sidebar__link--current:hover .icon { color: var(--purple); }
.sidebar__link--quiet { color: var(--text-muted); }
.sidebar__link--person { gap: var(--space-10); }

.sidebar__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar__badge {
  flex: none;
  min-width: 22px;
  padding: 1px var(--space-6);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  color: var(--status-soon-text);
  background: var(--status-soon);
  border-radius: var(--radius-pill);
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-12);
  border-top: 1px solid var(--line-fine);
}

.sidebar__user { display: flex; align-items: center; gap: var(--space-10); padding: var(--space-6) var(--space-12); min-width: 0; }
.sidebar__user-text { display: flex; flex-direction: column; min-width: 0; }

.sidebar__user-name,
.sidebar__user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar__user-name { font-size: var(--text-md); font-weight: 600; color: var(--ink); }
.sidebar__user-email { font-size: var(--text-xs); color: var(--text-muted); }

/* Club (or admin) identity at the top of the sidebar. */
.club-switch {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-10) var(--space-8) var(--space-10) var(--space-12);
  background: var(--canvas);
  border: 1px solid var(--line-fine);
  border-radius: var(--radius-md);
}

.club-switch__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.club-switch__name { font-size: var(--text-base); font-weight: 600; line-height: var(--leading-snug); color: var(--ink); overflow-wrap: anywhere; }
.club-switch__role { font-size: var(--text-sm); color: var(--text-muted); }
.club-switch__change { width: 36px; height: 36px; color: var(--text-muted); }
.club-switch--admin .avatar { background: var(--ink); }

/* ---------- Top bar (phones and tablets) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: 60px;
  padding: var(--space-8) var(--space-12) var(--space-8) var(--space-6);
  background: rgb(var(--paper-rgb) / .92);
  border-bottom: 1px solid var(--line-fine);
  backdrop-filter: blur(10px);
}

.topbar__home .logo__wordmark { font-size: var(--text-3xl); }
.topbar__spacer { flex: 1; }

/* ---------- Content ---------- */
.shell { min-width: 0; }

.shell__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-24);
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-20) var(--space-16) var(--space-48);
}

.app-body--tabbar .shell__main { padding-bottom: calc(var(--tabbar-height) + var(--space-40) + env(safe-area-inset-bottom)); }

/* Flash messages inside the shell read as toasts at the top of the page. */
.shell__main .flash {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-12) var(--space-16);
  font-size: var(--text-base);
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-notification);
}

.shell__main .flash::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.shell__main .flash--notice { color: var(--success-text); background: var(--success-bg); }
.shell__main .flash--alert { color: var(--error-text); background: var(--error-bg); }

/* ---------- Bottom tab bar (member side, phones; US-2.19) ---------- */
/* Five labelled tabs on white; the current one in purple on a lilac pill, the OktoKard raised in the middle. */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  min-height: var(--tabbar-height);
  padding: var(--space-4) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom));
  background: rgb(var(--white-rgb) / .97);
  border-top: var(--border-hairline) solid var(--line-fine);
  backdrop-filter: blur(10px);
}

.tabbar__slot { display: contents; }

.tabbar__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tabbar__icon { display: grid; place-items: center; width: 52px; height: 28px; border-radius: var(--radius-pill); transition: background-color var(--duration-fast) ease; }
.tabbar__link:hover { color: var(--ink); }
.tabbar__link:active .tabbar__icon { background: var(--lilac-glow); }
.tabbar__link--current,
.tabbar__link--current:hover { font-weight: 700; color: var(--purple-deep); }
.tabbar__link--current .tabbar__icon { background: var(--lilac); }

/* The OktoKard tab: a small card that sits above the bar. */
.tabbar__card { font-weight: 600; color: var(--ink); }

.tabbar__card-mark {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 50px;
  height: 34px;
  margin-top: calc(-1 * var(--space-16));
  padding: var(--space-6) 7px;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  border-radius: 9px;
  box-shadow: 0 0 0 4px var(--white), 0 8px 18px rgb(var(--purple-rgb) / .35);
  transition: transform var(--duration-fast) ease;
}

.tabbar__card:active .tabbar__card-mark { transform: scale(.94); }
.tabbar__card-chip { width: 11px; height: 8px; background: var(--yellow); border-radius: 2px; }
.tabbar__card-line { width: 22px; height: 3px; background: rgb(var(--white-rgb) / .7); border-radius: 2px; }

/* The bar's sheets slide up from the bottom on phones; they reuse the card modal (member.css), which loads later,
   so the sheet rules name both classes to win over its width. */
@media (max-width: 1023px) {
  .card-dialog.sheet {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--space-48));
    margin: auto 0 0;
  }

  .card-dialog.sheet .sheet__panel { padding-bottom: calc(var(--space-24) + env(safe-area-inset-bottom)); border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
  .card-dialog.sheet[open] { animation: sheet-up var(--duration-base) var(--ease-out); }
}

@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }

.sheet__card .member-card-wrap { max-width: none; }
.sheet__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-8); }

.sheet__chip {
  min-height: 40px;
  padding: 0 var(--space-16);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  background: var(--white);
  border: var(--border-hairline) solid var(--line-lilac);
  border-radius: var(--radius-pill);
}

.sheet__chip[aria-selected="true"] { color: var(--white); background: var(--ink); border-color: var(--ink); }
.sheet__people { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.sheet__people li + li { border-top: var(--border-hairline) solid var(--line-fine); }
.sheet__person { display: flex; align-items: center; gap: var(--space-14); min-height: 64px; color: var(--ink); text-decoration: none; }
.sheet__person:hover { color: var(--ink); }
.sheet__person > .icon { flex: none; color: var(--status-inactive); }
.sheet__avatar { flex: none; width: 44px; height: 44px; }
.sheet__person-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sheet__person-name { font-weight: 600; overflow-wrap: anywhere; }
.sheet__person-meta, .sheet__loading { margin: 0; font-size: var(--text-md); color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  .card-dialog.sheet[open], .tabbar__card-mark, .tabbar__icon { animation: none; transition: none; }
}

/* ---------- Wide screens: the sidebar is part of the page ---------- */
@media (min-width: 1024px) {
  .sidebar { transform: none; visibility: visible; transition: none; }
  .sidebar__close,
  .sidebar-backdrop,
  .topbar,
  .tabbar { display: none; }
  .sidebar-open { overflow: auto; }
  .sidebar-open .sidebar { box-shadow: none; }
  .shell { margin-left: var(--sidebar-width); }
  .shell__main,
  .app-body--tabbar .shell__main { gap: var(--space-28); padding: var(--space-40) var(--space-40) var(--space-64); }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .shell__main { padding: var(--space-28) var(--space-28) var(--space-56); }
}
