:root {
  --bg: #0d1117;
  --surface: #151922;
  --surface-2: #1d2230;
  --paper: #e8d7b0;
  --paper-2: #cbb684;
  --ink: #f4ead2;
  --muted: #b8a98c;
  --faint: #796f5d;
  --border: #3a3140;
  --border-soft: #282633;
  --crimson: #d54545;
  --gold: #c58b3a;
  --teal: #4fb5a8;
  --violet: #9d5cff;
  --blue: #76a9ff;
  --shadow: rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(900px 520px at 92% -12%, rgba(213, 69, 69, 0.14), transparent 64%),
    radial-gradient(780px 520px at 0% 100%, rgba(79, 181, 168, 0.11), transparent 62%),
    linear-gradient(180deg, #0d1117, #111018 42%, #0b0d12);
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

p {
  overflow-wrap: break-word;
}

.skip {
  position: absolute;
  left: -999px;
  top: 10px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 4px;
  color: #111;
  background: var(--paper);
}

.skip:focus {
  left: 10px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 12px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--crimson);
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.nav {
  display: inline-flex;
  gap: 8px;
}

.nav a {
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.hero {
  position: relative;
  min-height: clamp(420px, 68vh, 720px);
  display: grid;
  align-items: end;
  overflow: hidden;
  padding: clamp(48px, 8vw, 92px) clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--border-soft);
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 17, 23, 0.94), rgba(13, 17, 23, 0.7) 44%, rgba(13, 17, 23, 0.2)),
    linear-gradient(180deg, rgba(13, 17, 23, 0.04), rgba(13, 17, 23, 0.76));
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--crimson);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  font-family: var(--font-display);
  font-size: clamp(3rem, 7.5vw, 6.8rem);
  font-weight: 700;
  line-height: 0.93;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 62ch;
  margin-top: 22px;
  color: var(--muted);
  font-size: clamp(1rem, 1.45vw, 1.22rem);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 150px));
  gap: 12px;
  margin-top: 28px;
}

.hero-stats div {
  padding: 14px;
  border: 1px solid rgba(197, 139, 58, 0.28);
  border-radius: var(--radius);
  background: rgba(21, 25, 34, 0.78);
}

.hero-stats span {
  display: block;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
}

.hero-stats small {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.atlas-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) clamp(18px, 3.5vw, 48px);
  align-items: start;
}

.controls {
  position: sticky;
  top: 82px;
  z-index: 30;
  display: grid;
  grid-template-columns:
    minmax(150px, 0.55fr)
    minmax(210px, 0.9fr)
    minmax(220px, 0.85fr)
    minmax(360px, 1.8fr)
    minmax(170px, 0.7fr)
    minmax(130px, auto);
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: 0 18px 46px var(--shadow);
}

h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1;
}

.search-box,
.range-box {
  display: grid;
  gap: 8px;
}

.search-box span,
.range-box span,
.category-panel > span,
.location-focus span {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.search-box input {
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  background: #0a0d12;
}

.search-box input:focus {
  outline: 0;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 139, 58, 0.16);
}

.range-box input {
  accent-color: var(--gold);
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.category-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  font-size: 0.86rem;
  white-space: nowrap;
}

.category-btn.active {
  color: var(--ink);
  border-color: var(--cat-color);
  background: color-mix(in srgb, var(--cat-color) 14%, transparent);
}

.category-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cat-color);
}

.location-focus {
  display: grid;
  gap: 6px;
  padding-top: 0;
  border-top: 0;
}

.location-focus strong {
  color: var(--paper);
  font-size: 0.95rem;
}

.location-focus button,
.reset-btn {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
}

.location-focus button:hover,
.reset-btn:hover {
  color: var(--paper);
  border-color: var(--gold);
}

.reset-btn {
  color: var(--ink);
  border-color: rgba(213, 69, 69, 0.46);
  background: rgba(213, 69, 69, 0.12);
}

.atlas-main {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(330px, 0.62fr);
  gap: 20px;
  align-items: start;
  min-width: 0;
}

.map-card,
.detail-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: 0 18px 46px var(--shadow);
}

.map-card {
  min-width: 0;
  overflow: hidden;
}

