/* Screen: shipyard (overlay) — big ship art on the left (sticky on wide screens),
   tabs and offer cards on the right, then name & paint. One column on tablets in portrait and phones. */

.screen--shipyard {
  gap: var(--sp-4);
}

.screen--shipyard.is-rerender,
.screen--shipyard .mate.is-still {
  animation: none;
}

.screen--shipyard .mate {
  max-width: 640px;
}

/* ── Header ────────────────────────────────────────────── */
.sy-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.sy-head__sub {
  margin-top: var(--sp-1);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink-soft);
}

/* ── Layout ────────────────────────────────────────────── */
.sy-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas:
    'ship shop'
    'ship looks';
  grid-template-rows: auto 1fr;
  gap: var(--sp-4) var(--sp-5);
  align-items: start;
}

.sy-ship {
  grid-area: ship;
  position: sticky;
  top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 55%, var(--sea-50) 100%);
}

.sy-shop {
  grid-area: shop;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.sy-looks-wrap {
  grid-area: looks;
  min-width: 0;
}

@media (max-width: 56.1875em) {
  .sy-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'ship'
      'shop'
      'looks';
    grid-template-rows: auto;
  }

  .sy-ship {
    position: static;
  }

  .sy-ship .sy-art {
    max-width: 420px;
  }
}

/* ── Ship art (every preview drawn at the same scale) ──── */
.sy-art {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.sy-art__ship {
  position: absolute;
  left: 50%;
  bottom: 0;
  height: auto;
  transform: translateX(-50%);
  transition: opacity var(--dur-2) var(--ease);
}

.sy-art__ship.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.sy-art__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 1.6em;
  font-weight: 800;
  text-align: center;
}

.sy-art__new {
  color: var(--accent-700);
}

.sy-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sy-fact {
  padding: 0.15em 0.7em;
  border-radius: var(--r-pill);
  background: var(--sea-50);
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--sea-800);
  white-space: nowrap;
}

.sy-fact.is-class {
  background: var(--sea-600);
  border-color: var(--sea-700);
  color: #ffffff;
}

.sy-fact.is-dent {
  background: var(--accent-100);
  border-color: var(--accent-200);
  color: var(--accent-700);
}

/* ── Tabs ──────────────────────────────────────────────── */
.sy-shop__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
}

.sy-tabs {
  flex: 1 1 100%;
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--card);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--line);
}

.sy-tab {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: var(--tap);
  padding: 0.3em 0.8em;
  white-space: nowrap;
  border: 2px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--sea-800);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.sy-tab:hover {
  background: var(--sea-50);
}

.sy-tab.is-on {
  background: var(--sea-600);
  border-color: var(--sea-700);
  color: #ffffff;
}

.sy-tab__emoji {
  font-size: 1.2em;
  line-height: 1;
}

.sy-tab__count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 0.3em;
  border-radius: var(--r-pill);
  background: var(--accent-500);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 900;
}

.sy-cash {
  font-weight: 900;
  font-size: var(--fs-md);
  color: var(--gain);
  white-space: nowrap;
}

/* ── Offer cards ───────────────────────────────────────── */
.sy-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.sy-intro {
  font-weight: 700;
  color: var(--ink-soft);
}

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

.sy-empty {
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--card);
  border: 2px dashed var(--line-strong);
  font-weight: 800;
  text-align: center;
}

.sy-offer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.sy-offer.is-refit:hover,
.sy-offer.is-refit:focus-within {
  border-color: var(--accent-400);
  box-shadow: var(--shadow-2);
}

.sy-offer.is-installed {
  border-color: var(--green-300);
  background: linear-gradient(180deg, var(--green-100) 0%, #ffffff 60%);
}

.sy-offer.is-broken,
.sy-offer.is-repair {
  border-color: var(--accent-200);
  background: linear-gradient(180deg, var(--accent-100) 0%, #ffffff 60%);
}

.sy-offer__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.sy-offer__emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--sea-50);
  border: 2px solid var(--line);
  font-size: 1.7rem;
  line-height: 1;
}

