/* Fonts are served from this site (fonts/ folder). Until those files are in
   place the page falls back to Georgia and the system sans-serif. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/fraunces.woff") format("woff");
}
@font-face {
  font-family: "Fraunces"; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url("../fonts/fraunces-italic.woff") format("woff");
}
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/figtree.woff") format("woff");
}

:root {
  --paper: #f7f1e6;
  --paper-2: #fffaf2;
  --ink: #2a211c;
  --ink-soft: #6e6157;
  --line: #e3d8c6;
  --rust: #b8502c;
  --rust-dark: #8f3a1d;
  --gold: #c08a1e;
  --ocean: #dde6e3;
  --graticule: rgba(60, 90, 90, 0.13);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(42, 33, 28, 0.06), 0 4px 14px rgba(42, 33, 28, 0.07);
  --panel-w: 420px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); margin: 0; font-weight: 600; }
a { color: var(--rust-dark); }
button { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--ink-soft); font-size: 0.92rem; margin: 0.25rem 0 0; }

/* ---------------- Header ---------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.5rem;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: inherit; }
.brand-mark { width: 44px; height: 44px; color: var(--rust); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.1;
  color: var(--rust-dark);
  letter-spacing: -0.01em;
}
.brand-tagline { font-size: 0.88rem; color: var(--ink-soft); }

.header-tools { display: flex; align-items: center; gap: 1.25rem; }
.stats {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  white-space: nowrap;
}
.search input {
  width: 300px;
  padding: 0.55rem 0.9rem 0.55rem 2.2rem;
  font: inherit;
  color: var(--ink);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236e6157' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.search input:focus { outline: 2px solid var(--rust); outline-offset: 1px; background-color: #fff; }

/* ---------------- Layout ---------------- */
.layout { flex: 1; display: flex; min-height: 0; }

.map-wrap { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--paper); }
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }

.sphere { fill: var(--ocean); stroke: #c9d6d2; stroke-width: 1; vector-effect: non-scaling-stroke; }
.graticule { fill: none; stroke: var(--graticule); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.country {
  stroke: var(--paper-2);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.15s ease;
}
.country:hover { stroke: var(--ink); stroke-width: 1.4; filter: brightness(0.93); }
.country.has-books { stroke-width: 0.8; }
.country.selected { stroke: var(--ink); stroke-width: 1.8; }

/* States / provinces: fade in when zoomed in */
.regions { opacity: 0; transition: opacity 0.3s ease; pointer-events: none; }
#map.show-regions .regions { opacity: 1; }
.region {
  fill: none;
  stroke: rgba(42, 33, 28, 0.28);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.region.has-books { fill: url(#hatch); stroke: rgba(42, 33, 28, 0.55); }
#map.show-regions .region.has-books { pointer-events: auto; cursor: pointer; }
.region.has-books:hover { stroke: var(--ink); stroke-width: 1.2; }
.region.selected { stroke: var(--ink); stroke-width: 1.8; }

/* Country borders redrawn above the states/provinces when zoomed in */
.country-borders {
  fill: none;
  stroke: rgba(42, 33, 28, 0.6);
  stroke-width: 1.3;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#map.show-regions .country-borders { opacity: 1; }

.monsters { pointer-events: none; opacity: 0.3; }
.monster { opacity: 0; transition: opacity 1.2s ease; }
.monster.shown { opacity: 1; }   /* change 0.3 to make them stronger/fainter */

/* Map labels. --k is the zoom level, so sizes stay constant on screen. */
.labels { pointer-events: none; }
.label {
  display: none;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke-linejoin: round;
}
.label.on { display: inline; }
.label--country {
  font-family: var(--sans);
  font-weight: 600;
  font-size: calc(10.67px / var(--k, 1));          /* 8 pt */
  fill: #3a2f28;
  stroke: #fff;
  stroke-width: calc(2.67px / var(--k, 1));         /* 1 pt halo each side */
}
.label--ocean, .label--sea, .label--lake {
  font-family: var(--serif);
  font-style: italic;
  fill: #4f7178;
  stroke: var(--ocean);
  stroke-width: calc(2px / var(--k, 1));
}
.label--ocean {
  font-size: calc(12px / var(--k, 1));
  letter-spacing: 0.22em;
  text-transform: uppercase;
  fill: #5f8187;
}
.label--sea { font-size: calc(10.5px / var(--k, 1)); letter-spacing: 0.03em; }
.label--lake { font-size: calc(9.5px / var(--k, 1)); }
.hatch-dark { stroke: rgba(42, 33, 28, 0.7); }
.hatch-light { stroke: rgba(255, 250, 242, 0.85); }

.map-status {
  position: absolute; inset: 0; margin: auto; height: fit-content;
  max-width: 28rem; padding: 1rem; text-align: center; color: var(--ink-soft);
}

/* Map controls */
.segmented, .zoom-controls, .legend {
  position: absolute;
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}
.map-toggles { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; z-index: 2; }
.segmented { position: static; display: flex; padding: 3px; gap: 2px; }
.segmented button {
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--ink-soft);
  cursor: pointer;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--rust); color: #fff; }
.shelf-filter button.active { background: var(--ink); }

.zoom-controls { top: 14px; right: 14px; display: flex; flex-direction: column; overflow: hidden; }
.zoom-controls button {
  width: 34px; height: 34px;
  font-size: 1.1rem; line-height: 1;
  background: none; border: none; cursor: pointer;
}
.zoom-controls button + button { border-top: 1px solid var(--line); }
.zoom-controls button:hover { background: var(--paper); }

.legend { left: 14px; bottom: 14px; padding: 0.55rem 0.75rem; font-size: 0.78rem; }
.legend-title { margin: 0 0 0.35rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.7rem; color: var(--ink-soft); }
.legend ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.legend li { display: flex; align-items: center; gap: 0.3rem; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.08); }
.swatch--hatch {
  background: repeating-linear-gradient(45deg, rgba(42, 33, 28, 0.7) 0 1.2px, rgba(255, 250, 242, 0.9) 1.2px 2.4px, #d47d50 2.4px 4.2px);
}
.legend-regions { flex-basis: 100%; }

.tooltip {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 5;
}
.tooltip strong { display: block; font-weight: 600; }
.tooltip span { opacity: 0.85; font-size: 0.8rem; }
.tooltip .muted { color: #fff; opacity: 0.65; }

/* ---------------- Panel ---------------- */
.panel {
  width: var(--panel-w);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 1.4rem 1.4rem 2rem;
  background: var(--paper-2);
  border-left: 1px solid var(--line);
}
.panel-heading { font-size: 1.25rem; color: var(--ink); }
.panel-heading--spaced { margin-top: 2rem; }
.panel-title { font-size: 1.75rem; color: var(--rust-dark); line-height: 1.15; }

.back-link {
  margin-bottom: 0.6rem; padding: 0;
  font-size: 0.9rem; color: var(--ink-soft);
  background: none; border: none; cursor: pointer;
}
.back-link:hover { color: var(--ink); }

.country-list { list-style: none; padding: 0; margin: 0.6rem 0 0; columns: 2; column-gap: 1rem; }
.country-list li { break-inside: avoid; }
.country-list button {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.country-list button:hover { color: var(--rust-dark); }
.country-list .count { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); }
.region-list { columns: 1; }
.muted-inline { color: var(--ink-soft); font-size: 0.8rem; margin-left: 0.25rem; }

.up-link {
  margin-top: 0.4rem; padding: 0;
  font-size: 0.88rem; font-weight: 600; color: var(--rust-dark);
  background: none; border: none; cursor: pointer;
}
.up-link:hover { text-decoration: underline; }

.book-regions { margin: 0.3rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.region-chip {
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem; font-weight: 600;
  color: var(--rust-dark);
  background: #f6e3d6;
  border-radius: 999px;
}

.warning {
  margin-top: 1rem; padding: 0.6rem 0.75rem; font-size: 0.85rem;
  background: #fff4e0; border: 1px solid #f0d49a; border-radius: 6px;
}

/* ---------------- Book cards ---------------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem 1rem;
  margin-top: 1rem;
}

.book-card { display: flex; flex-direction: column; min-width: 0; border-radius: var(--radius); }
#featured .book-card { cursor: pointer; }
.book-card.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px rgba(184, 80, 44, 0.45); } 100% { box-shadow: 0 0 0 4px rgba(184, 80, 44, 0); } }

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  box-shadow: var(--shadow), inset 4px 0 0 rgba(0, 0, 0, 0.12);
  margin-bottom: 0.6rem;
  transition: transform 0.2s ease;
}
.book-card:hover .cover { transform: translateY(-2px); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--paper); }
.cover--photo { aspect-ratio: auto; }
.cover--photo img { position: static; display: block; height: auto; }
.cover--photo .cover-placeholder { display: none; }

.cover-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14% 12% 12% 16%;
  color: #fff7ec;
}
.cover-placeholder::before {
  content: ""; position: absolute; left: 7%; top: 0; bottom: 0; width: 1px; background: rgba(255, 247, 236, 0.25);
}
.cover-placeholder-title { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; line-height: 1.15; overflow-wrap: anywhere; }
.cover-placeholder-author { font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.85; }

.book-rank {
  position: absolute; top: 8px; right: 8px;
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem; font-weight: 700;
  color: #fff; background: var(--rust);
  border-radius: 999px;
}

.book-title { font-size: 0.98rem; line-height: 1.25; }
.book-author { margin: 0.15rem 0 0; font-size: 0.82rem; color: var(--ink-soft); }
.book-pub { margin: 0.1rem 0 0; font-size: 0.74rem; color: var(--ink-soft); opacity: 0.85; letter-spacing: 0.01em; }
.book-rating { margin: 0.3rem 0 0; font-size: 0.85rem; }
.stars { color: var(--gold); letter-spacing: 1px; }
.book-desc {
  margin: 0.35rem 0 0; font-size: 0.82rem; line-height: 1.4; color: var(--ink-soft);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.buy-button {
  align-self: flex-start;
  margin-top: 0.6rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem; font-weight: 600;
  color: #fff; text-decoration: none;
  background: var(--rust);
  border-radius: 6px;
}
.buy-button:hover { background: var(--rust-dark); }

/* ---------------- Footer ---------------- */
.site-footer {
  display: flex; justify-content: space-between; gap: 0.5rem 1.5rem; flex-wrap: wrap;
  padding: 0.6rem 1.5rem;
  font-size: 0.78rem; color: var(--ink-soft);
  background: var(--paper-2);
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; }
.disclosure { font-style: italic; }
.boundary-note { flex-basis: 100%; font-size: 0.72rem; opacity: 0.85; }

/* ---------------- Small screens ---------------- */
@media (max-width: 900px) {
  :root { --panel-w: 340px; }
  .search input { width: 220px; }
  .stats { display: none; }
}

@media (max-width: 760px) {
  body { height: auto; min-height: 100%; }
  .site-header { padding: 0.75rem 1rem; }
  .header-tools, .search, .search input { width: 100%; }
  .layout { flex-direction: column; }
  .map-wrap { height: 58vh; min-height: 320px; flex: none; }
  .panel { width: auto; border-left: none; border-top: 1px solid var(--line); padding: 1.2rem 1rem 2rem; overflow: visible; }
  .segmented button { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
  .legend { font-size: 0.72rem; padding: 0.4rem 0.55rem; }
  .legend ul { gap: 0.4rem; }
  .site-footer { padding: 0.75rem 1rem; }
}

/* ---------------- Owned / wishlist ---------------- */
.book-status { margin: 0.3rem 0 0; font-size: 0.75rem; font-weight: 600; }
.book-status--owned { color: #2f5d50; }
.book-status--wanted { color: #9a6b22; }
.book-card.is-wanted .cover { opacity: 0.82; }
/* ---------------- About ---------------- */
.about-link {
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem; font-weight: 600;
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.about-link:hover { border-color: var(--rust); color: var(--rust-dark); }

.about {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 2rem 2.2rem 1.6rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(42, 33, 28, 0.25);
}
.about::backdrop { background: rgba(42, 33, 28, 0.45); }
.about h2 { font-size: 1.7rem; color: var(--rust-dark); margin-bottom: 0.8rem; }
.about p { margin: 0 0 0.9rem; line-height: 1.6; }
.about-close {
  position: absolute; top: 0.6rem; right: 0.8rem;
  width: 2rem; height: 2rem;
  font-size: 1.5rem; line-height: 1;
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft);
}
.about-close:hover { color: var(--ink); }
@media (max-width: 760px) {
  .about { padding: 1.5rem 1.2rem 1rem; }
  .header-tools { flex-wrap: wrap; gap: 0.6rem; }
  .search { flex: 1 1 200px; }
}
