/* ============================================================
   TaskNotes Documentation

   Aesthetic: Scholarly Reference / Technical Manual
   ──────────────────────────────────────────────────────────
   Display  — Cormorant Garamond  (refined optical serif)
   Body     — IBM Plex Serif      (technical warmth)
   UI / Nav — IBM Plex Mono       (the weird part: the sidebar
                                   reads like a file listing
                                   while content reads like
                                   a typeset book)
   ──────────────────────────────────────────────────────────
   One accent colour: amber. Used sparingly.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400&family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&family=IBM+Plex+Serif:ital,wght@0,300;0,400;1,300;1,400&display=swap');

/* ============================================================
   Tokens
   ============================================================ */

:root {
  --font-display : 'Cormorant Garamond', Georgia, serif;
  --font-body    : 'IBM Plex Serif', Georgia, serif;
  --font-mono    : 'IBM Plex Mono', 'Courier New', monospace;

  /* Light */
  --bg            : #f9f7f4;
  --bg-sidebar    : #f3f0eb;
  --bg-code       : #efece7;
  --bg-hover      : #ece8e2;
  --text          : #1a1714;
  --text-subtle   : #6b625a;
  --text-faint    : #a09890;
  --border        : #e0dbd4;
  --border-strong : #c8c2ba;
  --amber         : #b76b1c;
  --amber-bg      : rgba(183, 107, 28, 0.08);
  --amber-border  : rgba(183, 107, 28, 0.25);

  --sidebar-w  : 256px;
  --content-max: 680px;
  --toc-w      : 200px;
}

[data-theme="dark"] {
  --bg            : #131110;
  --bg-sidebar    : #1a1815;
  --bg-code       : #1f1c19;
  --bg-hover      : #231f1c;
  --text          : #e6e2da;
  --text-subtle   : #8a8078;
  --text-faint    : #564e48;
  --border        : #2d2925;
  --border-strong : #403b36;
  --amber         : #d4832a;
  --amber-bg      : rgba(212, 131, 42, 0.08);
  --amber-border  : rgba(212, 131, 42, 0.25);
}

/* ============================================================
   Reset & base
   ============================================================ */

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 3rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Reading progress — 3px amber rail on the left viewport edge
   ============================================================ */

.progress-rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  z-index: 200;
  background: var(--border);
}

.progress-fill {
  width: 100%;
  height: 0%;
  background: var(--amber);
  transition: height 0.1s linear;
}

/* ============================================================
   Layout
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__header {
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Stage (everything to the right of sidebar) */
.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Content row: prose + TOC */
.content-row {
  display: flex;
  flex: 1;
  gap: 0;
  justify-content: center;
}

/* ============================================================
   Logotype
   ============================================================ */

.logotype {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  text-decoration: none;
  color: var(--text);
}

.logotype__name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
}

.logotype__sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ============================================================
   Navigation
   ============================================================ */

/* The monospace font is the key design decision here —
   the sidebar reads like a directory listing or terminal output,
   contrasting with the serif content area. */

.nav-list {
  list-style: none;
  padding: 0;
}

.nav-link {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-decoration: none;
  padding: 0.3rem 1.5rem;
  line-height: 1.4;
  transition: color 0.1s, background 0.1s;
}

.nav-link:hover {
  color: var(--amber);
  background: var(--amber-bg);
}

.nav-link.is-active {
  color: var(--amber);
  font-weight: 500;
}

/* Section groups */
.nav-section {
  margin-top: 1.5rem;
}

.nav-section:first-child {
  margin-top: 0.25rem;
}

.nav-section__label {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 1.5rem 0.3rem;
  cursor: default;
}

/* The § symbol — subtle but distinctive */
.nav-section__sym {
  color: var(--amber);
  font-style: normal;
  opacity: 0.7;
}

.nav-list--child {
  padding-bottom: 0.25rem;
}

.nav-list--child .nav-link {
  padding-left: 2.25rem;
  font-size: 0.72rem;
}

/* ============================================================
   Theme toggle
   ============================================================ */

.repo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: border-color 0.12s, background 0.12s, opacity 0.12s;
}

.repo-link:hover {
  border-color: var(--amber);
  opacity: 0.9;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 0.6em;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theme-btn__track {
  width: 28px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}

.theme-btn__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: left 0.15s, background 0.15s;
}

[data-theme="dark"] .theme-btn__knob {
  left: 16px;
  background: var(--amber);
}

/* ============================================================
   Mobile top bar (hidden on desktop)
   ============================================================ */

.topbar {
  display: none;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-subtle);
  padding: 0.25rem;
  display: flex;
  flex-shrink: 0;
}

/* ============================================================
   Prose area
   ============================================================ */

.prose {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
  padding: 4rem 3rem 6rem 3.5rem;
}

.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.8rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 2.5rem;
  color: var(--text);
}

/* Headings */
.prose h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 3.5rem;
  margin-bottom: 1rem;
  color: var(--text);
  position: relative;
}

/* The ornament: a small amber marker before each h2.
   Reads like a typographic chapter marker. */
.prose h2::before {
  content: '—';
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--amber);
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.prose h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.prose h4 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

/* Body text */
.prose p {
  margin-bottom: 1.25em;
  font-weight: 300;
  line-height: 1.8;
}

