/* =========================================================
   Mizan Theme Layer
   - Dark mode is the default brand theme.
   - Light mode changes the page/surface system only.
   - Branded category/book cards keep their own colors.
   ========================================================= */
:root{
  color-scheme:dark;
}
/* View navigation must control visibility independently from theme. */
.view-section{
  display:none;
}
.view-section.active{
  display:block;
}
.platform-home{
  display:block;
}
html[data-theme="light"]{
  color-scheme:light;
}
/* ---------- Base ---------- */
html[data-theme="light"] body{
  background:var(--mizan-bg-light);
  color:var(--mizan-text-light);
}
html[data-theme="light"] header p{
  color:var(--mizan-muted-light);
}
/* ---------- Search ---------- */
html[data-theme="light"] #search-input{
  background:var(--mizan-surface-light);
  color:var(--mizan-text-light);
  border-color:var(--mizan-border-light);
  box-shadow:var(--mizan-shadow-theme-header);
}
html[data-theme="light"] #search-input::placeholder{
  color:var(--mizan-muted-light);
}
/* ---------- Header controls ---------- */
/* Keep the toggle aligned with the existing header utility controls.
   Position it in the header context (not fixed to a transformed ancestor). */
.mizan-header > #theme-toggle.theme-toggle{
  position:absolute;
  top:var(--mizan-header-tools-offset);
  left:var(--mizan-header-tools-offset);
  z-index:20;
  display:grid;
  place-items:center;
  width:var(--mizan-header-control-size);
  height:var(--mizan-header-control-size);
  margin:0;
  padding:0;
  border:1px solid var(--mizan-primary-500-border);
  border-radius:50%;
  background:var(--mizan-primary-900);
  color:var(--mizan-primary-300);
  box-shadow:none;
  backdrop-filter:none;
  cursor:pointer;
}
.mizan-header > #theme-toggle.theme-toggle i,
.mizan-header > #theme-toggle.theme-toggle svg{
  display:block;
  background:transparent;
  color:inherit;
}
.mizan-header > #theme-toggle.theme-toggle:hover{
  border-color:var(--mizan-primary-300);
  background:var(--mizan-surface-dark);
  transform:translateY(-1px);
}
html[data-theme="light"] .mizan-header > #theme-toggle.theme-toggle{
  background:var(--mizan-surface-light);
  color:var(--mizan-primary-700);
  border-color:var(--mizan-border-light);
  box-shadow:none;
}
@media (max-width:600px){
  .mizan-header > #theme-toggle.theme-toggle{
    top:var(--mizan-header-tools-offset);
    left:var(--mizan-header-tools-offset);
    width:var(--mizan-header-control-size);
    height:var(--mizan-header-control-size);
  }
}
/* ---------- Exam / content surfaces ---------- */
html[data-theme="light"] .book-card,
html[data-theme="light"] .chapter-item,
html[data-theme="light"] .exam-box,
html[data-theme="light"] .results-box,
html[data-theme="light"] .review-item{
  background:var(--mizan-surface-light);
  border-color:var(--mizan-border-light);
  box-shadow:var(--mizan-shadow-surface-soft);
}
html[data-theme="light"] .stat-item,
html[data-theme="light"] .option-btn,
html[data-theme="light"] .progress-bar-container,
html[data-theme="light"] .result-details{
  background:var(--mizan-bg-light);
  border-color:var(--mizan-border-light);
}
html[data-theme="light"] .option-btn{
  color:var(--mizan-text-light);
}
html[data-theme="light"] .option-btn:hover:not(:disabled){
  background:var(--mizan-primary-500-pale);
}
html[data-theme="light"] .exam-home-btn{
  border-color:var(--mizan-border-light);
  color:var(--mizan-muted-light);
}
html[data-theme="light"] .exam-btn.prev{
  background:var(--mizan-border-light);
  color:var(--mizan-heading);
}
/* ---------- Polish: shared interaction primitives ---------- */
/* Motion tokens are provided by mizan-design-tokens.css. */
button,
a,
input,
select,
textarea{
  -webkit-tap-highlight-color:transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible{
  outline:var(--mizan-focus-ring-width) solid var(--mizan-focus-ring);
  outline-offset:var(--mizan-focus-ring-offset);
}
button:not(:disabled),
a{
  transition:color var(--mizan-duration-fast) ease,background-color var(--mizan-duration-fast) ease,border-color var(--mizan-duration-fast) ease,box-shadow var(--mizan-duration-regular) ease,transform var(--mizan-duration-medium) var(--mizan-ease-out);
}
button:active:not(:disabled){
  transform:translateY(1px);
}
#theme-toggle.theme-toggle{
  transition:transform var(--mizan-duration-medium) var(--mizan-ease-out),border-color var(--mizan-duration-fast) ease,background var(--mizan-duration-fast) ease,box-shadow var(--mizan-duration-regular) ease;
}
#theme-toggle.theme-toggle:active{
  transform:scale(.94);
}
@media(prefers-reduced-motion:reduce){
  *,
  *::before,
  *::after{
    scroll-behavior:auto;
    animation-duration:.001ms;
    animation-iteration-count:1;
    transition-duration:.001ms;
  }
  button:active:not(:disabled),
  #theme-toggle.theme-toggle:active{
    transform:none;
  }
}
/* Light theme audit repair */
html[data-theme="light"] .custom-exam-book-option,
html[data-theme="light"] .custom-exam-count-row,
html[data-theme="light"] .question-search-results{
  background:var(--mizan-surface-light);
  border-color:var(--mizan-border-light);
  color:var(--mizan-text-light);
  box-shadow:var(--mizan-shadow-theme-subtle);
}
html[data-theme="light"] .custom-exam-count-row input{
  background:var(--mizan-bg-light);
  border-color:var(--mizan-border-light);
  color:var(--mizan-text-light);
}
html[data-theme="light"] .question-search-header,
html[data-theme="light"] .question-search-item{
  border-color:var(--mizan-border-light);
}
html[data-theme="light"] .question-search-item:active{
  background:var(--mizan-primary-500-pale);
}
html[data-theme="light"] .question-search-source,
html[data-theme="light"] .custom-exam-book-option small{
  color:var(--mizan-muted-light);
}
