/* ==========================================================
   Notes Archive — stylesheet
   Aesthetic: warm-dark scholarly archive, editorial layout
   ========================================================== */

:root {
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body:    "Geist", system-ui, -apple-system, sans-serif;
  --font-mono:    "Geist Mono", ui-monospace, "SF Mono", monospace;

  /* Dark theme (default) */
  --bg:           #0e0d0b;
  --bg-elevated:  #16140f;
  --surface:      #1c1a14;
  --surface-2:    #232017;
  --border:       #2c2920;
  --border-strong:#3a3628;
  --text:         #ede6d6;
  --text-muted:   #9a9382;
  --text-faint:   #6b6555;
  --accent:       #d4a25a;     /* warm amber */
  --accent-soft:  rgba(212, 162, 90, 0.14);
  --accent-line:  rgba(212, 162, 90, 0.32);

  --status-done:    #8aa67a;
  --status-active:  #d4a25a;
  --status-soon:    #6b6555;

  --radius:       2px;
  --radius-lg:    6px;
  --shadow-card:  0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -16px rgba(0,0,0,0.6);

  --max-width:    1180px;
}

[data-theme="light"] {
  --bg:           #f6f1e6;
  --bg-elevated:  #ece6d6;
  --surface:      #fbf7ec;
  --surface-2:    #f1ecde;
  --border:       #d9d0bb;
  --border-strong:#bfb39a;
  --text:         #1f1c14;
  --text-muted:   #5b5444;
  --text-faint:   #8a8270;
  --accent:       #9c6614;
  --accent-soft:  rgba(156, 102, 20, 0.10);
  --accent-line:  rgba(156, 102, 20, 0.28);

  --status-done:   #5a7a4a;
  --status-active: #9c6614;
  --status-soon:   #8a8270;

  --shadow-card:  0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 20px -14px rgba(0,0,0,0.18);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* -------- grain texture overlay -------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* -------- header -------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  color: var(--accent);
  font-weight: 400;
  font-style: italic;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-nav { display: flex; align-items: center; gap: 20px; }
.counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theme-toggle {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}
.theme-toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  display: inline-block;
  transition: background 0.25s;
}
.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="light"] .theme-toggle-thumb { transform: translateX(16px); }

/* -------- hero -------- */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 88px 28px 56px;
  position: relative;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin: 0 0 18px;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 350;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
  max-width: 14ch;
}
.hero-title em {
  font-style: italic;
  font-weight: 350;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.hero-blurb {
  max-width: 56ch;
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
}

/* -------- controls (search + filters) -------- */
.controls {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}
.search-wrap {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}
.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 11px 14px 11px 40px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
#search::placeholder { color: var(--text-faint); }
#search:focus {
  border-color: var(--accent-line);
  background: var(--surface-2);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius-lg);
  transition: all 0.18s;
}
.filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* -------- archive sections -------- */
.archive {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px 80px;
  position: relative;
  z-index: 2;
}

.year-section { margin-bottom: 64px; }

.year-header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding-bottom: 14px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.year-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.year-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  margin: 0;
  letter-spacing: -0.02em;
}
.year-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.semester-block { margin-bottom: 36px; }
.semester-block:last-child { margin-bottom: 0; }

.semester-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.semester-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* -------- module card grid -------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.25s,
              background 0.25s;
  box-shadow: var(--shadow-card);
}
.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.module-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-2px);
}
.module-card:hover::before { width: 100%; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.card-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 4px 8px;
  border-radius: var(--radius);
  text-transform: uppercase;
  flex-shrink: 0;
}
.card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}
.card-status[data-status="completed"] .status-dot { background: var(--status-done); }
.card-status[data-status="in-progress"] .status-dot {
  background: var(--status-active);
  box-shadow: 0 0 0 0 var(--status-active);
  animation: pulse 2s ease-in-out infinite;
}
.card-status[data-status="upcoming"] .status-dot { background: var(--status-soon); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 162, 90, 0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(212, 162, 90, 0); }
}

.card-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
  color: var(--text);
}

.card-desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 18px;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
}
.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid var(--border);
  padding: 3px 7px;
  border-radius: var(--radius);
  letter-spacing: 0.03em;
}

.card-arrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  transition: color 0.2s, gap 0.25s;
}
.module-card:hover .card-arrow {
  color: var(--accent);
  gap: 10px;
}
.card-arrow svg { width: 12px; height: 12px; }

/* -------- empty state -------- */
.empty-state {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 28px;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--text-faint);
}

/* -------- footer -------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 28px 36px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.site-footer code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--accent);
}
.site-footer .dot { margin: 0 8px; opacity: 0.5; }

/* -------- entrance animations -------- */
.module-card {
  opacity: 0;
  transform: translateY(8px);
  animation: card-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes card-in {
  to { opacity: 1; transform: translateY(0); }
}

.year-section {
  opacity: 0;
  animation: section-in 0.6s ease-out forwards;
}
@keyframes section-in {
  to { opacity: 1; }
}

/* -------- responsive -------- */
@media (max-width: 640px) {
  .header-inner { padding: 14px 18px; }
  .hero { padding: 56px 18px 40px; }
  .controls { padding: 0 18px 28px; }
  .archive { padding: 0 18px 60px; }
  .module-grid { grid-template-columns: 1fr; }
  .year-header { flex-wrap: wrap; }
  .year-meta { margin-left: 0; width: 100%; }
}
