/* ============================================================
   Marginalia — styles
   An original warm, editorial, card-based look.
   ============================================================ */

:root {
  --bg: #fbf7f0;
  --bg-soft: #f3ece0;
  --surface: #fffdfa;
  --ink: #2b2722;
  --ink-soft: #6b6157;
  --ink-faint: #9b9085;
  --line: #e8ddcd;
  --accent: #b4541f; /* warm terracotta */
  --accent-soft: #f6e7da;
  --accent-ink: #8c3f15;
  --shadow: 0 1px 2px rgba(60, 45, 30, 0.04),
    0 8px 24px -12px rgba(60, 45, 30, 0.18);
  --shadow-lift: 0 2px 6px rgba(60, 45, 30, 0.07),
    0 18px 40px -18px rgba(60, 45, 30, 0.28);
  --radius: 18px;
  --radius-sm: 11px;
  --maxw: 1080px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  min-height: 70px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  font-size: 26px;
  line-height: 1;
  filter: saturate(0.9);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 23px;
  letter-spacing: -0.01em;
}
.brand-tagline {
  font-size: 12.5px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 22px;
}
.site-nav a {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
}
.site-nav a:hover {
  color: var(--accent-ink);
  text-decoration: none;
}
@media (max-width: 420px) {
  .site-nav {
    gap: 16px;
  }
  .brand-tagline {
    display: none;
  }
}

/* ---------- Main / hero ---------- */
#app {
  outline: none;
  padding-top: 38px;
  padding-bottom: 64px;
  min-height: 60vh;
}

.hero {
  margin-bottom: 26px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 4.4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16.5px;
  max-width: 56ch;
}

