/* ships.css - Ship Codex (ship_codex.php) and Org Fleet (org_fleet.php).
   Sits on top of supply_chain.css (cards, badges, buttons, tables).

   v7 "Mission Control" (Oct 2026): every ship card is a spec plate - a
   serial strip with the maker's code and size, the picture in a recessed
   viewscreen, then the specs in a ruled grid. The detail popup is a spec
   sheet: picture banner with the name plate, then a side column (a CRT
   price readout, the spec rows, the actions) beside the description,
   dealers and owners. The Org Fleet numbers are CRT readouts.
   Colours come only from the root.css tokens, so all three themes follow. */

/* ------------------------------------------------------------- filters */
.ship-page .ship-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    justify-content: flex-start;
    margin-bottom: 1.1rem;
    padding: 1rem 1.1rem 1.1rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: 0 0 0 transparent;
}

.ship-page .ship-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    /* 120px (was 140, 27 Oct 2026): every filter still fits on one line now the page has the site gutter. */
    min-width: 120px;
    flex: 1 1 120px;
    max-width: 240px;
    font-size: var(--label-size);
    font-weight: 600;
    color: var(--ink-2);
    text-align: left;
}

/* The Member filter starts hidden (members only); label's display:flex
   above would otherwise beat the hidden attribute. */
.ship-page .ship-toolbar label[hidden] {
    display: none;
}

.ship-page .ship-toolbar input,
.ship-page .ship-toolbar select {
    box-sizing: border-box;
    width: 100%;
    height: var(--control-h);
    background-color: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 0;
}

/* A wider search box - the name you type is what most people use. */
.ship-page .ship-toolbar label:first-child {
    flex: 2 1 260px;
    max-width: 420px;
}

.ship-page .ship-toolbar #ship-reset {
    margin: 0;
}

.ship-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
    font-size: 0.92rem;
    color: var(--ink-2);
}

.ship-bar #ship-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink);
    font-weight: 500;
}

.ship-bar .sc-dim {
    font-size: 0.82rem;
}

/* "My fleet" pressed: a lit switch. */
.ship-page .sc-btn.active {
    background: var(--solid);
    color: var(--on-solid);
    border-color: var(--rule);
}

/* ------------------------------------------------------------- spec plates */
.ship-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.1rem;
}

.ship-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: 0 0 0 transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.ship-card:hover,
.ship-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 0 0 transparent;
}

.ship-card:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 transparent;
}

.ship-card:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

/* The serial strip: maker's code left, size right, two rivets. */
.ship-card-plate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 1.4rem;
    background:
        radial-gradient(circle at 0.65rem 50%, var(--ink-3) 0 2.5px, transparent 3px),
        radial-gradient(circle at calc(100% - 0.65rem) 50%, var(--ink-3) 0 2.5px, transparent 3px),
        var(--sheet-3);
    border-bottom: 1px solid var(--rule);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    font-weight: 500;
}

.ship-card-code {
    color: var(--ink);
}

.ship-card-size {
    color: var(--ink-2);
}

/* The picture in a recessed viewscreen. */
.ship-card-img {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    margin: 0.7rem 0.7rem 0;
    overflow: hidden;
    background: var(--sheet-3);
    border: 1px solid var(--rule);
    border-radius: 0;
}

.ship-card-img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ship-card-img.noimg::after,
.ship-noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    font-weight: 500;
}

.ship-card-img.noimg::after {
    content: "No picture";
}

.ship-owned-flag {
    position: absolute;
    left: 0.5rem;
    bottom: 0.5rem;
    padding: 0.15rem 0.6rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 0;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.ship-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.8rem 0.9rem 0.9rem;
}

.ship-card-name {
    font-family: var(--font-display);
    font-size: 0.98rem;
    line-height: 1.25;
    color: var(--ink);
    overflow-wrap: anywhere;
    text-transform: uppercase;
}

.ship-card-mfr {
    font-size: 0.86rem;
    color: var(--ink-2);
}

/* The spec grid, ruled like a data plate. */
.ship-card-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 0.65rem 0 0.7rem;
    border: 1px solid var(--rule-soft);
    border-radius: 0;
    overflow: hidden;
}

.ship-spec {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border-top: 1px solid var(--rule-soft);
}

.ship-spec:nth-child(even) {
    border-left: 1px solid var(--rule-soft);
}

.ship-spec.is-wide {
    grid-column: 1 / -1;
    border-top: 0;
}

