/* Atlas page and home teaser. Builds on tokens and components in styles.css.
   Everything is prefixed (.atlas-, .field-) because this sheet also loads on the home page.
   Layout switches use container queries in rem, so they follow text zoom as well as width. */

/* ---------- Heading ---------- */
.atlas-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  align-items: last baseline;
  gap: 0 clamp(2rem, 6vw, 5.5rem);
  max-width: none;
  padding-block: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 3vw, 2.5rem);
}
.atlas-heading > .eyebrow {
  flex: 1 0 100%;
  max-width: none;
}
.atlas-heading h1 {
  flex: none;
}
.atlas-heading > p:not(.eyebrow) {
  flex: 1 1 20rem;
  max-width: 44ch;
  margin-top: 1rem;
}

/* ---------- Stage: map and index ---------- */
.atlas-stage-wrap {
  container: atlas-stage / inline-size;
}
.atlas-stage {
  display: grid;
  gap: var(--gutter);
}
.atlas-main {
  display: grid;
  gap: 1rem;
  min-width: 0;
  container: atlas-main / inline-size;
}
@container atlas-stage (min-width: 62rem) {
  .atlas-stage[data-enhanced] {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 30%);
  }
  .atlas-stage[data-enhanced] .atlas-index {
    contain: size;
    height: 100%;
  }
  .atlas-stage[data-enhanced] .atlas-index-scroll {
    max-height: none;
  }
}

.atlas-map {
  margin: 0;
  min-width: 0;
}
.atlas-canvas {
  position: relative;
  display: block;
  aspect-ratio: var(--atlas-aspect, 2.3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
  touch-action: manipulation;
}
a.atlas-canvas {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s var(--ease);
}
a.atlas-canvas:hover {
  border-color: var(--ink);
}
a.atlas-canvas:focus-visible {
  outline-offset: 3px;
  border-radius: var(--radius);
}
.atlas-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.atlas-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: grid;
  gap: 0.1rem;
  max-width: min(17rem, calc(100% - 8px));
  padding: 0.6rem 0.75rem 0.65rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--step--1);
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 14px 30px -16px rgb(0 0 0 / 0.5);
}
.atlas-tip strong {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.atlas-tip span:not(.mono) {
  color: color-mix(in srgb, var(--paper) 72%, transparent);
}
.atlas-tip .mono {
  margin-top: 0.2rem;
}
/* Small maps: the tip is a card under the map, in the flow. */
.atlas-tip[data-bar] {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6rem;
  max-width: none;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem 0.55rem;
  box-shadow: none;
}
.atlas-tip[data-bar] .mono {
  margin-top: 0;
}
.atlas-tip[data-bar] .atlas-tip-also {
  flex-basis: 100%;
}
.atlas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  color: var(--muted);
}
.atlas-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.atlas-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.atlas-key-place {
  background: var(--accent);
}
.atlas-key-home {
  background: var(--accent);
  box-shadow:
    0 0 0 2px var(--paper),
    0 0 0 3.5px var(--ink);
  width: 8px;
  height: 8px;
  margin-inline: 2px;
}

/* Under the map: the legend. */
.atlas-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.25rem;
}