/* ---------- Toolbar (search + sort) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 26px 0 22px;
}
.search {
  position: relative;
  flex: 1 1 280px;
  min-width: 0;
}
.search svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  font-family: inherit;
  font-size: 15.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px 12px 42px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder {
  color: var(--ink-faint);
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.sort-btn:hover {
  border-color: var(--accent);
}
.sort-btn:active {
  transform: translateY(1px);
}
.sort-btn .arrow {
  font-size: 13px;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.sort-btn.asc .arrow {
  transform: rotate(180deg);
}
.sort-btn .label-strong {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- Category filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0 0 20px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s, color 0.15s,
    transform 0.05s;
}
.filter-chip:hover {
  border-color: var(--accent);
}
.filter-chip:active {
  transform: translateY(1px);
}
.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.fc-count {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-faint);
}
.filter-chip.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: transparent;
  font-weight: 600;
}
.filter-chip.active .fc-count {
  background: rgba(0, 0, 0, 0.07);
  color: inherit;
}
/* per-domain active tints — mirror the .tag palette */
.filter-chip.active[data-domain="Money"] { background: #e4efe1; color: #3f6b46; }
.filter-chip.active[data-domain="Decisions"] { background: #e4ecf6; color: #3a5b86; }
.filter-chip.active[data-domain="Psychology"] { background: #f3e5ef; color: #82407a; }
.filter-chip.active[data-domain="Philosophy"] { background: #efe9da; color: #7a6326; }
.filter-chip.active[data-domain="History"] { background: #f6e7da; color: #8c3f15; }
.filter-chip.active[data-domain="Science"] { background: #e1eef0; color: #2f6670; }
.filter-chip.active[data-domain="Relationships"] { background: #fae6e3; color: #9c463b; }
.filter-chip.active[data-domain="Business"] { background: #e9e8f3; color: #54508a; }
.filter-chip.active[data-domain="Craft"] { background: #efeae3; color: #6b5d4c; }

/* ---------- About page photo ---------- */
.about-intro {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.about-bio {
  flex: 1 1 auto;
  min-width: 0;
}
.about-photo {
  position: relative;
  margin: 0;
  flex: 0 0 auto;
  width: 220px;
}
.about-photo img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--surface);
  cursor: help;
}
.about-photo img:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* hover thought-bubble with typewriter text */
.thought-cloud {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%) translateY(-6px) scale(0.96);
  width: min(250px, 78vw);
  min-height: 1.5em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 16px;
  box-shadow: var(--shadow-lift);
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 5;
}
/* the little trailing bubbles of a thought cloud */
.thought-cloud::before,
.thought-cloud::after {
  content: "";
  position: absolute;
  left: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
}
.thought-cloud::before {
  width: 14px;
  height: 14px;
  bottom: -9px;
}
.thought-cloud::after {
  width: 7px;
  height: 7px;
  bottom: -20px;
  left: 26px;
}
.about-photo.thinking .thought-cloud {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.thought-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--accent);
}
.about-photo.thinking .thought-caret {
  animation: caret-blink 0.9s step-end infinite;
}
@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .about-intro {
    flex-direction: column-reverse;
    gap: 18px;
  }
  .about-photo {
    width: 100%;
    max-width: 260px;
    align-self: center;
  }
}

.count-line {
  font-size: 13.5px;
  color: var(--ink-faint);
  margin: 0 0 18px;
}

/* ---------- Card grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease,
    border-color 0.16s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: #ddcdb5;
  text-decoration: none;
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.card-date {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  white-space: nowrap;
}
/* per-domain tints */
.tag[data-domain="Money"] { background: #e4efe1; color: #3f6b46; }
.tag[data-domain="Decisions"] { background: #e4ecf6; color: #3a5b86; }
.tag[data-domain="Psychology"] { background: #f3e5ef; color: #82407a; }
.tag[data-domain="Philosophy"] { background: #efe9da; color: #7a6326; }
.tag[data-domain="History"] { background: #f6e7da; color: #8c3f15; }
.tag[data-domain="Science"] { background: #e1eef0; color: #2f6670; }
.tag[data-domain="Relationships"] { background: #fae6e3; color: #9c463b; }
.tag[data-domain="Business"] { background: #e9e8f3; color: #54508a; }
.tag[data-domain="Craft"] { background: #efeae3; color: #6b5d4c; }

.card-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.card-author {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.card-teaser {
  font-size: 14.5px;
  color: var(--ink-soft);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-cta {
  margin-top: 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.card-cta .chev {
  transition: transform 0.16s ease;
}
.card:hover .card-cta .chev {
  transform: translateX(3px);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty .big {
  font-size: 40px;
  margin-bottom: 10px;
}
.empty h2 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}

/* ---------- Lesson detail ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 22px;
}
.back-link:hover {
  color: var(--accent-ink);
}

.lesson {
  max-width: 720px;
}
.lesson-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
  margin-bottom: 8px;
}
.lesson-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.lesson-date {
  font-size: 13.5px;
  color: var(--ink-faint);
  font-weight: 500;
}
.lesson-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.07;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.lesson-subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.lesson-byline {
  font-size: 15.5px;
  color: var(--ink-soft);
}
.lesson-byline .year {
  color: var(--ink-faint);
}

.section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}
.section:last-of-type {
  border-bottom: none;
}
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}
.section-label .ico {
  font-size: 15px;
}
.section p {
  margin: 0;
  font-size: 17.5px;
  line-height: 1.62;
  color: var(--ink);
}
.section.big-idea p {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

/* the signature "drop it in conversation" callout */
.dropin {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.dropin .section-label {
  margin-bottom: 12px;
}
.dropin p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink);
}

.lesson-footer {
  margin-top: 34px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.nav-pill {
  flex: 1 1 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.05s;
}
.nav-pill:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.nav-pill.next {
  text-align: right;
}
.nav-pill .dir {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.nav-pill .ttl {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--ink);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
  margin-top: 20px;
}
.site-footer p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-faint);
}

/* ---------- Motion / responsive ---------- */
@media (max-width: 560px) {
  .hero {
    margin-bottom: 18px;
  }
  .section.big-idea p {
    font-size: 20px;
  }
  .dropin p {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
