/* Bharat Heritage Trail — design tokens & layout
   Warm, editorial "Heritage Passport" system: a traveller's passport gets a
   stamp per country; this site stamps a passport per site visited. */

:root {
  --bg: #f0eee6;
  --surface: #faf9f5;
  --ink: #1f1e1d;
  --muted: #6b6862;
  --accent: #c15f3c;
  --danger: #b3453d;
  --success: #4b7355;
  --accent-ink: #faf9f5;
  --border: #ddd8cc;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-brand: "Rozha One", Georgia, serif;
  --max-width: 720px;
  --topbar-height: 48px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Top navbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-wrap {
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar-progress {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow-x: auto;
}

.progress-item strong {
  font-weight: 700;
  color: var(--accent);
}

.progress-sep {
  color: var(--border);
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.site-header-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  max-width: 46ch;
}

@media (min-width: 760px) {
  .site-header-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    max-width: 960px;
    gap: 24px;
  }
  .tagline {
    flex: 1;
  }
  .base-city {
    margin-top: 0;
    flex-shrink: 0;
    width: 300px;
  }
}

/* ---------- Base city picker ---------- */

.base-city {
  position: relative;
  margin-top: 4px;
  max-width: 360px;
}

.base-city label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.base-city-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.base-city-input-wrap input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.base-city-clear {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}

.base-city-clear:hover {
  background: var(--border);
}

.city-suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(31, 30, 29, 0.08);
  max-height: 260px;
  overflow-y: auto;
}

.city-suggestions li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14.5px;
  cursor: pointer;
}

.city-suggestions li:hover,
.city-suggestions li[aria-selected="true"] {
  background: var(--bg);
}

/* ---------- Tabs ---------- */

.tabs-row {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tabs-row-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-x: auto;
}

.tabs {
  display: flex;
  gap: 4px;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  flex-shrink: 0;
}

.view-toggle .tab {
  border: none;
  padding: 6px 12px;
}

.view-toggle .tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--surface);
}

.tab {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

/* ---------- Ledger ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 20px 48px;
}

.state-group {
  margin-top: 28px;
}

.state-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 0 0 4px;
}

.state-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.site-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-row {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.site-row:last-child {
  border-bottom: none;
}

.visited-toggle {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--danger);
  background: var(--danger);
  cursor: pointer;
  padding: 0;
  position: relative;
}

.visited-toggle[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
}

.visited-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  width: 6px;
  height: 11px;
  border-right: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(45deg);
}

.site-info {
  min-width: 0;
}

.site-name {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 2px;
}

.site-meta {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.site-blurb {
  margin: 0 0 6px;
  font-size: 14.5px;
  color: var(--ink);
  max-width: 62ch;
}

.site-links {
  margin: 0;
  font-size: 13px;
  display: flex;
  gap: 14px;
}

.site-links a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ---------- Map ---------- */

.map-section {
  border-bottom: 1px solid var(--border);
}

.site-map {
  height: 60vh;
  min-height: 340px;
  max-height: 560px;
  width: 100%;
  background: var(--bg);
}

.map-marker {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(31, 30, 29, 0.25);
  background: var(--danger);
}

.map-marker--visited {
  background: var(--success);
  opacity: 1;
}

.map-marker--visited::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 4px;
  height: 7px;
  border-right: 1.5px solid var(--surface);
  border-bottom: 1.5px solid var(--surface);
  transform: rotate(45deg);
}

.leaflet-popup-content-wrapper,
.leaflet-tooltip {
  font-family: var(--font);
  border-radius: var(--radius);
}

/* ---------- Detail panel ---------- */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 30, 29, 0.35);
  z-index: 2000;
}

.detail-panel {
  position: fixed;
  z-index: 2001;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px 32px;
}

@media (min-width: 720px) {
  .detail-panel {
    left: auto;
    top: 0;
    bottom: 0;
    width: 420px;
    max-height: none;
    border-top: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
  }
}

.detail-close {
  position: sticky;
  top: 0;
  float: right;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.detail-body {
  clear: both;
  padding-top: 8px;
}

.detail-image {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 14px;
  background: var(--bg);
}

.detail-name {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 4px;
}

.detail-meta {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 12px;
}

.detail-blurb {
  font-size: 15px;
  margin: 0 0 14px;
}

.detail-distance {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin: 0 0 14px;
}

.detail-distance-empty {
  color: var(--muted);
  font-weight: 400;
}

.detail-travel {
  margin: 0 0 14px;
  font-size: 14px;
}

.detail-travel dt {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.detail-travel dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.detail-links {
  display: flex;
  gap: 16px;
  font-size: 14px;
  margin: 0 0 18px;
}

.detail-links a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.detail-visited-toggle {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--danger);
  background: var(--danger);
  color: var(--accent-ink);
  cursor: pointer;
  margin-bottom: 18px;
}

.detail-visited-toggle[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
  color: var(--accent-ink);
}

.detail-nearby h3 {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.detail-nearby ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-nearby-link {
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border);
  cursor: pointer;
}

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

footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px 60px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

footer p {
  max-width: 62ch;
  margin: 0 0 10px;
}

/* ---------- Topbar actions ---------- */

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.topbar-btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

/* ---------- Quick add ---------- */

.quickadd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 30, 29, 0.4);
  z-index: 3000;
}

.quickadd-modal {
  position: fixed;
  z-index: 3001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 94vw);
  height: min(80vh, 760px);
  background: var(--surface);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(31, 30, 29, 0.25);
}

.quickadd-modal[hidden] {
  display: none;
}

.quickadd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.quickadd-count {
  margin: 0;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.quickadd-count strong {
  color: var(--success);
  font-size: 20px;
}

.quickadd-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quickadd-done {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.quickadd-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.quickadd-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.qa-section {
  margin-bottom: 20px;
}

.qa-section-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 8px;
}

.qa-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qa-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.qa-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.qa-item[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
  color: var(--accent-ink);
}

.qa-item[aria-pressed="true"] .qa-dot {
  background: var(--accent-ink);
}

/* ---------- Share card ---------- */

.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 30, 29, 0.4);
  z-index: 3000;
}

.share-modal {
  position: fixed;
  z-index: 3001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 92vw);
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(31, 30, 29, 0.25);
}

.share-canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin-bottom: 16px;
}

.share-actions {
  display: flex;
  gap: 10px;
}

.share-btn {
  flex: 1;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.share-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.share-btn-full {
  width: 100%;
  margin-bottom: 10px;
}

.share-btn:not(.share-btn-primary) {
  font-size: 13.5px;
  padding: 10px 8px;
}

.share-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Trip planner ---------- */

.tripplanner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 30, 29, 0.4);
  z-index: 3000;
}

.tripplanner-modal {
  position: fixed;
  z-index: 3001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 24px 24px 28px;
  box-shadow: 0 20px 60px rgba(31, 30, 29, 0.25);
}

.tripplanner-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 18px;
  padding-right: 40px;
}

.tripplanner-field {
  margin-bottom: 18px;
}

.tripplanner-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented-btn {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.segmented-btn[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.tp-results {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tp-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tp-card-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 4px;
}

.tp-card-meta {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tp-card-season {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--accent);
}

.tp-card-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.tp-route {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}

.tp-route li {
  margin-bottom: 4px;
}

.tp-route-state {
  color: var(--muted);
  font-size: 12.5px;
}

.tp-empty {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
