/* Teaching site overrides */
body, html { font-family: var(--font-primary); }

/* Table styling */
table { width: 100%; border-collapse: collapse; margin: var(--space-md) 0; }
table th { background-color: var(--color-surface-emphasized); padding: var(--space-sm); text-align: left; font-weight: var(--font-weight-semibold); }
table td { padding: var(--space-sm); border-bottom: 1px solid var(--color-divider); background-color: var(--color-surface); }
table td:first-child { white-space: nowrap; width: 1%; }

/* List indentation adjustments */
ul, ol { padding-left: 0; }
ul ul, ol ol, ul ol, ol ul { padding-left: 0; }

/* Accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  z-index: 100000;
  padding: 8px 16px;
  background: var(--color-skip-link-bg);
  color: var(--color-skip-link-text);
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
}
.skip-link:focus {
  top: 6px;
}

/* General link underline styling - exclude navigation, masthead, and project cards */
a:not(nav a):not(.masthead-title a):not(.theme-switcher a):not(.project-card a):not(.chapter-card) {
  text-decoration: underline;
  text-underline-offset: 0.3em;
  text-decoration-thickness: 0.1em;
}

/* Custom bullets */
ul { list-style: none; }
ul li {
  padding-left: 0.9em;
  text-indent: -0.9em;
}
ul li::before {
  content: "⚬ ";
  color: var(--color-bullet);
  font-weight: var(--font-weight-regular);
}

/* Ordered list numbers inside content box */
ol { padding-left: 1.4em; }

/* Active navigation */
nav a[aria-current="page"],
nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* Exclude navigation from custom bullets */
nav ul { list-style: none; padding-left: 0; }
nav ul li { padding-left: 0; text-indent: 0; }
nav ul li::before { content: none; }

/* Masthead */
.masthead-title { font-size: var(--font-size-masthead); font-weight: var(--font-weight-regular); }
.masthead-title .tagline { display: block; font-size: 0.9rem; margin-top: 0.3rem; }
.masthead-title .sitename:hover {
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* Align navigation with masthead */
.masthead { display: flex; justify-content: space-between; align-items: baseline; }
.masthead-title { float: none; }
nav.nav { float: none; }

/* === Mobile Navigation Toggle === */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--color-primary);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.nav-toggle-icon {
  position: relative;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-toggle-icon::before { top: -7px; }
.nav-toggle-icon::after { top: 7px; }

/* Animate to X when open */
.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
  background-color: transparent;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

/* === Theme Select (hidden on desktop) === */
.theme-select {
  display: none;
  font-family: var(--font-navigation);
  font-size: var(--font-size-medium);
  color: var(--color-quaternary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 3px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 769px) {
  .container { max-width: var(--container-max-width); }
  .container h2 { font-size: var(--font-size-h2); line-height: var(--line-height-tight); }

  nav.nav {
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .masthead {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  nav ul {
    display: flex;
    gap: 1rem;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
  }
  nav ul li { display: inline-block; }
}

/* ===== MOBILE STYLES ===== */
@media (max-width: 768px) {
  /* Navigation mobile */
  .masthead { flex-direction: row; align-items: center; justify-content: space-between; }
  .nav-toggle { display: block; position: relative; z-index: 100002; }
  nav.nav { display: none; margin-top: 0; }

  /* Full-screen overlay when open */
  nav.nav.is-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100001;
    background-color: var(--color-surface);
    margin: 0;
    padding: 3rem 1.5rem;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    animation: fadein 0.2s ease;
  }
  nav.nav.is-open ul {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
  }
  nav.nav.is-open ul li { display: block; }
  nav.nav.is-open ul li a { font-size: 1.5rem; }

  /* Mobile font sizes */
  html { font-size: 18px; }
  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.8rem; }
  h3 { font-size: 1.4rem; }
  .page-title { font-size: 1.8rem; margin-bottom: 1.2rem; }
  .masthead-title { font-size: 1.6rem; }
  nav ul li a { font-size: 1.1rem; }
  p, li { font-size: 1.05rem; line-height: 1.6; }
  .container { padding-left: 1.2rem; padding-right: 1.2rem; }

  /* Footer mobile */
  .footer {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
  }
  .footer .footer-text { text-align: right; }

  /* Mobile theme switcher */
  .theme-links { display: none; }
  .theme-switcher .footer-sep { display: none; }
  .theme-select { display: inline-block; }
  .theme-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
}

/* Horizontal rule */
hr { margin-bottom: var(--space-sm); }

/* === Footer === */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-xl);
}
.theme-switcher a {
  color: var(--color-quaternary);
  text-decoration: none;
  margin-left: 0.75rem;
}
.theme-switcher .footer-sep {
  margin-left: 0.75rem;
}
.theme-switcher a:hover {
  color: var(--color-primary);
}
.theme-switcher a.active {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 0.1em;
}

/* === Breadcrumb === */
.breadcrumb {
  font-size: var(--font-size-small);
  color: var(--color-quaternary);
  margin-bottom: var(--space-md);
}
.breadcrumb a {
  color: var(--color-quaternary);
}
.breadcrumb a:hover {
  color: var(--color-primary);
}

/* === Two-column layout === */
.two-col {
  display: grid;
  grid-template-columns: 30% 1fr;
  gap: 0 var(--space-xl);
  border-top: 1px solid var(--color-divider);
  padding-top: 0.75rem;
  margin-bottom: var(--space-2xl);
}

.two-col-label {
  grid-column: 1;
  grid-row: 1;
  color: var(--color-primary);
  font-weight: 550;
}

.two-col-content {
  grid-column: 2;
  grid-row: 1 / span 20;
}
.two-col-content > :first-child { margin-top: 0; }
/* Visual first children (images, grids) need a nudge back — the rule above
   collapses their natural top margin, leaving them too close to the divider. */
.two-col-content > .figure:first-child,
.two-col-content > .columns:first-child,
.two-col-content > .project-grid:first-child { margin-top: 0.6rem; }

.two-col-note {
  grid-column: 1;
  grid-row: 2;
  font-size: var(--font-size-small);
  color: var(--color-quaternary);
  line-height: var(--line-height-tight);
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .two-col-label { margin-bottom: 1rem; }
  .two-col-label,
  .two-col-content,
  .two-col-note {
    grid-column: 1;
    grid-row: auto;
  }
  .two-col-note {
    margin-top: 0.15rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
  }
}
