@import url('https://fonts.googleapis.com/css2?family=Gambarino&family=Epilogue:ital,wght@0,100..900;1,100..900&display=swap');

/* ── Tokens ── */
:root {
  --bg:        oklch(12% 0.008 75);
  --bg-raised: oklch(17% 0.009 75);
  --fg:        oklch(91% 0.007 75);
  --fg-muted:  oklch(53% 0.008 75);
  --border:    oklch(23% 0.009 75);
  --accent:    oklch(72% 0.13 72);

  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  --font-display: 'Gambarino', Georgia, serif;
  --font-body:    'Epilogue', system-ui, sans-serif;

  --text-xs:      0.75rem;
  --text-sm:      0.875rem;
  --text-base:    1rem;
  --text-lg:      1.375rem;
  --text-xl:      1.75rem;
  --text-display: clamp(2.25rem, 5vw + 0.75rem, 4.5rem);

  --max-w:       1600px;
  --max-w-prose: 65ch;

  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
}

[data-theme="light"] {
  --bg:        oklch(97% 0.008 75);
  --bg-raised: oklch(92% 0.010 75);
  --fg:        oklch(14% 0.008 75);
  --fg-muted:  oklch(44% 0.009 75);
  --border:    oklch(85% 0.010 75);
  --accent:    oklch(40% 0.14 72);
}

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

/* ── Focus ── */
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--bg-raised);
  color: var(--fg);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: 2px;
  z-index: 200;
  transition: top var(--dur-fast);
}
.skip-link:focus { top: var(--space-sm); }

/* ── Base ── */
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  padding: 0 clamp(20px, 4vw, 80px);
  transition:
    background var(--dur-slow) var(--ease-out-quart),
    color var(--dur-slow) var(--ease-out-quart);
}

/* ── Layout shells ── */
.site-header,
main,
.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ── Site header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: 1px solid var(--border);
  gap: var(--space-md);
}

.site-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

#primary-nav .nav-inner {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  align-items: center;
}

#primary-nav .nav-inner a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--dur-fast) var(--ease-out-quart);
}

#primary-nav .nav-inner a:hover { color: var(--fg); }
#primary-nav .nav-inner a[aria-current="page"] { color: var(--fg); }

/* ── Hamburger button ── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--fg-muted);
  position: relative;
  flex-shrink: 0;
  transition: color var(--dur-fast) var(--ease-out-quart);
}

.hamburger:hover { color: var(--fg); }
.hamburger::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.ham-line {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transition:
    transform var(--dur-base) var(--ease-out-quart),
    opacity var(--dur-base) var(--ease-out-quart);
}

.hamburger[aria-expanded="true"] .ham-line:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.hamburger[aria-expanded="true"] .ham-line:nth-child(2) {
  transform: scaleX(0);
  opacity: 0;
}
.hamburger[aria-expanded="true"] .ham-line:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ── Theme toggle ── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  line-height: 1;
  padding: 0;
  position: relative;
  transition: color var(--dur-fast) var(--ease-out-quart);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.theme-toggle::before {
  content: '';
  position: absolute;
  inset: -10px;
}
.theme-toggle:hover { color: var(--fg); }

/* ── Main ── */
main {
  padding: var(--space-4xl) 0;
  min-height: 60vh;
}

/* ── Site footer ── */
.site-footer {
  color: var(--fg-muted);
  font-size: var(--text-xs);
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--border);
}

/* ── Homepage intro ── */
.intro { margin-bottom: var(--space-4xl); }

.intro-headline {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: var(--space-xl);
}

.intro-body {
  font-size: var(--text-base);
  color: var(--fg-muted);
  max-width: var(--max-w-prose);
  line-height: 1.75;
}

.intro-body a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: text-decoration-color var(--dur-fast) var(--ease-out-quart);
}
.intro-body a:hover { text-decoration-color: var(--accent); }

/* ── Section label ── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: var(--space-xl);
}

/* ── Currently reading ── */
.currently-reading {
  margin-top: var(--space-4xl);
  padding-top: var(--space-3xl);
  border-top: 1px solid var(--border);
  container-type: inline-size;
}

/* ── Book grid ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-xl) var(--space-lg);
}

/* ── Book card (link) ── */
.book-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  text-decoration: none;
  color: inherit;
}

.book-card .book-cover {
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}

.book-card:hover .book-cover,
.book-card:focus-visible .book-cover {
  opacity: 0.75;
}

.book-card:hover .book-title,
.book-card:focus-visible .book-title {
  color: var(--accent);
}

.book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-raised);
}

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

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}

.cover-placeholder span {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.4;
}

.book-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.book-title {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
  transition: color var(--dur-fast) var(--ease-out-quart);
}