.map-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.result-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.map-stage {
  position: relative;
  aspect-ratio: 1000 / 620;
  overflow: hidden;
  min-height: 540px;
  background:
    radial-gradient(220px 160px at 80% 74%, rgba(197, 139, 58, 0.16), transparent 68%),
    radial-gradient(320px 220px at 21% 39%, rgba(79, 181, 168, 0.12), transparent 70%),
    linear-gradient(140deg, rgba(232, 215, 176, 0.08), transparent 38%),
    #0a0d12;
}

.map-stage::before {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1px solid rgba(197, 139, 58, 0.18);
  border-radius: 48% 52% 45% 55%;
  transform: rotate(-8deg);
}

#routeSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.route-line {
  stroke: rgba(197, 139, 58, 0.44);
  stroke-width: 1.8;
  stroke-dasharray: 6 8;
  fill: none;
}

.route-line.active {
  stroke: var(--crimson);
  stroke-width: 2.4;
  stroke-dasharray: none;
}

.map-pins {
  position: absolute;
  inset: 0;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--cat-color, var(--gold));
  border-radius: 50%;
  color: var(--paper);
  background: rgba(13, 17, 23, 0.82);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--cat-color, var(--gold)) 14%, transparent);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.pin::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat-color, var(--gold));
}

.pin:hover,
.pin.active {
  transform: translate(-50%, -50%) scale(1.12);
  background: rgba(13, 17, 23, 0.96);
}

.pin-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  max-width: 130px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.map-label {
  position: absolute;
  color: rgba(232, 215, 176, 0.18);
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 3.2rem);
  font-weight: 700;
  pointer-events: none;
}

.map-label.europe {
  left: 13%;
  top: 28%;
}

.map-label.levant {
  right: 10%;
  top: 58%;
}

.map-label.egypt {
  right: 22%;
  bottom: 8%;
}

.detail-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.detail-year {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.detail-panel h3 {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.05;
}

.detail-panel p {
  color: var(--muted);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
}

.pill.category {
  color: var(--paper);
  border-color: var(--cat-color);
  background: color-mix(in srgb, var(--cat-color) 13%, transparent);
}

.detail-block {
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.detail-block strong {
  display: block;
  margin-bottom: 6px;
  color: var(--paper);
}

.timeline-section,
.notes-section {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 64px) clamp(36px, 6vw, 72px);
}

.section-heading {
  margin-bottom: 18px;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 14px;
}

.event-card {
  min-height: 100%;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--cat-color);
  border-radius: var(--radius);
  color: var(--ink);
  background: linear-gradient(180deg, rgba(21, 25, 34, 0.94), rgba(29, 34, 48, 0.94));
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 220ms ease;
}

.event-card:hover,
.event-card.active {
  transform: translateY(-2px);
  border-color: var(--cat-color);
  box-shadow: 0 14px 34px var(--shadow);
}

.event-card .year {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.event-card h3 {
  margin-top: 8px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1.1;
}

.event-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.notes-grid > div {
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.notes-grid h3 {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.notes-grid p {
  color: var(--muted);
  font-size: 0.93rem;
}

.site-footer {
  padding: 30px clamp(20px, 5vw, 64px) 44px;
  border-top: 1px solid var(--border-soft);
  color: var(--faint);
  text-align: center;
}

@media (max-width: 1180px) {
  .atlas-main {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls > div:first-child,
  .search-box,
  .range-box,
  .category-panel,
  .location-focus,
  .reset-btn {
    min-width: 0;
  }

  .category-panel,
  .reset-btn {
    grid-column: 1 / -1;
  }

  .category-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .map-stage {
    min-height: 460px;
  }
}

@media (max-width: 760px) {
  .brand small,
  .nav a {
    display: none;
  }

  .brand-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .hero {
    min-height: 560px;
  }

  .hero-media::after {
    background:
      linear-gradient(180deg, rgba(13, 17, 23, 0.78), rgba(13, 17, 23, 0.94)),
      linear-gradient(90deg, rgba(13, 17, 23, 0.96), rgba(13, 17, 23, 0.44));
  }

  h1 {
    font-size: 3.2rem;
  }

  .hero-stats,
  .controls,
  .category-buttons,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .atlas-shell {
    padding-inline: 16px;
  }

  .map-heading {
    align-items: start;
    flex-direction: column;
  }

  .map-stage {
    min-width: 720px;
  }

  .map-card {
    overflow-x: auto;
  }

  .pin-label {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
