/* ==========================================================================
   Books — stylesheet

   The whole look is driven by the design tokens in :root below. When you want
   to redesign later, start there (colours, fonts, spacing) — most of the page
   will follow without touching the rules underneath.
   ========================================================================== */

:root {
  /* Palette — a warm "old paper + ink" library feel by default */
  --bg: #f4efe6;
  --bg-card: #fbf8f2;
  --ink: #2b2722;
  --ink-soft: #6f675c;
  --line: #e3dccd;
  --accent: #c9824a; /* the o/J hooks + highlights */

  /* Type */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;

  /* Shape & rhythm */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 39, 34, 0.08), 0 8px 24px rgba(43, 39, 34, 0.08);
  --maxw: 1040px;
  --gap: clamp(14px, 2vw, 22px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --bg-card: #211d16;
    --ink: #efe9dd;
    --ink-soft: #b0a795;
    --line: #322c22;
    --accent: #e0a36a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(127, 103, 92, 0.14);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.92em;
}

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

/* ---- Header / wordmark ---------------------------------------------------- */

.topbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) var(--gap) clamp(8px, 2vw, 18px);
  text-align: center;
}

.wordmark {
  display: block;
  width: clamp(180px, 42vw, 300px);
  height: auto;
  margin: 0 auto;
}

.wm-letter {
  fill: var(--ink);
  font-family: var(--font-display);
  font-size: 135px;
  font-weight: 800;
  letter-spacing: -1px;
}

.wm-hook {
  fill: none;
  stroke: var(--accent);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tagline {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  color: var(--ink-soft);
}

.stats {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- Shelf / sections ----------------------------------------------------- */

.shelf {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(12px, 3vw, 32px) var(--gap) 64px;
}

.section {
  margin-top: clamp(28px, 5vw, 48px);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 700;
}

.section-head .count {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--gap);
}

/* ---- A book --------------------------------------------------------------- */

.book {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--cover-bg, #555);
  color: #fff;
  /* Left "spine" line to suggest a real book */
  border-left: 3px solid rgba(255, 255, 255, 0.28);
}

/* The generated typographic cover (shown until a real image loads) */
.cover .gen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 13px;
  text-align: left;
}

.cover .gen .gen-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  line-height: 1.18;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  /* clamp very long titles */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover .gen .gen-author {
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  opacity: 0.92;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.cover .gen::after {
  /* a thin decorative rule above the author */
  content: "";
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 34px;
  height: 1px;
  background: rgba(255, 255, 255, 0.4);
}

/* Real cover image, layered on top; hidden until it successfully loads */
.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cover img.loaded {
  opacity: 1;
}

.book .meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.book .b-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
}

.book .b-author {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.book .b-date {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

.book .b-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

/* "Currently reading" gets a little progress note */
.progress {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---- Activity heatmap ----------------------------------------------------- */

.heatmap {
  display: grid;
  grid-template-columns: auto repeat(12, 1fr);
  gap: 5px;
  align-items: center;
  max-width: 640px;
}

.hm-month,
.hm-year {
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
}

.hm-year {
  text-align: right;
  padding-right: 8px;
}

.hm-cell {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--line);
}

.hm-cell.lvl-1 {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg-card));
  box-shadow: none;
}
.hm-cell.lvl-2 {
  background: color-mix(in srgb, var(--accent) 52%, var(--bg-card));
  box-shadow: none;
}
.hm-cell.lvl-3 {
  background: color-mix(in srgb, var(--accent) 76%, var(--bg-card));
  box-shadow: none;
}
.hm-cell.lvl-4 {
  background: var(--accent);
  box-shadow: none;
}

.hm-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.hm-legend .hm-cell {
  width: 15px;
  height: 15px;
  aspect-ratio: auto;
}

/* ---- Footer --------------------------------------------------------------- */

.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px var(--gap) 48px;
  text-align: center;
  border-top: 1px solid var(--line);
}

.error {
  color: #b3402f;
}
