/* Living-boat layout fixes and stability overrides. */

.live-first {
  padding-top: clamp(4.5rem, 7vw, 7rem);
  padding-bottom: clamp(4.5rem, 7vw, 7rem);
}

/* Keep the live section vertically compact: AIS first, metadata/links below. */
.live-layout-primary {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 1rem;
}

.ais-frame {
  position: relative;
  min-height: 0;
  border-radius: 1.2rem;
  overflow: hidden;
  background: #0b2630;
  border: 1px solid var(--dark-line);
}

.ais-frame iframe {
  display: block;
  width: 100%;
  height: 390px;
  min-height: 0;
  border: 0;
  background: #d9e0dc;
}

.embed-fallback {
  position: static;
  margin: 0;
  padding: .65rem .8rem;
  border-radius: 0;
  background: rgba(7, 27, 36, .96);
  color: rgba(255,255,255,.78);
  font-size: .7rem;
}

.embed-fallback a { color: var(--sand-soft); }
.live-status-label { margin: 0 0 .25rem; text-transform: uppercase; letter-spacing: .12em; font-size: .65rem; color: rgba(255,255,255,.48); }

.live-layout-primary .live-card {
  display: grid;
  grid-template-columns: minmax(240px, .72fr) minmax(0, 1.28fr);
  grid-template-rows: auto auto 1fr;
  column-gap: 1.5rem;
  align-items: start;
}
.live-layout-primary .live-status-label { grid-column: 1; grid-row: 1; }
.live-layout-primary .radio-details { grid-column: 1; grid-row: 2; }
.live-layout-primary .live-note { grid-column: 1; grid-row: 3; margin-bottom: 0; }
.live-layout-primary .link-stack {
  grid-column: 2;
  grid-row: 1 / 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

/* The supplied Great Dane engineering silhouette stays fully inside its slot.
   The repeated technical caption under it is intentionally hidden. */
.hero-visual > svg { display: none; }
.hero-visual::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: .6rem -.4rem 1.2rem;
  background: url("hero-aurora.svg") center / auto 96% no-repeat;
  filter: drop-shadow(0 22px 28px rgba(0,0,0,.22));
  pointer-events: none;
}
.hero-visual .moon { z-index: 1; }
.hero-visual .hero-caption { display: none; }

/* Presentation-style ownership flow. Only outgoing arrowheads point right;
   later cards simply make room for the incoming arrow from the previous owner. */
.ownership-line {
  --arrow: 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 1rem;
  filter: drop-shadow(0 10px 24px rgba(7,27,36,.08));
}

.ownership-line article {
  position: relative;
  z-index: 3;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem calc(1.5rem + var(--arrow)) 1.5rem 1.5rem;
  border: 0;
  border-radius: 1.1rem 0 0 1.1rem;
  background: #eee8dc;
}

.ownership-line article:nth-child(2) {
  z-index: 2;
  padding-left: calc(1.5rem + var(--arrow));
  background: #e2dacb;
  border-radius: 0;
}

.ownership-line article:last-child {
  z-index: 1;
  padding-left: calc(1.5rem + var(--arrow));
  padding-right: 1.5rem;
  border-radius: 0 1.1rem 1.1rem 0;
}

.ownership-line article:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 4;
  top: 0;
  right: calc(var(--arrow) * -1);
  width: var(--arrow);
  height: 100%;
  background: inherit;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  pointer-events: none;
}

.ownership-line article + article {
  margin-left: 0;
}

.ownership-line article > span {
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: .65rem;
  color: #71848a;
}

.ownership-line h3 {
  margin: auto 0 .7rem;
  font: 1.7rem var(--serif);
  color: var(--navy);
}

.ownership-line p { margin: 0; color: #576b72; }
.ownership-line .current-owner { background: var(--teal); color: var(--white); }
.ownership-line .current-owner > span,
.ownership-line .current-owner p { color: rgba(255,255,255,.72); }
.ownership-line .current-owner h3 { color: var(--white); }

/* This-boat facts: identity/current particulars only; refit dates live below. */
.current-specs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.current-specs > div {
  min-width: 0;
  border: 0 !important;
  background: var(--paper);
}
.current-specs strong { overflow-wrap: anywhere; }

/* Dense gallery mosaic adapted from the Rassvet archive. */
.gallery-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 220px;
  grid-auto-flow: dense;
  gap: .8rem;
}
.gallery-card,
.gallery-card:nth-child(5n+1),
.gallery-card:nth-child(5n+4) {
  grid-column: span 4;
  grid-row: span 1;
  min-height: 220px;
  aspect-ratio: auto;
}
.gallery-card.gallery-featured { grid-column: span 7; grid-row: span 2; }
.gallery-card.gallery-wide { grid-column: span 8; grid-row: span 1; }
.gallery-card.gallery-portrait { grid-column: span 4; grid-row: span 2; }

