/* Component: the ocean chart (src/ui/components/chart.js; lane UI-M, SPEC-2 §4.13): the drawing (regions
   as island clusters, fog and ❓ until charted, lanes with their days, the storm band, crossers, the ship)
   and the overlay's region cards (season, words, days, news rows, the fuzzy band, the soon line, Why?). */

.chart {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  background: #2f7fb0;
  font-family: var(--font);
  user-select: none;
}

.chart text {
  font-family: var(--font);
}

.chart-grid {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.2;
  stroke-dasharray: 3 9;
  opacity: 0.18;
}

.chart-wave {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.45;
}

/* Lanes: a white casing and a dashed line; the chosen one (the departure, the voyage) in the accent color. */
.chart-lane-casing {
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 10;
  stroke-linecap: round;
}

.chart-lane-line {
  fill: none;
  stroke: #ffffff;
  stroke-width: 4;
  stroke-dasharray: 3 11;
  stroke-linecap: round;
}

.chart-lane.is-fog .chart-lane-line {
  opacity: 0.6;
}

.chart-lane.is-chosen .chart-lane-casing {
  stroke: #ffffff;
  stroke-width: 14;
  opacity: 0.9;
}

.chart-lane.is-chosen .chart-lane-line {
  stroke: var(--accent-600);
  stroke-width: 7;
  stroke-dasharray: none;
}

.chart-storm-band {
  fill: none;
  stroke-width: 54;
  stroke-linecap: round;
  opacity: 0.85;
}

.chart-lane-days rect {
  fill: #ffffff;
  stroke: var(--sea-700);
  stroke-width: 2.5;
}

.chart-lane-days text {
  font-size: 19px;
  font-weight: 900;
  fill: var(--sea-800);
}

.chart-storm-chip rect {
  fill: #eef2f5;
  stroke: #5f86a3;
  stroke-width: 2;
}

.chart-storm-chip text {
  font-size: 17px;
  font-weight: 800;
  fill: #2f4a5e;
}

/* Regions: island clusters; a fog with ❓ until the chart is bought; a dashed ring where she is. */
.chart-region.is-button {
  cursor: pointer;
}

.chart-region.is-button:focus-visible {
  outline: none;
}

.chart-region.is-button:focus-visible .chart-island path:last-child,
.chart-region.is-button:hover .chart-island path:last-child {
  stroke: var(--focus-dark);
  stroke-width: 3;
}

.chart-fog ellipse {
  fill: #e9eef2;
  opacity: 0.82;
}

.chart-fog-badge {
  fill: #ffffff;
  stroke: #8a9caa;
  stroke-width: 2.5;
}

.chart-fog-q {
  font-size: 26px;
}

/* A region's tap area: its whole cluster, islands and the water between them. */
.chart-region-hit {
  fill: transparent;
}

.chart-here {
  fill: none;
  stroke: var(--accent-400);
  stroke-width: 4;
  stroke-dasharray: 8 6;
}

.chart-region-label {
  font-size: 26px;
  font-weight: 900;
  fill: #16324a;
  stroke: #ffffff;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
}

.chart-crosser-face {
  font-size: 19px;
}

.chart-crosser-cargo text {
  font-size: 13px;
}

.chart-crosser {
  filter: drop-shadow(0 1px 1.5px rgba(13, 48, 71, 0.35));
}

/* ── The overlay ───────────────────────────────────────── */
.chart-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

.chart-view__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
}

.chart-view__title {
  font-size: var(--fs-xl);
  color: var(--sea-800);
}

.chart-goal {
  font-weight: 800;
  background: var(--accent-100);
  border: 2px solid var(--accent-400);
  max-width: 100%;
  white-space: normal;
}

.chart-frame {
  min-width: 0;
}

.chart-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: var(--sp-3);
  align-items: start;
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.chart-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chart-card.is-here {
  border-color: var(--accent-400);
  background: var(--paper);
}

.chart-card.is-fog {
  background: #f3f6f8;
  border-style: dashed;
}

.chart-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
}

.chart-card__emoji {
  font-size: var(--fs-lg);
}

.chart-card__name {
  font-size: var(--fs-md);
  color: var(--sea-800);
  margin-right: auto;
}

.chart-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
}

.chart-chip {
  font-size: var(--fs-sm);
  white-space: normal;
}

.chart-chip--here {
  background: var(--accent-100);
}

.chart-chip--news.is-veryOld {
  background: var(--loss-bg);
  color: var(--ink-soft);
}

.chart-card__blurb,
.chart-card__fits,
.chart-card__why {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
}

.chart-card__days {
  font-weight: 900;
  color: var(--sea-800);
}

.chart-card__offer {
  font-weight: 800;
}

.chart-card__sale {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
}

/* News rows: the top row carries the price and the fuzzy band under it. */
.chart-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--sea-50);
}

.chart-row.is-top {
  background: var(--sea-100);
  font-weight: 800;
}

.chart-row__text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Why the row moves, in words under its text (a phone shows no title). */
.chart-row__cause {
  grid-column: 1 / -1;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
}

.chart-band {
  grid-column: 1 / -1;
  position: relative;
  height: 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.75);
  overflow: hidden;
}

.chart-band__fuzz {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: var(--r-pill);
  background: radial-gradient(closest-side, rgba(31, 111, 158, 0.75), rgba(31, 111, 158, 0.08));
}

.chart-band__mark {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--sea-800);
}

.chart-soon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  font-weight: 700;
}

.chart-why__btn {
  cursor: pointer;
  font-weight: 800;
  color: var(--sea-700);
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  list-style: none;
  border-radius: var(--r-sm);
}

/* A ▾ says Why? opens (flex hides the browser's own marker); it turns over when open, as the port's
   "sail empty" list does. */
.chart-why__btn::-webkit-details-marker {
  display: none;
}

.chart-why__btn::after {
  content: '▾';
  color: var(--sea-600);
  transition: transform var(--dur-2) var(--ease);
}

.chart-why[open] .chart-why__btn::after {
  transform: rotate(180deg);
}

.chart-why__lines {
  margin: 0;
  padding-left: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.chart-why__lines li + li {
  margin-top: 2px;
}

/* Phones: the chart is about a third of its size here, so its words and badges grow (each badge round its
   own middle; the region names by font size). A lane's days stand further off the lane and some names move
   (--phone-shift, set by chart.js), so they stay off every lane line (tests/unit/map-lanes.test.js). */
@media (max-width: 37.5em) {
  .chart-region-label {
    font-size: 46px;
    stroke-width: 9px;
    transform: var(--phone-shift, none);
  }

  .chart-days-shift {
    transform: var(--phone-shift, none);
  }

  .chart-grow {
    transform: scale(1.6);
  }

  .chart-lane-casing {
    stroke-width: 14;
  }

  .chart-lane-line {
    stroke-width: 6;
  }
}

/* ── C6: a chart lane's card (the Long Way while its chart is for sale), after the region cards: the region
   card's look with a dashed edge (its chart is not bought yet). Its own class, so "one card a region" stays
   true; its parts reuse the region card's (.chart-card__head, __blurb, __sale). */
.chart-lane-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
  background: #f3f6f8;
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.chart-lane-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chart-lane-card__wants {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--sea-800);
}

@media (max-width: 37.5em) {
  .chart-lane-card {
    padding: var(--sp-3);
  }

  .chart-lane-card__wants {
    overflow-wrap: anywhere;
  }
}
