:root {
  --forest: #193727;
  --green: #006b09;
  --paper: #e1efbc;
  --ink: #202c1f;
  --red: #a51815;
  --blue: #123c96;
  --line: #9aaf79;
  --photo-height: min(281px, 40dvh);
  --photo-panel: calc(var(--photo-height) * 345 / 281);
  --header-height: calc(var(--photo-height) + 5px);
  --rail: clamp(12rem, 18.5vw, 16rem);
  --inset: clamp(1rem, 2vw, 1.5rem);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--paper) url('sand.jpg'); color: var(--ink); }
a { color: var(--green); text-underline-offset: 0.16em; }
a:focus-visible { outline: 2px solid #1762a0; outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 3;
  inset: 0 auto auto 0;
  padding: 0.4rem 0.65rem;
  background: var(--paper);
  transform: translateY(-120%);
}

.skip-link:focus { transform: none; }

.masthead {
  position: sticky;
  z-index: 2;
  top: 0;
  display: grid;
  grid-template-columns: var(--photo-panel) minmax(0, 1fr);
  height: var(--header-height);
  border-bottom: 5px solid var(--green);
  color: white;
}

.masthead-emblem {
  display: grid;
  place-items: center;
  background: var(--forest) url('fr3.jpg') left center / auto 100% no-repeat;
}

.masthead-emblem img {
  display: block;
  width: auto;
  height: calc(var(--photo-height) * 0.8);
  max-width: 90%;
  object-fit: contain;
}

.masthead-inner {
  position: relative;
  min-width: 0;
  background: var(--forest) url('fr1.jpg') left center / max(100%, calc(var(--photo-height) * 1840 / 281)) 100% no-repeat;
  text-align: center;
}

.masthead a:focus-visible { outline-color: white; }

.language {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 4px 8px;
  background: #17281c;
  color: white;
  font-size: 0.9rem;
}

h1 {
  margin: 0;
  padding: clamp(2.1rem, 5dvh, 3rem) 0.55rem 0;
  font-size: clamp(1.5rem, 4vw, 3.3rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-shadow: 1px 2px 5px #000, 0 0 12px #000;
}

.section-layout {
  display: grid;
  grid-template-areas: 'rail main';
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.section-rail {
  grid-area: rail;
  position: sticky;
  top: var(--header-height);
  align-self: start;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--header-height));
  border-right: 1px solid var(--line);
}

.section-nav {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  text-align: center;
}

.section-nav ul { list-style: none; padding: 0; margin: 0; }
.section-nav-group + .section-nav-group { border-top: 1px solid var(--line); }

.section-nav a {
  display: block;
  padding: 0.78rem 0.55rem;
  color: var(--green);
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.section-nav a:hover,
.section-nav [aria-current='page'] { background: var(--green); color: white; }
.section-nav a:focus-visible { outline-offset: -3px; }

main {
  grid-area: main;
  min-width: 0;
  max-width: 1100px;
  padding: 1.2rem var(--inset) 2rem;
  font-size: clamp(1.05rem, 1.75vw, 1.25rem);
  line-height: 1.45;
}

main[id], main [id] { scroll-margin-top: calc(var(--header-height) + 0.6rem); }
main > :first-child { margin-top: 0; }
p { max-width: 68ch; }
h2 { margin: 1.5rem 0 0.55rem; font-size: 1.4em; line-height: 1.2; }
.byline { margin-bottom: 1.15rem; font-weight: 700; }

.trip-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 1.5rem;
  margin-block: 1.25rem;
  text-align: center;
}

.trip-photo-grid figure { margin: 0; }
.trip-photo-link { display: inline-block; max-width: 100%; color: var(--ink); text-decoration: none; }
.trip-photo-link img { display: block; max-width: 100%; height: auto; margin: 0 auto 0.6rem; }
.trip-photo-label strong { color: var(--blue); text-decoration: underline; }

.route-lead, .nz-routes h3 { color: var(--red); }
.nz-routes h3 { margin: 1.25em 0 0.18em; font-size: 1.45em; line-height: 1.15; }
.route-list { margin: 0; padding: 0; list-style: none; }
.route-list li + li { margin-top: 0.12rem; }
.route-list a { color: var(--blue); font-weight: 700; overflow-wrap: anywhere; }
.route-list a:visited { color: #523585; }

.year-links { margin-bottom: 1.2rem; }
.year-links ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.year-links a {
  display: block;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  background: rgb(250 255 236 / 55%);
  font-size: 0.9rem;
}

.license {
  flex-shrink: 0;
  padding: 0.7rem 0.5rem 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--forest);
  text-align: center;
  font-size: 0.82rem;
}

.license p { margin: 0.3rem auto; }
.license img { display: block; margin: 0 auto 0.45rem; }

@media (max-width: 720px) {
  :root { --photo-height: clamp(70px, 25vw, min(130px, 30dvh)); }

  h1 { padding-top: 2rem; font-size: clamp(1.05rem, 4.6vw, 2rem); }
  .language { top: 0.22rem; right: 0.35rem; padding: 0.16rem 0.45rem; font-size: 0.8rem; }

  .section-layout {
    grid-template-areas: 'navigation' 'main' 'license';
    grid-template-columns: minmax(0, 1fr);
  }

  .section-rail { display: contents; }

  .section-nav {
    grid-area: navigation;
    overflow: visible;
    scrollbar-gutter: auto;
    border-bottom: 1px solid var(--line);
  }

  .section-nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-nav-group > li:only-child { grid-column: 1 / -1; }
  .section-nav a { display: grid; place-items: center; height: 100%; padding: 0.45rem; font-size: 0.9rem; }
  main { padding-top: 0.85rem; }
  .trip-photo-grid { grid-template-columns: minmax(0, 1fr); }
  .license { grid-area: license; }
}

.masthead-inner {
  background-size: max(100%, calc(var(--photo-height) * 1629 / 281)) 100%;
}

.nw-story > section + section { margin-top: 2rem; }
.nw-story .route-list { max-width: 68ch; }

@media (max-width: 720px) {
  .masthead { grid-template-columns: minmax(0, 1fr); }
  .masthead-emblem { display: none; }
  .masthead-inner { background-position: center; background-size: cover; }
}
