/* ============================================================
   hamdhern.com — Dark theme
   Activated when theme.js sets <html data-theme="dark">.
   Light mode is completely untouched — every rule below is
   scoped to html[data-theme="dark"].

   Palette: a soft, comfortable navy-brown dark that mirrors the
   light pastel gradient (peach/sky -> warm dusk/navy). Brand
   navy -> soft periwinkle, brown -> soft tan, gold kept.
   ============================================================ */

/* ---------------- tokens ---------------- */
html[data-theme="dark"] {
  color-scheme: dark;

  /* shared :root vars used by most public pages */
  --primary-color: #b9c5e2;      /* navy headings/labels -> soft periwinkle */
  --secondary-color: #e0c093;    /* brown accents -> soft tan */
  --text-color: #e8eaf1;
  --light-text-color: #b3b9c7;
  --background-light: #2e3547;   /* pastel #f6faff panels -> dark panel */

  /* portal.css vars */
  --primary: #b9c5e2;
  --accent: #e0c093;
  --bg: #2e3547;
  --card-bg: rgba(46, 54, 73, 0.85);
  --text: #e8eaf1;
  --muted: #b3b9c7;

  /* lockdown.html vars */
  --panel-bg: rgba(40, 47, 66, 0.9);
  --panel-border: #454d63;
  --soft-card: #2e3547;
  --accent-underline: #ffdd9e;
}

html[data-theme="dark"] ::selection {
  background: rgba(255, 221, 158, 0.3);
  color: #fff;
}

