/* MSquared Quests: quiet, bookish, reading-first. */

:root {
  --paper: #f6f3eb;
  --white: #fffdf8;
  --ink: #243945;
  --muted: #58656a;
  --line: #d9d9cd;
  --accent: #74413d;
  --soft: #e9eee9;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171c1f;
    --white: #1e2529;
    --ink: #e6e2d8;
    --muted: #9aa3a6;
    --line: #333d42;
    --accent: #d09a92;
    --soft: #243034;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #171c1f; --white: #1e2529; --ink: #e6e2d8; --muted: #9aa3a6; --line: #333d42; --accent: #d09a92; --soft: #243034;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--ink); line-height: 1.15; }
h1 { font-size: clamp(2.2rem, 6vw, 3rem); letter-spacing: -0.033em; margin: 0.15em 0 0.35em; }
h2 { font-size: clamp(1.5rem, 4vw, 1.8rem); letter-spacing: -0.024em; margin: 0 0 0.5em; }
h3 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 0 0 0.3em; }
h1 em, h2 em { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 520px) { .wrap { padding: 0 16px; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 10; font-family: var(--sans); }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* small letter-spaced sans labels */
.kicker { font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 0; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--accent); }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 36em; margin: 0; }

/* ---- header ---- */
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 22px; padding-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--accent); color: var(--accent); font-size: 1rem; flex: none; }
.brand-name { font-size: 1.35rem; letter-spacing: -0.01em; white-space: nowrap; }
.site-nav { display: flex; gap: 22px; font-family: var(--sans); font-size: 0.85rem; font-weight: 500; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
@media (max-width: 760px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 16px; padding-bottom: 8px; }
  .site-nav { width: 100%; gap: 18px; }
}

main { padding-top: 40px; padding-bottom: 72px; min-height: 60vh; }
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 44px; color: var(--muted); font-family: var(--sans); font-size: 0.85rem; }
.site-footer a { color: inherit; }

/* ---- buttons, labels ---- */
.btn { display: inline-flex; align-items: center; gap: 10px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 2px; padding: 12px 22px; font-family: var(--sans); font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); background: transparent; }
.label-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.label-row a { color: var(--muted); text-decoration: none; }
.label-row a:hover { color: var(--accent); text-decoration: underline; }
.label-row .theme-label { color: var(--accent); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; }
.status { font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.status-open, .status-investigating { color: var(--muted); }
.status-solved { color: var(--accent); }

/* ---- sections ---- */
.hero { padding: 8px 0 36px; border-bottom: 1px solid var(--line); }
.hero h1 { margin-top: 0.3em; }
.section { margin-top: 48px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 { margin: 0.2em 0 0; }
.section-head > a { font-family: var(--sans); font-size: 0.9rem; white-space: nowrap; }
.page-head { padding-bottom: 28px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }

/* ---- cards (Reader Guide style) ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px; }
.card { background: var(--white); border: 1px solid var(--line); padding: 28px; display: flex; flex-direction: column; }
.card-cover { margin: -28px -28px 24px; border-bottom: 1px solid var(--line); }
.card-cover { display: block; }
.card-cover img, .card-cover .quest-tile { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card h3 { font-size: 1.7rem; letter-spacing: -0.024em; margin: 0.35em 0 0.25em; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.card .desc { font-size: 1.1rem; margin: 0.6em 0; }
.card .detail { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin: 0 0 1.4em; }
.card .btn { align-self: flex-start; margin-top: auto; }
.progress { display: flex; gap: 4px; margin: 0 0 1.2em; }
.progress i { flex: 1; height: 3px; background: var(--line); }
.progress i.on { background: var(--accent); }

/* ---- compact entry list (home, themes) ---- */
.entry-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.entry-list li { border-bottom: 1px solid var(--line); }
.entry-list a.row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 20px; align-items: center; padding: 18px 0; text-decoration: none; color: var(--ink); }
.entry-list a.row.no-photo { grid-template-columns: 1fr; }
.entry-list h3 { font-size: 1.3rem; margin: 0.15em 0 0.2em; }
.entry-list a.row:hover h3 { color: var(--accent); }
.entry-list p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.entry-list img { width: 96px; height: 72px; object-fit: cover; border: 1px solid var(--line); }

/* ---- the log feed (full posts, like a paper journal) ---- */
.feed { max-width: 720px; }
.post { padding: 0 0 48px; margin-bottom: 48px; border-bottom: 1px solid var(--line); }
.post:last-child { border-bottom: 0; }
.post-title { font-size: clamp(1.7rem, 4.5vw, 2.2rem); letter-spacing: -0.028em; margin: 0 0 0.25em; }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--accent); }
.post-date { color: var(--muted); font-size: 1rem; margin: 0 0 1.2em; }
.post-photo { margin: 1.4em 0; }
.post-photo img { width: 100%; border: 1px solid var(--line); background: var(--white); }
.found { margin-top: 1.6em; }
.found > h2 { font-size: 1.35rem; margin-bottom: 0.4em; }
.wondering { margin-top: 1.6em; padding: 4px 0 4px 18px; border-left: 3px solid var(--line); color: var(--muted); font-style: italic; }
.post .label-row, .feed > .label-row { margin-top: 1.6em; }
.post.teaser .clip { position: relative; max-height: 20em; overflow: hidden; }
.post.teaser .clip::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5em; background: linear-gradient(rgba(246, 243, 235, 0), var(--paper)); }
.read-more { display: inline-block; margin-top: 0.8em; font-family: var(--sans); font-size: 0.9rem; font-weight: 600; }

