/* =====================================================
   OpenAA DMV Practice — Global Styles
   Mobile-first, OpenAA brand (blue #0057b8 / green #4caf00)
   ===================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-dark:   #0046a0;
  --blue:        #0066cc;
  --blue-light:  #1a88e8;
  --green:       #4caf00;
  --green-light: #6ed100;
  --bg:          #f2f4f7;
  --card-bg:     #ffffff;
  --text:        #1a1a2e;
  --text-sub:    #555f70;
  --border:      #e2e6ed;
  --correct:     #1db954;
  --wrong:       #e53e3e;
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   22px;
  --shadow:      0 2px 12px rgba(0,0,0,.09);
  --shadow-lg:   0 6px 24px rgba(0,0,0,.13);
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-light) 100%);
  padding: 16px 20px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-img {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1); /* white on blue header */
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
}
.logo-text span { color: var(--green-light); }

.header-subtitle {
  flex: 1;
  font-size: .78rem;
  color: rgba(255,255,255,.75);
  line-height: 1.3;
}

/* Search bar (visual) */
.header-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 999px;
  padding: 9px 16px;
  gap: 8px;
}
.header-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: .93rem;
  font-family: var(--font);
}
.header-search input::placeholder { color: rgba(255,255,255,.6); }
.header-search .search-icon {
  color: rgba(255,255,255,.7);
  font-size: 1rem;
  flex-shrink: 0;
}

/* ---------- Page Container ---------- */
.page-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-title .icon { font-size: 1.1em; }

/* ---------- Section heading ---------- */
.section-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-sub);
  margin: 20px 0 8px;
}

/* ---------- Divider ---------- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: .92rem;
  padding: 11px 24px;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,102,204,.35);
}
.btn-primary:hover { opacity: .9; text-decoration: none; }

.btn-success {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(76,175,0,.35);
}
.btn-success:hover { opacity: .9; text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 2px solid var(--blue);
}
.btn-outline:hover { background: rgba(0,102,204,.07); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 2px solid var(--border);
}
.btn-ghost:hover { border-color: #c0c8d5; text-decoration: none; }

.btn-danger {
  background: linear-gradient(135deg, #e53e3e 0%, #fc5252 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(229,62,62,.3);
}

.btn-lg { font-size: 1.05rem; padding: 14px 32px; }
.btn-sm { font-size: .82rem; padding: 7px 16px; }
.btn-block { width: 100%; }

/* ---------- Mode cards (index) ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, box-shadow .15s, background .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:hover,
.mode-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,102,204,.12);
  background: rgba(0,102,204,.04);
}
.mode-card .mode-icon { font-size: 2rem; margin-bottom: 6px; }
.mode-card .mode-name { font-weight: 700; font-size: .93rem; color: var(--text); }
.mode-card .mode-desc { font-size: .77rem; color: var(--text-sub); margin-top: 3px; line-height: 1.3; }

/* ---------- Form controls ---------- */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.form-row:last-child { border-bottom: none; padding-bottom: 0; }
.form-row:first-child { padding-top: 0; }

.form-label {
  font-size: .9rem;
  color: var(--text);
  font-weight: 500;
  flex: 1;
}
.form-label .sub { font-size: .75rem; color: var(--text-sub); display: block; }

.form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: .88rem;
  font-family: var(--font);
  padding: 7px 10px;
  min-width: 100px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555f70' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.form-select:focus { border-color: var(--blue); }

.form-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: .88rem;
  font-family: var(--font);
  padding: 7px 10px;
  width: 80px;
  outline: none;
  text-align: center;
}
.form-input:focus { border-color: var(--blue); }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; }
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cdd2db;
  border-radius: 999px;
  transition: background .2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Progress bar ---------- */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
  border-radius: 999px;
  transition: width .3s ease;
}

.progress-label {
  font-size: .78rem;
  color: var(--text-sub);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ---------- Timer ---------- */
.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff3cd;
  color: #856404;
  border: 1.5px solid #ffc107;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: .88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timer-badge.urgent {
  background: #ffe0e0;
  color: #c0392b;
  border-color: var(--wrong);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* ---------- Question card ---------- */
.question-number {
  font-size: .78rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 18px;
  color: var(--text);
}

/* ---------- Options ---------- */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .13s, background .13s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.option-item:hover:not(.disabled) {
  border-color: var(--blue);
  background: rgba(0,102,204,.04);
}
.option-item.selected {
  border-color: var(--blue);
  background: rgba(0,102,204,.08);
}
.option-item.correct {
  border-color: var(--correct);
  background: rgba(29,185,84,.09);
}
.option-item.wrong {
  border-color: var(--wrong);
  background: rgba(229,62,62,.08);
}
.option-item.disabled { cursor: default; }

.option-letter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-sub);
  margin-top: 1px;
}
.option-item.selected .option-letter { color: var(--blue); border-color: var(--blue); }
.option-item.correct .option-letter  { color: var(--correct); border-color: var(--correct); }
.option-item.wrong   .option-letter  { color: var(--wrong);   border-color: var(--wrong); }

.option-text {
  font-size: .92rem;
  line-height: 1.45;
  color: var(--text);
  flex: 1;
}

/* ---------- Explanation ---------- */
.explanation-box {
  background: #f0f7ff;
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: .88rem;
  line-height: 1.55;
  color: var(--text);
  display: none;
}
.explanation-box.show { display: block; }
.explanation-box strong { color: var(--blue); }

/* ---------- Nav buttons (quiz) ---------- */
.quiz-nav {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}
.quiz-nav .btn { flex: 1; }
.quiz-nav .btn-ghost { flex: 0 0 auto; }

