/* ============================================================
   ICT583 Exam Revision – Clean Study Theme
   White background · Black text · Red/Yellow only for important
   Fully responsive – optimized for mobile exam revision
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* --- Design Tokens --- */
:root {
  --bg:         #ffffff;
  --bg-subtle:  #f8f8f8;
  --bg-card:    #ffffff;
  --border:     #e0e0e0;
  --border-dark:#c0c0c0;
  --text:       #111111;
  --text-muted: #555555;
  --text-light: #888888;

  /* Accent – ONLY for important/formula/note content */
  --red:        #cc0000;
  --red-bg:     #fff5f5;
  --red-border: #ffcccc;
  --yellow:     #b36a00;
  --yellow-bg:  #fffbf0;
  --yellow-border: #ffd980;

  --radius:     6px;
  --radius-lg:  10px;
  --shadow:     0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 2px 8px rgba(0,0,0,0.12);
}

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

/* --- Base --- */
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
nav {
  background: var(--bg);
  border-bottom: 2px solid var(--text);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.nav-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 0.75rem;
}

.nav-home {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.75rem 0.75rem 0.75rem 0;
  margin-right: 0.5rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.nav-home:hover { color: var(--red); }

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.45rem;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

nav a:hover { color: var(--text); border-bottom-color: var(--border-dark); }
nav a.active { color: var(--red); border-bottom-color: var(--red); }

/* Mobile nav scrolling */
@media (max-width: 600px) {
  .nav-inner {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 0 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-inner::-webkit-scrollbar { display: none; }
  nav a { font-size: 0.75rem; padding: 0.55rem 0.4rem; }
  .nav-home { font-size: 0.85rem; }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  padding: 1.5rem 0 1.25rem;
  border-bottom: 2px solid var(--text);
  margin-bottom: 1.75rem;
}

.lec-num {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

h1 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* ============================================================
   HEADINGS
   ============================================================ */
h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1.5px solid var(--border);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.25rem 0 0.4rem;
}

h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.9rem 0 0.3rem;
}

/* ============================================================
   BODY TEXT
   ============================================================ */
p {
  margin-bottom: 0.65rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}
p strong { color: var(--text); }

ul, ol {
  padding-left: 1.3rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}
li { margin-bottom: 0.3rem; }
li strong { color: var(--text); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}

/* Important card – red border */
.card.important,
.card.red {
  border-color: var(--red-border);
  background: var(--red-bg);
  border-left: 4px solid var(--red);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

/* Note card – yellow border */
.card.note,
.card.yellow {
  border-color: var(--yellow-border);
  background: var(--yellow-bg);
  border-left: 4px solid var(--yellow);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

/* Info card – subtle bg */
.card.blue,
.card.green {
  background: var(--bg-subtle);
  border-color: var(--border-dark);
}

/* ============================================================
   ALERT BOXES
   ============================================================ */
/* General alert – yellow (important info) */
.alert {
  background: var(--yellow-bg);
  border: 1.5px solid var(--yellow-border);
  border-left: 4px solid var(--yellow);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.7rem 1rem;
  margin: 0.85rem 0;
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 500;
}
.alert strong { color: var(--yellow); }

/* Info box – plain bordered */
.info {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-left: 4px solid var(--text);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.7rem 1rem;
  margin: 0.85rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   FORMULA BLOCKS  ← RED = important to memorize
   ============================================================ */
.formula-block {
  background: var(--red-bg);
  border: 1.5px solid var(--red-border);
  border-left: 4px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
}

.formula-block .f {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  color: var(--red);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.formula-block .fl {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  word-break: break-all;
}

.formula-block .vars {
  color: var(--yellow);
  font-size: 0.83rem;
  margin-top: 0.25rem;
  font-style: italic;
}

.formula-block .note {
  color: var(--text-muted);
  font-size: 0.83rem;
  margin-top: 0.2rem;
}

/* ============================================================
   DEFINITION BLOCKS
   ============================================================ */
.def {
  border-left: 3px solid var(--text);
  padding: 0.5rem 0.9rem;
  margin: 0.4rem 0;
  background: var(--bg-subtle);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
}

.def .term {
  font-weight: 700;
  color: var(--text);
}

.def .meaning {
  color: var(--text-muted);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.7rem 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  margin: 0.7rem 0;
  min-width: 300px;
}

th {
  background: var(--text);
  color: #ffffff;
  padding: 0.5rem 0.7rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

td {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

tr:nth-child(even) td { background: var(--bg-subtle); }
td strong { color: var(--text); }

/* Make tables scrollable on mobile */
@media (max-width: 600px) {
  table { font-size: 0.82rem; }
  th, td { padding: 0.4rem 0.55rem; }
}

/* ============================================================
   GRIDS
   ============================================================ */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 640px) {
  .grid2, .grid3, .two-col {
    grid-template-columns: 1fr;
  }
  h1 { font-size: 1.35rem; }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.badge-red {
  background: var(--red);
  color: #ffffff;
}

.badge-yellow {
  background: var(--yellow);
  color: #ffffff;
}

.badge-green {
  background: #1a7a3c;
  color: #ffffff;
}

.badge-blue {
  background: #1a5276;
  color: #ffffff;
}

/* ============================================================
   STEPS / NUMBERED LISTS
   ============================================================ */
.steps { counter-reset: step; margin: 0.5rem 0; }

.step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  font-size: 0.91rem;
  color: var(--text-muted);
}

.step::before {
  counter-increment: step;
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  background: var(--text);
  color: #ffffff;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.step strong { color: var(--text); }

/* ============================================================
   SUMMARY BOX (end-of-lecture quick revision)
   ============================================================ */
.summary-box {
  background: var(--yellow-bg);
  border: 1.5px solid var(--yellow-border);
  border-top: 4px solid var(--yellow);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  margin: 2rem 0 0.5rem;
}

.summary-box h3 {
  color: var(--yellow);
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-box p { font-size: 0.91rem; color: var(--text); }
.summary-box strong { color: var(--red); }

/* ============================================================
   MCQ SECTION
   ============================================================ */
.mcq-section h2 {
  border-bottom-color: var(--border);
}

.mcq {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.mcq:hover { box-shadow: var(--shadow-md); }

.mcq .question {
  color: var(--text);
  font-size: 0.93rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
  line-height: 1.5;
}

.mcq .options {
  padding-left: 0;
  list-style: none;
}

.mcq .options li {
  padding: 0.35rem 0.7rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  cursor: default;
  transition: background 0.12s;
}

.mcq .options li:hover { background: #f0f0f0; }

/* Answer reveal */
details.answer {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

details.answer summary {
  cursor: pointer;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

details.answer summary::-webkit-details-marker { display: none; }

details.answer summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

details[open].answer summary::before { transform: rotate(90deg); }

details.answer .ans-body {
  margin-top: 0.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-dark);
  border-left: 4px solid #1a7a3c;
  border-radius: 0 var(--radius) var(--radius) 0;
}

details.answer .correct {
  color: #1a7a3c;
  font-weight: 700;
  font-size: 0.93rem;
  margin-bottom: 0.35rem;
}

details.answer .explanation {
  color: var(--text-muted);
  font-size: 0.87rem;
  margin: 0;
}

/* ============================================================
   HOME PAGE LECTURE CARDS
   ============================================================ */
.lec-card {
  display: block;
  text-decoration: none;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
  box-shadow: var(--shadow);
}

.lec-card:hover {
  border-color: var(--text);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.lec-card:active { transform: translateY(0); }

.lec-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.lec-card-desc {
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.4;
}

.lec-card.formula-card {
  border-color: var(--red-border);
  background: var(--red-bg);
  border-left: 4px solid var(--red);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.lec-card.formula-card .lec-card-title { color: var(--red); }

/* ============================================================
   KEY DISTINCTIONS TABLE
   ============================================================ */
.distinctions-table td:first-child strong { color: var(--text); }
.distinctions-table td:nth-child(3) { color: var(--text-muted); font-size: 0.84rem; }

/* ============================================================
   CONFIRMED ANSWERS SECTION
   ============================================================ */
.answers-list {
  padding-left: 0;
  list-style: none;
}

.answers-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.answers-list li:last-child { border-bottom: none; }

.answers-list li::before {
  content: '→';
  color: var(--text-light);
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.answers-list li strong { color: var(--red); }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-light);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ============================================================
   PRINT OPTIMIZATIONS
   ============================================================ */
@media print {
  nav { display: none; }
  .container { padding: 0; }
  details.answer[open] .ans-body { display: block; }
  .formula-block { border: 1px solid #999; background: #f8f8f8; }
  .alert { border: 1px solid #999; background: #f8f8f8; }
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-red    { color: var(--red) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-muted  { color: var(--text-muted) !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
