@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Source+Sans+3:wght@400;600&display=swap');

@font-face {
  font-family: 'ChesapeakeRomanLoco';
  src: url('../fonts/CHESRL__.TTF') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy:        #0a1628;
  --navy-mid:    #112240;
  --navy-light:  #1e3a5f;
  --gold:        #c8a84b;
  --gold-light:  #e8cc80;
  --cyan:        #4fc3c8;
  --white:       #f4f1eb;
  --grey-light:  #d8d2c4;
  --grey-mid:    #8a8070;
  --text-body:   #e8e4da;
  --text-muted:  #9a9488;
  --rule:        rgba(200,168,75,0.35);
  --sidebar-w:   240px;
  --content-max: 860px;
  --font-display: 'ChesapeakeRomanLoco', Georgia, serif;
  --font-body:    'Source Serif 4', Georgia, serif;
  --font-ui:      'Source Sans 3', Verdana, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--navy);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--gold-light); text-decoration: underline; }
a:visited { color: #9a7830; }

/* Header */
.site-header { background: var(--navy-mid); border-bottom: 2px solid var(--gold); padding: 0 1.5rem; }
.site-header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; padding: 0.75rem 0; flex-wrap: wrap;
}
.site-title { font-family: var(--font-display); font-size: 1.45rem; letter-spacing: 0.06em; color: var(--white); white-space: nowrap; }
.site-title span { color: var(--gold); }
.site-subtitle { font-family: var(--font-ui); font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--grey-mid); }

/* Section nav */
.section-nav { background: var(--navy-light); border-bottom: 1px solid var(--rule); }
.section-nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; display: flex; gap: 0; flex-wrap: wrap; }
.section-nav a {
  font-family: var(--font-ui); font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--grey-light);
  padding: 0.55rem 0.85rem; display: block;
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.section-nav a:hover { color: var(--gold-light); border-bottom-color: var(--gold); text-decoration: none; }
.section-nav a:visited { color: #9a7830; }
.section-nav a.active { color: var(--gold); border-bottom-color: var(--gold); }

/* Towns strip */
.towns-nav {
  background: var(--navy); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--navy-light) transparent; padding: 6px 0;
}
.towns-nav-inner { display: flex; align-items: flex-start; padding: 0 1rem; white-space: nowrap; }
.towns-nav-label {
  font-family: var(--font-ui); font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--grey-mid);
  padding-right: 0.75rem; flex-shrink: 0;
  border-right: 1px solid var(--rule); margin-right: 0.5rem; align-self: center;
}
.towns-nav a {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 8px; border-bottom: 2px solid transparent;
  text-decoration: none; transition: border-color 0.15s; vertical-align: top;
}
.towns-nav a:hover { border-bottom-color: var(--cyan); text-decoration: none; }
.towns-nav a:hover .mp-name { color: var(--cyan); }
.towns-nav a:visited .mp-name { color: var(--grey-light); }
.towns-nav a.current { border-bottom-color: var(--gold); }
.towns-nav a.current .mp-name { color: var(--gold); font-weight: 600; }
.mp-marker { width: 30px; height: 38px; flex-shrink: 0; display: block; }
.mp-name { font-family: var(--font-ui); font-size: 0.68rem; color: var(--grey-light); text-align: center; line-height: 1.2; max-width: 72px; white-space: normal; }
.towns-nav-sep { color: rgba(200,168,75,0.25); font-size: 0.6rem; padding: 0 1px; align-self: flex-start; margin-top: 19px; user-select: none; flex-shrink: 0; }

/* Section strip (placeholder for future section-specific nav bars) */
.section-strip {
  background: var(--navy); border-bottom: 1px solid var(--rule);
  overflow-x: auto; padding: 6px 0;
}
.section-strip-inner { display: flex; align-items: flex-start; padding: 0 1rem; white-space: nowrap; gap: 0; }
.section-strip a {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 14px; border-bottom: 2px solid transparent;
  text-decoration: none; transition: border-color 0.15s;
}
.section-strip a:hover { border-bottom-color: var(--cyan); text-decoration: none; }
.section-strip a:hover .ss-label { color: var(--cyan); }
.section-strip a.current { border-bottom-color: var(--gold); }
.section-strip a.current .ss-label { color: var(--gold); font-weight: 600; }
.ss-icon { width: 32px; height: 32px; display: block; flex-shrink: 0; }
.ss-label { font-family: var(--font-ui); font-size: 0.68rem; color: var(--grey-light); text-align: center; line-height: 1.2; }

/* Page layout */
.page-layout {
  max-width: 1200px; margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  gap: 2.5rem; align-items: start;
}
.page-layout.no-sidebar { grid-template-columns: 1fr; }
.page-layout.wide { grid-template-columns: 220px 1fr; }
.page-layout.wide .main-content { max-width: 900px; }

