/* === Notion AI Quiz - Design System === */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

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

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f0f1f4;
  --banner: #f2f3f5;
  --text: #1a1a2e;
  --text-dim: #8a8d9a;
  --accent: #8e9aab;
  --accent-warm: #b8a07a;
  --lavender: #8d839e;
  --correct: #7a9e86;
  --wrong: #c45a5a;
  --border: #e6e8ec;
  --btn-start: #9aacbc;
  --btn-export: #8da3b5;
  --btn-email: #a3b0be;
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Layout === */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

/* === Banner (persistent) === */
.banner {
  background: var(--banner);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
}

.banner-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.banner-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* === Screens === */
.screen {
  display: none;
  padding: 40px 0 60px;
}

.screen.active {
  display: block;
}

/* === Login Screen === */
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 40px 32px;
  max-width: 400px;
  margin: 60px auto 0;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  text-align: center;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-group svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-dim);
}

.input-group input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-group input::placeholder {
  color: var(--text-dim);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  color: #fff;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-start {
  background: var(--btn-start);
}

.btn-export {
  background: var(--btn-export);
}

.btn-email {
  background: var(--btn-email);
}

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-alt);
}

.btn-full {
  width: 100%;
}

.btn-login {
  background: var(--btn-start);
  margin-top: 8px;
}

/* === Landing Page === */
.landing-header {
  text-align: center;
  margin-bottom: 36px;
}

.landing-header h1 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.landing-header p {
  font-size: 14px;
  color: var(--text-dim);
}

/* === Category Badges === */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}

.badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
}

.badge-icon {
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  color: var(--accent);
}

.badge-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.badge-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.landing-actions {
  text-align: center;
}