.sy-offer__titles {
  flex: 1 1 auto;
  min-width: 0;
}

.sy-offer__name {
  font-size: var(--fs-md);
}

.sy-offer__price {
  font-weight: 900;
  font-size: var(--fs-md);
  color: var(--sea-700);
  font-variant-numeric: tabular-nums;
}

.sy-offer.is-installed .sy-offer__price {
  font-size: var(--fs-sm);
  color: var(--green-700);
}

.sy-badge {
  flex: none;
  align-self: flex-start;
  padding: 0.1em 0.6em;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 900;
  white-space: nowrap;
}

.sy-badge.is-on {
  background: var(--gain-bg);
  color: var(--gain);
  border: 1px solid var(--green-300);
}

.sy-badge.is-broken {
  background: var(--accent-100);
  color: var(--accent-700);
  border: 1px solid var(--accent-400);
}

.sy-offer__blurb {
  color: var(--ink-soft);
}

.sy-offer__effect {
  font-weight: 800;
}

.sy-offer__effect.is-broken {
  color: var(--accent-700);
}

.sy-payback {
  margin: 0 !important;
  padding: 0.25em 0.7em;
  border-radius: var(--r-md);
  background: var(--gain-bg);
  color: var(--gain);
  font-weight: 800;
}

.sy-payback.is-loan {
  background: var(--sea-50);
  color: var(--sea-700);
}

.sy-payback.is-never {
  background: var(--loss-bg);
  color: var(--loss);
}

.sy-offer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: auto;
  padding-top: var(--sp-1);
}

.sy-why {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
}

.sy-why__text {
  font-weight: 800;
  color: var(--ink-soft);
}

.sy-why__next {
  margin: 0 !important;
}

/* ── Closed shipyard ───────────────────────────────────── */
.sy-closed {
  align-items: center;
  text-align: center;
  padding: var(--sp-6) var(--sp-5);
}

.sy-closed__icon {
  font-size: 64px;
  line-height: 1;
}

/* ── Name and paint ────────────────────────────────────── */
.sy-looks {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.sy-looks__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-lg);
}

.sy-name {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sy-name__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.sy-name__input {
  flex: 1 1 200px;
  min-width: 0;
  font-weight: 800;
}

/* ── Paint picker (also used by the title screen) ──────── */
.screen--shipyard .paint-picker,
.screen--title .paint-picker {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.screen--shipyard .paint-picker__legend,
.screen--title .paint-picker__legend {
  padding: 0;
  margin-bottom: var(--sp-2);
  font-weight: 800;
}

.screen--shipyard .paint-picker__grid,
.screen--title .paint-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), 1fr)); /* rem: wider swatches with bigger text */
  gap: var(--sp-2);
}

.screen--shipyard .paint-swatch,
.screen--title .paint-swatch {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  font-weight: 800;
  font-size: var(--fs-sm);
  line-height: 1.15;
  min-width: 0;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.screen--shipyard .paint-swatch:hover,
.screen--title .paint-swatch:hover {
  background: var(--sea-50);
}

.screen--shipyard .paint-swatch.is-on,
.screen--title .paint-swatch.is-on {
  border-color: var(--sea-600);
  background: var(--sea-50);
  box-shadow: 0 0 0 2px var(--sea-600);
}

.screen--shipyard .paint-swatch:has(.paint-swatch__input:focus-visible),
.screen--title .paint-swatch:has(.paint-swatch__input:focus-visible) {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.screen--shipyard .paint-swatch__input,
.screen--title .paint-swatch__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.screen--shipyard .paint-swatch__chip,
.screen--title .paint-swatch__chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paint, #888);
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px var(--line-strong);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.1rem;
  text-shadow: 0 0 2px #000000, 0 0 3px rgba(0, 0, 0, 0.7);
}

/* ── Celebration modal ─────────────────────────────────── */
.sy-celebrate .modal__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}

.sy-celebrate__art {
  width: min(100%, 340px);
  animation: sy-bob 1.6s var(--ease) 2 alternate;
}

