/* Screen: logbook — totals, the money-a-day chart, best trip, year reports, every trip. */

.screen--logbook.is-rerender {
  animation: none;
}

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

.lb-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
  padding: var(--sp-4);
  min-width: 0;
}

.lb-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-3);
}

.lb-card__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-md);
  margin-bottom: var(--sp-2);
}

/* ── Totals ── */
.lb-tiles {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
}

.lb-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-3) var(--sp-2);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  text-align: center;
  min-width: 0;
}

.lb-tile__emoji {
  font-size: 1.5em;
  line-height: 1;
}

.lb-tile__num {
  font-size: var(--fs-xl);
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.lb-tile.is-money .lb-tile__num {
  color: var(--gain);
}

.lb-tile.is-neutral .lb-tile__num {
  color: var(--loss);
}

.lb-tile__label {
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--ink-soft);
}

/* ── Chart + side ── */
.lb-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.lb-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

.lb-chart__wrap {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.lb-chart__svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
}

.lb-chart__svg:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.lb-bar {
  fill: var(--sea-400);
  transition: fill var(--dur-1);
}

.lb-bar.is-last {
  fill: var(--sea-600);
}

.lb-bar.is-best {
  fill: var(--accent-500);
}

.lb-bar.is-loss {
  fill: var(--loss);
}

.lb-bar.is-active {
  fill: var(--sea-800);
}

.lb-bar.is-best.is-active {
  fill: var(--accent-700);
}

.lb-hit {
  fill: transparent;
}

.lb-chart__grid {
  stroke: var(--line);
  stroke-width: 1;
}

.lb-chart__zero {
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.lb-chart__tick {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink-faint);
}

.lb-chart__label {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 900;
  fill: var(--ink);
}

.lb-chart__label.is-best {
  fill: var(--accent-700);
}

.lb-chart__readout {
  min-height: 1.6em;
  margin-top: var(--sp-2) !important;
  font-weight: 700;
  color: var(--ink-soft);
}

.lb-chart__readout strong {
  color: var(--ink);
}

.lb-chart__readout .is-loss {
  color: var(--loss);
}

.lb-best__money {
  font-size: var(--fs-xl);
  font-weight: 900;
  color: var(--gain);
  line-height: 1.1;
}

.lb-best__trip {
  margin-top: var(--sp-1) !important;
  font-weight: 800;
}

.lb-reports__list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.lb-report {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--accent-100);
}

.lb-report__text {
  min-width: 0;
}

.lb-report__year {
  font-weight: 900;
}

.lb-report__text p + p {
  margin-top: 0;
}

/* ── Every trip ── */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.lb-table thead th {
  text-align: left;
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--ink-faint);
  padding: var(--sp-1) var(--sp-2);
  border-bottom: 2px solid var(--line);
}

.lb-table th.num,
.lb-table td.num {
  text-align: right;
  white-space: nowrap;
}

