/* Shared chrome: topbar (logo), site footer, utility fixes */

/* Enforce native [hidden] behavior against display: flex overrides */
[hidden] {
  display: none !important;
}


/* Topbar */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: flex-start;
  pointer-events: none;
}

.topbar-brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--fg, #E8E8E8);
  opacity: 0.72;
  transition: opacity 200ms ease;
  padding-left: 3.75rem;
}
.topbar-brand:hover,
.topbar-brand:focus-visible {
  opacity: 1;
}

.topbar-mark {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent, #00FF88);
  letter-spacing: -0.05em;
  line-height: 1;
}

.topbar-wordmark {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.9rem 1rem;
  }
  .topbar-brand {
    padding-left: 3.25rem;
    gap: 0.45rem;
  }
  .topbar-wordmark {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  .topbar-wordmark {
    display: none;
  }
}


/* Site footer */

.site-footer {
  margin-top: 4rem;
  padding: clamp(3rem, 8vh, 5rem) clamp(1.5rem, 5vw, 4rem) 2rem;
  border-top: 1px solid var(--dim, #1F1F1F);
  background: linear-gradient(180deg, transparent, rgba(0, 255, 136, 0.02));
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--dim, #1F1F1F);
}

.footer-brand {
  max-width: 340px;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--fg, #E8E8E8);
  margin-bottom: 1rem;
}
.footer-mark {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent, #00FF88);
  letter-spacing: -0.05em;
}
.footer-wordmark {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

.footer-tagline {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted, #9A9A9A);
  line-height: 1.4;
  margin: 0;
}

.footer-col {
  min-width: 0;
}
.footer-heading {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted, #6B6B6B);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin: 0 0 1.25rem;
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.footer-col a {
  color: var(--fg, #E8E8E8);
  text-decoration: none;
  font-size: 0.92rem;
  opacity: 0.72;
  transition: opacity 200ms ease, color 200ms ease;
}
.footer-col a:hover,
.footer-col a:focus-visible {
  opacity: 1;
  color: var(--accent, #00FF88);
}

.footer-bottom {
  max-width: 1280px;
  margin: 2rem auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-copy {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted, #6B6B6B);
  letter-spacing: 0.05em;
}
.footer-meta {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted, #7A7A7A);
}

@media (max-width: 900px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
  .footer-brand {
    grid-column: 1 / -1;
    max-width: 500px;
  }
}

@media (max-width: 540px) {
  .site-footer {
    padding: 3rem 1.25rem 1.75rem;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-bottom: 2rem;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 1.5rem;
  }
  .footer-meta {
    font-size: 0.9rem;
  }
}


/* Topnav — global navigation injected by common.js */

.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--dim, #1F1F1F);
}

.topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--fg, #E8E8E8);
  flex-shrink: 0;
  transition: opacity 200ms ease;
}
.topnav-brand:hover { opacity: 0.8; }

.topnav-mark {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent, #00FF88);
  letter-spacing: -0.05em;
  line-height: 1;
}

.topnav-wordmark {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.topnav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  margin-left: 1.5rem;
}

.topnav-links a {
  padding: 0.5rem 0.85rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted, #9A9A9A);
  text-decoration: none;
  border-radius: 6px;
  transition: color 200ms ease, background 200ms ease;
}
.topnav-links a:hover {
  color: var(--fg, #E8E8E8);
  background: rgba(255, 255, 255, 0.03);
}
.topnav-links a.is-active {
  color: var(--accent, #00FF88);
  background: rgba(0, 255, 136, 0.08);
}

.topnav-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topnav-login {
  padding: 0.5rem 0.85rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--fg, #E8E8E8);
  text-decoration: none;
  border-radius: 6px;
  transition: background 200ms ease;
}
.topnav-login:hover {
  background: rgba(255, 255, 255, 0.04);
}

.topnav-cta {
  padding: 0.55rem 1rem;
  background: var(--accent, #00FF88);
  color: #000;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: transform 150ms ease, background 200ms ease;
}
.topnav-cta:hover {
  transform: translateY(-1px);
  background: #00E67A;
}

.topnav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a1a, #0a0a0a);
  border: 1px solid var(--dim, #1F1F1F);
  text-decoration: none;
  transition: border-color 200ms ease;
}
.topnav-avatar:hover {
  border-color: rgba(0, 255, 136, 0.35);
}
.topnav-avatar span {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--fg, #F0F0F0);
  line-height: 1;
}

.topnav-logout {
  padding: 0.5rem 0.85rem;
  background: transparent;
  border: 1px solid var(--dim, #2A2A2A);
  color: var(--muted, #9A9A9A);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease;
}
.topnav-logout:hover {
  color: var(--fg, #E8E8E8);
  border-color: rgba(255, 255, 255, 0.15);
}

.topnav-burger {
  display: none;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  flex-direction: column;
  justify-content: space-around;
  align-items: stretch;
}
.topnav-burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--fg, #E8E8E8);
  border-radius: 1px;
  transition: transform 300ms ease, opacity 300ms ease;
}


/* Push main content below the fixed nav */
main.main,
main.auth-main {
  padding-top: 4rem;
}


/* Mobile */

@media (max-width: 768px) {
  .topnav {
    justify-content: space-between;
    padding: 0.75rem 1rem;
  }
  .topnav-links,
  .topnav-auth {
    display: none;
  }
  .topnav-burger {
    display: flex;
  }

  .topnav.is-open {
    flex-direction: column;
    align-items: stretch;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    padding: 4.5rem 1.5rem 2rem;
    gap: 0;
    overflow-y: auto;
  }
  .topnav.is-open .topnav-brand {
    position: fixed;
    top: 0.75rem;
    left: 1rem;
  }
  .topnav.is-open .topnav-burger {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
  }
  .topnav.is-open .topnav-burger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .topnav.is-open .topnav-burger span:nth-child(2) {
    opacity: 0;
  }
  .topnav.is-open .topnav-burger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .topnav.is-open .topnav-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 1rem 0 auto;
    flex: 0;
  }
  .topnav.is-open .topnav-links a {
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 2.25rem;
    padding: 0.65rem 0.5rem;
    letter-spacing: -0.02em;
  }
  .topnav.is-open .topnav-links a.is-active {
    color: var(--accent, #00FF88);
    background: transparent;
  }

  .topnav.is-open .topnav-auth {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding-top: 2rem;
    border-top: 1px solid var(--dim, #1F1F1F);
  }
  .topnav.is-open .topnav-login,
  .topnav.is-open .topnav-cta,
  .topnav.is-open .topnav-logout {
    text-align: center;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
  }
  .topnav.is-open .topnav-avatar {
    align-self: center;
    width: 64px;
    height: 64px;
    margin-bottom: 0.5rem;
  }
  .topnav.is-open .topnav-avatar span {
    font-size: 1.75rem;
  }
}


/* Legacy: hide the old .topbar styles if any leaked in */
.topbar { display: none !important; }


/* Let clicks pass through empty areas of the topnav */
.topnav {
  pointer-events: none;
}
.topnav-brand,
.topnav-links a,
.topnav-login,
.topnav-cta,
.topnav-avatar,
.topnav-logout,
.topnav-burger {
  pointer-events: auto;
}

/* Push the redflag game topbar below the fixed topnav so they don't overlap */
.rf-topbar {
  top: 4rem !important;
}

/* Same for the reader progress bar */
.reader-progress {
  top: 4rem !important;
}

/* And the lessons filter bar (also sticky top:0) */
.lessons-filters {
  top: 4rem !important;
}


/* Mobile drawer: turn the tiny avatar circle into a full-width Profile row */

@media (max-width: 768px) {

  /* Add a "Profile" row to the mobile drawer via the avatar link */
  .topnav.is-open .topnav-avatar {
    align-self: stretch;
    width: 100%;
    height: auto;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    border: 1px solid var(--dim, #1F1F1F);
    background: rgba(255, 255, 255, 0.02);
    order: -1;
  }
  .topnav.is-open .topnav-avatar::after {
    content: 'Profile';
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 1.75rem;
    color: var(--fg, #F0F0F0);
    letter-spacing: -0.01em;
    line-height: 1;
  }
  .topnav.is-open .topnav-avatar span {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
  }

  /* Logout: full-width matching style, less "afterthought" */
  .topnav.is-open .topnav-logout {
    align-self: stretch;
    width: 100%;
    padding: 0.85rem 1rem;
    background: transparent;
    border: 1px solid var(--dim, #1F1F1F);
    color: var(--muted, #9A9A9A);
    font-size: 0.9rem;
    border-radius: 12px;
    text-align: center;
  }
}


/* Wordmark — Option 1: color split (Cyber white, Educ green, same font) */
.tw-cyber,
.tw-educ {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  font-style: normal;
  font-size: 1em;
  line-height: inherit;
  letter-spacing: 0;
  margin: 0;
}
.tw-cyber { color: var(--fg, #E8E8E8); }
.tw-educ  { color: var(--accent, #00FF88); }
