/*
  QCM CORVNI & SRC
  Clean stylesheet structure:
  1. Design tokens
  2. Base layout
  3. Header and navigation
  4. Buttons and switches
  5. Quiz sections and cards
  6. Answer options and feedback
  7. Responsive rules
  8. Animations and accessibility
  9. About page
*/

/* 1. Design tokens */
:root {
  --accent: #6390f1;
  --accent-strong: #7aa3ff;
  --accent-deep: #315fc7;
  --purple: #8c6cf4;
  --success: #55c879;
  --danger: #ff6464;

  --text-dark: #eef2ff;
  --text-light: #111827;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-soft: 0 18px 60px rgba(0, 0, 0, 0.22);
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.16);

  --header-offset: 98px;
  --page-width: 1120px;
}

/* 2. Base layout */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-offset);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.dark-mode {
  background:
    radial-gradient(circle at top left, rgba(99, 144, 241, 0.24), transparent 34rem),
    linear-gradient(135deg, #0d111b 0%, #151927 45%, #0b0d13 100%);
  color: var(--text-dark);
}

body.light-mode {
  background:
    radial-gradient(circle at top left, rgba(99, 144, 241, 0.18), transparent 32rem),
    linear-gradient(135deg, #f6f8ff 0%, #eef2fb 48%, #ffffff 100%);
  color: var(--text-light);
}

.app-shell {
  width: min(var(--page-width), calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 42px;
}

.container {
  display: grid;
  gap: 34px;
  padding-bottom: 36px;
}

/* 3. Header and navigation */
.site-header {
  position: sticky;
  top: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  border: 1px solid;
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.dark-mode .site-header {
  background: rgba(20, 25, 39, 0.86);
  border-color: rgba(255, 255, 255, 0.09);
}

.light-mode .site-header {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(17, 24, 39, 0.08);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: clamp(1rem, 1.6vw, 1.22rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.64;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.header-actions,
.section-nav,
.practice-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions,
.section-nav {
  flex-wrap: nowrap;
  min-width: 0;
}

.practice-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(99, 144, 241, 0.32);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(99, 144, 241, 0.10);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.dark-mode .section-nav a {
  background: rgba(99, 144, 241, 0.12);
  color: #bcd0ff;
}

.light-mode .section-nav a {
  background: rgba(99, 144, 241, 0.11);
  color: var(--accent-deep);
}

/* 4. Buttons and switches */
button {
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  padding: 7px 13px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.dark-mode button {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dark);
}

.light-mode button {
  background: rgba(17, 24, 39, 0.06);
  color: var(--text-light);
}

button.active,
.toggle-practice.active {
  background: var(--accent);
  color: #fff;
}

.control-button.secondary {
  opacity: 1;
}

.control-button.secondary:disabled,
.control-button.secondary.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.segmented-control {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
}

.switch-control {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  gap: 0;
  border: 1px solid transparent;
}

.dark-mode .switch-control {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.08);
}

.light-mode .switch-control {
  background: rgba(17, 24, 39, 0.06);
  border-color: rgba(17, 24, 39, 0.07);
}

.switch-control::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 2);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  box-shadow: 0 8px 18px rgba(99, 144, 241, 0.28);
  transition: transform 0.24s cubic-bezier(.2, .8, .2, 1), box-shadow 0.24s ease;
}

.switch-control[data-active="fr"]::before,
.switch-control[data-active="light"]::before {
  transform: translateX(100%);
}

.switch-control button {
  position: relative;
  z-index: 1;
  min-width: 52px;
  min-height: 30px;
  padding: 5px 10px;
  background: transparent !important;
  color: inherit;
  transition: color 0.18s ease, opacity 0.18s ease, transform 0.16s ease;
}

.switch-control button.active {
  color: #fff;
}

.switch-control button:not(.active) {
  opacity: 0.72;
}

.toggle-practice {
  padding-inline: 15px;
}

/* 5. Quiz sections and cards */
.quiz-section {
  scroll-margin-top: var(--header-offset);
  padding: 4px 0 10px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.practice-heading {
  align-items: center;
}

h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

#corvni-questions,
#src-questions,
#practice-questions {
  display: grid;
  gap: 16px;
}

.question,
.empty-state {
  border: 1px solid;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.dark-mode .question,
.dark-mode .empty-state {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.08);
}

.light-mode .question,
.light-mode .empty-state {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(17, 24, 39, 0.07);
}

.question-meta {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 10px;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(99, 144, 241, 0.14);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.question-text {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 750;
}

.empty-state {
  text-align: center;
}

.empty-state h4 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0;
  opacity: 0.72;
}

/* 6. Answer options and feedback */
.options {
  display: grid;
  gap: 9px;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.options li {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.dark-mode .options li {
  background: rgba(255, 255, 255, 0.045);
}

.light-mode .options li {
  background: rgba(17, 24, 39, 0.035);
}

label,
.options label {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 0.98rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.option-checkbox {
  appearance: none;
  position: relative;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid;
  border-radius: 50%;
  cursor: pointer;
}

.dark-mode .option-checkbox {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.28);
}

.light-mode .option-checkbox {
  background-color: rgba(255, 255, 255, 0.8);
  border-color: rgba(17, 24, 39, 0.25);
}

.option-checkbox:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.option-checkbox:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
}

.option-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.correct {
  color: var(--success);
}

.incorrect {
  color: var(--danger);
}

.options li.correct-answer {
  background: rgba(76, 175, 80, 0.16);
  border-color: rgba(76, 175, 80, 0.32);
}

.options li.incorrect-answer {
  background: rgba(244, 67, 54, 0.16);
  border-color: rgba(244, 67, 54, 0.32);
}

.light-mode .options li.correct-answer {
  background: rgba(76, 175, 80, 0.14);
}

.light-mode .options li.incorrect-answer {
  background: rgba(244, 67, 54, 0.13);
}

/* 7. Responsive rules */
@media (max-width: 900px) {
  :root {
    --header-offset: 116px;
  }

  .site-header {
    top: 6px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .brand {
    width: 100%;
  }

  .header-controls {
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .header-controls::-webkit-scrollbar {
    display: none;
  }

  .section-nav,
  .header-actions {
    flex: 0 0 auto;
  }
}

@media (max-width: 780px) {
  :root {
    --header-offset: 122px;
  }

  .app-shell {
    width: min(100% - 18px, var(--page-width));
    padding-top: 8px;
  }

  .site-header {
    margin-bottom: 22px;
    border-radius: 20px;
    padding: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 11px;
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-subtitle {
    font-size: 0.64rem;
  }

  button,
  .section-nav a {
    min-height: 33px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .switch-control button {
    min-height: 28px;
    padding: 5px 8px;
  }

  .section-heading,
  .practice-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .practice-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .practice-actions button {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  .question,
  .empty-state {
    border-radius: 14px;
    padding: 14px;
  }

  .question-text {
    font-size: 1rem;
  }

  .options li {
    padding: 9px;
  }
}

@media (max-width: 420px) {
  :root {
    --header-offset: 118px;
  }

  .section-nav a,
  .header-actions button {
    padding-inline: 9px;
    font-size: 0.76rem;
  }

  .brand-title {
    font-size: 0.94rem;
  }

  .practice-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}


@media (orientation: landscape) and (max-height: 520px) {
  .question-text,
  .options label {
    font-size: 0.98rem;
  }
}

/* 8. Animations and accessibility */
@media (hover: hover) and (pointer: fine) {
  .section-nav a:hover,
  button:hover {
    transform: translateY(-1px);
  }

  .dark-mode button:hover {
    background: rgba(255, 255, 255, 0.14);
  }

  .light-mode button:hover {
    background: rgba(17, 24, 39, 0.12);
  }

  .dark-mode .section-nav a:hover,
  .light-mode .section-nav a:hover {
    background: rgba(99, 144, 241, 0.22);
    border-color: rgba(99, 144, 241, 0.52);
  }

  .dark-mode button.active:hover,
  .light-mode button.active:hover,
  .dark-mode .toggle-practice.active:hover,
  .light-mode .toggle-practice.active:hover {
    background: var(--accent-strong);
    color: #fff;
  }

  .switch-control:hover::before {
    box-shadow: 0 10px 22px rgba(99, 144, 241, 0.36);
  }

  .dark-mode .switch-control button:hover,
  .light-mode .switch-control button:hover {
    background: transparent !important;
  }

  .options li:has(.option-checkbox:not(:disabled)):hover {
    transform: translateY(-1px);
  }
}

button:active,
.section-nav a:active {
  transform: translateY(0);
}

button:focus-visible,
.section-nav a:focus-visible,
.option-checkbox:focus-visible {
  outline: 3px solid rgba(99, 144, 241, 0.45);
  outline-offset: 3px;
}

@keyframes sectionButtonClick {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 0 0 rgba(99, 144, 241, 0);
  }
  45% {
    transform: translateY(1px) scale(0.965);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 0 0 6px rgba(99, 144, 241, 0.14);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 0 0 0 rgba(99, 144, 241, 0);
  }
}

@keyframes resetButtonClick {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 rgba(99, 144, 241, 0);
  }
  45% {
    transform: translateY(1px) scale(0.955);
    box-shadow: 0 0 0 7px rgba(99, 144, 241, 0.16);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(99, 144, 241, 0);
  }
}

.section-nav a.nav-clicking {
  animation: sectionButtonClick 0.24s ease-out;
}

#reset.reset-clicking,
.practice-actions button.practice-clicking {
  animation: resetButtonClick 0.22s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* 9. About page */
.about-page .quiz-section {
  max-width: 860px;
  margin: 0 auto;
}

.about-card {
  margin-top: 10px;
}

.about-card p {
  margin: 0;
}

.about-card p + p {
  margin-top: 10px;
}