.book-author {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.book-rating {
  font-size: 0.55rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.progress-bar {
  height: 2px;
  background: var(--border);
  margin-top: var(--space-xs);
  overflow: hidden;
  border-radius: 1px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
}

.progress-label {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Books page ── */
.books-section {
  margin-bottom: var(--space-4xl);
  container-type: inline-size;
}
.books-section:last-child { margin-bottom: 0; }

.want-list { list-style: none; }

.want-list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
}

.want-list li:first-child { border-top: 1px solid var(--border); }

.want-list .book-author {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  flex-shrink: 0;
}

/* ── Page heading ── */
.page-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--fg);
  margin-bottom: var(--space-3xl);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* ── Post list ── */
.post-list { list-style: none; }

.post-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: var(--space-md);
  align-items: baseline;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.post-list li:first-child { border-top: 1px solid var(--border); }

.post-list--no-date li { grid-template-columns: 1fr; }

.post-list a {
  color: var(--fg);
  text-decoration: none;
  font-size: var(--text-base);
  transition: color var(--dur-fast) var(--ease-out-quart);
}

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

.post-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.date {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
}

.tag {
  font-size: var(--text-xs);
  padding: 2px var(--space-sm);
  border-radius: 2px;
  background: var(--bg-raised);
  color: var(--fg-muted);
}

.muted {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

/* ── Article / prose ── */
.article-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
}

.meta {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.prose { max-width: var(--max-w-prose); }
.prose p { margin: 1em 0; }

.prose h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: -0.01em;
  margin: var(--space-2xl) 0 var(--space-md);
}

.prose h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--fg);
  margin: var(--space-xl) 0 var(--space-sm);
}

.prose a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: text-decoration-color var(--dur-fast) var(--ease-out-quart);
}
.prose a:hover { text-decoration-color: var(--accent); }

.prose code {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  background: var(--bg-raised);
  padding: 0.15em 0.4em;
  border-radius: 2px;
  font-size: 0.875em;
  font-variant-ligatures: none;
}

.prose pre {
  background: var(--bg-raised);
  padding: var(--space-lg) var(--space-xl);
  border-radius: 4px;
  overflow-x: auto;
  font-size: var(--text-sm);
  margin: var(--space-xl) 0;
}

.prose pre code { background: none; padding: 0; }

.prose blockquote {
  border-left: 1px solid var(--border);
  margin: var(--space-xl) 0;
  padding-left: var(--space-lg);
  color: var(--fg-muted);
  font-style: italic;
}

.prose ul, .prose ol {
  padding-left: var(--space-xl);
  margin: 1em 0;
}

.prose li { margin: 0.4em 0; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-2xl) 0;
}

/* ── Book detail page ── */
.book-back {
  display: inline-block;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3xl);
  transition: color var(--dur-fast) var(--ease-out-quart);
}
.book-back:hover { color: var(--fg); }

.book-page-header {
  display: grid;
  grid-template-columns: min(160px, 38%) 1fr;
  gap: var(--space-3xl);
  align-items: start;
  margin-bottom: var(--space-3xl);
  padding-bottom: var(--space-3xl);
  border-bottom: 1px solid var(--border);
}

.book-page-cover-img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.book-page-cover-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: var(--bg-raised);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.book-page-cover-placeholder span {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.4;
}

.book-page-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-xs);
}

.book-page-rating {
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-bottom: var(--space-xs);
}

.book-page-title {
  font-family: var(--font-display);
  font-size: clamp(var(--text-xl), 4vw + 0.25rem, var(--text-display));
  font-weight: 400;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.book-page-author {
  font-size: var(--text-base);
  color: var(--fg-muted);
  margin-top: var(--space-xs);
}

.book-page-stats {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-top: var(--space-sm);
  font-variant-numeric: tabular-nums;
}

.book-page-review {
  max-width: var(--max-w-prose);
}

.review-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.review-header .section-label {
  margin-bottom: 0;
}

.review-stats {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.book-page-review-text {
  font-size: var(--text-base);
  color: var(--fg-muted);
  line-height: 1.85;
  margin-bottom: var(--space-lg);
}

.book-page-review-text:last-child {
  margin-bottom: 0;
}

/* ── Reading progress bar ── */
#read-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 5px;
  width: 0%;
  background: oklch(40% 0.04 60);
  z-index: 300;
  transition: width 200ms ease;
  pointer-events: none;
}

[data-theme="light"] #read-progress {
  background: oklch(38% 0.07 55);
}

/* ── Back to top ── */
.back-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 40px;
  height: 40px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity var(--dur-base) var(--ease-out-quart),
    transform var(--dur-base) var(--ease-out-quart),
    color var(--dur-fast) var(--ease-out-quart);
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover { color: var(--fg); }

/* ── Scroll reveal ── */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition:
      opacity 0.55s var(--ease-out-expo),
      transform 0.55s var(--ease-out-expo);
  }
  .reveal.visible {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Container queries for book grid ── */
@container (max-width: 480px) {
  .book-grid { grid-template-columns: repeat(3, 1fr); }
}

@container (max-width: 280px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .site-header {
    flex-wrap: wrap;
    padding-top: var(--space-lg);
    align-items: center;
  }

  /* hamburger replaces inline nav */
  .hamburger { display: flex; }

  /* nav drops below the header row */
  #primary-nav {
    order: 10;
    flex: 0 0 100%;
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    transition: grid-template-rows var(--dur-slow) var(--ease-out-expo);
  }

  #primary-nav.open {
    grid-template-rows: 1fr;
  }

  #primary-nav .nav-inner {
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border);
  }

  #primary-nav .nav-inner a {
    font-size: var(--text-base);
    padding: var(--space-sm) 0;
    width: 100%;
  }

  main { padding: var(--space-3xl) 0; }
  .intro { margin-bottom: var(--space-3xl); }

  .post-list li {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .book-page-header {
    gap: var(--space-xl);
  }

  .back-to-top {
    bottom: var(--space-lg);
    right: var(--space-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.prose img {
  max-width: 100%;
  width: 600px;
}