.lb-year th {
  text-align: left;
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: 900;
  color: var(--sea-700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lb-row th,
.lb-row td {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 700;
}

.lb-row__no {
  font-weight: 900;
  white-space: nowrap;
  color: var(--ink-soft);
}

.lb-row__when {
  color: var(--ink-soft);
  white-space: nowrap;
}

.lb-row__kept {
  color: var(--gain);
  font-weight: 900 !important;
}

.lb-row.is-loss .lb-row__kept,
.lb-row.is-loss .lb-row__perday {
  color: var(--loss);
}

.lb-row.is-best {
  background: var(--accent-100);
}

.lb-row__days-inline {
  display: none;
}

/* Keep a number with its word, and a port's name in one piece. */
.lb-keep {
  white-space: nowrap;
}

.lb-more {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-3);
}

.lb-empty {
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 700;
  padding: var(--sp-6) var(--sp-4);
}

.lb-empty__ship {
  font-size: 56px;
  line-height: 1;
  margin-bottom: var(--sp-3);
}

.lb-foot {
  display: flex;
  justify-content: center;
}

/* ── Smaller screens ── */
@media (max-width: 56.25em) {
  .lb-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .lb-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 47.5em) {
  /* The table becomes one card per trip. */
  .lb-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .lb-table,
  .lb-table tbody {
    display: block;
  }

  .lb-year {
    display: block;
  }

  .lb-year th {
    display: block;
  }

  .lb-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'no route kept'
      'no when perday';
    column-gap: var(--sp-3);
    row-gap: 0;
    padding: var(--sp-2) var(--sp-1);
    border-bottom: 1px solid var(--line);
  }

  .lb-row th,
  .lb-row td {
    padding: 0;
    border: 0;
  }

  .lb-row__no {
    grid-area: no;
    align-self: center;
    min-width: 2.2em;
  }

  .lb-row__route {
    grid-area: route;
  }

  .lb-row__when {
    grid-area: when;
    font-size: var(--fs-sm);
    white-space: normal;
  }

  .lb-row__days {
    display: none;
  }

  .lb-row__days-inline {
    display: inline;
  }

  .lb-row__kept {
    grid-area: kept;
  }

  .lb-row__perday {
    grid-area: perday;
    font-size: var(--fs-sm);
    color: var(--ink-soft);
  }
}

@media (max-width: 37.5em) {
  .lb-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lb-tile__num {
    font-size: var(--fs-lg);
  }

  .lb-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── 🏁 Rivals (WS-D): tabs, captain cards ────────────── */
.lb-tabs {
  margin-bottom: var(--sp-1);
}

.lb-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

.lb-rivals {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.lb-rivals__intro {
  font-weight: 700;
  color: var(--ink-soft);
}

.lb-rivals__group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.lb-captains {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--sp-3);
}

.lb-captain {
  --rival: var(--sea-500);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--card);
  border: 2px solid var(--line);
  border-top: 6px solid var(--rival);
  min-width: 0;
}

.lb-captain__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
}

.lb-captain__face {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--rival);
  background: var(--sea-50);
  font-size: 26px;
  line-height: 1;
}

.lb-captain__names {
  min-width: 0;
}

.lb-captain__name {
  font-size: var(--fs-md);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.lb-captain__style {
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--ink-soft);
}

.lb-captain__boat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.lb-captain__speed {
  font-size: 1.1em;
  line-height: 1;
}

.lb-captain__likes {
  font-weight: 800;
}

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

.lb-captain__where {
  font-weight: 700;
  color: var(--sea-800);
  min-width: 0;
}

.lb-captain__score {
  background: var(--accent-100);
  color: var(--accent-700);
}

.lb-captain__copy {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-md);
  background: var(--loss-bg);
  color: var(--loss);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.lb-captain__season-title {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lb-bars {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 3px var(--sp-2);
}

.lb-bars__who {
  font-size: var(--fs-sm);
  font-weight: 800;
  text-align: center;
  min-width: 2.2em;
}

.lb-bar-track {
  display: block;
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--sea-50);
  border: 1px solid var(--line);
  overflow: hidden;
}

.lb-bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
}

.lb-bar-fill.is-you {
  background: var(--accent-500);
}

.lb-bar-fill.is-her {
  background: var(--rival);
}

/* ── UI-S2 (SPEC-2 §2.9): far waters on the Rivals page ── */
.lb-rivals__note {
  margin-top: calc(-1 * var(--sp-2));
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-soft);
}

.lb-rivals__group.is-far {
  background: linear-gradient(180deg, var(--card) 0%, var(--sea-50) 100%);
}

/* UI-S2: the places she traded (logbookView.regions), each its emoji and its name. */
.lb-places {
  font-weight: 700;
}

.lb-places .rp-place {
  white-space: nowrap;
}

/* ── C3: the shipyard's depth (docs/roadmap/C3-shipyard-depth.md §6): a captain's favourite part under her
   goods ("🪁 Likes kites."), quieter than the goods she likes. ── */
.rv-fan {
  margin-top: calc(-1 * var(--sp-1));
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-soft);
}
/* ── end C3 ── */
