/* SERA portal shell — ColorStack-inspired sidebar layout
   Brand blues preserved. Public Explore tabs + member-only Member tabs. */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-deep: #1e3a8a;
  --brand-light: #eff6ff;
  --brand-mid: #bfdbfe;
  --ink: #0f172a;
  --ink2: #1e293b;
  --muted: #64748b;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --white: #ffffff;
  --sidebar-w: 240px;
  --radius: 16px;
  --radius-sm: 10px;
  --page-bg: #f8fafc;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.portal-app {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  line-height: 1.5;
  overflow-x: hidden;
  margin: 0;
}

body.portal-app a { color: inherit; }
body.portal-app a:focus-visible,
body.portal-app button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
  position: fixed; left: 1rem; top: 1rem; z-index: 1000;
  background: var(--brand); color: #fff; padding: 0.75rem 1rem;
  border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
}

/* Hide legacy top nav when portal shell is active */
body.portal-app > nav,
body.portal-app .nav-backdrop,
body.portal-app .nav-mobile,
body.portal-app .topnav,
body.portal-app > footer,
.portal > nav,
.portal > .nav-backdrop,
.portal > .nav-mobile,
.portal > .topnav,
.portal > footer:not(.page-footer) {
  display: none !important;
}

.portal { min-height: 100vh; }

/* Hard overrides so legacy page `nav { position:fixed; top:0; … }` rules
   cannot turn the portal rail into a jumping top bar between tabs. */
.sidebar,
aside.sidebar,
#sidebar {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  right: auto !important;
  bottom: auto !important;
  width: var(--sidebar-w) !important;
  height: 100vh !important;
  max-width: var(--sidebar-w);
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1.5rem !important;
  margin: 0 !important;
  border: none !important;
  border-right: 1px solid var(--gray-200) !important;
  background: var(--white) !important;
  backdrop-filter: none !important;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 40 !important;
  transform: none !important;
}

.sidebar-nav,
.sidebar .sidebar-nav {
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  width: 100% !important;
  height: auto !important;
  flex: 1;
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  backdrop-filter: none !important;
}

.sidebar-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.35rem; padding: 0 0.35rem;
}

.sidebar-logo {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em;
  text-decoration: none; color: var(--ink);
}
.sidebar-logo-img {
  width: 28px; height: 28px; object-fit: contain; border-radius: 6px;
}

.nav-section-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 0.85rem 0.5rem 0.35rem;
}

.sidebar-nav { width: 100%; flex: 1; }
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 0.2rem; margin: 0; padding: 0; }

.nav-member-block {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--gray-100);
}

.nav-item {
  display: flex; align-items: center; gap: 0.55rem;
  width: 100%; padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink2);
  font-size: 0.92rem; font-weight: 500;
  border: none; background: none; cursor: pointer;
  font-family: inherit; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(37, 99, 235, 0.08); color: var(--brand); }
.nav-item.is-active,
.nav-item[aria-current="page"] {
  background: var(--brand); color: #fff;
}
.nav-item.is-active:hover,
.nav-item[aria-current="page"]:hover { color: #fff; background: var(--brand-dark); }
.nav-item-danger:hover { background: #fef2f2; color: #dc2626; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 0.65rem; padding-top: 0.75rem; }
.sidebar-cta { width: 100%; text-align: center; justify-content: center; }

.sidebar-user-chip {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.35rem 0.25rem;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.sidebar-user-name { font-size: 0.9rem; font-weight: 600; }
.sidebar-user-link { font-size: 0.75rem; color: var(--brand); text-decoration: none; }
.sidebar-user-link:hover { text-decoration: underline; }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35);
  z-index: 30;
}

.page,
.portal > .page,
#main-content.page,
section.page#main-content,
body.portal-app .page,
body.portal-app #main-content.page,
body.portal-app section.page#main-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem 1.75rem 3.5rem;
  margin-left: var(--sidebar-w) !important;
  margin-right: 0 !important;
  max-width: none;
  background: var(--page-bg);
  box-sizing: border-box;
}

.page-bar {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: 2rem;
}
.page-eyebrow {
  font-size: 0.8rem; font-weight: 600; color: var(--brand);
}
.page-title {
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.2; color: var(--ink);
  margin: 0;
}
.page-sub {
  color: var(--muted); max-width: 40rem; margin: 0;
  font-size: 1rem;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 0.35rem;
}
.home-col { display: flex; flex-direction: column; gap: 1rem; }

.card {
  display: flex; flex-direction: column; gap: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.15rem;
  background: var(--white);
}
.card-title {
  font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 0;
}
.card-desc { color: var(--muted); font-size: 0.95rem; margin: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; margin-top: 0.25rem; }

