/* =========================================================================
   NotesWebpage — stylesheet
   ========================================================================= */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #fafaf8;
  --fg:          #1c1c1a;
  --muted:       #6b6b5e;
  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --border:      #e4e4da;
  --code-bg:     #f2f2ed;
  --done-fg:     #15803d;
  --todo-fg:     #b91c1c;
  --tag-bg:      #eeeee8;
  --max-width:   740px;
}

/* ── Reset / base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  line-height: 1.8;
  padding: 3rem 1.25rem 5rem 1in;
}

/* ── Page layout ────────────────────────────────────────────────────────── */
#content {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Page title ─────────────────────────────────────────────────────────── */
h1.title {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 2.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--fg);
}

/* ── Headings ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-top: 2.5rem;
  margin-bottom: 0.6rem;
  color: var(--fg);
}
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; color: var(--muted); }

/* ── Body text ──────────────────────────────────────────────────────────── */
p { margin: 1rem 0; }

/* ── Links ──────────────────────────────────────────────────────────────── */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
a:hover {
  border-bottom-color: var(--accent);
}

/* ── Lists ──────────────────────────────────────────────────────────────── */
ul, ol { margin: 0.75rem 0 0.75rem 1.6rem; }
li { margin: 0.35rem 0; }
ul ul, ol ol, ul ol, ol ul { margin-top: 0.2rem; margin-bottom: 0.2rem; }

/* org generates <ul class="org-ul"> and <ol class="org-ol"> */
ul.org-ul { list-style-type: disc; }

/* ── Code & pre ─────────────────────────────────────────────────────────── */
code, kbd {
  font-family: "SFMono-Regular", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

pre {
  font-family: "SFMono-Regular", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.83em;
  line-height: 1.6;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
}
pre code, pre kbd { background: none; border: none; padding: 0; font-size: inherit; }

/* ── Images ─────────────────────────────────────────────────────────────── */
img {
  max-width: min(500px, 100%);
  height: auto;
  display: block;
  margin: 1rem 0;
}

/* ── Blockquote ─────────────────────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--border);
  margin: 1.25rem 0;
  padding: 0.4rem 1.25rem;
  color: var(--muted);
  font-style: italic;
}
blockquote p { margin: 0.4rem 0; }

/* org uses <p class="verse"> for verse blocks */
p.verse {
  font-style: italic;
  margin-left: 2rem;
  color: var(--muted);
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-size: 0.93rem;
}

/* Monthly note pages: expand tables to full viewport width */
body.monthly-page table {
  width: 100vw;
  margin: 1.25rem calc(-50vw + 50%);
}
th, td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.85rem;
  text-align: left;
}
th {
  background: var(--code-bg);
  font-family: system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:nth-child(even) td { background: #f8f8f4; }

/* ── Horizontal rule ────────────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Org-specific: todo / done / priority / timestamps ──────────────────── */
.todo {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--todo-fg);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 0.1em 0.45em;
  margin-right: 0.3em;
}

.done {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--done-fg);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 0.1em 0.45em;
  margin-right: 0.3em;
}

.priority {
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 0.1em 0.45em;
  margin-right: 0.3em;
}

.timestamp, .timestamp-kwd {
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Org tags ───────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.5em;
  margin-left: 0.4em;
  color: var(--muted);
  vertical-align: middle;
}

/* ── Outline sections ───────────────────────────────────────────────────── */
div.outline-2, div.outline-3, div.outline-4 {
  margin-top: 0.25rem;
}

/* ── Footnotes ──────────────────────────────────────────────────────────── */
#footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── Day navigation ─────────────────────────────────────────────────────── */
nav.day-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  font-family: system-ui, sans-serif;
  font-size: 0.88rem;
}

nav.day-nav a {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2em 0.75em;
  transition: border-color 0.15s, color 0.15s;
}

nav.day-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Backlinks ──────────────────────────────────────────────────────────── */
.backlinks {
  margin-top: 4rem;
  padding: 1.25rem 1.5rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.backlinks h2 {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0.75rem;
  border: none;
  padding: 0;
}

.backlinks ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.backlinks li { margin: 0; }

.backlinks a {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2em 0.65em;
  color: var(--accent);
  transition: background 0.15s, border-color 0.15s;
}
.backlinks a:hover {
  background: white;
  border-color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  html  { font-size: 16px; }
  body  { padding: 1.5rem 1rem 3rem; }
  h1.title  { font-size: 1.75rem; }
}