.sy-celebrate__art .ship-art {
  width: 100%;
  height: auto;
}

@keyframes sy-bob {
  from {
    transform: translateY(0) rotate(0deg);
  }
  to {
    transform: translateY(-6px) rotate(-1.5deg);
  }
}

/* ── Footer ────────────────────────────────────────────── */
.sy-foot {
  display: flex;
  justify-content: center;
}

/* A tab's one-word phone label ("Bigger"): hidden on wide screens. */
.sy-tab__short {
  display: none;
}

/* Five tabs (Tilly is here and the 🧰 workshop is earned): each tab is its emoji over one word, at every size,
   so the row fits a tablet and the shop column (a phone always draws them so: below). */
.sy-tabs:has(> .sy-tab:nth-child(5)) {
  border-radius: var(--r-lg);
}

.sy-tabs:has(> .sy-tab:nth-child(5)) .sy-tab {
  flex: 1 1 0;
  flex-direction: column;
  white-space: normal;
  gap: 2px;
  padding: 0.3em 0.4em;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.1;
}

.sy-tabs:has(> .sy-tab:nth-child(5)) .sy-tab.has-short .sy-tab__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sy-tabs:has(> .sy-tab:nth-child(5)) .sy-tab.has-short .sy-tab__short {
  display: inline;
}

/* ── Phones ────────────────────────────────────────────── */
@media (max-width: 37.5em) {
  .sy-tabs {
    width: 100%;
    border-radius: var(--r-lg);
  }

  /* One word under the emoji, never "Make her / bigger" on two lines (the tabs row stays one line of
     words, so her card's Swap stays above the fold); the full name stays the spoken name. */
  .sy-tab.has-short .sy-tab__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .sy-tab.has-short .sy-tab__short {
    display: inline;
  }

  .sy-tab {
    flex: 1 1 0;
    flex-direction: column;
    white-space: normal;
    gap: 2px;
    padding: 0.3em 0.4em;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    line-height: 1.1;
  }

  .sy-ship {
    padding: var(--sp-3);
  }

  .sy-offer {
    padding: var(--sp-3);
  }

  .sy-offer__actions .btn {
    flex: 1 1 auto;
  }
}

/* ── WS-D: save up or borrow, rent vs buy, the Satellite Link's line, swap ── */
.sy-saveup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--card);
  border: 2px dashed var(--accent-200);
}

.sy-saveup__line {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
}

.sy-offer__note {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-soft);
}

.sy-offer__note.is-swap {
  color: var(--sea-800);
}

/* ── UI-S2: 🦦 Tilly's tab on a phone (the UI-T leftover) ──
   On her tab Pip sits under her card (placeMate in shipyard.js), and in one column her card comes first:
   the shop, then the ship, then name and paint. On a phone the heading is one row (the way back beside
   it; the tab "Make her bigger" says what the sub-line said, as "Bigger"), and her offer comes before her
   greeting (a compact strip), so her whole card, Buy or Swap too, fits above the fold at 390 × 844, also
   with the top bar's goal chip and its "Keep cash ready" note (final-ui). */
.sy-shop > .mate.sy-mate--tilly {
  max-width: none;
}

@media (max-width: 56.1875em) {
  .sy-layout.is-tilly {
    grid-template-areas:
      'shop'
      'ship'
      'looks';
  }
}

