/* The California Dispatch — editorial family album */

:root {
  --paper: #FAF9F6;
  --ink: #181611;
  --muted: #6B675E;
  --soft: #504C43;
  --rule: #E6E2D9;
  --rule-strong: #D8D4CB;
  --accent: #9A3B16;
  --accent-soft: #DCC9BE;
  --panel: #14181B;
  --panel-ink: #F2EFE8;
  --panel-muted: #9BAAB3;
  --tile: #ECE8DF;
  --card-bg: #FFFFFF;
  --chip-bg: #FFFFFF;
}

/* Dark theme — explicit choice, or system preference when no choice is stored */
:root[data-theme="dark"] {
  --paper: #161411;
  --ink: #EAE7E0;
  --muted: #9A968C;
  --soft: #B5B1A6;
  --rule: #2E2B25;
  --rule-strong: #3C3830;
  --accent: #E08A5C;
  --accent-soft: #4A3A30;
  --panel: #0E1214;
  --tile: #2A2722;
  --card-bg: #1E1B17;
  --chip-bg: #1E1B17;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161411;
    --ink: #EAE7E0;
    --muted: #9A968C;
    --soft: #B5B1A6;
    --rule: #2E2B25;
    --rule-strong: #3C3830;
    --accent: #E08A5C;
    --accent-soft: #4A3A30;
    --panel: #0E1214;
    --tile: #2A2722;
    --card-bg: #1E1B17;
    --chip-bg: #1E1B17;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent); opacity: 0.75; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 38px;
}

.loading {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}
.loading-mark { font-size: 28px; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.error-box {
  margin: 10vh auto;
  max-width: 480px;
  padding: 28px;
  border: 1px solid var(--rule);
  text-align: center;
  line-height: 1.6;
}

/* Masthead */
.masthead { display: flex; flex-direction: column; gap: 14px; border-bottom: 3px solid var(--ink); padding-bottom: 22px; }
.masthead-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.masthead h1 { margin: 0; font-family: Fraunces, serif; font-weight: 700; font-size: clamp(36px, 6vw, 62px); line-height: 1.02; letter-spacing: -0.01em; }
.masthead h1 a { color: inherit; text-decoration: none; }
.masthead-sub { margin: 0; font-size: 14px; color: var(--soft); }

/* Breadcrumb */
.crumb { font-size: 13px; color: var(--muted); }
.crumb a { text-decoration: none; font-weight: 600; }
.crumb .sep { padding: 0 8px; }

/* Section headers */
.section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--rule-strong); padding-bottom: 10px; }
.section-head h2 { margin: 0; font-family: Fraunces, serif; font-weight: 600; font-size: 28px; }
.section-head .hint { font-size: 13px; color: var(--muted); }

/* Hero */
.hero { display: flex; flex-direction: column; gap: 12px; }
.hero-date { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero-title { margin: 0; font-family: Fraunces, serif; font-weight: 600; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.15; }
.hero-title a { color: inherit; text-decoration: none; }
.hero-meta { font-size: 14px; color: var(--soft); }
.hero-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hero-grid .tile:first-child { grid-column: span 2; grid-row: span 2; }

/* Chapter list */
.chapter-card { display: grid; grid-template-columns: minmax(220px, 3fr) 6fr; gap: 20px; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.chapter-info { display: flex; flex-direction: column; gap: 7px; }
.chapter-date { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.chapter-date a { color: inherit; text-decoration: none; }
.hero-open { font-size: 14px; font-weight: 600; text-decoration: none; }
.chapter-title { margin: 0; font-family: Fraunces, serif; font-size: 22px; font-weight: 600; line-height: 1.2; }
.chapter-title a { color: var(--ink); text-decoration: none; }
.chapter-title a:hover { color: var(--accent); }
.chapter-counts { font-size: 13px; color: var(--muted); }
.chapter-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }

/* Place chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.chip {
  font-size: 11px; font-weight: 600; text-decoration: none; color: var(--accent);
  border: 1px solid var(--accent-soft); border-radius: 12px; padding: 4px 10px; background: var(--chip-bg);
}
.chip:hover { border-color: var(--accent); }

/* Tiles */
.tile {
  position: relative; background: var(--tile); overflow: hidden; display: block;
  border: 0; padding: 0; width: 100%; cursor: pointer;
}
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge {
  position: absolute; top: 8px; right: 8px; background: rgba(24,22,17,0.85); color: #FAF9F6;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 9px; z-index: 1;
}
.tile .more {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(24,22,17,0.45); color: #FAF9F6; font-size: 15px; font-weight: 600; z-index: 1;
}
.tile.ratio { aspect-ratio: 4 / 3; }

/* Day sections in chapter view */
.day { display: flex; flex-direction: column; gap: 12px; }
.day-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.day-head h3 { margin: 0; font-family: Fraunces, serif; font-weight: 600; font-size: 24px; }
.day-head .day-meta { font-size: 13px; color: var(--muted); }
.day-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }

/* Chapter header */
.chapter-head { display: grid; grid-template-columns: 7fr 5fr; gap: 24px; border-bottom: 3px solid var(--ink); padding-bottom: 26px; }
.chapter-head-info { display: flex; flex-direction: column; gap: 10px; }
.chapter-head h1 { margin: 0; font-family: Fraunces, serif; font-weight: 700; font-size: clamp(30px, 4.4vw, 46px); line-height: 1.05; }
.route-box { position: relative; min-height: 260px; border: 1px solid var(--rule); background: var(--card-bg); }
.route-box svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-map { position: absolute; inset: 0; }
.route-note {
  position: absolute; bottom: 8px; left: 10px; z-index: 2; font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--soft); background: var(--card-bg); padding: 3px 7px; border-radius: 3px; opacity: 0.92;
}
.place-map { height: 300px; border: 1px solid var(--rule); background: var(--card-bg); }
.place-map.tall { height: 440px; }

