/* ============================================================
   Polyphase Induction Machines — Lecture Series
   Shared Stylesheet | Prof. Mithun Mondal | BITS Pilani
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,700;1,600&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,300&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --navy:        #0d1b2a;
  --navy-mid:    #1a3a5c;
  --navy-light:  #264d73;
  --steel:       #4a7fa5;
  --sky:         #7fb8d4;
  --cream:       #f5f0e8;
  --warm-white:  #faf8f4;
  --gold:        #c9a84c;
  --gold-light:  #e8d08a;
  --red:         #c0392b;
  --green:       #1a6b3c;
  --text-dark:   #1a1a2e;
  --text-mid:    #334155;
  --text-light:  #64748b;
  --border:      #d4cfc6;
  --shadow-sm:   0 2px 8px rgba(13,27,42,0.08);
  --shadow-md:   0 8px 32px rgba(13,27,42,0.12);
  --shadow-lg:   0 20px 60px rgba(13,27,42,0.18);
  --radius:      6px;
  --radius-lg:   12px;
  --ff-display:  'Playfair Display', Georgia, serif;
  --ff-body:     'Source Serif 4', Georgia, serif;
  --ff-mono:     'JetBrains Mono', 'Courier New', monospace;
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--ff-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-dark);
  background: var(--warm-white);
  -webkit-font-smoothing: antialiased;
}

/* ─── Navigation Bar ─────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  border-bottom: 2px solid var(--gold);
  padding: 0 2rem;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 1rem;
}
.nav-brand {
  font-family: var(--ff-display);
  font-size: 1rem;
  color: var(--gold-light);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex-wrap: wrap;
}
.nav-links a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  color: #b0c4d8;
  text-decoration: none;
  font-size: 0.82rem;
  font-family: var(--ff-body);
  letter-spacing: 0.04em;
  transition: background 0.2s, color 0.2s;
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--navy-light);
  color: #fff;
}

/* ─── Hero / Page Header ─────────────────────────────────── */
.page-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #1f4870 100%);
  color: white;
  padding: 4rem 2rem 3rem;
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 80% 50%, rgba(201,168,76,0.08) 0%, transparent 70%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 40px,
      rgba(255,255,255,0.015) 40px,
      rgba(255,255,255,0.015) 41px
    );
  pointer-events: none;
}
.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}
.hero-tag {
  display: inline-block;
  background: rgba(201,168,76,0.2);
  border: 1px solid rgba(201,168,76,0.5);
  color: var(--gold-light);
  font-size: 0.75rem;
  font-family: var(--ff-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 2px;
  margin-bottom: 1.25rem;
}
.hero-title {
  font-family: var(--ff-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  margin-bottom: 0.5rem;
}
.hero-subtitle {
  font-family: var(--ff-display);
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.3rem);
  color: var(--sky);
  margin-bottom: 1.5rem;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: #8faec8;
  font-family: var(--ff-body);
}
.hero-meta span::before {
  content: '▪ ';
  color: var(--gold);
}

/* ─── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 2rem;
}
.breadcrumb-inner {
  max-width: 1100px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--text-light);
  font-family: var(--ff-body);
}
.breadcrumb-inner a {
  color: var(--navy-mid);
  text-decoration: none;
}
.breadcrumb-inner a:hover { text-decoration: underline; }
.breadcrumb-inner span { color: var(--text-light); margin: 0 0.4rem; }

/* ─── TOC Sidebar Layout ────────────────────────────────── */
.page-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  align-items: start;
}
.toc-sidebar {
  position: sticky;
  top: 72px;
}
.toc-box {
  background: var(--cream);
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy-mid);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
}
.toc-box h3 {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.toc-box ol {
  list-style: none;
  counter-reset: toc-counter;
}
.toc-box li {
  counter-increment: toc-counter;
  margin-bottom: 0.4rem;
}
.toc-box a {
  display: flex;
  gap: 0.5rem;
  color: var(--text-mid);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
.toc-box a::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  color: var(--steel);
  min-width: 1.6em;
  flex-shrink: 0;
  margin-top: 0.05em;
}
.toc-box a:hover {
  background: rgba(26,58,92,0.07);
  color: var(--navy);
}

/* ─── Main Content ──────────────────────────────────────── */
.lecture-content { min-width: 0; }

/* ─── Section Headings ──────────────────────────────────── */
.section-heading {
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.section-heading:first-child { margin-top: 0; border-top: none; padding-top: 0; }
.section-number {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  color: var(--steel);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.3rem;
}
.section-heading h2 {
  font-family: var(--ff-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-family: var(--ff-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy-mid);
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--navy-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title .icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--navy-mid);
  color: white;
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card ul {
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: var(--text-mid);
}
.card ul li { margin-bottom: 0.3rem; }
.card p { font-size: 0.9rem; color: var(--text-mid); }

/* Card variants */
.card-alert {
  background: #fff8f0;
  border-color: #e8a050;
  border-left: 4px solid #e07020;
}
.card-alert .card-title { color: #8b3a00; border-color: #e07020; }

.card-example {
  background: #f0f8f0;
  border-color: #80c080;
  border-left: 4px solid var(--green);
}
.card-example .card-title { color: var(--green); border-color: var(--green); }

.card-navy {
  background: var(--navy);
  border-color: var(--navy-light);
}
.card-navy .card-title { color: var(--gold-light); border-color: var(--navy-light); }
.card-navy p, .card-navy ul, .card-navy li { color: #c0d4e8; }

/* ─── Equation Blocks ────────────────────────────────────── */
.eq-block {
  background: #eef4fa;
  border-left: 4px solid var(--steel);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.1rem 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  display: block;
  width: 100%;
}
.eq-block .eq-label {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  color: var(--navy-mid);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.eq-block .math {
  font-family: var(--ff-mono);
  font-size: 1.05rem;
  color: var(--text-dark);
  letter-spacing: 0.02em;
}
.eq-block .math sub, .eq-block .math sup {
  font-size: 0.65em;
}
.eq-inline {
  font-family: var(--ff-mono);
  font-size: 0.92em;
  background: rgba(26,58,92,0.08);
  border: 1px solid rgba(26,58,92,0.15);
  border-radius: 3px;
  padding: 0.05em 0.35em;
  color: var(--navy-mid);
}

/* Equation description - appears below equation */
.eq-desc {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  margin-bottom: 0.75rem;
  font-size: 0.93rem;
  color: var(--text-mid);
  line-height: 1.6;
  clear: both;
}

/* ─── Key Result Callout ─────────────────────────────────── */
.key-result {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  box-shadow: var(--shadow-md);
}
.key-result .kr-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.key-result .kr-body {}
.key-result .kr-label {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.key-result .kr-title {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.4rem;
}
.key-result .kr-body p {
  font-size: 0.9rem;
  color: #9bb8d4;
  line-height: 1.6;
}

/* ─── Data Table ─────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; margin: 1.25rem 0; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-family: var(--ff-body);
}

/* Improved table header styling - lighter with better contrast */
.data-table thead tr,
.data-table tr.header {
  background-color: #2c3e50;
  color: #ffffff;
}

.data-table thead th,
.data-table thead td,
.data-table tr.header th,
.data-table tr.header td {
  background-color: #2c3e50;
  color: #ffffff;
  padding: 0.7rem 1rem;
  text-align: left;
  font-family: var(--ff-body);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
  border-bottom: 2px solid #1a2632;
}

/* Ensure highlighted text in headers is visible */
.data-table thead .highlight,
.data-table thead strong.highlight {
  color: #ffd700;
  font-weight: 600;
}

.data-table tbody tr:nth-child(odd)  { background: var(--cream); }
.data-table tbody tr:nth-child(even) { background: #fff; }
.data-table tbody tr:hover { background: rgba(74,127,165,0.08); }
.data-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-mid);
  vertical-align: middle;
}
.data-table td:first-child { font-weight: 600; color: var(--text-dark); }

/* ─── Highlight Chip ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(26,58,92,0.1);
  border: 1px solid rgba(26,58,92,0.2);
  color: var(--navy-mid);
  font-size: 0.8rem;
  font-family: var(--ff-mono);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 500;
}
.chip-gold {
  background: rgba(201,168,76,0.15);
  border-color: rgba(201,168,76,0.4);
  color: #7a5c10;
}
.chip-red {
  background: rgba(192,57,43,0.1);
  border-color: rgba(192,57,43,0.3);
  color: var(--red);
}
.chip-green {
  background: rgba(26,107,60,0.1);
  border-color: rgba(26,107,60,0.3);
  color: var(--green);
}

/* ─── Insight Divider ────────────────────────────────────── */
.insight-strip {
  background: var(--cream);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.9rem 1.25rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: var(--text-mid);
  display: block;
  width: 100%;
}
.insight-strip strong { color: var(--navy); }

/* Override any flex properties that might affect layout */
.insight-strip {
  flex-direction: column;
  align-items: flex-start;
}

/* ─── Step List ──────────────────────────────────────────── */
.step-list {
  counter-reset: step-ctr;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}
.step-list li {
  counter-increment: step-ctr;
  display: flex;
  gap: 0.9rem;
  margin-bottom: 0.65rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: var(--text-mid);
}
.step-list li::before {
  content: counter(step-ctr);
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--navy-mid);
  color: white;
  border-radius: 50%;
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.2em;
}

/* ─── Figure Placeholder ─────────────────────────────────── */
.fig-placeholder {
  background: linear-gradient(135deg, var(--cream) 0%, #ebe5d8 100%);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.82rem;
  font-family: var(--ff-mono);
  margin: 1rem 0;
}
.fig-placeholder .fig-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.fig-caption {
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-light);
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}
.fig-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: block;
  margin: 0.5rem auto 0;
  box-shadow: var(--shadow-sm);
}

/* ─── Lecture Navigation Footer ─────────────────────────── */
.lecture-nav {
  background: var(--cream);
  border-top: 2px solid var(--border);
  padding: 2rem;
  margin-top: 4rem;
}
.lecture-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.lec-nav-btn {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-dark);
  transition: box-shadow 0.2s, border-color 0.2s;
  min-width: 180px;
  box-shadow: var(--shadow-sm);
}
.lec-nav-btn:hover { border-color: var(--navy-mid); box-shadow: var(--shadow-md); }
.lec-nav-btn .dir { font-size: 0.7rem; color: var(--text-light); font-family: var(--ff-mono); letter-spacing: 0.08em; margin-bottom: 0.2rem; }
.lec-nav-btn .title { font-size: 0.9rem; font-weight: 600; color: var(--navy-mid); }
.lec-nav-btn.next { text-align: right; }
.lec-nav-center { font-family: var(--ff-mono); font-size: 0.75rem; color: var(--text-light); }

/* ─── Page Footer ────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  color: #7a9bb8;
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  font-family: var(--ff-body);
}
.site-footer a { color: var(--sky); text-decoration: none; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .page-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 1.5rem 1rem;
  }
  .toc-sidebar { position: static; margin-bottom: 2rem; }
  .nav-brand { font-size: 0.85rem; }
  .card-grid { grid-template-columns: 1fr; }
  .page-hero { padding: 2.5rem 1rem 2rem; }
  .hero-title { font-size: 1.5rem; }
  .lecture-nav-inner { flex-direction: column; align-items: stretch; }
  .lec-nav-btn { min-width: unset; }
  .lec-nav-btn.next { text-align: left; }
  .key-result { flex-direction: column; gap: 0.75rem; }
}

@media (max-width: 480px) {
  .nav-links { display: none; }
}

/* ─── Utility ────────────────────────────────────────────── */
.mt-sm { margin-top: 0.75rem; }
.mt-md { margin-top: 1.25rem; }
.mt-lg { margin-top: 2rem; }
.mb-sm { margin-bottom: 0.75rem; }
.mb-md { margin-bottom: 1.25rem; }
.highlight { color: var(--navy-mid); font-weight: 600; }
.hl-gold { color: #9a7010; font-weight: 600; }
.prose p { margin-bottom: 1rem; font-size: 0.95rem; color: var(--text-mid); }
.prose p:last-child { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin: 1.25rem 0; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* ─── Lecture content defaults (formerly per-page inline styles) ─── */
.lecture-content img   { max-width: 100%; height: auto; display: block; }
.lecture-content figure { max-width: 100%; }

/* Nested card suppression */
.card > .card           { box-shadow: none; border: none; padding: 0.5rem 0 0; background: transparent; }
.card > .card-grid      { margin-top: 0.75rem; }
.card .eq-block         { border-radius: var(--radius); }
.card .data-table-wrap  { margin-top: 0.75rem; }

/* Inline text utilities */
.text-sm, .text-xs { font-size: 0.875rem; color: var(--text-mid); }
.num { font-family: var(--ff-mono); color: var(--navy-mid); font-weight: 600; }