/* FojtikLab site header (templates/_site_header.html).

   The one stylesheet for the header wherever it appears: the portal's own
   pages and the mounted mini-apps (e.g. /projekty/algoritmizace), whose own
   stylesheets define different variables, fonts, links and .container.
   Every rule is scoped to .site-header and the header sets its own colours
   and typography, so it looks the same next to any page stylesheet. Load it
   after the page stylesheet. */

.site-header {
  --surface: #ffffff;
  --primary: #234d8b;
  --primary-dark: #183965;
  --primary-soft: #eaf1ff;
  --accent: #6aa8ff;
  --text: #1b2430;
  --muted: #5f6f82;
  --border: #dfe7f3;
  --shadow: 0 18px 35px rgba(26, 35, 56, 0.08);

  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(245, 247, 251, 0.9);
  border-bottom: 1px solid rgba(223, 231, 243, 0.9);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.site-header a {
  color: inherit;
  text-decoration: none;
}

.site-header button {
  font: inherit;
}

.site-header .container {
  width: min(1120px, calc(100% - 2rem));
  max-width: none;
  margin: 0 auto;
  padding: 0;
}

.site-header .nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  gap: 1rem;
}

.site-header .nav-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 auto;
  min-width: 0;
  gap: 1rem;
}

.site-header .nav-group {
  display: contents;
}

.site-header .mobile-nav-toggle {
  display: none;
}

.site-header .brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--primary-dark);
}

.site-header .brand:hover,
.site-header .brand:focus-visible {
  color: var(--primary);
  text-decoration: none;
}

.site-header .brand:focus-visible {
  outline: 3px solid rgba(15, 159, 154, 0.28);
  outline-offset: 4px;
  border-radius: 8px;
}

.site-header .main-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.site-header .main-nav a {
  color: var(--muted);
  font-weight: 600;
}

.site-header .nav-creation-menu {
  position: relative;
}

.site-header .nav-creation-menu > summary {
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.site-header .nav-creation-menu > summary::-webkit-details-marker {
  display: none;
}

.site-header .nav-creation-menu > summary::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin: 0 0.15rem 0.2rem 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.site-header .nav-creation-menu[open] > summary::after {
  margin-bottom: -0.05rem;
  transform: rotate(225deg);
}

.site-header .nav-creation-menu-panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  left: -0.75rem;
  z-index: 30;
  display: grid;
  min-width: 13rem;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.site-header .nav-creation-menu-panel a {
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
}

.site-header .nav-creation-menu-panel a:hover,
.site-header .nav-creation-menu-panel a:focus-visible {
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-decoration: none;
}

.site-header .nav-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-header .teacher-nav-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.site-header .login-btn {
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.1rem;
  background: #edf3ff;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-weight: 700;
}

.site-header .theme-toggle {
  min-height: 2.8rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.site-header .theme-toggle:hover,
.site-header .theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

@media (max-width: 860px), (max-height: 520px) and (orientation: landscape) {
  .site-header .nav-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 64px;
    gap: 0;
    padding: 0.5rem 0;
  }

  .site-header.mobile-nav-ready .mobile-nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 1.45rem;
    line-height: 1;
  }

  .site-header .mobile-nav-toggle:hover {
    border-color: var(--accent);
    background: var(--primary-soft);
  }

  .site-header .mobile-nav-toggle:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }

  .site-header .mobile-nav-toggle-close {
    display: none;
  }

  .site-header.mobile-nav-open .mobile-nav-toggle-open {
    display: none;
  }

  .site-header.mobile-nav-open .mobile-nav-toggle-close {
    display: inline;
  }

  .site-header .nav-panel {
    grid-column: 1 / -1;
    display: flex;
    align-items: stretch;
    flex-direction: column;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem 0 0.75rem;
    border-top: 1px solid var(--border);
    gap: 0;
  }

  .site-header.mobile-nav-ready .nav-panel {
    display: none;
  }

  .site-header.mobile-nav-ready.mobile-nav-open .nav-panel {
    display: flex;
  }

  .site-header .main-nav {
    display: grid;
    width: 100%;
    gap: 0;
  }

  .site-header .nav-group {
    display: grid;
  }

  .site-header .nav-group-teacher {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
  }

  .site-header .nav-creation-menu {
    position: static;
  }

  .site-header .nav-creation-menu > summary {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0.65rem 0.6rem;
    border-radius: 8px;
  }

  .site-header .nav-creation-menu-panel {
    position: static;
    min-width: 0;
    padding: 0 0 0.25rem 0.75rem;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .site-header .nav-creation-menu-panel a {
    white-space: normal;
  }

  .site-header .main-nav a,
  .site-header .nav-creation-menu > summary,
  .site-header .teacher-nav-status,
  .site-header .nav-account .login-btn,
  .site-header .nav-account .theme-toggle {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 46px;
    padding: 0.65rem 0.6rem;
    border-radius: 8px;
    overflow-wrap: anywhere;
  }

  .site-header .main-nav a:hover,
  .site-header .main-nav a:focus-visible,
  .site-header .teacher-nav-status:hover,
  .site-header .teacher-nav-status:focus-visible,
  .site-header .nav-account .login-btn:hover,
  .site-header .nav-account .login-btn:focus-visible {
    outline: none;
    background: var(--primary-soft);
    color: var(--primary-dark);
  }

  .site-header .main-nav a:focus-visible,
  .site-header .teacher-nav-status:focus-visible,
  .site-header .nav-account .login-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--accent) inset;
  }

  .site-header .nav-account {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
    gap: 0;
  }

  .site-header .teacher-nav-status {
    white-space: normal;
    text-align: left;
  }

  .site-header .nav-account .login-btn {
    justify-content: flex-start;
    width: 100%;
    border: 0;
    background: transparent;
  }

  .site-header .nav-account .theme-toggle {
    justify-content: flex-start;
    width: 100%;
    margin-top: 0.4rem;
    border-radius: 8px;
    background: var(--primary-soft);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .site-header .nav-wrap {
    min-height: 52px;
    padding: 0.2rem 0;
  }

  .site-header.mobile-nav-ready .mobile-nav-toggle {
    width: 42px;
    height: 42px;
  }

  .site-header.mobile-nav-ready.mobile-nav-open .nav-panel {
    max-height: calc(100vh - 52px);
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .site-header .main-nav a,
  .site-header .nav-creation-menu > summary,
  .site-header .teacher-nav-status,
  .site-header .nav-account .login-btn,
  .site-header .nav-account .theme-toggle {
    min-height: 40px;
    padding-block: 0.45rem;
  }
}

/* Unread Zprávy (teacher_feedback.py): a count next to the link, a dot on
   the mobile menu button. */
.site-header .nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  margin-left: 0.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #d64545;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: 0.1em;
}

.site-header .mobile-nav-toggle {
  position: relative;
}

.site-header .mobile-nav-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d64545;
}

/* FojtíkLab Pro (subscriptions.py): marks a menu item the free account can
   only look into. */
.site-header .pro-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--premium-soft, #f0ebff);
  color: var(--premium, #8257ff);
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: 0.1em;
}