/* Places index */
.place-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.place-card {
  display: flex; flex-direction: column; gap: 4px; text-decoration: none;
  border: 1px solid var(--rule); background: var(--card-bg); border-radius: 8px; padding: 14px 16px;
}
.place-card:hover { border-color: var(--accent); opacity: 1; }
.place-card-name { font-family: Fraunces, serif; font-weight: 600; font-size: 17px; color: var(--ink); }
.place-card-meta { font-size: 12px; color: var(--muted); }

/* Theme toggle — one quiet icon, click cycles system → light → dark */
.masthead-right { display: inline-flex; align-items: center; gap: 14px; }
.theme-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; border: none; background: none;
  color: var(--muted); cursor: pointer; padding: 0;
}
.theme-icon:hover { color: var(--ink); background: var(--tile); }

/* Map-dot filter bar */
.filter-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--accent-soft); border-radius: 8px;
  padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--ink);
}
.filter-bar button {
  font-family: Inter, sans-serif; font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #FAF9F6; border: none; border-radius: 14px; padding: 6px 14px;
}

/* Admin note editing */
.note-area { display: flex; flex-direction: column; gap: 8px; }
.note-edit {
  align-self: flex-start; font-family: Inter, sans-serif; font-size: 12px; font-weight: 600;
  background: none; border: 1px dashed var(--rule-strong); border-radius: 12px;
  color: var(--muted); padding: 4px 12px; cursor: pointer;
}
.note-edit:hover { color: var(--accent); border-color: var(--accent); }
.note-input {
  font-family: Fraunces, serif; font-style: italic; font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--card-bg); border: 1px solid var(--rule-strong);
  padding: 10px 12px; width: 100%; max-width: 60ch; box-sizing: border-box; resize: vertical;
}
.note-actions { display: flex; align-items: center; gap: 10px; }
.note-actions button {
  font-family: Inter, sans-serif; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 7px 16px; border: 1px solid var(--rule-strong); background: none; color: var(--soft);
}
.note-actions .note-save { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.note-status { font-size: 12px; color: var(--muted); }

/* Chapter note (admin-written, from data/notes.json) */
.chapter-note {
  margin: 4px 0 0; font-family: Fraunces, serif; font-style: italic; font-size: 16px;
  line-height: 1.55; color: var(--soft); max-width: 60ch;
}

/* Dark crossover / atlas panels */
.panel { background: var(--panel); border-radius: 10px; padding: 26px 28px; color: var(--panel-ink); display: flex; flex-direction: column; gap: 14px; }
.panel .eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #8FD0E3; font-weight: 600; }
.panel h2, .panel h3 { margin: 0; font-family: Fraunces, serif; font-weight: 600; }
.panel p { margin: 0; font-size: 13px; color: var(--panel-muted); line-height: 1.55; }
.panel a { color: #8FD0E3; }
.cross-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cross-card { text-decoration: none; display: flex; flex-direction: column; gap: 7px; }
.cross-card .tile { aspect-ratio: 4 / 3; background: #1D2428; border-radius: 6px; }
.cross-card span { font-size: 12px; color: var(--panel-muted); }
.cross-card:hover span { color: var(--panel-ink); }

/* Place page header */
.place-head { display: flex; flex-direction: column; gap: 10px; border-bottom: 3px solid var(--ink); padding-bottom: 22px; }
.place-head h1 { margin: 0; font-family: Fraunces, serif; font-weight: 700; font-size: clamp(30px, 4.4vw, 46px); }

/* Prev/next footer */
.pager { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 3px solid var(--ink); padding-top: 18px; }
.pager a { font-size: 13px; font-weight: 600; text-decoration: none; }
.site-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; border-top: 3px solid var(--ink); padding-top: 16px; font-size: 12px; color: var(--muted); }
.site-foot a { color: var(--muted); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(14,13,11,0.96); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px;
}
.lightbox img, .lightbox video { max-width: 94vw; max-height: 82vh; object-fit: contain; }
.lightbox-caption { color: #CFCBC2; font-size: 13px; text-align: center; }
.lightbox-caption a { color: #E0A183; text-decoration: none; font-weight: 600; }
.lightbox-caption a:hover { color: #F0C3AA; opacity: 1; }
.lightbox-close {
  position: absolute; top: 14px; right: 16px; background: none; border: 1px solid #4a473f; color: #CFCBC2;
  font-size: 15px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); background: none; border: none;
  color: #CFCBC2; font-size: 34px; cursor: pointer; padding: 18px 14px;
}
.lightbox-nav:hover, .lightbox-close:hover { color: #fff; }
.lightbox-nav.prev { left: 6px; }
.lightbox-nav.next { right: 6px; }

.show-more {
  align-self: center; font-family: Inter, sans-serif; font-size: 13px; font-weight: 600;
  background: none; border: 1px solid var(--rule-strong); padding: 10px 22px; cursor: pointer; color: var(--soft);
}
.show-more:hover { border-color: var(--ink); color: var(--ink); }

@media (max-width: 760px) {
  .wrap { padding: 28px 16px 48px; gap: 30px; }
  .chapter-card { grid-template-columns: 1fr; gap: 12px; }
  .chapter-strip, .day-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid .tile:first-child { grid-column: span 2; grid-row: auto; }
  .chapter-head { grid-template-columns: 1fr; }
  .cross-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .place-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
