/* Airy Flow header + slide-in drawer shared by the mobile Career Guides (/blog/) and Events & Live Sessions
   (/sessions/) pages. Same markup, tokens and status-bar handling as the program pages (<program>/header.css) and
   scripts/program-chrome.js drives it. Only header/drawer selectors live here so it can sit next to any page stylesheet;
   the page keeps its own body/typography tokens. */
:root {
  --af-bg: #f9fafb;
  --af-text: #0f1b2d;
  --af-sub: #647592;
  --af-chip: #eef2f9;
  --af-brand: #2563eb;
  --af-header-h: 64px;
  /* Status-bar height: native env() or the Flutter-injected var, max() (never a sum) so they can't stack */
  --msc-sai-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
}

/* Pages reserve the fixed header (+ status bar) once, here, so the page stylesheet needs no header knowledge. */
body.airy-page {
  padding-top: calc(var(--af-header-h) + var(--msc-sai-top));
}

/* ── Airy Flow app header ── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--af-header-h) + max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px)));
  background: var(--af-bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  padding-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-decoration: none;
}

.header-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

.header-greeting {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.header-greeting .greeting-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--af-sub);
  line-height: 1.4;
}

.header-greeting .greeting-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--af-text);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Header action icons ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.auth-buttons-container {
  display: flex;
  align-items: center;
}

.hdr-icon-btn,
.menu-button-style,
.auth-icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--af-text);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
  position: relative;
}

.hdr-icon-btn:hover,
.menu-button-style:hover,
.auth-icon-btn:hover {
  background: var(--af-chip);
}

.hdr-icon-btn:active,
.menu-button-style:active,
.auth-icon-btn:active {
  transform: scale(0.94);
}

.hdr-icon-btn svg,
.menu-button-style svg {
  width: 24px;
  height: 24px;
}

/* Account button keeps a soft brand tint so it reads as "you" */
.auth-icon-btn {
  background: #eaf1ff;
  color: var(--af-brand);
}

.auth-icon-btn:hover {
  background: #dbe7ff;
}

.auth-icon-btn i {
  font-size: 1.05rem;
}

/* ── Slide-in expanded menu (side menu) ── */
.expanded-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  z-index: 9999;
}