.ship-spec-k {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 500;
}

.ship-spec-v {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.ship-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
}

/* "You own this" (12 Oct 2026). */
.ship-own-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    background: var(--good);
    border: 1px solid var(--rule);
    border-radius: 0;
    color: var(--on-accent);
    font-size: 0.82rem;
    font-weight: 700;
}

.ship-card.is-owned {
    border-color: var(--good);
    box-shadow: 0 4px 0 var(--good);
}

.ship-card.is-owned .ship-card-plate {
    background:
        radial-gradient(circle at 0.65rem 50%, var(--on-accent) 0 2.5px, transparent 3px),
        radial-gradient(circle at calc(100% - 0.65rem) 50%, var(--on-accent) 0 2.5px, transparent 3px),
        var(--good);
    border-bottom-color: var(--good);
}

.ship-card.is-owned .ship-card-code,
.ship-card.is-owned .ship-card-size {
    color: var(--on-accent);
}

.ship-grid > .os-skel,
.ship-grid > .sc-empty {
    grid-column: 1 / -1;
}

/* ------------------------------------------------------------- the popup */
.ship-backdrop[hidden] {
    display: none;
}

.ship-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;          /* above the site nav (1000), like the Supply Chain modals */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 1rem;
    overflow-y: auto;
    background: rgba(5, 6, 8, 0.6);
}

body.ship-modal-open {
    overflow: hidden;
}

.ship-modal {
    position: relative;
    width: min(1100px, 100%);
    margin: auto;
    overflow: hidden;
    /* 6.66 (Matt: zoomed in, the card ran off the screen and the wheel only scrolled it with the pointer off the card):
       clip, not hidden, so the card is not a scroll box of its own and the wheel over it scrolls the popup */
    overflow: clip;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: 0 0 0 transparent, 0 30px 80px rgba(0, 0, 0, 0.35);
    animation: ship-modal-in 0.18s ease-out;
}

/* 31 Oct 2026 (Theme Review, every theme): no stripe band along the top of
   the sheet any more - the ship's picture reaches the top edge. */

@keyframes ship-modal-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ship-modal { animation: none; }
}

.ship-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: var(--shadow);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.ship-modal-close:hover {
    background: var(--solid);
    color: var(--on-solid);
}

.sc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.ship-modal-body {
    display: block;
}

.ship-modal-body > .sc-empty {
    margin: 1.5rem;
}

/* Banner: the picture with the name plate over its lower edge. The overlay
   is always dark (it sits on a photo), so the words on it are always light. */
.ship-modal-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 300px;
    background: var(--console);
    border-bottom: 1px solid var(--rule);
}

.ship-modal-hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ship-modal-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(transparent, transparent),
        linear-gradient(180deg, rgba(5, 6, 8, 0) 35%, rgba(5, 6, 8, 0.9) 100%);
}

.ship-modal-hero.noimg {
    min-height: 170px;
}

.ship-modal-hero-text {
    position: relative;
    z-index: 1;
    /* 31 Oct 2026 (Theme Review): never wider than the picture, so a long
       ship name wraps instead of running off the right edge. */
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    padding: 1.4rem 1.6rem;
}

.ship-modal-hero-text h3 {
    overflow-wrap: break-word;
}

.ship-modal-mfr {
    display: inline-block;
    margin: 0;
    padding: 0.3rem 0.8rem;
    background: var(--s1);
    border-radius: 0;
    color: var(--on-accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    font-weight: 500;
}

.ship-modal-hero-text h3 {
    margin: 0.55rem 0 0.7rem;
    font-size: clamp(1.7rem, 4vw, 2.6rem);
    line-height: 1.05;
    text-transform: uppercase;
    color: var(--console-ink);
}

.ship-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
}

/* Badges on the photo get a solid backing so they read on any picture. */
.ship-modal-hero .sc-badge {
    background: var(--sheet);
    color: var(--ink);
}

/* Sheet body: spec column + the rest. */
.ship-modal-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
}

.ship-modal-side {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
    padding: 1.3rem 1.3rem 1.5rem;
    background: var(--sheet-2);
    border-right: 1px solid var(--rule);
    align-self: stretch;
}

.ship-side-plate,
.ship-modal-body h4 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink-2);
}

.ship-price.crt {
    font-size: 2.8rem;
    padding: 0.7rem 1rem 0.6rem;
}

