/* =====================================================
   MR. F'S ULTIMATE GRAMMAR GUIDE — STYLESHEET
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #f5f7fa;
  --surface:   #ffffff;
  --border:    #e2e6ed;
  --text:      #1a1f2e;
  --text-soft: #5a6278;
  --text-mute: #8a93a8;
  --navy:      #1e3a5f;

  --blue:      #2563eb; --blue-lt:   #eff6ff; --blue-mid:  #bfdbfe;
  --green:     #16a34a; --green-lt:  #f0fdf4; --green-mid: #bbf7d0;
  --teal:      #0d9488; --teal-lt:   #f0fdfa; --teal-mid:  #99f6e4;
  --amber:     #d97706; --amber-lt:  #fffbeb; --amber-mid: #fde68a;
  --rose:      #e11d48; --rose-lt:   #fff1f2; --rose-mid:  #fecdd3;
  --purple:    #7c3aed; --purple-lt: #f5f3ff; --purple-mid:#ddd6fe;
  --orange:    #ea580c; --orange-lt: #fff7ed;
  --success:   #16a34a;

  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow:    0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10);

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* ── PAGES ────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ── HOME HEADER ─────────────────────────── */
.home-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #1a2d4a 60%, #0f1f35 100%);
  color: white;
  padding: 48px 24px 64px;
  position: relative;
  overflow: hidden;
}
.home-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 40px; background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 40px; flex-wrap: wrap;
}

