/* ICT582 Python Revision — style.css */

:root {
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #b45309;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info-light: #e0f2fe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Courier New', Courier, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --t: 0.15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.65;
  font-size: 15px;
}

/* === TYPOGRAPHY === */
h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.2rem; font-weight: 600; line-height: 1.3; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.4rem; }
p { margin-bottom: 0.65rem; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.3rem; margin-bottom: 0.65rem; }
li { margin-bottom: 0.3rem; }
strong { font-weight: 600; }
a { color: var(--primary); }

/* === PROGRESS BAR TOP === */
.progress-bar-global { height: 3px; background: var(--gray-200); position: sticky; top: 0; z-index: 300; }
.progress-bar-fill { height: 100%; background: var(--success); transition: width 0.6s ease; }

/* === HEADER === */
header {
  background: var(--primary);
  color: white;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 3px;
  z-index: 200;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.header-brand {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: white; flex-shrink: 0;
}
.header-brand .badge {
  background: rgba(255,255,255,0.22);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.header-brand .name {
  font-size: 0.92rem; font-weight: 600;
}

.header-search { flex: 1; max-width: 340px; }
.header-search input {
  width: 100%;
  padding: 0.38rem 0.75rem;
  border: none; border-radius: var(--radius);
  font-size: 0.88rem;
  background: rgba(255,255,255,0.18); color: white; outline: none;
}
.header-search input::placeholder { color: rgba(255,255,255,0.55); }
.header-search input:focus { background: rgba(255,255,255,0.28); }

.header-nav { margin-left: auto; flex-shrink: 0; }
.header-nav a {
  color: rgba(255,255,255,0.82); text-decoration: none;
  font-size: 0.85rem; padding: 0.28rem 0.6rem;
  border-radius: var(--radius); transition: background var(--t);
}
.header-nav a:hover { background: rgba(255,255,255,0.15); color: white; }

/* === MAIN LAYOUT === */
main { max-width: 1080px; margin: 0 auto; padding: 1.5rem; }

/* === HOMEPAGE HERO === */
.hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}
.hero h1 { color: var(--primary); margin-bottom: 0.4rem; }
.hero .sub { color: var(--gray-600); font-size: 0.92rem; margin-bottom: 1rem; }

.progress-pill {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  padding: 0.5rem 1.1rem;
  border-radius: 100px;
  font-size: 0.88rem; color: var(--gray-700);
  box-shadow: var(--shadow);
}
.progress-pill strong { color: var(--primary); }

.search-hint {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  min-height: 1.4rem;
}

/* === TOPIC GRID === */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 1rem;
}

.topic-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 0.45rem;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  box-shadow: var(--shadow);
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #93c5fd;
}
.topic-card.completed { border-left: 4px solid var(--success); }

.card-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 0.5rem;
}
.topic-num {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  background: var(--primary-light); color: var(--primary);
  padding: 0.18rem 0.45rem; border-radius: 4px;
}
.topic-card.completed .topic-num { background: var(--success-light); color: var(--success); }
.check { color: var(--success); font-size: 1rem; display: none; }
.topic-card.completed .check { display: block; }

.topic-card h3 { font-size: 0.97rem; color: var(--gray-900); }
.topic-card p { font-size: 0.84rem; color: var(--gray-600); flex: 1; margin-bottom: 0; }
.card-link { font-size: 0.8rem; color: var(--primary); font-weight: 500; margin-top: 0.3rem; }
.topic-card.completed .card-link { color: var(--success); }
.topic-card[hidden] { display: none; }