.card-stat .stat-value {
  font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
  color: var(--ink); margin: 0;
}
.stat-value-sm { font-size: 1.5rem !important; }
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}

.help-list, .resource-list, .opp-list, .steps, .team-list, .social-row {
  list-style: none; display: flex; flex-direction: column; gap: 0.75rem;
  margin: 0; padding: 0;
}
.help-list li { font-size: 0.92rem; color: var(--ink2); }
.help-list strong { color: var(--ink); }

.resource-list p { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }

.opp-list li {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding-bottom: 0.75rem; border-bottom: 1px solid var(--gray-100);
}
.opp-list li:last-child { border-bottom: none; padding-bottom: 0; }
.opp-link { font-weight: 600; text-decoration: none; color: var(--ink); }
.opp-link:hover { color: var(--brand); }
.meta { font-size: 0.8rem; color: var(--muted); }

.pill {
  display: inline-block; align-self: flex-start;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--brand-dark);
  background: var(--brand-light); padding: 0.15rem 0.45rem; border-radius: 4px;
}

.steps li { display: flex; gap: 0.75rem; align-items: flex-start; }
.steps span {
  font-size: 1.1rem; font-weight: 700; color: var(--brand); min-width: 1.75rem;
}
.steps strong { display: block; font-size: 0.95rem; }
.steps p { font-size: 0.85rem; color: var(--muted); margin: 0.15rem 0 0; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.team-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.15rem;
  background: var(--white);
  display: flex; flex-direction: column; gap: 0.65rem; align-items: flex-start;
}
.team-card img {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--brand-mid);
}
.team-card h2 { font-size: 1.05rem; margin: 0; }
.team-card .role { color: var(--brand); font-weight: 600; font-size: 0.85rem; }
.team-card p { color: var(--muted); font-size: 0.9rem; margin: 0; }

.social-row { flex-direction: row; gap: 1rem; }
.social-row a { color: var(--brand); display: flex; }
.social-row a:hover { color: var(--brand-dark); }

.link {
  color: var(--brand); font-weight: 600; text-decoration: underline;
  text-underline-offset: 2px; font-size: 0.95rem;
}
.link:hover { color: var(--brand-dark); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff !important;
  padding: 0.65rem 1.15rem; min-height: 42px;
  border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn-primary:hover { background: var(--brand-dark); }

.btn-ghost {
  display: inline-flex; align-items: center;
  color: var(--ink2); font-size: 0.9rem; font-weight: 600;
  text-decoration: none; padding: 0.5rem 0.25rem;
}
.btn-ghost:hover { color: var(--brand); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: none; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--gray-100); }

.page-footer {
  margin-top: 1.5rem; padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  justify-content: space-between;
  font-size: 0.8rem; color: var(--muted);
}
.page-footer a { color: var(--muted); text-decoration: none; }
.page-footer a:hover { color: var(--brand); }

/* Interior page content inside portal: drop fixed-nav offset */
body.portal-app .hub-hero,
body.portal-app .page > .hub-hero {
  margin-top: 0;
  padding-top: 0.25rem;
}
body.portal-app main#main-content.page,
body.portal-app #main-content.page {
  margin-top: 0;
}
body.portal-app .dash-auth-screen {
  margin-top: 0 !important;
  min-height: 60vh;
}
body.portal-app .dash-wrap {
  margin-top: 0;
  padding: 0.5rem 0 2rem;
  max-width: none;
}
body.portal-app .profile-head {
  max-width: none;
  margin: 0;
  padding: 0.25rem 0 1rem;
}
body.portal-app .webinar-detail {
  max-width: none;
  margin: 0;
  padding: 0.25rem 0 2rem;
}
body.portal-app .profile-hero-card,
body.portal-app .profile-sections {
  max-width: none;
}

.md-only-show { display: none; }
.md-only-hide { display: none; }

@media (min-width: 900px) {
  .home-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1200px) {
  .home-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar,
  aside.sidebar,
  #sidebar {
    display: none !important;
    width: calc(100% - 3.5rem) !important;
    max-width: 300px !important;
    z-index: 50 !important;
  }
  .portal.sidebar-open .sidebar,
  .portal.sidebar-open aside.sidebar,
  .portal.sidebar-open #sidebar {
    display: flex !important;
  }
  .portal.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-backdrop[hidden] { display: none; }
  .md-only-show { display: inline-flex; }
  .md-only-hide { display: inline-flex; }
  .page,
  .portal > .page,
  #main-content.page,
  section.page#main-content,
  body.portal-app .page,
  body.portal-app #main-content.page,
  body.portal-app section.page#main-content {
    margin-left: 0 !important;
    padding: 1rem 1rem 3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .nav-item, .btn-primary { transition: none; }
}