.prose > p:first-child {
  font-size: 1.07rem;
}

/* ============================================================
   Links
   ============================================================ */

.prose a {
  color: var(--amber);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity 0.1s;
}

.prose a:hover {
  opacity: 0.75;
}

/* ============================================================
   Inline code
   ============================================================ */

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.12em 0.38em;
  border-radius: 3px;
}

/* ============================================================
   Code blocks
   ============================================================ */

.prose pre {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  /* Amber left border — the distinctive mark of a code block */
  border-left: 3px solid var(--amber);
  border-radius: 0 4px 4px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.65;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* Syntax highlighting — warm monochrome with amber keywords */
.hljs-comment, .hljs-quote      { color: var(--text-faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag,
.hljs-built_in                  { color: var(--amber); }
.hljs-string, .hljs-attr        { color: var(--text-subtle); }
.hljs-number, .hljs-literal     { color: var(--amber); opacity: 0.85; }
.hljs-title, .hljs-section      { color: var(--text); font-weight: 500; }
.hljs-variable, .hljs-template-variable { color: var(--text); }
.hljs-type, .hljs-class         { color: var(--text); }
.hljs-emphasis                  { font-style: italic; }
.hljs-strong                    { font-weight: 500; }

/* ============================================================
   Copy button
   ============================================================ */

.prose pre {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.2em 0.55em;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.6;
}

.prose pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--amber);
  border-color: var(--amber-border);
}

.copy-btn.is-copied {
  color: var(--amber);
  border-color: var(--amber-border);
  opacity: 1;
}

/* ============================================================
   Tables
   ============================================================ */

/* Scrollable wrapper prevents wide tables (e.g. formula references)
   from overflowing into the TOC column */
.table-wrap {
  overflow-x: auto;
  margin: 1.75rem 0;
  -webkit-overflow-scrolling: touch;
  /* Subtle fade on the right edge hints at scrollability */
  background:
    linear-gradient(to right, var(--bg) 0%, transparent 2rem) left  / 2rem 100% no-repeat,
    linear-gradient(to left,  var(--bg) 0%, transparent 2rem) right / 2rem 100% no-repeat;
}

.prose table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.9rem;
  font-family: var(--font-body);
}

.prose th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border-strong);
}

.prose td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 300;
  vertical-align: top;
}

.prose tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   Lists
   ============================================================ */

.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25em;
}

.prose li {
  margin-bottom: 0.3em;
  font-weight: 300;
}

.prose li > p { margin-bottom: 0.4em; }

/* ============================================================
   Blockquote
   ============================================================ */

.prose blockquote {
  border-left: 3px solid var(--amber);
  padding: 0.5rem 1.25rem;
  margin: 1.75rem 0;
  color: var(--text-subtle);
  font-style: italic;
}

.prose blockquote p {
  margin: 0;
}

/* ============================================================
   Images / figures
   ============================================================ */

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin: 1.75rem 0;
  display: block;
}

.prose figure {
  margin: 1.75rem 0;
}

.prose figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   Horizontal rule
   ============================================================ */

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* ============================================================
   Strong / em
   ============================================================ */

.prose strong { font-weight: 500; color: var(--text); }
.prose em     { font-style: italic; }

/* ============================================================
   Keyboard keys
   ============================================================ */

.prose kbd {
  font-family: var(--font-mono);
  font-size: 0.78em;
  background: var(--bg-code);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0.1em 0.4em;
  white-space: nowrap;
}

/* ============================================================
   Card grid (home page quick links)
   ============================================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.75rem 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 0 4px 4px 0;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.card:hover {
  background: var(--bg-hover);
  border-left-color: var(--amber);
}

.card__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.card__desc {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text-subtle);
  line-height: 1.5;
}

/* ============================================================
   TOC (right column)
   ============================================================ */

.toc-col {
  flex: 0 0 var(--toc-w);
  padding-top: 4rem;
  padding-right: 2rem;
}

.toc {
  position: sticky;
  top: 2rem;
}

.toc__heading {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.toc ul {
  list-style: none;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc a {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--text-subtle);
  text-decoration: none;
  padding: 0.25rem 0 0.25rem 0.875rem;
  line-height: 1.4;
  transition: color 0.1s;
}

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

.toc a.is-active {
  color: var(--amber);
  border-left: 2px solid var(--amber);
  margin-left: -1px;
}

.toc__sub a {
  padding-left: 1.5rem;
  color: var(--text-faint);
  font-size: 0.68rem;
}

/* ============================================================
   Mobile overlay
   ============================================================ */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1200px) {
  .toc-col { display: none; }
  .prose { padding-right: 3.5rem; }
}

@media (max-width: 900px) {
  .prose {
    padding: 2.5rem 1.75rem 4rem;
  }

  .page-title { font-size: 2.2rem; }
  .prose h2   { font-size: 1.6rem; }
}

@media (max-width: 720px) {
  .topbar { display: flex; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 99;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  .overlay {
    display: block;
  }

  .overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .stage {
    width: 100%;
  }

  .prose {
    padding: 2rem 1.25rem 4rem;
  }

  .page-title { font-size: 2rem; }
}