/* ---- filters ---- */
.filters { display: flex; gap: 10px; margin: 0 0 16px; max-width: 520px; }
.filters input[type="search"] { flex: 1; min-width: 0; font-family: var(--sans); font-size: 0.95rem; padding: 11px 14px; border: 1px solid #b9b9ad; border-radius: 2px; background: var(--white); color: var(--ink); }
.filters .btn { padding: 10px 18px; }
.theme-filter { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--sans); font-size: 0.85rem; margin: 0 0 12px; }
.theme-filter a { color: var(--muted); text-decoration: none; padding: 2px 0; border-bottom: 2px solid transparent; }
.theme-filter a:hover { color: var(--ink); }
.theme-filter a.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.active-filters { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin: 0 0 32px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }

/* ---- entry page ---- */
.entry-grid { display: grid; grid-template-columns: minmax(0, 720px) 240px; gap: 56px; justify-content: space-between; }
@media (max-width: 900px) { .entry-grid { grid-template-columns: 1fr; gap: 32px; } }
.aside-box { border-top: 1px solid var(--line); padding-top: 16px; font-family: var(--sans); font-size: 0.9rem; align-self: start; }
.aside-box dl { margin: 0; }
.aside-box dt { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 14px; }
.aside-box dt:first-child { margin-top: 0; }
.aside-box dd { margin: 2px 0 0; color: var(--ink); }
.mini-map { height: 180px; margin-top: 18px; border: 1px solid var(--line); z-index: 0; }
.sources { margin-top: 2em; font-family: var(--sans); font-size: 0.9rem; }
.sources h2 { font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.sources ol { padding-left: 1.2em; margin: 0; }
.sources a { word-break: break-word; }
.entry-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); }
.entry-nav a { text-decoration: none; color: var(--ink); }
.entry-nav a:hover { color: var(--accent); }
.entry-nav small { display: block; font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.entry-nav .right { text-align: right; }

/* ---- prose ---- */
.prose { overflow-wrap: break-word; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 1em; }
.prose h3, .prose h4, .prose h5 { font-weight: 700; margin: 1.4em 0 0.4em; font-size: 1.3rem; }
.prose h4, .prose h5 { font-size: 1.1rem; }
.prose blockquote { border-left: 3px solid var(--accent); padding-left: 16px; color: var(--muted); font-style: italic; }
.prose code { font-family: var(--mono); font-size: 0.85em; background: var(--soft); padding: 1px 5px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose > :last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.prose table { border-collapse: collapse; font-family: var(--sans); font-size: 0.9rem; min-width: 100%; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { font-weight: 600; }
.readable { max-width: 720px; }

/* ---- quest page ---- */
.quest-cover { max-width: 720px; margin-bottom: 32px; border: 1px solid var(--line); }
.quest-cover img, .quest-cover svg { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.milestones { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); max-width: 720px; }
.milestones li { display: flex; gap: 14px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.milestones .tick { font-family: var(--sans); width: 18px; flex: none; color: var(--muted); }
.milestones .done .tick { color: var(--accent); }
.milestones .done span:last-child { color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; max-width: 720px; }
.timeline li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.timeline img { max-width: 100%; border: 1px solid var(--line); margin: 12px 0; }

/* ---- themes ---- */
.theme-index { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); max-width: 760px; }
.theme-index li { border-bottom: 1px solid var(--line); }
.theme-index a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 20px 0; text-decoration: none; color: var(--ink); }
.theme-index a:hover h3 { color: var(--accent); }
.theme-index h3 { font-size: 1.5rem; margin: 0; }
.theme-index p { margin: 4px 0 0; color: var(--muted); font-size: 1rem; }
.theme-index .count { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

/* ---- map ---- */
.map-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; font-family: var(--sans); font-size: 0.9rem; }
.map-controls select { font: inherit; padding: 8px 12px; border: 1px solid #b9b9ad; border-radius: 2px; background: var(--white); color: var(--ink); }
.seg { display: inline-flex; border: 1px solid #b9b9ad; border-radius: 2px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: var(--white); color: var(--ink); padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.big-map { height: min(70vh, 620px); border: 1px solid var(--line); z-index: 0; }
.map-dot { background: none; border: 0; }
.map-dot span { display: block; width: 14px; height: 14px; border-radius: 50%; background: #74413d; border: 2px solid #fffdf8; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.map-pop { display: block; width: 190px; text-decoration: none; color: #243945; font-family: Georgia, serif; }
.map-pop img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin-bottom: 6px; }
.map-pop strong { display: block; font-weight: 400; font-size: 1rem; line-height: 1.3; }
.map-pop small { color: #58656a; font-family: system-ui, sans-serif; }
.leaflet-container { font-family: var(--sans); }
.marker-cluster { background: rgba(116, 65, 61, 0.25) !important; }
.marker-cluster div { background: #74413d !important; color: #fffdf8 !important; font-family: system-ui, sans-serif; font-weight: 600; }

/* ---- life hub ---- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px; }
.book { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 18px; }
.book-cover { width: 84px; height: 126px; object-fit: cover; border: 1px solid var(--line); }
.book-blank { display: grid; place-items: center; padding: 8px; background: var(--white); font-size: 0.8rem; text-align: center; line-height: 1.25; color: var(--muted); }
.book h3 { margin: 0; }
.stars { color: var(--accent); letter-spacing: 2px; font-family: var(--sans); font-size: 0.9rem; }
.stack { max-width: 720px; border-top: 1px solid var(--line); }
.stack > article { padding: 28px 0; border-bottom: 1px solid var(--line); }
.stack h3 { font-size: 1.5rem; }
.embed { margin: 14px 0; }
.embed iframe { width: 100%; border: 0; }
.embed.video iframe { aspect-ratio: 16 / 9; }
.embed.audio iframe { height: 152px; }

/* ---- empty ---- */
.empty { padding: 32px 0; color: var(--muted); max-width: 520px; }
.empty h3 { color: var(--ink); }