.header-text { flex: 1; min-width: 280px; }
.header-eyebrow {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: #93c5fd; margin-bottom: 14px;
}
.header-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.15; margin-bottom: 18px; color: #fff;
}
.header-title em { color: #93c5fd; font-style: italic; }
.header-sub { font-size: 1rem; color: rgba(255,255,255,0.72); max-width: 500px; line-height: 1.7; }

.header-avatar-wrap { text-align: center; flex-shrink: 0; }
.avatar-img {
  width: 220px; height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: block;
  object-fit: cover;
}
.avatar-caption { font-size: 0.78rem; color: rgba(255,255,255,0.55); margin-top: 8px; }

/* ── HOME MAIN ───────────────────────────── */
.home-main { max-width: 1100px; margin: 0 auto; padding: 48px 24px 64px; }
.units-intro { margin-bottom: 32px; }
.units-intro h2 { font-family: var(--font-display); font-size: 1.6rem; margin-bottom: 8px; }
.units-intro p { color: var(--text-soft); font-size: 0.95rem; }

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.unit-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative; overflow: hidden;
}
.unit-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--card-color, var(--blue));
  border-radius: 4px 0 0 4px;
}
.unit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--card-color, var(--blue)); }
.unit-card-num { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.unit-card-title { font-family: var(--font-display); font-size: 1.05rem; color: var(--text); line-height: 1.3; margin-bottom: 8px; }
.unit-card-meta { font-size: 0.8rem; color: var(--text-mute); }
.unit-card-arrow { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; color: var(--text-mute); transition: all 0.2s; }
.unit-card:hover .unit-card-arrow { color: var(--card-color, var(--blue)); right: 16px; }

.site-footer { background: #1a1f2e; color: rgba(255,255,255,0.4); text-align: center; padding: 20px; font-size: 0.8rem; }

/* ── EXPLANATION LAYOUT ──────────────────── */
.exp-layout { display: flex; min-height: 100vh; align-items: stretch; }

.exp-sidebar {
  width: 230px; flex-shrink: 0; background: var(--navy); color: white;
  padding: 24px 16px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}

.sidebar-avatar-wrap { text-align: center; padding: 8px 0; }
.avatar-img-small {
  width: 150px; height: auto;
  border-radius: var(--radius); display: block; margin: 0 auto;
  object-fit: cover;
}
.sidebar-unit-label { font-size: 0.72rem; color: rgba(255,255,255,0.5); margin-top: 6px; }

.unit-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.unit-nav-item {
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 0.77rem; color: rgba(255,255,255,0.6); cursor: pointer;
  transition: all 0.15s; border: none; background: none;
  text-align: left; width: 100%; line-height: 1.3;
}
.unit-nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.unit-nav-item.active { background: rgba(147,197,253,0.15); color: #93c5fd; font-weight: 500; }

.exp-main { flex: 1; padding: 40px 48px; max-width: 860px; min-width: 0; }
.exp-header { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 2px solid var(--border); }
.exp-unit-num {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--blue-lt); color: var(--blue);
  padding: 4px 12px; border-radius: 50px; margin-bottom: 12px;
}
.exp-title { font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2.2rem); color: var(--text); line-height: 1.2; }

.exp-footer {
  margin-top: 48px; padding-top: 28px; border-top: 2px solid var(--border);
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.practice-cta-text { color: var(--text-soft); font-size: 0.95rem; }

/* ── EXPLANATION CONTENT ─────────────────── */
.exp-content { line-height: 1.75; }
.exp-content h3 { font-family: var(--font-display); font-size: 1.2rem; color: var(--text); margin: 32px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.exp-content h3:first-child { margin-top: 0; }
.exp-content h4 { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-soft); margin: 20px 0 10px; }
.exp-content p { margin-bottom: 14px; font-size: 0.97rem; }
.exp-content ul, .exp-content ol { padding-left: 22px; margin-bottom: 14px; }
.exp-content li { margin-bottom: 7px; font-size: 0.97rem; }
.exp-content strong { font-weight: 600; }
.exp-content em { font-style: italic; }
.exp-content .note { font-size: 0.88rem; color: var(--text-soft); font-style: italic; background: var(--amber-lt); border-left: 3px solid var(--amber); padding: 8px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 10px 0; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 18px 0; }
.info-card { border-radius: var(--radius); padding: 18px 20px; font-size: 0.93rem; }
.info-card h4 { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; margin-bottom: 10px; margin-top: 0 !important; padding-bottom: 0 !important; border: none !important; }
.info-card.blue  { background: var(--blue-lt);   border: 1px solid var(--blue-mid);   } .info-card.blue h4  { color: var(--blue);   }
.info-card.teal  { background: var(--teal-lt);   border: 1px solid var(--teal-mid);   } .info-card.teal h4  { color: var(--teal);   }
.info-card.green { background: var(--green-lt);  border: 1px solid var(--green-mid);  } .info-card.green h4 { color: var(--green);  }
.info-card.purple{ background: var(--purple-lt); border: 1px solid var(--purple-mid); } .info-card.purple h4{ color: var(--purple); }
.info-card.amber { background: var(--amber-lt);  border: 1px solid var(--amber-mid);  } .info-card.amber h4 { color: var(--amber);  }
.info-card.rose  { background: var(--rose-lt);   border: 1px solid var(--rose-mid);   } .info-card.rose h4  { color: var(--rose);   }
.info-card.orange{ background: var(--orange-lt); border: 1px solid #fed7aa;           } .info-card.orange h4{ color: var(--orange); }

.tense-section { margin: 18px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.tense-header { padding: 10px 18px; font-weight: 700; font-size: 0.88rem; letter-spacing: 0.06em; text-transform: uppercase; color: white; }
.tense-header.green  { background: var(--green);  }
.tense-header.blue   { background: var(--blue);   }
.tense-header.purple { background: var(--purple); }
.tense-header.teal   { background: var(--teal);   }
.tense-header.amber  { background: var(--amber);  }
.tense-header.rose   { background: var(--rose);   }
.tense-header.orange { background: var(--orange); }
.tense-body { padding: 18px 20px; background: var(--surface); }
.tense-body p { margin-bottom: 10px; font-size: 0.95rem; }
.tense-body ul { font-size: 0.93rem; }

.example-block { background: #f8f9fc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; font-size: 0.93rem; }
.example-block p { margin-bottom: 10px; }
.example-block p:last-child { margin-bottom: 0; }
.example-block h4 { color: var(--text); font-size: 0.88rem; margin-bottom: 10px; margin-top: 0 !important; }

.label { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.label.simple   { background: #e0f2fe; color: #0369a1; }
.label.prog     { background: #dcfce7; color: #15803d; }
.label.perf     { background: #f3e8ff; color: #7c3aed; }
.label.perfprog { background: #fff7ed; color: #c2410c; }
.label.good     { background: #dcfce7; color: #15803d; }
.label.bad      { background: #fee2e2; color: #dc2626; }
.label.def      { background: #dbeafe; color: #1d4ed8; }
.label.nondef   { background: #fce7f3; color: #be185d; }

.tense-table-wrap { overflow-x: auto; margin: 18px 0; border-radius: var(--radius); border: 1px solid var(--border); }
.tense-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 460px; }
.tense-table th { background: var(--navy); color: white; padding: 10px 14px; text-align: left; font-weight: 600; font-size: 0.8rem; }
.tense-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.83rem; }
.tense-table tr:last-child td { border-bottom: none; }
.tense-table tr:nth-child(even) td { background: #f8f9fc; }
.tense-table td.row-head { font-family: var(--font-body); font-weight: 600; font-size: 0.85rem; background: #f0f4f8; color: var(--text-soft); font-style: italic; }

.compare-table-wrap { overflow-x: auto; margin: 18px 0; border-radius: var(--radius); border: 1px solid var(--border); }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.compare-table th { padding: 10px 14px; text-align: left; font-weight: 700; font-size: 0.8rem; background: #f0f4f8; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 2px solid var(--border); }
.compare-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.91rem; vertical-align: top; }
.compare-table tr:last-child td { border-bottom: none; }

.academic-box { margin: 28px 0 8px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid #93c5fd; box-shadow: 0 0 0 4px rgba(37,99,235,0.05); }
.academic-label { display: block; background: var(--blue); color: white; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 9px 18px; }
.academic-box-body { background: var(--blue-lt); padding: 18px 20px; font-size: 0.93rem; }
.academic-box-body p { margin-bottom: 10px; }
.academic-box-body p:last-child { margin-bottom: 0; }
.academic-box-body ul { padding-left: 20px; }
.academic-box-body li { margin-bottom: 6px; }

/* ── BUTTONS ──────────────────────────────── */
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1.5px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8); padding: 8px 16px; border-radius: 50px;
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}
.btn-back:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); color: white; }

.exp-layout .btn-back, .practice-topbar .btn-back {
  border-color: var(--border); color: var(--text-soft); background: var(--surface);
}
.exp-layout .btn-back:hover, .practice-topbar .btn-back:hover {
  border-color: var(--blue); color: var(--blue); background: var(--blue-lt);
}

.btn-back-white {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border); color: var(--text-soft); background: var(--surface);
  padding: 12px 22px; border-radius: 50px; font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn-back-white:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-lt); }

.btn-practice {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue); color: white; border: none;
  padding: 12px 26px; border-radius: 50px; font-family: var(--font-body);
  font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
.btn-practice:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,0.35); }

.btn-home {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--navy); color: white; border: none;
  padding: 12px 22px; border-radius: 50px; font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn-home:hover { background: #2a4d7f; transform: translateY(-1px); }

/* ── PRACTICE PAGE ────────────────────────── */
.practice-layout { min-height: 100vh; background: var(--bg); }
.practice-topbar { background: var(--navy); padding: 16px 32px 0; position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow); }
.practice-title-bar { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 8px; }
.practice-unit-label { font-size: 0.85rem; font-weight: 600; color: #93c5fd; }
.practice-q-counter { font-size: 0.8rem; color: rgba(255,255,255,0.5); font-family: var(--font-mono); }
.progress-track { height: 4px; background: rgba(255,255,255,0.12); border-radius: 50px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #34d399); border-radius: 50px; transition: width 0.4s ease; }

.practice-body { max-width: 720px; margin: 0 auto; padding: 40px 24px 60px; }

.question-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow); }
.question-text { font-size: 1.05rem; color: var(--text); line-height: 1.7; margin-bottom: 26px; font-weight: 400; }
.question-text strong { font-weight: 600; }

/* ── MCQ OPTIONS ─────────────────────────── */
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; text-align: left; font-family: var(--font-body);
  font-size: 0.95rem; color: var(--text); cursor: pointer; transition: all 0.15s;
  display: flex; align-items: flex-start; gap: 12px; line-height: 1.5;
}
.option-btn:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-lt); color: var(--blue); }
.option-btn .opt-letter {
  font-size: 0.78rem; font-weight: 700; min-width: 22px; height: 22px;
  background: var(--border); color: var(--text-soft); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  margin-top: 1px; transition: all 0.15s;
}
.option-btn:hover:not(:disabled) .opt-letter { background: var(--blue); color: white; }
.option-btn.correct { border-color: var(--green); background: var(--green-lt); color: var(--green); }
.option-btn.correct .opt-letter { background: var(--green); color: white; }
.option-btn.incorrect { border-color: var(--rose); background: var(--rose-lt); color: var(--rose); }
.option-btn.incorrect .opt-letter { background: var(--rose); color: white; }
.option-btn:disabled { cursor: not-allowed; opacity: 0.75; }
.option-btn.correct:disabled, .option-btn.incorrect:disabled { opacity: 1; }

/* ── FEEDBACK ─────────────────────────────── */
.feedback-wrap { margin-top: 18px; }
.feedback-box { border-radius: var(--radius); padding: 14px 18px; font-size: 0.92rem; line-height: 1.6; display: none; }
.feedback-box.show { display: block; }
.feedback-box.fb-correct { background: var(--green-lt); border: 1px solid var(--green-mid); color: #15803d; }
.feedback-box.fb-hint { background: var(--amber-lt); border: 1px solid var(--amber-mid); color: #92400e; }
.feedback-box .hint-label { font-weight: 700; margin-right: 6px; font-size: 0.82rem; letter-spacing: 0.05em; text-transform: uppercase; }

.btn-next {
  display: none; margin-top: 18px;
  background: var(--teal); color: white; border: none;
  padding: 12px 26px; border-radius: 50px; font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(13,148,136,0.25);
}
.btn-next.show { display: inline-flex; align-items: center; gap: 8px; }
.btn-next:hover { background: #0f766e; transform: translateY(-1px); }

/* ── COMPLETION ───────────────────────────── */
.completion-panel { max-width: 720px; margin: 0 auto; padding: 40px 24px 60px; }
.completion-inner {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-xl); padding: 40px; box-shadow: var(--shadow-lg);
  display: flex; gap: 36px; align-items: flex-start; flex-wrap: wrap;
}
.completion-avatar { width: 160px; height: auto; border-radius: var(--radius-lg); flex-shrink: 0; object-fit: cover; }
.completion-text-wrap { flex: 1; min-width: 240px; }
.completion-title { font-family: var(--font-display); font-size: 1.8rem; color: var(--text); margin-bottom: 10px; }
.completion-score { font-family: var(--font-mono); font-size: 2.2rem; font-weight: 500; color: var(--blue); margin-bottom: 14px; }
.completion-msg { font-size: 0.97rem; color: var(--text-soft); line-height: 1.7; margin-bottom: 24px; }
.completion-btns { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
  .exp-layout { flex-direction: column; }
  .exp-sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; }
  .sidebar-avatar-wrap { display: none; }
  .unit-nav { flex-direction: row; flex-wrap: wrap; }
  .exp-main { padding: 24px 20px; }
  .practice-topbar { padding: 14px 20px 0; }
  .practice-body { padding: 24px 16px 48px; }
  .question-card { padding: 22px 18px; }
  .completion-inner { padding: 24px 20px; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .units-grid { grid-template-columns: 1fr; }
  .header-avatar-wrap { display: none; }
}
@media (max-width: 480px) {
  .completion-avatar { display: none; }
  .completion-btns { flex-direction: column; }
}