/* ---------------- global page chrome ---------------- */
html[data-theme="dark"] body {
  color: #e8eaf1;
  /* peach/sky pastel -> warm dusk / navy, keeps the 4-stop sway */
  background: linear-gradient(-45deg, #3a332d, #272e3f, #3b322c, #262d3d);
  background-size: 400% 400%;
}

html[data-theme="dark"] .container {
  background: rgba(22, 27, 40, 0.4);
}

html[data-theme="dark"] header {
  background: linear-gradient(90deg, #29375a 0%, #4e3823 100%);
  color: #fff;
}

html[data-theme="dark"] footer {
  background: #252e47;
  color: #e8eaf1;
}

html[data-theme="dark"] footer a {
  color: #ffdd9e;
}

/* keep the navbar hover underline gold -> white like light mode */
html[data-theme="dark"] .navbar a:after {
  background: linear-gradient(90deg, #ffdd9e 0%, #fff 100%);
}

/* frosted sections that were #f6faff */
html[data-theme="dark"] .features,
html[data-theme="dark"] .pdf-library,
html[data-theme="dark"] .contact-form,
html[data-theme="dark"] .about-section,
html[data-theme="dark"] .contact-section,
html[data-theme="dark"] .archive,
html[data-theme="dark"] .paid-content,
html[data-theme="dark"] .topic-content {
  background: #2e3547;
  border-color: #454d63;
}

/* flashcards sections carry an inline style attr -> !important */
html[data-theme="dark"] section.flashcards {
  background: #2e3547 !important;
  border-color: #454d63 !important;
}

/* ---------------- headings & text ---------------- */
html[data-theme="dark"] .features h2,
html[data-theme="dark"] .features li h3,
html[data-theme="dark"] .pdf-library h2,
html[data-theme="dark"] .contact-form h2,
html[data-theme="dark"] .archive h2,
html[data-theme="dark"] .archive li h3,
html[data-theme="dark"] .paid-content h2,
html[data-theme="dark"] .topic-content h2,
html[data-theme="dark"] .flashcards h2,
html[data-theme="dark"] .note-title,
html[data-theme="dark"] #question,
html[data-theme="dark"] #score-container h2 {
  color: #b9c5e2;
}

html[data-theme="dark"] .features li p,
html[data-theme="dark"] .archive li p,
html[data-theme="dark"] #score-container p,
html[data-theme="dark"] .content-description,
html[data-theme="dark"] .no-quiz-message {
  color: #b3b9c7;
}

/* ---------------- cards & list items ---------------- */
html[data-theme="dark"] .features li {
  background: #363e53;
  border-color: transparent;
}

html[data-theme="dark"] .features li:hover {
  border-color: #e0c093;
}

html[data-theme="dark"] .archive li {
  background: #3a4257;
  border-color: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .archive li:hover {
  border-color: #e0c093;
}

html[data-theme="dark"] .category {
  background: rgba(45, 52, 69, 0.75);
  border-color: rgba(255, 255, 255, 0.08);
  color: #cdd6ea;
}

html[data-theme="dark"] .category:hover {
  background: rgba(58, 66, 86, 0.85);
}

html[data-theme="dark"] .quiz-item {
  background: rgba(45, 52, 69, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .quiz-item:hover {
  background: rgba(58, 66, 86, 0.9);
}

html[data-theme="dark"] .no-quiz-message {
  background: rgba(45, 52, 69, 0.6);
}

/* ---------------- pdf library (index) ---------------- */
html[data-theme="dark"] .pdf-item {
  background: #3a4257;
}

html[data-theme="dark"] .pdf-item a,
html[data-theme="dark"] .pdf-item p {
  color: #b9c5e2;
}

html[data-theme="dark"] .pdf-item a:hover,
html[data-theme="dark"] .pdf-item a:focus {
  color: #e0c093;
}

/* ---------------- shared round nav buttons ---------------- */
html[data-theme="dark"] .nav-button {
  background: rgba(58, 66, 87, 0.95);
  color: #b9c5e2;
}

html[data-theme="dark"] .nav-button:hover {
  background: rgba(255, 221, 158, 0.25);
  color: #ffdd9e;
}

html[data-theme="dark"] .pdf-container .nav-button {
  background: #3a4257;
  color: #b9c5e2;
}

html[data-theme="dark"] .pdf-container .nav-button:hover,
html[data-theme="dark"] .pdf-container .nav-button:focus {
  background: #7a5f35;
  color: #ffedd0;
}

/* ---------------- forms ---------------- */
html[data-theme="dark"] .form-group label {
  color: #b9c5e2;
}

html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group textarea {
  background: rgba(15, 19, 30, 0.55);
  color: #e8eaf1;
  border-color: #4a5268;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group textarea:focus {
  background: rgba(15, 19, 30, 0.75);
}

html[data-theme="dark"] .form-container {
  background: #413a2d;
}

/* filter bar (choose-quiz) */
html[data-theme="dark"] .filter-bar input[type="text"],
html[data-theme="dark"] .filter-bar select {
  background: rgba(15, 19, 30, 0.55);
  border-color: #4a5268;
}

html[data-theme="dark"] .filter-bar input[type="text"]:focus,
html[data-theme="dark"] .filter-bar select:focus {
  box-shadow: 0 0 0 3px rgba(143, 163, 214, 0.2);
}

/* ---------------- brand buttons ---------------- */
html[data-theme="dark"] .download-btn,
html[data-theme="dark"] .submit-btn,
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .nav-btn,
html[data-theme="dark"] #quiz-container button:not(.option-btn),
html[data-theme="dark"] #score-container button {
  background: linear-gradient(90deg, #33456e 0%, #5c4327 100%);
  color: #fff;
}

html[data-theme="dark"] .back-btn:hover {
  background: linear-gradient(90deg, #3d5080 0%, #6d5233 100%);
}

html[data-theme="dark"] .nav-btn:disabled {
  background: #3a4257;
  color: #9aa1b2;
}

/* ---------------- flashcards ---------------- */
html[data-theme="dark"] .flashcard-inner {
  background: #413a2d;
}

html[data-theme="dark"] .flashcard-front,
html[data-theme="dark"] .flashcard-back {
  color: #f0e4c4;
}

html[data-theme="dark"] .flashcard-back {
  background: #463f31;
}

/* ---------------- difficulty badges (choose-quiz, quiz) ---------------- */
html[data-theme="dark"] .difficulty-badge {
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .diff-beginner { background: #1e3b2a; color: #85d9a0; }
html[data-theme="dark"] .diff-basic { background: #1f2c4e; color: #94b1f2; }
html[data-theme="dark"] .diff-intermediate { background: #3e331a; color: #ecc378; }
html[data-theme="dark"] .diff-advanced { background: #442130; color: #f19cb9; }
html[data-theme="dark"] .diff-expert { background: #33254c; color: #c9a3f0; }

/* ---------------- quiz page ---------------- */
html[data-theme="dark"] #quiz-container,
html[data-theme="dark"] #score-container {
  background: rgba(35, 41, 58, 0.72);
  border-color: rgba(255, 255, 255, 0.09);
}

html[data-theme="dark"] #score-container {
  background: rgba(35, 41, 58, 0.8);
}

html[data-theme="dark"] .option-btn {
  background: #363e53;
  border-color: transparent;
  color: #dfe4ee;
}

html[data-theme="dark"] .option-btn:hover {
  border-color: #e0c093;
}

html[data-theme="dark"] #progress {
  color: #e0c093 !important; /* also beats the inline style attr */
}

/* content slide viewer styles (injected at runtime by quiz.js) */
html[data-theme="dark"] .content-body,
html[data-theme="dark"] .text-content {
  background: rgba(35, 41, 58, 0.8);
}

html[data-theme="dark"] .slide-progress {
  color: #e0c093;
}

/* name capture overlay (built with inline styles -> !important) */
html[data-theme="dark"] #name-overlay > div {
  background: #2d3445 !important;
}

html[data-theme="dark"] #name-overlay h2 {
  color: #b9c5e2 !important;
}

html[data-theme="dark"] #name-overlay p {
  color: #b3b9c7 !important;
}

html[data-theme="dark"] #name-input {
  background: #232a3c;
  color: #e8eaf1;
  border-color: #4a5268 !important;
}

html[data-theme="dark"] #start-quiz-btn {
  background: linear-gradient(90deg, #33456e, #5c4327) !important;
  color: #fff !important;
}

/* ---------------- materials page ---------------- */
html[data-theme="dark"] .material-thumb {
  background: linear-gradient(135deg, #39415a 0%, #2f3648 100%);
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .material-thumb:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .material-thumb-initial {
  background: rgba(255, 255, 255, 0.12);
  color: #b9c5e2;
}

/* ---------------- topic page ---------------- */
html[data-theme="dark"] .note-container {
  background: #3a4257;
}

html[data-theme="dark"] .note-container.is-doc {
  background: linear-gradient(135deg, #3a4257 0%, #2e3547 100%);
}

html[data-theme="dark"] .note-container.is-doc .note-title {
  border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .note-doc-thumb {
  background: linear-gradient(135deg, #39415a 0%, #2f3648 100%);
}

html[data-theme="dark"] .note-doc-thumb:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .note-doc-badge {
  background: rgba(41, 48, 68, 0.95);
  color: #c9d3ea;
}

html[data-theme="dark"] .note-doc-thumb:hover .note-doc-badge {
  background: #4a5b88;
  color: #fff;
}

html[data-theme="dark"] .note-doc-type {
  background: rgba(41, 48, 68, 0.95);
  color: #94b1f2;
}

html[data-theme="dark"] .note-image {
  background: #2e3547;
}

/* image lightbox buttons */
html[data-theme="dark"] .modal-nav-button,
html[data-theme="dark"] .zoom-button {
  background: rgba(58, 66, 87, 0.92);
  color: #cdd6ea;
}

html[data-theme="dark"] .modal-nav-button:hover,
html[data-theme="dark"] .zoom-button:hover {
  background: rgba(255, 221, 158, 0.28);
  color: #ffdd9e;
}

html[data-theme="dark"] .modal-nav-button:disabled {
  background: rgba(45, 52, 69, 0.5);
}

/* ---------------- contact page ---------------- */
html[data-theme="dark"] .contact-details a {
  color: #b9c5e2;
  background-color: rgba(58, 66, 87, 0.7);
}

html[data-theme="dark"] .contact-details a:hover {
  background-color: rgba(74, 83, 107, 0.85);
}

/* ---------------- login page ---------------- */
html[data-theme="dark"] form#loginForm {
  background: rgba(22, 27, 40, 0.55);
}

html[data-theme="dark"] form#loginForm h2 {
  color: #b9c5e2;
}

html[data-theme="dark"] form#loginForm input {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

html[data-theme="dark"] form#loginForm input:focus {
  background-color: rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] form#loginForm input::placeholder {
  color: rgba(232, 234, 241, 0.45);
}

html[data-theme="dark"] form#loginForm button {
  background-color: #6d5233;
  color: #fff;
}

html[data-theme="dark"] form#loginForm button:hover {
  background-color: #46557c;
}

html[data-theme="dark"] .error-message {
  background: rgba(220, 53, 69, 0.16);
  color: #ff9d97;
  border-color: rgba(220, 53, 69, 0.35);
}

html[data-theme="dark"] .contact-link {
  color: #e0c093;
}

html[data-theme="dark"] .contact-link a {
  color: #b9c5e2;
}

html[data-theme="dark"] .contact-link a:hover {
  color: #e0c093;
}

/* ---------------- lockdown page ---------------- */
html[data-theme="dark"] .msg {
  background: #363e53;
  color: #e8eaf1;
}

html[data-theme="dark"] .lockdown-anim-svg {
  background: #293246;
}

html[data-theme="dark"] .wrap a:after {
  background: linear-gradient(90deg, var(--accent-underline) 0%, #b9c5e2 100%);
}

/* SVG maintenance graphic — darken the white panel, keep brand gears */
html[data-theme="dark"] #panelGrad stop[offset="0%"] { stop-color: #333c52; }
html[data-theme="dark"] #panelGrad stop[offset="100%"] { stop-color: #2a3244; }
html[data-theme="dark"] .gearCore { fill: #dfe4f0; }
html[data-theme="dark"] .wrench path { fill: #dfe4f0; }

/* ---------------- portal page ---------------- */
/* portal's header has no band in light mode — keep it clean */
html[data-theme="dark"] .portal-shell header {
  background: none;
  color: var(--primary);
}

html[data-theme="dark"] .mode-card {
  border-color: rgba(185, 197, 226, 0.14);
}

html[data-theme="dark"] .mode-badge {
  background: rgba(185, 197, 226, 0.12);
}

html[data-theme="dark"] .mode-meta {
  color: #9aa1b2;
}

html[data-theme="dark"] .mode-preview {
  background: rgba(185, 197, 226, 0.1);
  border-color: rgba(185, 197, 226, 0.12);
}

html[data-theme="dark"] .mode-card button {
  background: linear-gradient(90deg, #33456e, #5c4327);
  color: #fff;
}

/* ---------------- JS-injected widgets ---------------- */
/* profile dropdown (innerHTML with inline styles -> !important) */
html[data-theme="dark"] #dropdown-menu {
  background: #2d3445 !important;
  border-color: #454d63 !important;
}

html[data-theme="dark"] #dropdown-menu button {
  color: #b9c5e2 !important;
}

/* mode switcher injected by mode-client.js */
html[data-theme="dark"] #site-mode-switcher {
  background: rgba(30, 36, 52, 0.85);
  border-color: rgba(185, 197, 226, 0.25);
}

html[data-theme="dark"] #site-mode-switcher label {
  color: #c7d0e4;
}

html[data-theme="dark"] #site-mode-switcher select {
  background: #2d3445;
  color: #e8eaf1;
  border-color: rgba(185, 197, 226, 0.25);
}

html[data-theme="dark"] #site-mode-switcher select:focus {
  border-color: #8fa3d6;
  box-shadow: 0 0 0 2px rgba(143, 163, 214, 0.25);
}

/* ---------------- theme toggle (injected by theme.js) ---------------- */
/* base icon button */
#theme-toggle-btn {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#theme-toggle-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* variant: inside the mode-switcher pill — styled like its <select> */
#site-mode-switcher #theme-toggle-btn {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border-color: rgba(46, 60, 93, 0.22);
  background: rgba(255, 255, 255, 0.92);
  color: #2e3c5d;
}

#site-mode-switcher #theme-toggle-btn:hover,
#site-mode-switcher #theme-toggle-btn:focus-visible {
  border-color: rgba(46, 60, 93, 0.6);
  box-shadow: 0 0 0 2px rgba(46, 60, 93, 0.2);
}

