/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg: #fbf9f5;
  --surface: #ffffff;
  --surface-2: #f3efe7;
  --ink: #221f1a;
  --ink-2: #56504a;
  --ink-3: #8b8378;
  --line: #e2dbcf;
  --accent: #8a5a2b;
  --accent-soft: #f0e4d5;
  --essay: #2f6f6a;
  --story: #8a4a6b;
  --poem: #4a5a9a;
  --shadow: 0 1px 2px rgba(34, 31, 26, 0.05), 0 6px 20px rgba(34, 31, 26, 0.06);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1d1b16;
    --surface-2: #26231d;
    --ink: #efe9df;
    --ink-2: #b8b0a3;
    --ink-3: #857d71;
    --line: #332f27;
    --accent: #d8a163;
    --accent-soft: #33291d;
    --essay: #6fb8b1;
    --story: #d190b0;
    --poem: #93a4e0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ── Top bar ────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.brand-sub { color: var(--ink-3); font-size: 0.82rem; letter-spacing: 0.04em; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ── Views ──────────────────────────────────────────────────────────── */
.view { display: none; }
.view.is-active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.datebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 34px 0 20px;
}
.datebar-center { text-align: center; min-width: 0; flex: 1; }
.datebar h1 {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.datebar p { margin: 4px 0 0; font-size: 0.86rem; }

.nav-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.muted { color: var(--ink-3); }

.banner {
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.86rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.today-jump {
  display: block;
  margin: 28px auto 0;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.today-jump:hover { border-color: var(--accent); color: var(--accent); }
/* An explicit display value outranks the UA's [hidden] rule — restore it. */
.today-jump[hidden] { display: none; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; }
.loading { grid-column: 1 / -1; text-align: center; color: var(--ink-3); padding: 60px 0; }

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-accent { height: 3px; background: var(--kind); }

.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }

.kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--kind);
  margin-bottom: 12px;
}

.card h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.byline { font-size: 0.92rem; color: var(--ink-2); margin: 0 0 4px; }
.byline .author { color: var(--ink); font-weight: 500; }
.meta { font-size: 0.78rem; color: var(--ink-3); margin: 0 0 14px; }

.note {
  font-size: 0.9rem;
  color: var(--ink-2);
  margin: 0 0 18px;
  font-style: italic;
  border-left: 2px solid var(--line);
  padding-left: 12px;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.tag {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
}
.tag.classic { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.card-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.read-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--kind);
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}
.read-link:hover { filter: brightness(1.1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .read-link { color: #14130f; }
}

.alt-links { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.75rem; }
.alt-links a { color: var(--ink-3); text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.alt-links a:hover { color: var(--accent); border-color: var(--accent); }

.swap-note {
  margin: 14px 0 0;
  font-size: 0.76rem;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 8px 11px;
  border-radius: 8px;
}

/* Full poem text, when PoetryDB has it. */
.poem-text { margin: 4px 0 16px; }
.poem-text summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}
.poem-text summary:hover { color: var(--accent); }
.poem-text pre {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 12px 0 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: 10px;
  max-height: 380px;
  overflow-y: auto;
  color: var(--ink);
}
.poem-src { font-size: 0.72rem; color: var(--ink-3); margin: 8px 0 0; }

/* ── Calendar ───────────────────────────────────────────────────────── */
.weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.weekdays {
  margin-bottom: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
}

.day {
  position: relative;
  min-height: 92px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s;
}
.day:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.day:disabled { background: transparent; border-style: dashed; color: var(--ink-3); cursor: default; opacity: 0.5; }
.day.is-blank { border: 0; background: transparent; cursor: default; }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.day-num { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.day.is-today .day-num { color: var(--accent); }

.day-titles { margin-top: 5px; display: flex; flex-direction: column; gap: 2px; }
.day-title {
  font-size: 0.66rem;
  line-height: 1.3;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-title::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--kind);
}

.calendar-legend { margin-top: 20px; font-size: 0.8rem; text-align: center; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 0.78rem;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dot { opacity: 0.5; }

@media (max-width: 640px) {
  .datebar { padding: 22px 0 16px; }
  .day { min-height: 66px; padding: 6px; }
  .day-titles { display: none; }
  .weekdays span { font-size: 0.62rem; }
  main { padding: 0 12px 48px; }
  .calendar-grid, .weekdays { gap: 5px; }
}