/* Sidebar */
.sidebar { position: sticky; top: 1rem; font-family: var(--font-ui); font-size: 0.84rem; }
.sidebar-section { margin-bottom: 1.75rem; }
.sidebar-heading {
  font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--grey-mid); border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem; margin-bottom: 0.6rem;
}
.sidebar-section ul { list-style: none; }
.sidebar-section li { margin-bottom: 0.25rem; }
.sidebar-section a { color: var(--grey-light); display: block; padding: 0.2rem 0.4rem; border-radius: 3px; transition: background 0.12s, color 0.12s; }
.sidebar-section a:hover { background: var(--navy-light); color: var(--cyan); text-decoration: none; }
.sidebar-section a:visited { color: #9a7830; }
.sidebar-section a.section-link::before { content: 'S '; opacity: 0.4; font-size: 0.8em; }

/* Main content */
.main-content { min-width: 0; max-width: var(--content-max); }
.page-title-block { margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--rule); }
.page-eyebrow { font-family: var(--font-ui); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.35rem; }
.page-title { font-family: var(--font-display); font-size: 2.1rem; color: var(--white); line-height: 1.2; }
.content-section { margin-bottom: 2.5rem; }
.content-section h2 { font-family: var(--font-display); font-size: 1.25rem; color: var(--gold-light); margin-bottom: 1rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
p { margin-bottom: 1rem; }
b { color: var(--white); }
h1, h2, h3 { margin-bottom: 0.75rem; }
img { max-width: 100%; height: auto; }
table { max-width: 100%; border-collapse: collapse; }

/* Footer */
.site-footer { background: var(--navy-mid); border-top: 1px solid var(--rule); padding: 1.5rem; font-family: var(--font-ui); font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; }
.site-footer a { color: var(--grey-mid); }
.site-footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.site-footer p { margin-bottom: 0.4rem; }

/* Page subtitle & sourced section headings (as-needed: opt-in via class, inert on pages that don't use it) */
.page-subtitle { font-family: var(--font-ui); font-size: 0.88rem; color: var(--grey-mid); margin-top: 0.3rem; }
.section-heading { display: flex; align-items: baseline; gap: 0.75rem; }
.section-heading-note { font-family: var(--font-ui); font-size: 0.72rem; color: var(--grey-mid); font-weight: normal; letter-spacing: 0.04em; }

/* Large section heading (as-needed: opt-in via class, for document-index pages like operations/) */
.section-heading-lg {
  font-family: var(--font-display); font-size: 1.35rem; color: var(--gold-light);
  margin-bottom: 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--rule);
}

/* Era date-nail strip + pager + history figures (as-needed: opt-in via class, history/era-*.htm pages) */
.era-nav {
  background: var(--navy);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-light) transparent;
  padding: 6px 0;
}
.era-nav-inner { display: flex; align-items: center; padding: 0 1rem; white-space: nowrap; }
.era-nav-label {
  font-family: var(--font-ui); font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--grey-mid);
  padding-right: 0.75rem; flex-shrink: 0;
  border-right: 1px solid var(--rule); margin-right: 0.5rem; align-self: center;
}
.era-nav a {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 8px; border-bottom: 2px solid transparent;
  text-decoration: none; transition: border-color 0.15s; vertical-align: top;
}
.era-nav a:hover { border-bottom-color: var(--cyan); text-decoration: none; }
.era-nav a:hover .era-name { color: var(--cyan); }
.era-nav a:visited .era-name { color: var(--grey-light); }
.era-nav a.current { border-bottom-color: var(--gold); }
.era-nav a.current .era-name { color: var(--gold); font-weight: 600; }
.dn-nail { width: 34px; height: 44px; flex-shrink: 0; display: block; }
.era-name { font-family: var(--font-ui); font-size: 0.68rem; color: var(--grey-light); text-align: center; line-height: 1.2; max-width: 72px; white-space: normal; }
.era-nav-sep { color: rgba(200,168,75,0.25); font-size: 0.6rem; padding: 0 1px; align-self: center; margin-bottom: 20px; user-select: none; flex-shrink: 0; }
.sidebar-era-current { color: var(--gold) !important; font-weight: 600; }

.hist-figure { margin: 1.25rem 0; }
.hist-figure img { display: block; max-width: 100%; height: auto; border: 1px solid rgba(200,168,75,0.2); }
.hist-figure.center { text-align: center; }
.hist-figure.center img { margin: 0 auto; }
.hist-figure figcaption { font-family: var(--font-ui); font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }

.era-pager {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--rule);
  font-family: var(--font-ui); font-size: 0.82rem;
}
.era-pager a { color: var(--grey-light); display: flex; align-items: center; gap: 0.4rem; }
.era-pager a:hover { color: var(--gold-light); text-decoration: none; }
.era-pager .pager-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); display: block; }
.era-pager .pager-era { color: var(--grey-light); }
.era-pager .next { text-align: right; }
.era-pager .prev-spacer { flex: 1; }

/* Map panel with optional legend (as-needed: opt-in via class) */
.map-panel {
  margin: 0 0 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--navy-mid);
}
.map-panel-header {
  padding: 0.5rem 0.85rem;
  background: rgba(200,168,75,0.08);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-ui); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}
