/* Shared UI foundation for CE Board Exam Generator pages. */
:root {
  --ce-blue: #18398a;
  --ce-blue-2: #0e2a6d;
  --ce-accent: #2962ff;
  --ce-bg: #f5f7fb;
  --ce-surface: #ffffff;
  --ce-text: #243044;
  --ce-muted: #64748b;
  --ce-line: #dbe3ef;
  --ce-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  --ce-radius: 10px;
  --ce-header-height: 60px;
}

body.dark-mode {
  --ce-blue: #1f1f1f;
  --ce-blue-2: #242b3a;
  --ce-accent: #82b4ff;
  --ce-bg: #121212;
  --ce-surface: #1e1e1e;
  --ce-text: #f0f0f0;
  --ce-muted: #b8c1d1;
  --ce-line: #334155;
  --ce-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

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

html {
  overflow-x: hidden;
}

body {
  min-height: 100%;
  background-color: var(--ce-bg);
  color: var(--ce-text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.light-mode {
  background-color: var(--ce-bg);
  color: var(--ce-text);
}

a {
  color: var(--ce-accent);
}

img,
svg {
  max-width: 100%;
}

header,
header.site-header {
  background-color: var(--ce-blue);
  color: #fff;
  min-height: var(--ce-header-height);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  gap: 14px;
}

header a,
header h1,
header .menu-btn {
  color: #fff;
}

.logo,
header img.logo {
  height: 40px;
  width: auto;
  flex: 0 0 auto;
}

.center-logo,
.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.center-logo {
  justify-content: center;
  margin-inline: auto;
  max-width: 100%;
  flex-wrap: wrap;
}

.center-logo img {
  width: 32px;
  height: 32px;
}

.center-logo h1,
.title-group h1,
header h1 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  line-height: 1.2;
}

.title-group h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #fff;
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

header .menu-btn,
header.site-header .menu-btn {
  width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  color: #fff !important;
  padding: 0 !important;
  margin: 0 !important;
  border-width: 1px !important;
  border-style: solid !important;
  border-color: transparent !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  font-size: 26px !important;
  line-height: 1 !important;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background-color: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  outline: none;
}

#dropdownMenu,
header nav,
.menu-wrapper nav {
  background-color: var(--ce-blue);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: var(--ce-shadow);
  min-width: 240px;
  z-index: 1001;
}

nav[data-site-nav] {
  display: none !important;
  position: fixed !important;
  top: calc(var(--ce-header-height) + 10px) !important;
  left: 16px !important;
  right: auto !important;
  width: min(360px, calc(100vw - 32px)) !important;
  max-width: min(360px, calc(100vw - 32px)) !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  padding: 12px !important;
}

nav[data-site-nav].open,
nav[data-site-nav].active,
.menu-wrapper.menu-open nav[data-site-nav] {
  display: block !important;
}

header:hover nav[data-site-nav]:not(.open):not(.active) {
  display: none !important;
}

.menu-list,
.submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav[data-site-nav] .menu-list,
nav[data-site-nav] .menu-list li,
nav[data-site-nav] .dropdown,
nav[data-site-nav] .submenu {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
}

.menu-list li {
  position: relative;
}

.menu-list a {
  display: flex;
  align-items: center;
  min-height: 38px;
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.25;
}

.menu-list a:hover {
  background-color: rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

.submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 220px;
  background-color: var(--ce-blue-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: var(--ce-shadow);
  padding: 6px;
}

.dropdown:hover > .submenu,
.dropdown.submenu-open > .submenu {
  display: block;
}

nav[data-site-nav] .dropdown:hover > .submenu {
  display: none;
}

nav[data-site-nav] .dropdown.submenu-open > .submenu {
  display: block;
}

nav[data-site-nav] .submenu {
  position: fixed;
  left: min(392px, calc(100vw - 344px));
  top: var(--site-nav-submenu-top, calc(var(--ce-header-height) + 10px));
  width: min(340px, calc(100vw - 408px));
  min-width: 260px;
  max-height: none;
  overflow: visible;
  margin: 0;
  padding: 10px;
  background-color: var(--ce-blue-2);
  border-radius: 12px;
  box-shadow: var(--ce-shadow);
}

nav[data-site-nav] .submenu a {
  min-height: 44px;
  padding: 9px 12px;
  font-size: 15px;
  white-space: normal;
}

nav[data-site-nav] .dropdown > a[href="#"]:hover,
nav[data-site-nav] .dropdown > a[href="#"]:focus-visible {
  background-color: rgba(255, 255, 255, 0.12);
}

.back-btn-header {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background-color: #fff !important;
  color: #18398a !important;
  border: 1px solid rgba(24, 57, 138, 0.14) !important;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  letter-spacing: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.back-btn-header:hover {
  background-color: #f3f6ff !important;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
  text-decoration: none;
}

.back-btn-header:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.dark-mode-toggle {
  flex-shrink: 0;
}

.switch {
  width: 52px;
  height: 28px;
  position: relative;
  display: inline-block;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  background-color: #ccc;
  border-radius: 34px;
  transition: 0.4s;
  cursor: pointer;
}

.slider::before {
  content: '🌙';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: 0.4s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.switch input:checked ~ .slider {
  background-color: #4d90fe;
}

.switch input:checked ~ .slider::before {
  transform: translateX(24px);
  content: '☀️';
}

.lecture-details {
  margin: 20px auto;
  max-width: 900px;
  background: #f8f9fb;
  border-radius: 10px;
  border: 1px solid #e0e3ea;
  padding: 12px 18px;
  transition: all 0.3s ease;
}

.lecture-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  color: #1e3a8a;
  outline: none;
}

.lecture-details summary:hover {
  color: #2563eb;
}

.lecture-details[open] {
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.lecture-text {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.7;
  color: #333;
}

body.dark-mode .lecture-details {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .lecture-details[open] {
  background: #0f172a;
}

body.dark-mode .lecture-text {
  color: #e2e8f0;
}

body.dark-mode .lecture-details summary {
  color: #60a5fa;
}

@media (max-width: 700px) {
  .center-logo {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .title-group {
    gap: 8px;
  }

  .center-logo h1,
  .title-group h1,
  header h1 {
    font-size: 16px;
  }

  .submenu {
    position: static;
    margin-top: 4px;
  }

  nav[data-site-nav] {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    left: 12px !important;
  }

  nav[data-site-nav] .submenu {
    position: static;
    width: auto;
    min-width: 0;
    margin: 6px 0 2px;
    box-shadow: none;
    background-color: rgba(14, 42, 109, 0.78);
  }
}