/* === Quiz Screen === */
.progress-bar-container {
  background: var(--surface-alt);
  border-radius: 4px;
  height: 6px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.question-category {
  font-size: 12px;
  font-weight: 600;
  color: var(--lavender);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.question-text {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* === Choice Options === */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  line-height: 1.5;
  transition: border-color 0.2s, background 0.2s;
}

.option-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.option-btn.correct {
  border-color: var(--correct);
  background: #f2f8f4;
}

.option-btn.wrong {
  border-color: var(--wrong);
  background: #fdf4f4;
}

.option-btn.disabled {
  cursor: default;
}

.option-letter {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.option-btn.correct .option-letter {
  background: var(--correct);
  color: #fff;
}

.option-btn.wrong .option-letter {
  background: var(--wrong);
  color: #fff;
}

/* === Multi-select === */
.option-btn.multi .option-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.option-btn.multi.selected .option-check {
  background: var(--accent);
  border-color: var(--accent);
}

.option-btn.multi.selected .option-check::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.multi-submit {
  margin-top: 16px;
}

/* === Free Text === */
.free-text-area {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  resize: vertical;
  margin-bottom: 16px;
}

.free-text-area:focus {
  outline: none;
  border-color: var(--accent);
}

.free-text-area::placeholder {
  color: var(--text-dim);
}

/* === Explanation === */
.explanation-box {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-top: 20px;
  display: none;
}

.explanation-box.visible {
  display: block;
}

.answer-result {
  margin-bottom: 12px;
}

.result-correct {
  font-size: 18px;
  font-weight: 700;
  color: var(--correct);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-wrong {
  font-size: 18px;
  font-weight: 700;
  color: var(--wrong);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.correct-answer-display {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-left: 3px solid var(--correct);
  border-radius: var(--radius-sm);
}

.correct-answer-label {
  font-weight: 700;
  color: var(--correct);
  margin-right: 4px;
}

.explanation-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--lavender);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.explanation-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.model-answer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
}

/* === Self-rating === */
.self-rate-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.self-rate-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.self-rate-btn.got-it {
  background: #f2f8f4;
  border: 1px solid var(--correct);
  color: var(--correct);
}

.self-rate-btn.got-it:hover {
  background: var(--correct);
  color: #fff;
}

.self-rate-btn.missed {
  background: #fdf4f4;
  border: 1px solid var(--wrong);
  color: var(--wrong);
}

.self-rate-btn.missed:hover {
  background: var(--wrong);
  color: #fff;
}

.self-rate-btn.selected {
  color: #fff;
}

.self-rate-btn.got-it.selected {
  background: var(--correct);
}

.self-rate-btn.missed.selected {
  background: var(--wrong);
}

/* === Next Button === */
.next-btn-container {
  text-align: right;
  margin-top: 20px;
  display: none;
}

.next-btn-container.visible {
  display: block;
}

/* === Mastery Report === */
.report-header {
  text-align: center;
  padding: 32px 0;
}

.report-score {
  font-size: 56px;
  font-weight: 300;
  color: var(--text);
  line-height: 1;
}

.report-score span {
  font-size: 24px;
  color: var(--text-dim);
}

.report-detail {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 8px;
}

.report-level {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.report-level.architect { background: #f2f8f4; color: var(--correct); }
.report-level.builder { background: #f5f3ee; color: var(--accent-warm); }
.report-level.explorer { background: #f0f1f6; color: var(--lavender); }
.report-level.starter { background: var(--surface-alt); color: var(--text-dim); }

.report-level-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* === Category Breakdown === */
.breakdown-section {
  margin-top: 36px;
}

.breakdown-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.breakdown-item {
  margin-bottom: 16px;
}

.breakdown-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.breakdown-name {
  font-size: 14px;
  font-weight: 500;
}

.breakdown-score {
  font-size: 13px;
  color: var(--text-dim);
}

.breakdown-bar {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 4px;
}

.breakdown-fill.high { background: var(--correct); }
.breakdown-fill.mid { background: var(--accent-warm); }
.breakdown-fill.low { background: var(--wrong); }

/* === Analysis Cards === */
.analysis-section {
  margin-top: 36px;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.analysis-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.analysis-card ul {
  list-style: none;
  padding: 0;
}

.analysis-card li {
  font-size: 14px;
  line-height: 1.6;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.analysis-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.card-strengths { border-left: 4px solid var(--correct); }
.card-gaps { border-left: 4px solid var(--wrong); }
.card-next { border-left: 4px solid var(--lavender); }

.card-strengths li::before { background: var(--correct); }
.card-gaps li::before { background: var(--wrong); }
.card-next li::before { background: var(--lavender); }

/* === Missed Questions === */
.missed-section {
  margin-top: 36px;
}

.missed-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
}

.missed-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 12px;
}

.missed-q-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--wrong);
  margin-bottom: 4px;
}

.missed-q-text {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.missed-answer {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 4px;
}

.missed-answer strong {
  font-weight: 600;
}

.missed-answer.user-wrong strong {
  color: var(--wrong);
}

.missed-answer.correct-ans strong {
  color: var(--correct);
}

/* === Priority Action Plan === */
.action-plan {
  margin-top: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.action-plan h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.action-step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.action-step:last-child {
  border-bottom: none;
}

.action-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}

.action-text {
  font-size: 14px;
  line-height: 1.6;
  padding-top: 3px;
}

/* === Report Actions === */
.report-actions {
  display: flex;
  gap: 12px;
  margin-top: 36px;
  padding-bottom: 40px;
}

.report-actions .btn {
  flex: 1;
}

/* === Advice Button === */
.btn-advice {
  background: var(--lavender);
  color: #fff;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 26, 46, 0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  z-index: 1000;
  animation: toast-slide-up 0.3s ease;
}

.toast.fade-out {
  animation: toast-fade-out 0.3s ease forwards;
}

@keyframes toast-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-fade-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(16px); }
}

/* === Print / PDF === */
@media print {
  body { background: #fff; }
  .banner { border-bottom: 1px solid #ddd; }
  .btn, .report-actions { display: none !important; }
  .screen.active { padding: 20px 0; }
  .container { max-width: 100%; }
  @page { size: A4; margin: 20mm; }
}

/* === Responsive === */
@media (max-width: 600px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 14px;
  }

  .banner {
    padding: 14px 0;
  }

  .banner-sub {
    font-size: 11px;
  }

  .banner-title {
    font-size: 15px;
  }

  /* Landing */
  .screen {
    padding: 24px 0 48px;
  }

  .landing-header {
    margin-bottom: 24px;
  }

  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .badge {
    padding: 12px 8px;
  }

  .badge-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 6px;
  }

  .badge-name {
    font-size: 11px;
  }

  .badge-count {
    font-size: 10px;
  }

  /* Login */
  .login-card {
    margin-top: 24px;
    padding: 24px 18px;
  }

  .login-card h2 {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .input-group input {
    padding: 11px 11px 11px 38px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Quiz */
  .question-card {
    padding: 18px;
    border-radius: var(--radius-sm);
  }

  .question-category {
    font-size: 11px;
    margin-bottom: 8px;
  }

  .question-text {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 18px;
  }

  .option-btn {
    padding: 12px 14px;
    font-size: 13px;
    gap: 10px;
  }

  .option-letter {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .options-list {
    gap: 8px;
  }

  .free-text-area {
    min-height: 120px;
    font-size: 16px; /* prevents iOS zoom */
    padding: 12px 14px;
  }

  /* Explanation */
  .explanation-box {
    padding: 16px;
    margin-top: 16px;
  }

  .result-correct,
  .result-wrong {
    font-size: 16px;
  }

  .correct-answer-display {
    font-size: 13px;
    padding: 10px 14px;
  }

  .explanation-text {
    font-size: 13px;
  }

  .model-answer {
    padding: 12px;
    font-size: 13px;
  }

  /* Self-rate */
  .self-rate-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .self-rate-btn {
    padding: 11px 14px;
    font-size: 13px;
  }

  /* Report */
  .report-header {
    padding: 24px 0;
  }

  .report-score {
    font-size: 48px;
  }

  .report-score span {
    font-size: 20px;
  }

  .report-level {
    font-size: 13px;
    padding: 6px 16px;
  }

  .breakdown-section h3,
  .missed-section h3,
  .action-plan h3 {
    font-size: 15px;
  }

  .breakdown-name {
    font-size: 13px;
  }

  .breakdown-score {
    font-size: 12px;
  }

  .analysis-card {
    padding: 18px;
  }

  .analysis-card h4 {
    font-size: 13px;
  }

  .analysis-card li {
    font-size: 13px;
  }

  .missed-item {
    padding: 16px;
  }

  .missed-q-text {
    font-size: 13px;
  }

  .missed-answer {
    font-size: 12px;
  }

  .action-plan {
    padding: 18px;
  }

  .action-text {
    font-size: 13px;
  }

  .action-num {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .report-actions {
    flex-direction: column;
    gap: 8px;
  }

  .report-actions .btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
  }

  /* Progress */
  .progress-bar-container {
    margin-bottom: 20px;
  }

  /* Toast */
  .toast {
    left: 14px;
    right: 14px;
    transform: none;
    bottom: 20px;
    text-align: center;
    font-size: 13px;
  }

  @keyframes toast-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes toast-fade-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(16px); }
  }
}

/* === Small phones (iPhone SE etc.) === */
@media (max-width: 375px) {
  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .badge {
    padding: 10px 6px;
  }

  .badge-name {
    font-size: 10px;
  }

  .question-card {
    padding: 14px;
  }

  .question-text {
    font-size: 14px;
  }

  .option-btn {
    padding: 10px 12px;
    font-size: 12px;
  }
}