.map-panel-header-right { font-weight: 400; color: var(--text-muted); letter-spacing: 0; text-transform: none; font-size: 0.72rem; }
.map-panel-body { display: block; }
.map-panel-body img { display: block; width: 100%; height: auto; }
.map-footer {
  padding: 0.5rem 0.85rem;
  border-top: 1px solid var(--rule);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.map-caption {
  font-family: var(--font-ui); font-size: 0.75rem; color: var(--text-muted); line-height: 1.5;
}
.map-legend {
  display: flex; gap: 1rem; flex-shrink: 0; flex-wrap: wrap; align-items: center;
  font-family: var(--font-ui); font-size: 0.72rem; color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-swatch {
  display: inline-block; width: 24px; height: 3px; border-radius: 2px; flex-shrink: 0;
}

/* Loco/car roster table + gallery + class specs (as-needed: opt-in via class, equipment/ pages) */
.loco-wrap { overflow-x: auto; margin-bottom: 2rem; }
.loco-table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 0.8rem; }
.loco-table th {
  background: var(--navy-light); color: var(--gold);
  padding: 0.45rem 0.6rem; text-align: left;
  border-bottom: 2px solid rgba(200,168,75,0.5);
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  white-space: nowrap;
}
.loco-table td {
  padding: 0.3rem 0.6rem; border-bottom: 1px solid rgba(200,168,75,0.1);
  color: var(--text-body); vertical-align: top;
}
.loco-table tr:hover td { background: rgba(255,255,255,0.03); }
.loco-table .loco-num a { color: var(--cyan); font-weight: 600; }
.loco-table .loco-num a:hover { color: var(--gold-light); }
.loco-table .loco-class { color: var(--gold-light); font-weight: 600; }
.loco-table .loco-notes { color: var(--text-muted); font-size: 0.75rem; line-height: 1.4; }
.loco-table .loco-section th { background: rgba(200,168,75,0.08); color: var(--gold); }

.loco-gallery { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0; }
.loco-gallery-item { display: flex; flex-direction: column; gap: 0.35rem; }
.loco-gallery-item img { border: 1px solid var(--rule); display: block; }
.loco-gallery-item .gal-cap { font-family: var(--font-ui); font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; max-width: 140px; }
.class-specs { background: var(--navy-light); border: 1px solid var(--rule); border-left: 3px solid var(--gold); border-radius: 4px; padding: 0.85rem 1.1rem; margin-bottom: 1.5rem; font-family: var(--font-ui); font-size: 0.85rem; }
.class-specs dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 1.2rem; }
.class-specs dt { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 0.1rem; }
.class-specs dd { color: var(--text-body); margin: 0; }

/* Figure component */
.fig { background: var(--navy-mid); border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: top; }
.fig img { display: block; width: 100%; height: auto; }
.fig figcaption { font-family: var(--font-ui); font-size: 0.78rem; color: var(--grey-mid); line-height: 1.45; padding: 0.5rem 0.7rem; }

/* Figure + text pairs */
.fig-pair { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; align-items: start; }
.fig-pair.fig-right { grid-template-columns: 1fr auto; }
.fig-pair.fig-left  { grid-template-columns: auto 1fr; }
.fig-pair .fig-text { min-width: 0; }

/* Full-width figure */
.fig-full { margin: 1.5rem 0; }
.fig-full .fig { display: block; max-width: 100%; }
.fig-full .fig img { width: 100%; }

/* Photo gallery */
.photo-gallery { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.photo-gallery .fig { flex: 0 0 auto; max-width: 320px; }

/* Industries table */
.industries-table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: 0.84rem; margin: 0.5rem 0 1rem; }
.industries-table th { background: var(--navy-light); color: var(--gold-light); text-align: left; padding: 0.5rem 0.75rem; font-weight: 600; border-bottom: 2px solid var(--gold); letter-spacing: 0.04em; }
.industries-table td { padding: 0.4rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: top; }
.industries-table tr:last-child td { border-bottom: none; }
.industries-table tr:nth-child(even) td { background: rgba(255,255,255,0.025); }
.industries-note { font-family: var(--font-ui); font-size: 0.84rem; color: var(--grey-mid); font-style: italic; }

/* Layout table (image + text column pairs, used on a subset of town pages) */
.layout-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.layout-table td { padding: 0 1rem 1.25rem 0; vertical-align: top; }
.layout-table td:first-child { width: 35%; padding-right: 1.25rem; }
.layout-table td:first-child img { max-width: 100%; height: auto; display: block; }
.layout-table td:last-child { width: 65%; }

/* Empty state */
.empty-state { font-family: var(--font-ui); font-size: 0.84rem; color: var(--grey-mid); font-style: italic; padding: 0.75rem 0; }

/* Responsive */
@media (max-width: 820px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; display: flex; flex-wrap: wrap; gap: 1.5rem; }
  .sidebar-section { flex: 1 1 160px; margin-bottom: 0; }
  .fig-pair.fig-right,
  .fig-pair.fig-left  { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .photo-gallery .fig { max-width: 100%; flex: 1 1 100%; }
}