.expanded-menu-backdrop.active,
.expanded-menu.active ~ .expanded-menu-backdrop,
#expandedMenu.active ~ .expanded-menu-backdrop,
body:has(#expandedMenu.active) .expanded-menu-backdrop,
body:has(.expanded-menu.active) .expanded-menu-backdrop {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

[data-theme="dark"] .expanded-menu-backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.expanded-menu {
  position: fixed;
  /* drawer starts BELOW the status bar; header row inside needs only a normal gap */
  top: var(--msc-sai-top, 0px);
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  height: calc(100vh - var(--msc-sai-top, 0px));
  height: calc(100dvh - var(--msc-sai-top, 0px));
  background: var(--surface-bg, #ffffff);
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.22);
  z-index: 10000;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 24px 0 0 24px;
}

.expanded-menu.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header bar inside menu */
.expanded-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px 20px;
  border-bottom: 1px solid var(--line, var(--af-border, #f1f5f9));
  background: var(--surface-bg, #ffffff);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
}

.menu-brand-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--af-text, #0f172a);
  letter-spacing: -0.01em;
}

.menu-brand-icon {
  color: var(--af-brand, #2563eb);
}

.menu-close-btn {
  position: relative;
  top: auto;
  right: auto;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--af-chip, #f1f5f9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.15s;
}

.menu-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: scale(1.05);
}

.menu-items-container {
  display: flex;
  flex-direction: column;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 20px) 16px;
  gap: 6px;
  flex: 1;
}

.menu-item {
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--af-text, #1e293b);
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.18s, color 0.18s, transform 0.12s;
  text-decoration: none;
  gap: 10px;
}

.menu-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-item-icon {
  width: 18px;
  height: 18px;
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.18s, transform 0.18s;
}

.menu-item:hover {
  background: var(--af-chip, #f1f5f9);
  color: var(--af-brand, #2563eb);
}

.menu-item:hover .menu-item-icon {
  color: var(--af-brand, #2563eb);
  transform: scale(1.1);
}

.menu-item-dropdown {
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
}

.dropdown-icon {
  width: 16px;
  height: 16px;
  color: #94a3b8;
  transition: transform 0.22s ease, color 0.18s;
  flex-shrink: 0;
}

.dropdown-icon.open {
  transform: rotate(180deg);
  color: var(--af-brand, #2563eb);
}

.dropdown-content {
  display: none;
  flex-direction: column !important;
  margin: 4px 0 6px 20px;
  padding-left: 10px;
  border-left: 2px solid var(--line, #e2e8f0);
  gap: 4px;
  width: calc(100% - 20px) !important;
  box-sizing: border-box !important;
}

.dropdown-content.active,
.dropdown-content[style*="display: block"] {
  display: flex !important;
  flex-direction: column !important;
}

.dropdown-item {
  display: flex !important;
  align-items: center;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap !important;
  clear: both !important;
}

.dropdown-item:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--af-brand, #2563eb);
}

.menu-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line, var(--af-border, #f1f5f9));
}

.menu-item--danger {
  color: #ef4444 !important;
  background: #fef2f2 !important;
  border: 1px solid #fee2e2 !important;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
}

.menu-item--danger:hover {
  background: #fee2e2 !important;
}

/* ── Expanded-menu scrollbar ── */
.expanded-menu::-webkit-scrollbar {
  width: 6px;
}

.expanded-menu::-webkit-scrollbar-track {
  background: transparent;
}

.expanded-menu::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
  border-radius: 10px;
}

.expanded-menu {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root {
    --af-header-h: 58px;
  }

  .app-header {
    padding: 0 14px;
    padding-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  }

  .header-logo {
    height: 36px;
  }

  .header-greeting .greeting-name {
    font-size: 16px;
  }

  .hdr-icon-btn,
  .menu-button-style,
  .auth-icon-btn {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 380px) {
  .header-greeting .greeting-sub {
    font-size: 10px;
  }

  .header-greeting .greeting-name {
    font-size: 15px;
  }
}

/* Icon-only brand mark in headers (assets/logo-mark*.svg), same as the existing Airy Flow header. */
img.header-logo { height: 38px; width: auto; max-width: none; object-fit: contain; flex-shrink: 0; display: block; border-radius: 0; }
[data-theme="dark"] img.header-logo { content: url("/assets/logo-mark-dark.svg"); }
@media (max-width: 360px) { img.header-logo { height: 34px; } }

/* ── Dark theme for the Airy Flow header + drawer (app-wide [data-theme] switch, key 'msc-theme') ── */
:root[data-theme="dark"] {
  --af-bg: #0b1020;
  --af-text: #e8eefb;
  --af-sub: #8d9ab6;
  --af-chip: #1a2338;
  --af-brand: #7db0ff;
  --af-border: #27324a;
  --line: #27324a;
  --surface-bg: #111a2e;
}
:root[data-theme="dark"] .auth-icon-btn { background: #17223a; color: #7db0ff; }
:root[data-theme="dark"] .auth-icon-btn:hover { background: #1f2d4d; }
:root[data-theme="dark"] .menu-close-btn { background: #1a2338; color: #c3cde2; }
:root[data-theme="dark"] .menu-close-btn:hover { background: #3a1a1e; color: #f87171; }
:root[data-theme="dark"] .menu-item-icon { color: #8d9ab6; }
:root[data-theme="dark"] .menu-item:hover { background: #1a2338; color: #7db0ff; }
:root[data-theme="dark"] .menu-item.active,
:root[data-theme="dark"] .expanded-menu .menu-item.active { background: #17223a !important; color: #7db0ff !important; }
:root[data-theme="dark"] .expanded-menu .menu-item.active:hover { background: #1c2a49 !important; }
:root[data-theme="dark"] .dropdown-item { color: #aab6cf; }
:root[data-theme="dark"] .dropdown-item:hover { background: rgba(125, 176, 255, 0.12); color: #7db0ff; }
:root[data-theme="dark"] .menu-item--danger { background: #2a1417 !important; border-color: #4a1f24 !important; color: #f87171 !important; }
:root[data-theme="dark"] .expanded-menu { box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6); }
:root[data-theme="dark"] .expanded-menu-header { background: var(--surface-bg); border-bottom-color: #27324a; }
:root[data-theme="dark"] .expanded-menu-header .menu-brand-title { color: #e8eefb; }
:root[data-theme="dark"] .menu-footer { border-top-color: #27324a; }

/* Theme toggle: sun in light mode, moon in dark mode */
#themeToggleBtn .icon-moon { display: none; }
[data-theme="dark"] #themeToggleBtn .icon-sun { display: none; }
[data-theme="dark"] #themeToggleBtn .icon-moon { display: block; }

:root[data-theme="dark"] .expanded-menu { background: #111a2e !important; }

.app-header { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }

/* Very narrow phones (320px): keep logo + greeting + 3 icon buttons on one row */
@media (max-width: 340px) {
  .app-header { padding-left: max(10px, env(safe-area-inset-left, 0px)); padding-right: max(10px, env(safe-area-inset-right, 0px)); gap: 6px; }
  .header-left { gap: 8px; }
  .header-actions { gap: 0; }
  .header-greeting .greeting-name { font-size: 14px; }
}

/* Current page inside the Free Resources list (same look as portal-style.css) */
.expanded-menu .dropdown-item.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--af-brand, #2563eb);
  font-weight: 600;
}
:root[data-theme="dark"] .expanded-menu .dropdown-item.active {
  background: rgba(125, 176, 255, 0.14);
  color: #7db0ff;
}
