/*
 * The Captain Solutions shell.
 *
 * One stylesheet for every public Solution page, so a second Solution is a folder with an
 * index.html and an app.js rather than a new design.
 *
 * Plain CSS with custom properties and no build step: these pages are static files served by
 * nginx, and a bundler would add a deployment stage to save nothing. Dark mode follows the
 * visitor's system setting — there is no account here to hold a preference in.
 */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f1f3f5;
    --border: #dfe3e8;
    --text: #1a1d21;
    --text-muted: #5b6672;
    --accent: #1f6feb;
    --accent-contrast: #ffffff;
    --danger: #b42318;
    --warning-bg: #fff6e6;
    --warning-border: #f0c56a;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
    --max-width: 920px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171a;
        --surface: #1c2024;
        --surface-muted: #23282d;
        --border: #313842;
        --text: #e9edf1;
        --text-muted: #9aa6b2;
        --accent: #4a90ff;
        --accent-contrast: #0d1117;
        --danger: #ff7b72;
        --warning-bg: #2b2415;
        --warning-border: #6b5526;
        --shadow: none;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

.shell {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 32px 16px 64px;
}

.masthead {
    margin-bottom: 24px;
}

.masthead h1 {
    margin: 0 0 6px;
    font-size: 1.9rem;
    letter-spacing: -0.01em;
}

.masthead p {
    margin: 0;
    color: var(--text-muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

.field {
    margin-bottom: 16px;
}

.field > label {
    display: block;
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 6px;
}

.field .hint {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

textarea,
input[type='text'] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

textarea:focus,
input[type='text']:focus,
button:focus-visible,
.dropzone:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The upload target. Also a label, so a click anywhere inside opens the picker and the
   keyboard reaches it without a tabindex hack. */
.dropzone {
    display: block;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--surface-muted);
}

.dropzone.is-dragging {
    border-color: var(--accent);
    color: var(--accent);
}

.dropzone input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.preview img {
    max-height: 96px;
    max-width: 160px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

button {
    font: inherit;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 10px 18px;
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
}

button.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* "Coming next" buttons. Visibly present and visibly not ready — a disabled button with no
   explanation reads as a bug. */
.pending {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
}

.pending small {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
}

.notice.error {
    border-color: var(--danger);
    color: var(--danger);
    background: transparent;
}

.notice.warn {
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.notice[hidden] {
    display: none;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: -3px;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* ── result ─────────────────────────────────────────────────────────────── */

.result section {
    margin-bottom: 22px;
}

.result h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.identity h2 {
    margin: 0 0 2px;
    font-size: 1.4rem;
}

.identity .title {
    color: var(--text-muted);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.chips li {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.88rem;
}

.chips.matched li {
    border-color: #2f9e44;
}

.chips.missing li {
    border-color: var(--warning-border);
}

.entry {
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

.entry:first-of-type {
    border-top: none;
}

.entry .entry-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.entry strong {
    font-size: 1rem;
}

.entry .meta {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.entry ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

details.raw {
    margin-top: 24px;
}

details.raw summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}

details.raw pre {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    overflow: auto;
    max-height: 420px;
    font-size: 0.82rem;
}

.footer {
    margin-top: 40px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

@media (max-width: 600px) {
    .shell {
        padding: 20px 14px 48px;
    }

    .masthead h1 {
        font-size: 1.5rem;
    }
}

/* ── progress ───────────────────────────────────────────────────────────── */

/*
 * A run takes minutes. Without visible stages the page is a spinner, and a spinner for four
 * minutes is indistinguishable from a page that has crashed.
 */
.steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.steps li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 5px 0;
    color: var(--text-muted);
}

.steps li .mark {
    width: 1.1em;
    flex: 0 0 1.1em;
    text-align: center;
}

.steps li.done {
    color: var(--text);
}

.steps li.done .mark::before {
    content: '¹3';
    color: #2f9e44;
}

.steps li.active {
    color: var(--text);
    font-weight: 600;
}

.steps li.active .mark::before {
    content: '2';
    color: var(--accent);
}

.steps li.pending .mark::before {
    content: 'CB';
    opacity: 0.45;
}

.steps li.failed .mark::before {
    content: '¹5';
    color: var(--danger);
}

.detected dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin: 0 0 12px;
}

.detected dt {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.detected dd {
    margin: 0;
}

.detected .group {
    margin-top: 10px;
}

.detected .group > span {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}