html[data-theme="dark"] #site-mode-switcher #theme-toggle-btn {
  background: #2d3445;
  color: #e8eaf1;
  border-color: rgba(185, 197, 226, 0.25);
}

html[data-theme="dark"] #site-mode-switcher #theme-toggle-btn:hover,
html[data-theme="dark"] #site-mode-switcher #theme-toggle-btn:focus-visible {
  border-color: #8fa3d6;
  box-shadow: 0 0 0 2px rgba(143, 163, 214, 0.25);
}

@media (max-width: 640px) {
  /* the pill becomes a centered bottom row — keep the button compact */
  #site-mode-switcher #theme-toggle-btn {
    width: 44px;
    flex: 0 0 44px;
  }
}

/* variant: standalone floating button (pages without the mode switcher) */
#theme-toggle-btn.floating {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, #33456e, #5c4327);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  z-index: 1600;
}

#theme-toggle-btn.floating:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

#theme-toggle-btn.floating svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 640px) {
  #theme-toggle-btn.floating {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #theme-toggle-btn {
    transition: none;
  }
}

/* light mode shows the moon (switch to dark), dark mode shows the sun */
#theme-toggle-btn .ic-sun { display: none; }
#theme-toggle-btn .ic-moon { display: block; }
html[data-theme="dark"] #theme-toggle-btn .ic-sun { display: block; }
html[data-theme="dark"] #theme-toggle-btn .ic-moon { display: none; }