.ship-price.crt small {
    font-size: 1.25rem;
}

.ship-tiles {
    display: flex;
    flex-direction: column;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 0;
    overflow: hidden;
}

.ship-tile {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: 0.6rem;
    align-items: baseline;
    padding: 0.5rem 0.8rem;
    border-top: 1px solid var(--rule-soft);
}

.ship-tile:first-child {
    border-top: 0;
}

.ship-tile-k {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 500;
}

.ship-tile-v {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.ship-modal-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}

.ship-modal-actions .sc-btn {
    margin: 0;
    justify-content: center;
}

/* Fleet control: the Supply Chain quantity stepper and a Remove button. */
.ship-fleet-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.3rem;
    padding-top: 0.9rem;
    border-top: 1px dashed var(--rule-soft);
}

.ship-fleet-label {
    flex: 1 0 100%;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink-2);
    font-weight: 500;
}

.ship-page .ship-fleet-remove {
    margin: 0;
}

.sc-qty-edit button[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

.ship-modal-main {
    min-width: 0;
    padding: 1.4rem 1.6rem 1.6rem;
}

.ship-modal-main > h4 {
    margin: 1.5rem 0 0.6rem;
}

.ship-modal-main > h4:first-child {
    margin-top: 0;
}

.ship-modal-main .sc-table-wrap {
    width: auto;
}

.ship-desc {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
}

.ship-owner {
    display: inline-block;
    margin: 0 0.3rem 0.35rem 0;
    padding: 0.15rem 0.65rem;
    background: var(--sheet);
    border: 1px solid var(--rule-soft);
    border-radius: 0;
    color: var(--ink);
    font-size: 0.88rem;
}

/* An owner whose profile is on (16 Oct 2026): the chip opens it. */
a.ship-owner.os-profile-link {
    text-decoration: none;
    border-color: var(--rule);
}

a.ship-owner.os-profile-link:hover,
a.ship-owner.os-profile-link:focus-visible {
    background: var(--solid);
    color: var(--on-solid);
}

@media (max-width: 860px) {
    .ship-modal-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ship-modal-side {
        border-right: 0;
        border-bottom: 1px solid var(--rule);
    }
}

@media (max-width: 700px) {
    .ship-backdrop {
        padding: 0;
    }

    .ship-modal {
        min-height: 100%;
        border-radius: 0;
        border-width: 0;
    }

    .ship-modal-hero {
        min-height: 220px;
    }

    .ship-modal-hero-text {
        padding: 1rem;
    }

    .ship-modal-side,
    .ship-modal-main {
        padding: 1rem;
    }

    /* The search box uses the full width now the other filters fold behind
       the "Filters" button (js/os-filters.js). */
    .ship-page .ship-toolbar {
        padding: 0.8rem;
    }

    .ship-page .ship-toolbar label:first-child {
        flex-basis: 100%;
        max-width: none;
    }
}

/* ------------------------------------------------------------- org fleet */
.ship-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

/* ships.js writes <span class=ship-stat-l>label</span><span class="ship-stat-n crt">n</span>. */
.ship-stat {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.45rem;
    min-width: 0;
    padding: 0.6rem 0.6rem 0.65rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: 0 0 0 transparent;
}

.ship-stat-l {
    padding: 0 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    line-height: 1.35;
    text-transform: uppercase;
    color: var(--ink-2);
    font-weight: 500;
}

.ship-stat-n.crt {
    display: block;
    padding: 0.5rem 0.8rem 0.35rem;
    font-size: clamp(2rem, 3vw, 2.6rem);
    white-space: nowrap;
}


@media (max-width: 700px) {
    .ship-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .ship-stat-n.crt {
        font-size: 1.9rem;
    }

    .ship-stat-l {
        font-size: 0.54rem;
        letter-spacing: 0.1em;
    }
}

@media (max-width: 600px) {
    .ship-grid {
        grid-template-columns: minmax(0, 1fr);
    }

}

/* High contrast: no green plate. */
.theme-contrast .ship-card.is-owned .ship-card-plate {
    background: var(--sheet-3);
}

.theme-contrast .ship-card.is-owned .ship-card-code,
.theme-contrast .ship-card.is-owned .ship-card-size {
    color: var(--ink);
}

/* Site audit (23 Oct 2026): MISC's grey on the picture box was 4.2:1. */
body.theme-mf-misc .ship-noimg { color: var(--ink); }
