@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Noto+Sans+SC:wght@300;400;500&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink:        #1a1f1c;
  --ink-light:  #3d4640;
  --ink-muted:  #6b7570;
  --paper:      #f7f4ee;
  --paper-warm: #efe9dc;
  --paper-dark: #e5ddd0;
  --accent:     #2d5a3d;
  --accent-light: #4a8a60;
  --accent-pale: #e8f2ec;
  --rule:       rgba(26,31,28,0.12);
  --rule-heavy: rgba(26,31,28,0.25);

  --font-serif: 'Noto Serif SC', 'Georgia', serif;
  --font-sans:  'Noto Sans SC', 'PingFang SC', sans-serif;
  --font-mono:  'JetBrains Mono', monospace;

  --sidebar-w: 260px;
  --content-max: 740px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.8;
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  overflow-y: auto;
  z-index: 100;
  padding: 0 0 2rem;
}

.sidebar-brand {
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--paper);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.sidebar-brand p {
  font-size: 0.72rem;
  color: rgba(247,244,238,0.45);
  margin-top: 0.3rem;
  letter-spacing: 0.04em;
}

.sidebar nav { padding: 1rem 0; flex: 1; }

.nav-section-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(247,244,238,0.35);
  padding: 1rem 1.5rem 0.4rem;
  font-weight: 500;
}

.sidebar nav a {
  display: block;
  padding: 0.45rem 1.5rem;
  color: rgba(247,244,238,0.7);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 300;
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--paper);
  background: rgba(255,255,255,0.06);
  border-left-color: var(--accent-light);
}

/* ─── Main content ─── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--paper-warm);
  border-bottom: 1px solid var(--rule-heavy);
  padding: 2.5rem 3rem 2rem;
}

.page-header .eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.page-header .meta {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.content-body {
  max-width: var(--content-max);
  padding: 2.5rem 3rem 4rem;
}

/* ─── Typography ─── */
.content-body h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin: 2.5rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

.content-body h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink-light);
  margin: 1.8rem 0 0.5rem;
}

.content-body p {
  margin-bottom: 1.2rem;
  color: var(--ink-light);
  font-size: 0.95rem;
}

.content-body ul, .content-body ol {
  margin: 0.8rem 0 1.2rem 1.5rem;
  color: var(--ink-light);
  font-size: 0.95rem;
}

.content-body li { margin-bottom: 0.3rem; }

.content-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.content-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.8rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--accent-pale);
  border-radius: 0 4px 4px 0;
}

.content-body blockquote p {
  margin: 0;
  color: var(--accent);
  font-style: italic;
  font-size: 0.9rem;
}

.content-body code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--paper-dark);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--ink);
}

.content-body pre {
  background: var(--ink);
  border-radius: 6px;
  padding: 1.2rem 1.5rem;
  overflow-x: auto;
  margin: 1.2rem 0;
}

.content-body pre code {
  background: none;
  padding: 0;
  color: #c9d1d9;
  font-size: 0.85rem;
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.88rem;
}

.content-body th {
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 0.9rem;
  text-align: left;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

.content-body td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-light);
}

.content-body tr:hover td { background: var(--accent-pale); }

/* ─── Home page cards ─── */
.index-intro {
  padding: 3rem 3rem 0;
  max-width: calc(var(--content-max) + 2rem);
}

.index-intro p {
  font-size: 1.05rem;
  color: var(--ink-light);
  line-height: 1.9;
  max-width: 600px;
}

.card-grid {
  padding: 2rem 3rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  max-width: 900px;
}

.card {
  background: var(--paper-warm);
  border: 1px solid var(--rule-heavy);
  border-radius: 4px;
  padding: 1.4rem 1.6rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform 0.2s;
  transform-origin: bottom;
}

.card:hover { 
  border-color: var(--accent-light);
  box-shadow: 0 4px 16px rgba(26,31,28,0.08);
  transform: translateY(-2px);
}

.card:hover::before { transform: scaleY(1); }

.card-type {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.card h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.card p {
  font-size: 0.82rem;
  color: var(--ink-muted);
  line-height: 1.6;
  flex: 1;
}

.card-meta {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* ─── Password gate ─── */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.gate-box {
  background: var(--paper);
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  border-radius: 4px;
}

.gate-box h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.gate-box p {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-bottom: 2rem;
}

.gate-options {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.role-btn {
  flex: 1;
  padding: 0.8rem;
  border: 1px solid var(--rule-heavy);
  background: transparent;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink-light);
  transition: all 0.15s;
  font-weight: 300;
}

.role-btn.selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.gate-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule-heavy);
  background: var(--paper-warm);
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.gate-input:focus { border-color: var(--accent); }

.gate-submit {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: var(--paper);
  border: none;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}

.gate-submit:hover { background: var(--accent-light); }

.gate-error {
  font-size: 0.8rem;
  color: #c0392b;
  margin-top: 0.5rem;
  display: none;
}

/* ─── Giscus comments ─── */
.comments-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  max-width: var(--content-max);
}

.comments-section h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.comments-section .comments-note {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

/* read-only overlay for students */
.readonly-mask {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}

.readonly-banner {
  background: var(--paper-dark);
  border: 1px solid var(--rule-heavy);
  border-radius: 3px;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Mobile ─── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  border: none;
  width: 38px; height: 38px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  body { display: block; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s;
    width: 80vw;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page-header, .content-body, .index-intro, .card-grid { padding-left: 1.5rem; padding-right: 1.5rem; }
  .menu-toggle { display: flex; }
  .page-header { padding-top: 4rem; }
}

/* ─── Animations ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header, .content-body, .card-grid, .index-intro {
  animation: fadeUp 0.4s ease both;
}

.card { animation: fadeUp 0.4s ease both; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.10s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5) { animation-delay: 0.20s; }
