/* Editorial light — Fraunces + DM Sans */
:root {
  --bg: #f4f2ed;
  --bg-elevated: #fffcf7;
  --surface: #ffffff;
  --surface-hover: #f5f2ec;
  --border: rgba(20, 18, 26, 0.1);
  --text: #14121a;
  --muted: #5e5a68;
  --accent: #b45309;
  --accent-soft: rgba(180, 83, 9, 0.12);
  --mint: #0f766e;
  --mint-soft: rgba(15, 118, 110, 0.12);
  --violet: #5b21b6;
  --on-accent-pill: #ffffff;
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --shadow: 0 20px 56px rgba(20, 18, 26, 0.08);
  --max: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.025;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
  color: #92400e;
}

.shell {
  width: min(100% - 2.5rem, var(--max));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 252, 247, 0.88);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--text);
}

.logo-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, #d97706, #0d9488);
  box-shadow: 0 2px 12px rgba(180, 83, 9, 0.25);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.nav-toggle {
  display: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  align-items: center;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0 0.75rem;
    border-top: 1px solid var(--border);
  }

  .site-nav.is-open {
    display: flex;
  }

  .nav-link {
    padding: 0.6rem 0;
    border-bottom: none;
    border-left: 3px solid transparent;
    padding-left: 0.75rem;
  }

  .nav-link.is-active {
    border-left-color: var(--accent);
    border-bottom-color: transparent;
  }
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2.25rem, 4vw, 3.25rem);
}

h2 {
  font-size: clamp(1.65rem, 2.8vw, 2.1rem);
}

h3 {
  font-size: 1.25rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 42ch;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

/* Sections */
.page-hero {
  padding: clamp(3rem, 8vw, 5.5rem) 0 3rem;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 120%;
  background: radial-gradient(ellipse 50% 45% at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}

.page-hero--books::before {
  background: radial-gradient(ellipse 50% 45% at 50% 0%, var(--mint-soft), transparent 70%);
}

.page-hero--papers::before {
  background: radial-gradient(ellipse 50% 45% at 30% 0%, rgba(91, 33, 182, 0.1), transparent 65%);
}

.page-hero--repos::before {
  background: radial-gradient(ellipse 50% 45% at 70% 0%, var(--accent-soft), transparent 65%);
}

.page-hero--training::before {
  background: radial-gradient(ellipse 55% 50% at 50% 0%, rgba(15, 118, 110, 0.1), transparent 70%);
}

.page-hero--blog::before {
  background: radial-gradient(ellipse 50% 45% at 50% 0%, rgba(180, 83, 9, 0.1), transparent 68%);
}

.page-hero-inner {
  position: relative;
}

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

/* Home */
.home-hero {
  display: grid;
  gap: 2.5rem;
  padding: clamp(3rem, 10vw, 6rem) 0 4rem;
  grid-template-columns: 1fr;
  align-items: center;
}

@media (min-width: 900px) {
  .home-hero {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3rem;
  }
}

.home-hero h1 {
  margin-bottom: 0.35em;
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.hero-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--surface) 0%, var(--bg-elevated) 100%);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.hero-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}

.hero-stat {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(20, 18, 26, 0.03);
  border: 1px solid var(--border);
}

.hero-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--mint);
}

.hero-stat span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #c2410c, #b45309);
  color: #fffaf5;
  box-shadow: 0 8px 24px rgba(180, 83, 9, 0.28);
}

.btn-primary:hover {
  color: #fffaf5;
  box-shadow: 0 12px 32px rgba(180, 83, 9, 0.35);
}

.btn-ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}

/* Cards & grids */
.section {
  padding: 3rem 0 4rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.link-arrow {
  font-weight: 600;
  font-size: 0.9rem;
}

.card-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.35rem 1.5rem;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.card:hover {
  border-color: rgba(180, 83, 9, 0.28);
  background: var(--surface-hover);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(20, 18, 26, 0.06);
}

.card h3 {
  margin-bottom: 0.35rem;
}

.card h3 a {
  color: var(--text);
}

.card h3 a:hover {
  color: var(--accent);
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.tag-mint {
  background: var(--mint-soft);
  color: var(--mint);
}

.tag-violet {
  background: rgba(91, 33, 182, 0.1);
  color: var(--violet);
}

/* Training thumbnails */
.training-card-thumb-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elevated);
  margin: 0.6rem 0 0.85rem;
}

.training-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-detail-thumb {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elevated);
  aspect-ratio: 16 / 9;
  margin: 0 0 1.25rem;
}

.training-detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Book / paper detail */
.split-layout {
  display: grid;
  gap: 2.5rem;
  padding-bottom: 4rem;
}

@media (min-width: 880px) {
  .split-layout {
    grid-template-columns: minmax(200px, 320px) 1fr;
    align-items: start;
  }
}