@media (max-width: 37.5em) {
  /* Since the switch-on nearly every captain Tilly meets has the top bar's chip row (the next unlock, then
     the ocean goal): the screen's rows and her card's lines sit closer, so Buy or Swap stays above the fold. */
  .screen--shipyard {
    gap: var(--sp-2);
  }

  .screen--shipyard .sy-tilly__cards .sy-offer {
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
  }

  .screen--shipyard .sy-tilly__cards .sy-offer > * {
    margin-top: 0;
  }

  .screen--shipyard .sy-tilly__cards .sy-offer__actions {
    padding-top: 0;
  }

  .screen--shipyard .sy-head {
    gap: var(--sp-2);
  }

  .screen--shipyard .sy-head__sub {
    display: none;
  }

  .screen--shipyard .sy-shop {
    gap: var(--sp-2);
  }

  .screen--shipyard .sy-tilly__hello {
    gap: var(--sp-2);
    padding: var(--sp-2);
  }

  .screen--shipyard .sy-tilly__portrait {
    width: 40px;
    height: 40px;
    border-width: 2px;
    font-size: 1.4rem;
  }

  .screen--shipyard .sy-tilly__greeting,
  .screen--shipyard .sy-tilly__until {
    font-size: var(--fs-sm);
  }

  /* Her offer first on a phone, her greeting strip right under it (its chip says "🦦 Only from Tilly";
     the greeting has nothing to focus, so the keyboard's order is as before). Once a part is bought, her
     thank-you stays after her greeting, as on a wide screen. */
  .screen--shipyard .sy-tilly__cards.has-offer {
    order: -1;
  }
}

/* UI-S2: the yard's own sentences on their own line ("🛠️ 2 days in the yard."). */
.sy-offer__effect.is-yard {
  font-weight: 700;
  color: var(--ink-soft);
}

/* ── The playtest's 🧰 workshop (the Build tab): a built part's boxes and the store room ── */
.chip.sy-build-chip {
  max-width: 100%;
  white-space: normal;
  background: #eef1fb;
  border: 1px solid #c8d0ee;
  color: var(--ink-soft);
}

.chip.sy-build-chip.is-missing {
  background: var(--accent-100);
  border-color: var(--accent-400);
  color: var(--accent-700);
}

.sy-build__title {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.sy-build__needs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sy-build__need {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  padding: 0.3em 0.6em;
  border-radius: var(--r-md);
  background: var(--sea-50);
}

.sy-build__need.is-done {
  background: var(--gain-bg);
}

.sy-build__good {
  min-width: 7.5em;
  font-weight: 800;
}

.sy-build__count {
  min-width: 4em;
  font-weight: 800;
  color: var(--ink-soft);
}

.sy-build__where,
.sy-build__short {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.sy-build__short {
  flex-basis: 100%;
}

.sy-build__done {
  margin: 0;
  font-weight: 800;
  color: var(--gain);
}

/* ── C3: the shipyard's depth (docs/roadmap/C3-shipyard-depth.md §9) ──
   Upgrade levels: the 🆙 row under an installed part's card (Mk II, Mk III), a dashed box of its own so it
   reads as the next step, not as the part; at its top level the card says so. On a phone the row stacks
   and its button is full width (no sideways scroll at 390 px). */
.sy-level {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  border: 2px dashed var(--green-300);
  background: var(--card);
}

.sy-level > * {
  margin: 0;
}

.sy-level.is-off {
  border-color: var(--line);
}

.sy-level__title {
  font-weight: 800;
}

.sy-level__mk {
  color: var(--green-700);
}

.sy-level__blurb {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

.sy-level__top {
  color: var(--green-700);
}

.sy-level .sy-offer__effect {
  font-size: var(--fs-sm);
}

@media (max-width: 37.5em) {
  .sy-level__actions .btn {
    flex: 1 1 100%;
  }
}

/* 🦦 Tilly's used part (§3.2): a block of its own after her rare card ("I fixed up an old part too." and its
   card, one column on a phone: .sy-cards' own grid); its new price and resale lines are quieter than its fix. */
.sy-tilly__used {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.sy-tilly__used-hello {
  margin: 0;
  font-weight: 800;
  color: var(--ink-soft);
}

.sy-offer.is-used .sy-used__new,
.sy-offer.is-used .sy-used__later {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}

/* A far shipyard's part (§4): its plain chip ("🏔️ Only in Frost Reach"), cool like the region's own chip. */
.chip.sy-far-chip {
  background: var(--cold-bg);
  border: 1px solid #b9d7ef;
  color: var(--sea-800);
}

/* A rival's favourite on the part's card (§6): "⚓ Rusty Anchor likes kites.", words only, the quietest line. */
.sy-offer__fan {
  font-style: italic;
}
/* ── end C3 ── */