/* Place index: also the no-JS version of the map. */
.atlas-index {
  display: flex;
  flex-direction: column;
  min-width: 0;
  container: atlas-index / inline-size;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.atlas-index-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.atlas-index-head h2 {
  font-size: var(--step-1);
  letter-spacing: -0.025em;
}
.atlas-index-scroll {
  position: relative; /* keeps the visually hidden labels inside the scroll box */
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(70vh, 36rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 0.5rem 1rem;
  scrollbar-width: thin;
}
.atlas-index-scroll:focus-visible {
  outline-offset: -3px;
}
/* Continent and country names stay in view while their places scroll past. */
.atlas-continent h3 {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.9rem 0.5rem 0.45rem;
  background: var(--white);
  font-weight: 500;
}
.atlas-countries,
.atlas-places {
  margin: 0;
  padding: 0;
  list-style: none;
}
.atlas-country + .atlas-country {
  margin-top: 0.35rem;
}
.atlas-country-head {
  position: sticky;
  top: var(--continent-h, 2.4rem); /* measured by atlas.js, since the heading can wrap */
  z-index: 1;
  padding: 0.5rem 0.5rem 0.3rem;
  border-top: 1px solid var(--line);
  background: var(--white);
  font-weight: 700;
  font-size: var(--step--1);
  letter-spacing: -0.01em;
}
.atlas-places li,
.atlas-place-button {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0.3rem 0.5rem;
  font-size: var(--step--1);
  line-height: 1.3;
}
.atlas-places li.has-button {
  display: block;
  min-height: 0;
  padding: 0;
}
.atlas-place-button {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  scroll-margin-block: 5.25rem 0.5rem;
  transition: background-color 0.15s;
}
.atlas-place-button:hover {
  background: var(--paper);
}
.atlas-place-button:focus-visible {
  outline-offset: -2px;
}
.atlas-place-button[aria-pressed="true"],
.atlas-places li[data-active] > .atlas-place-button {
  background: var(--accent-soft);
}
.atlas-place-button[aria-pressed="true"] .atlas-place-name {
  color: var(--accent-ink);
}
.atlas-place-name {
  font-weight: 500;
  min-width: 0;
}
.atlas-home-tag {
  margin-left: 0.35rem;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  vertical-align: 1px;
}
/* Full-width index (no JavaScript, or below the map): a multi-column gazetteer. */
@container atlas-index (min-width: 40rem) {
  .atlas-index-scroll {
    max-height: none;
    overflow: visible;
    columns: 17rem;
    column-gap: var(--gutter);
    padding-inline: 0.75rem;
  }
  .atlas-continent h3,
  .atlas-country-head {
    position: static;
  }
  .atlas-continent h3 {
    break-after: avoid;
  }
  .atlas-country {
    break-inside: avoid;
  }
}

/* ---------- Field notes ---------- */
.strip-controls {
  display: flex;
  gap: 0.5rem;
}
.strip-controls .icon-button {
  min-width: 44px;
  min-height: 44px;
}
.strip-controls [aria-disabled="true"] {
  opacity: 0.35;
  cursor: default;
}
.field-strip {
  margin-inline: calc(var(--pad) * -1);
  padding-inline: var(--pad);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--pad);
  scrollbar-width: thin;
}
.field-strip:focus-visible {
  outline-offset: -2px;
}
.field-strip ul {
  display: flex;
  gap: var(--gutter);
  width: max-content;
  margin: 0;
  padding: 0 0 1.25rem;
  list-style: none;
}
.field-strip li {
  flex: none;
  scroll-snap-align: start;
}
.field-note {
  position: relative;
  width: min-content;
  margin: 0;
}
.field-note-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
}
.field-note img {
  display: block;
  width: auto;
  max-width: none;
  height: clamp(220px, 27vw, 380px);
}
.field-note figcaption {
  display: grid;
  gap: 0.15rem;
  margin-top: 0.8rem;
}
.field-note figcaption > span:first-child {
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}
.field-note figcaption .mono {
  color: var(--muted);
}
.field-note-locate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}
.field-note-locate span,
.field-note-locate svg {
  pointer-events: none;
}
.field-note-locate::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0 var(--accent);
  transition: box-shadow 0.25s var(--ease);
}
.field-note-locate:hover::after {
  box-shadow: inset 0 0 0 3px var(--accent);
}
.field-note-locate:focus-visible {
  outline-offset: -4px;
}
.field-note-locate > svg {
  display: none;
}
.field-note-locate > span,
.field-note-locate::before {
  font: 500 var(--step--2) / 1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field-note-locate > span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 30px;
  padding: 0 0.6rem 0 2rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  color: var(--ink);
  transition:
    background-color 0.2s,
    color 0.2s;
}
.field-note-locate::before {
  content: "";
  position: absolute;
  top: 18px;
  right: calc(10px + 2.85rem);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--accent) 30%, transparent);
  z-index: 1;
}
.field-note-locate:hover > span,
.field-note-locate:focus-visible > span {
  background: var(--accent);
  color: var(--on-accent);
}
.field-note-locate:hover::before,
.field-note-locate:focus-visible::before {
  background: var(--on-accent);
}

/* ---------- Home teaser ---------- */
.atlas-teaser-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gutter);
}
.atlas-teaser-photos {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gutter);
  margin: 0;
  padding: 0;
  list-style: none;
}
.atlas-teaser-photos figure {
  margin: 0;
}
.atlas-teaser-photos img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--paper-2);
}
.atlas-teaser-photos figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .atlas-teaser-photos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-note-locate::after,
  a.atlas-canvas {
    transition: none;
  }
}
@media print {
  .strip-controls,
  .field-note-locate {
    display: none !important;
  }
  .field-strip {
    overflow: visible;
  }
  .field-strip ul {
    flex-wrap: wrap;
    width: auto;
  }
}