.compact-voyage-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  align-items: start;
}

/* Leaflet positioning fallback so the map remains usable if the CDN
   stylesheet cannot be loaded. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-container { overflow: hidden; outline-offset: 1px; }
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow { user-select: none; -webkit-user-drag: none; }
.leaflet-tile { visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top,
.leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }

/* Leaflet uses transforms internally. Do not animate/transform its ancestor:
   Safari can otherwise composite old tile positions during zoom. */
.map-wrap,
.map-wrap.reveal,
.map-wrap.reveal.visible {
  position: relative;
  height: 500px;
  min-height: 0;
  opacity: 1;
  transform: none;
  transition: none;
}

.map-panel {
  height: 500px !important;
  min-height: 0 !important;
  max-height: 500px;
  isolation: isolate;
}

.voyage-list {
  height: 500px;
  max-height: 500px;
}

.map-toolbar {
  position: absolute;
  z-index: 900;
  top: .75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .35rem;
  padding: .3rem;
  border-radius: 999px;
  background: rgba(7, 27, 36, .88);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  backdrop-filter: blur(10px);
}

.map-toolbar button {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 .75rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--white);
  cursor: pointer;
  font-size: .75rem;
}

.map-toolbar button:first-child,
.map-toolbar button:last-child {
  font-size: 1.2rem;
  padding: 0;
}