/* === TOPIC PAGE === */
.breadcrumb { font-size: 0.83rem; color: var(--gray-500); margin-bottom: 1.1rem; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.page-header {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.page-header .label {
  font-size: 0.75rem; font-weight: 700;
  color: var(--primary); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.3rem;
}
.page-header h1 { margin-bottom: 0.4rem; }
.page-header .sub { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 1rem; }

.btn-complete {
  padding: 0.48rem 1.2rem;
  background: var(--primary); color: white;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 0.88rem; font-weight: 500;
  transition: background var(--t);
}
.btn-complete:hover { background: var(--primary-hover); }
.btn-complete.done { background: var(--success); }

/* === SECTIONS === */
.section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.sec-title {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.97rem; font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--gray-100);
}

/* Objectives */
.obj-list { list-style: none; padding: 0; }
.obj-list li {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}
.obj-list li:last-child { border-bottom: none; }
.obj-list li::before { content: '→'; color: var(--primary); font-weight: 700; flex-shrink: 0; }

/* Concept cards */
.concept {
  background: var(--gray-50);
  border-left: 3px solid var(--primary);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 0.75rem;
}
.concept:last-child { margin-bottom: 0; }
.concept h3 { font-size: 0.93rem; color: var(--primary); margin-bottom: 0.3rem; }
.concept p, .concept ul, .concept ol { font-size: 0.87rem; color: var(--gray-700); margin-bottom: 0.4rem; }
.concept p:last-child, .concept ul:last-child { margin-bottom: 0; }

/* Code */
pre, code { font-family: var(--mono); }
pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.75;
  margin: 0.65rem 0;
}
code {
  background: var(--gray-100); color: #b91c1c;
  padding: 0.1em 0.3em;
  border-radius: 3px; font-size: 0.87em;
}
pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
.code-caption { font-size: 0.76rem; color: var(--gray-500); margin-bottom: 0.2rem; font-weight: 500; }

/* Syntax highlighting in pre (CSS-only comments) */
.cm { color: #64748b; } /* comment */
.kw { color: #7dd3fc; } /* keyword */
.st { color: #86efac; } /* string */
.nu { color: #fbbf24; } /* number */
.fn { color: #f9a8d4; } /* function name */
.bi { color: #c4b5fd; } /* built-in */

/* Exam box */
.exam-box {
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  margin-bottom: 1rem;
}
.exam-box .sec-title { border-bottom-color: #fcd34d; color: var(--warning); }
.exam-box ol { font-size: 0.9rem; color: var(--gray-800); }
.exam-box li { margin-bottom: 0.45rem; }

/* Mistakes box */
.mistakes-box {
  background: var(--danger-light);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  margin-bottom: 1rem;
}
.mistakes-box .sec-title { border-bottom-color: #fca5a5; color: var(--danger); }
.mistakes-box ul { font-size: 0.9rem; color: var(--gray-800); }
.mistakes-box li { margin-bottom: 0.45rem; }

/* Recap box */
.recap-box {
  background: var(--success-light);
  border: 1px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  margin-bottom: 1rem;
}
.recap-box .sec-title { border-bottom-color: #86efac; color: var(--success); }
.recap-list { list-style: none; padding: 0; }
.recap-list li {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.3rem 0; font-size: 0.9rem; color: var(--gray-800);
}
.recap-list li::before { content: '✓'; color: var(--success); font-weight: 700; flex-shrink: 0; }

/* === NAVIGATION === */
.topic-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.nav-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  text-decoration: none; color: var(--gray-700);
  font-size: 0.88rem; font-weight: 500;
  transition: all var(--t); box-shadow: var(--shadow);
}
.nav-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.nav-btn.disabled { color: var(--gray-300); pointer-events: none; }

/* === TABLE === */
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; margin: 0.65rem 0; }
th {
  background: var(--gray-100); font-weight: 600;
  text-align: left; padding: 0.45rem 0.7rem;
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-700);
}
td { padding: 0.42rem 0.7rem; border-bottom: 1px solid var(--gray-100); }
tr:hover td { background: var(--gray-50); }

/* === QUICK REVISION TOGGLE === */
.revision-toggle {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  background: var(--primary); color: white;
  border: none; padding: 0.55rem 1rem;
  border-radius: 100px; font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.35);
  z-index: 150; transition: background var(--t);
}
.revision-toggle:hover { background: var(--primary-hover); }

body.revision-mode .section:not(.section-recap):not(.section-exam) { display: none !important; }

/* === PRINT === */
@media print {
  header, .btn-complete, .revision-toggle, .topic-nav, .progress-bar-global { display: none !important; }
  body { background: white; }
  .section, .exam-box, .mistakes-box, .recap-box { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  pre { white-space: pre-wrap; background: #f5f5f5; color: #111; }
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
  main { padding: 1rem; }
  .page-header h1 { font-size: 1.25rem; }
  .section { padding: 1rem; }
  pre { font-size: 0.78rem; }
  header { padding: 0.6rem 1rem; }
  .header-brand .name { display: none; }
}