.media-frame {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elevated);
  aspect-ratio: 3/4;
  max-width: 320px;
}

.media-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.prose {
  max-width: 65ch;
}

.prose p {
  margin: 0 0 1em;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Repo list */
.repo-row {
  display: grid;
  gap: 0.5rem 1.5rem;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 0.85rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.repo-row:hover {
  border-color: rgba(15, 118, 110, 0.25);
  background: var(--surface-hover);
}

@media (min-width: 720px) {
  .repo-row {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
}

.repo-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.repo-name a {
  color: var(--text);
}

.repo-name a:hover {
  color: var(--mint);
}

.repo-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.repo-description {
  max-width: 72ch;
}

.repo-description p {
  margin: 0 0 0.5em;
}

.repo-description p:last-child {
  margin-bottom: 0;
}

.repo-description img {
  max-width: 100%;
  height: auto;
}

/* HTML from TinyMCE (admin-edited) */
.rich-text p {
  margin: 0 0 1em;
}

.rich-text p:last-child {
  margin-bottom: 0;
}

.rich-text img {
  max-width: 100%;
  height: auto;
}

.rich-text ul,
.rich-text ol {
  margin: 0 0 1em 1.25em;
  padding: 0;
}

.rich-text li {
  margin-bottom: 0.35em;
}

.rich-text h2,
.rich-text h3 {
  font-family: var(--font-display);
  margin: 1.25em 0 0.5em;
}

.rich-text h2:first-child,
.rich-text h3:first-child {
  margin-top: 0;
}

/* Training filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  align-items: center;
}

.filter-bar a {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  background: transparent;
}

.filter-bar a:hover {
  color: var(--text);
  background: var(--surface);
}

.filter-bar a.is-on {
  color: var(--on-accent-pill);
  background: var(--mint);
  border-color: var(--mint);
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  flex: 1 1 200px;
  max-width: 320px;
}

.search-form input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.search-form button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--on-accent-pill);
  cursor: pointer;
}

/* Blog */
.post-list article {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list article:first-child {
  padding-top: 0;
}

.post-list h2 {
  margin-bottom: 0.35rem;
}

.post-list h2 a {
  color: var(--text);
}

.post-list h2 a:hover {
  color: var(--accent);
}

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 2rem;
  font-size: 0.9rem;
}

/* About */
.about-grid {
  display: grid;
  gap: 2.5rem;
  padding-bottom: 4rem;
}

@media (min-width: 800px) {
  .about-grid {
    grid-template-columns: 280px 1fr;
    align-items: start;
  }
}

.about-photo {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 4/5;
  max-width: 280px;
  background: var(--surface);
}

.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.social-row a {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.social-row a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 3rem;
  margin-top: 2rem;
  background: var(--bg-elevated);
}

.footer-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .footer-copy {
    grid-column: 1 / -1;
  }
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.footer-tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links a {
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
}

/* Table of contents (blog post, training detail) */
.toc-article-section .toc-layout--with-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, 15rem);
  gap: 2rem 2.5rem;
  align-items: start;
}

@media (min-width: 1200px) {
  .toc-article-section .toc-layout--with-toc {
    grid-template-columns: minmax(0, 1fr) minmax(13rem, 17rem);
  }
}

.toc-main {
  min-width: 0;
}

/* Wider measure for article body next to TOC (default .prose is 65ch — too narrow here) */
.toc-article-section .toc-main.prose {
  max-width: min(88ch, 100%);
}

.toc-article-section .toc-main .rich-text,
.toc-article-section .toc-main .lead.rich-text {
  max-width: min(88ch, 100%);
}

.toc-aside {
  position: sticky;
  top: 5.25rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding: 1rem 0 1rem 1rem;
  border-left: 1px solid var(--border);
  font-size: 0.82rem;
}

.toc-nav-title {
  margin: 0 0 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  margin: 0 0 0.4rem;
  line-height: 1.35;
}

.toc-item a {
  display: block;
  color: var(--muted);
  border-radius: 4px;
  padding: 0.2rem 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.toc-item a:hover {
  color: var(--accent);
}

.toc-depth-3 {
  padding-left: 0.65rem;
}

.toc-depth-4 {
  padding-left: 1.2rem;
}

.toc-depth-5 {
  padding-left: 1.75rem;
}

.toc-depth-6 {
  padding-left: 2.3rem;
}

@media (max-width: 960px) {
  .toc-article-section .toc-layout--with-toc {
    grid-template-columns: 1fr;
  }

  .toc-aside {
    position: static;
    max-height: none;
    order: -1;
    padding: 0 0 1.25rem;
    margin-bottom: 0.5rem;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }
}

.toc-main .rich-text h2[id],
.toc-main .rich-text h3[id],
.toc-main .rich-text h4[id],
.toc-main .rich-text h5[id],
.toc-main .rich-text h6[id] {
  scroll-margin-top: 5.5rem;
}