.map-toolbar button:hover { background: rgba(255,255,255,.18); }
.leaflet-control-zoom { display: none !important; }
.leaflet-container { background: #d7ddd9; }
.leaflet-tile {
  image-rendering: auto;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.leaflet-zoom-animated { transition: none !important; }

.transition-reference {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: #667a80;
  font-size: .8rem;
}
.transition-reference a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: .18em; }

.voyage-atlas-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 0 0 .8rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255,255,255,.32);
}
.voyage-atlas-meta[hidden] { display: none; }
.voyage-atlas-totals { display: flex; gap: 1.5rem; margin: 0; }
.voyage-atlas-totals div { min-width: 7.5rem; }
.voyage-atlas-totals dt { font: 1.25rem var(--serif); color: var(--navy); }
.voyage-atlas-totals dd { margin: .15rem 0 0; color: #72858a; font-size: .6rem; letter-spacing: .09em; text-transform: uppercase; }
.voyage-year-filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.voyage-year-filters button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .48rem .72rem;
  background: transparent;
  color: #586c72;
  cursor: pointer;
  font-size: .68rem;
}
.voyage-year-filters button:hover,
.voyage-year-filters button.active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.voyage-group { margin-bottom: .55rem; overflow: hidden; border: 1px solid var(--line); border-radius: .85rem; background: rgba(255,255,255,.28); }
.voyage-group.active { border-color: rgba(138,108,66,.52); background: rgba(138,108,66,.06); }
.voyage-group-button,
.voyage-track-item button { display: block; width: 100%; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.voyage-group-button { padding: .9rem; border-bottom: 1px solid var(--line); }
.voyage-group-button:hover { background: rgba(7,27,36,.035); }
.voyage-group-button > span { display: block; margin-bottom: .35rem; color: var(--teal); font-size: .57rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.voyage-group-button strong { display: block; font: 1rem var(--serif); color: var(--navy); }
.voyage-group-button small { display: block; margin-top: .35rem; color: #72858a; font-size: .66rem; }
.voyage-group-legs { padding: .25rem .5rem .5rem; }
.voyage-track-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  border-bottom: 1px solid rgba(7,27,36,.08);
  border-radius: .55rem;
}
.voyage-track-item:last-child { border-bottom: 0; }
.voyage-track-item:hover,
.voyage-track-item.active { background: rgba(214,183,122,.14); }
.voyage-track-item.active { box-shadow: inset 3px 0 var(--sand); }
.voyage-track-item button { grid-column: 1; grid-row: 1; min-width: 0; padding: .7rem .25rem .7rem .6rem; }
.voyage-track-item strong { display: block; font: .92rem var(--serif); color: var(--navy); }
.voyage-track-item small { display: block; margin-top: .25rem; color: #72858a; font-size: .62rem; line-height: 1.45; }
.voyage-card-link {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  margin: 0 .42rem .46rem .15rem;
  place-items: center;
  border: 1px solid rgba(7,27,36,.12);
  border-radius: 999px;
  color: #71848a;
  background: rgba(255,255,255,.4);
  text-decoration: none;
}
.voyage-card-link svg { width: .9rem; height: .9rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.voyage-card-link:hover,
.voyage-card-link:focus-visible { border-color: #d84a1b; color: #d84a1b; background: rgba(216,74,27,.08); }
.voyages-section .leaflet-tile-pane { filter: grayscale(.62) sepia(.12) saturate(.72) brightness(1.05) contrast(.94); }
.voyages-section .leaflet-tooltip { border: 0; border-radius: .55rem; background: var(--navy); color: var(--white); box-shadow: 0 8px 20px rgba(0,0,0,.2); }

.source-group {
  min-height: 150px;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255,255,255,.34);
}

.source-group > strong { display: block; font: 1.1rem var(--serif); color: var(--navy); }
.source-group > span { display: block; margin-top: .65rem; color: #667a80; font-size: .8rem; }
.source-sublinks { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.source-sublinks a {
  min-height: 0;
  padding: .45rem .65rem;
  border-radius: 999px;
  background: rgba(7,27,36,.06);
  font-size: .7rem;
}

/* The owner is injected as a separate span; give it a visible separator. */
.footer-owner::before { content: " · "; }
.footer-owner {
  color: var(--sand-soft) !important;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: none;
}

@media (max-width: 1100px) {
  .current-specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); grid-auto-rows: 200px; }
  .gallery-card,
  .gallery-card:nth-child(5n+1),
  .gallery-card:nth-child(5n+4),
  .gallery-card.gallery-portrait { grid-column: span 4; }
  .gallery-card.gallery-featured,
  .gallery-card.gallery-wide { grid-column: span 8; }
  .compact-voyage-layout { grid-template-columns: 1fr; }
  .live-layout-primary .live-card { grid-template-columns: 1fr; }
  .live-layout-primary .live-status-label,
  .live-layout-primary .radio-details,
  .live-layout-primary .live-note,
  .live-layout-primary .link-stack { grid-column: 1; grid-row: auto; }
  .live-layout-primary .link-stack { margin-top: .8rem; }

  .ownership-line {
    grid-template-columns: 1fr;
    gap: .7rem;
    filter: none;
  }
  .ownership-line article,
  .ownership-line article:nth-child(2),
  .ownership-line article:last-child {
    min-height: 170px;
    margin-left: 0;
    padding: 1.4rem;
    border-radius: 1rem;
  }
  .ownership-line article::after { display: none; }
  .voyage-atlas-meta { align-items: flex-start; flex-direction: column; }
  .voyage-year-filters { justify-content: flex-start; }
  .voyage-list { height: auto; max-height: 320px; }
}

@media (max-width: 700px) {
  .gallery-grid { grid-template-columns: 1fr; grid-auto-rows: auto; gap: .7rem; }
  .gallery-card,
  .gallery-card:nth-child(5n+1),
  .gallery-card:nth-child(5n+4),
  .gallery-card.gallery-featured,
  .gallery-card.gallery-wide,
  .gallery-card.gallery-portrait {
    grid-column: 1;
    grid-row: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
  }
  .gallery-card.gallery-portrait { aspect-ratio: 3 / 4; }
  .ais-frame iframe { height: 300px; }
  .live-layout-primary .link-stack { grid-template-columns: 1fr; }
  .hero-visual { min-height: 330px; }
  .hero-visual::after {
    inset: 1.3rem 0 1.2rem;
    background-size: contain;
  }
  .map-wrap,
  .map-wrap.reveal,
  .map-wrap.reveal.visible,
  .map-panel { height: 390px !important; max-height: 390px; }
  .voyage-atlas-meta { padding: .75rem; }
  .voyage-atlas-totals { gap: .9rem; }
  .voyage-atlas-totals div { min-width: 0; }
  .map-toolbar { top: .55rem; }
}
