/* =========================
   NAVBAR.CSS — ICS Platform
   Top navigation bar, profile menu, options menu, level badge.
   Aligned with ichebo.online editorial design language.
========================= */

/* ─── NAVBAR ─────────────────────────────────────────────── */

.navbar {
  height: calc(56px + env(safe-area-inset-top, 0px));
  background: var(--bg-alpha);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

@media (min-width: 800px) {
  .navbar {
    max-width: 800px;
    margin: 0 auto;
    border-bottom-left-radius: var(--radius-l);
    border-bottom-right-radius: var(--radius-l);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* Logo colour responds to theme — white SVG inverted to black on light navbar */
.nav-logo {
  filter: brightness(0) invert(1);
  transition: filter var(--transition-fast, 0.15s);
}

html:not(.dark) .nav-logo {
  filter: brightness(0);
}

/* ─── LOGO ────────────────────────────────────────────────── */

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-link {
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* SVG logo mark — fills with currentColor so it respects dark/light */
.logo-svg {
  height: 22px;
  width: auto;
  flex-shrink: 0;
  /* Default: use --text colour */
  fill: var(--text);
  transition: fill var(--transition-fast);
}

/* Override fill-rule polygon and paths to use currentColor */
.logo-svg .logo-fill {
  fill: var(--text);
}

/* In dark mode the logo stays readable */
html.dark .logo-svg {
  fill: #f5f3f0;
}

/* Wordmark text alongside the SVG mark (optional — show on desktop) */
.logo-wordmark {
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
  line-height: 1;
  display: none;  /* hidden on mobile — logo mark is enough */
}

@media (min-width: 800px) {
  .logo-wordmark { display: block; }
}

/* ─── NAV RIGHT ───────────────────────────────────────────── */

.nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-title {
  font-size: var(--fz-0);
  font-weight: 700;
  color: var(--text);
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.nav-left .btn-touch {
  color: var(--text);
  padding: 0 12px;
  min-height: 44px;
}

.nav-right-item {
  position: relative;
}

/* ─── ICON BUTTON ────────────────────────────────────────── */

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast);
}

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

/* ─── LEVEL BADGE ────────────────────────────────────────── */

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.level-badge:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Level colours — aligned with var(--level-N) tokens in variables.css */
.level-grey   { background: var(--level-0); }
.level-green  { background: var(--level-1); }
.level-blue   { background: var(--level-2); }
.level-purple { background: var(--level-3); }
.level-orange { background: var(--level-4); }
.level-red    { background: var(--level-5); }

/* ─── NOTIFICATION BADGE ──────────────────────────────────── */

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

/* ─── PROFILE DROPDOWN ────────────────────────────────────── */

.profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.profile-avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  overflow: hidden;
  background: var(--hover);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast);
}

.profile-avatar-btn:hover { border-color: var(--primary); }

.profile-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: 48px;
  width: 280px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.97);
  transform-origin: top right;
  transition: opacity var(--transition-fast),
              transform var(--transition-fast),
              visibility var(--transition-fast);
  z-index: 1200;
}

.profile-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.profile-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-m);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: var(--font-weight-black);
  flex-shrink: 0;
}

.profile-identity strong {
  display: block;
  font-size: var(--fz-0);
  color: var(--text);
}

.profile-identity small {
  font-size: var(--fz--2);
  color: var(--muted);
}

.profile-menu-items a,
.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  font-size: var(--fz--1);
  font-weight: 500;
  border-radius: var(--radius-l);
  transition: background var(--transition-fast);
}

.profile-menu-items a:hover,
.logout-btn:hover { background: var(--hover); }

.profile-menu-items .material-symbols-outlined {
  font-size: 20px;
  color: var(--muted);
}

.logout-form { margin: 0; }

.logout-btn {
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--error);
  font-family: var(--ff-body);
}

.logout-btn .material-symbols-outlined { color: var(--error); }

/* ─── OPTIONS / THEME MENU ────────────────────────────────── */

.theme-toggle .material-symbols-outlined {
  font-size: 22px;
  display: none;
}

html:not(.dark) .theme-icon-sun  { display: block; }
html.dark       .theme-icon-moon { display: block; }

.options-menu {
  position: absolute;
  top: 48px;
  right: 0;
  width: 180px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--transition-fast),
              transform var(--transition-fast),
              visibility var(--transition-fast);
  z-index: 1100;
}

.options-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.options-menu a {
  display: block;
  padding: 12px 16px;
  font-size: var(--fz--1);
  color: var(--text);
  transition: background var(--transition-fast);
}

.options-menu a:hover { background: var(--hover); }

/* ─── TRANSITIONS (shell-level) ──────────────────────────── */

.navbar,
.drawer,
.drawer-header {
  transition: background var(--transition),
              color var(--transition),
              box-shadow var(--transition);
}