/* ---------- Score summary (result) ---------- */
.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 4px;
}
.score-ring {
  position: relative;
  width: 120px;
  height: 120px;
}
.score-ring svg {
  transform: rotate(-90deg);
  width: 120px;
  height: 120px;
}
.score-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.ring-bg    { stroke: #e8edf3; }
.ring-fill  { stroke: var(--blue); transition: stroke-dashoffset 1s ease; }
.ring-pass  { stroke: var(--correct); }
.ring-fail  { stroke: var(--wrong); }

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-pct  { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text); }
.score-frac { font-size: .78rem; color: var(--text-sub); margin-top: 2px; }

.score-verdict {
  margin-top: 10px;
  font-size: 1.1rem;
  font-weight: 700;
}
.score-verdict.pass { color: var(--correct); }
.score-verdict.fail { color: var(--wrong); }

.score-stats {
  display: flex;
  gap: 0;
  width: 100%;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.stat-item {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-val  { font-size: 1.35rem; font-weight: 800; }
.stat-lbl  { font-size: .72rem; color: var(--text-sub); margin-top: 1px; }
.stat-correct { color: var(--correct); }
.stat-wrong   { color: var(--wrong); }
.stat-skip    { color: #f59e0b; }

/* ---------- Wrong list ---------- */
.wrong-list { list-style: none; }
.wrong-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.wrong-item:last-child { border-bottom: none; }

.wrong-q { font-size: .92rem; font-weight: 600; margin-bottom: 8px; line-height: 1.45; }
.wrong-answers { display: flex; flex-direction: column; gap: 5px; font-size: .83rem; }
.wa-row { display: flex; align-items: baseline; gap: 6px; }
.wa-label { font-weight: 700; min-width: 55px; flex-shrink: 0; }
.wa-correct-lbl { color: var(--correct); }
.wa-wrong-lbl   { color: var(--wrong); }
.wa-text        { color: var(--text); line-height: 1.4; }

.wrong-explain {
  background: #f0f7ff;
  border-left: 3px solid var(--blue);
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.5;
}

/* Collapsible */
.collapsible-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  font-weight: 700;
  font-size: .92rem;
  color: var(--blue);
  padding: 4px 0;
  margin-bottom: 4px;
}
.collapsible-btn .caret { transition: transform .2s; }
.collapsible-btn.open .caret { transform: rotate(90deg); }
.collapsible-content { display: none; }
.collapsible-content.open { display: block; }

/* ---------- Result action buttons ---------- */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  font-size: .73rem;
  color: var(--text-sub);
  padding: 24px 20px 32px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.site-footer a { color: var(--text-sub); }

/* ---------- Utility ---------- */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-sub); }
.mt-0  { margin-top: 0 !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.gap-8 { gap: 8px; }

.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(26,26,46,.92);
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 9999;
  transition: transform .3s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Tablet / Desktop ---------- */
@media (min-width: 600px) {
  .page-wrap { padding: 28px 24px 80px; }
  .card { padding: 24px 28px; }
  .question-text { font-size: 1.12rem; }
  .mode-grid { gap: 16px; }
}

@media (min-width: 768px) {
  .result-actions { flex-direction: row; }
  .result-actions .btn { flex: 1; }
}
/* ---------- Image modal ---------- */
.img-modal.hidden { display: none; }
.img-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.82);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.img-modal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,.35);
  color: #fff;
}
.img-modal-title {
  font-weight: 800;
  font-size: .95rem;
  opacity: .95;
}
.img-modal-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
}
.img-modal-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
  background: #fff;
}

/* view image button (on white card) */
.view-img-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  margin: 10px 0 0;          /* 题干下面留点空 */
  padding: 8px 12px;
  font-size: .82rem;
  border-radius: 999px;

  border: 2px solid var(--blue);
  background: #fff;
  color: var(--blue);

  cursor: pointer;
}

.view-img-btn:hover { background: rgba(0,102,204,.07); }
/* ---------- Desktop optimization ---------- */
@media (min-width: 1024px) {
  /* 让内容区更宽一点，减少左右空白 */
  .page-wrap,
  .header-inner {
    max-width: 920px;
  }

  /* 头部更薄一些，减少占用高度 */
  .site-header {
    padding: 10px 20px 12px;
  }
  .header-top {
    margin-bottom: 10px;
  }

  /* 卡片更紧凑，让更多内容一屏显示 */
  .card {
    padding: 18px 22px;
  }
  .question-text {
    font-size: 1.08rem;
    margin-bottom: 12px;
  }

  /* 选项更紧凑 */
  .option-item {
    padding: 10px 12px;
  }

  /* 底部导航按钮更容易点到，并且不要太占高度 */
  .quiz-nav .btn {
    padding: 10px 18px;
  }
}
/* ---------- Index page (desktop) tuning ---------- */
@media (min-width: 768px) {
  /* 首页顶部大蓝卡：缩小高度与字体（覆盖 index.html 内联 style） */
  body > main.page-wrap > .card:first-child {
    padding: 18px 18px !important;
  }
  body > main.page-wrap > .card:first-child > div:first-child {
    font-size: 1.6rem !important;   /* 🚗 图标 */
    margin-bottom: 6px !important;
  }
  body > main.page-wrap > .card:first-child h1 {
    font-size: 1.1rem !important;
    margin-bottom: 4px !important;
  }
  body > main.page-wrap > .card:first-child p {
    font-size: .85rem !important;
    line-height: 1.45 !important;
  }

  /* 模式选择卡片更紧凑 */
  .mode-card {
    padding: 14px 12px;
  }
  .mode-card .mode-icon {
    font-size: 1.6rem;
    margin-bottom: 4px;
  }

  /* 让内容区在电脑端稍微更宽一点 */
  .page-wrap,
  .header-inner {
    max-width: 920px;
  }
}