/* Base Converter (/base-converter): only what is the app's own (the base fields, the bit grid, the steps). Panels,
   tiles, fields, buttons, tables and colours come from the app kit (css/app-kit, docs/app-kit.md).
   Loaded only on this app's page (StylePaths in its demo catalog entry). */

/* On a phone the site's photo-app rule (seo-pages.css) sets align-items: start on every stage, which beats the kit's
   stretch: the panels would shrink to their own width. */
.bc-landing-app > .ak-stage > * {
    align-self: stretch;
}

/* --- The fields: label, number, Copy ------------------------------------------------------------------------------- */

/* One grid for all rows, so the labels share a column. */
.bc-landing-app .bc-fields {
    display: grid;
    grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
}

.bc-landing-app .bc-row {
    display: contents;
}

.bc-landing-app .bc-fields > .ak-message {
    grid-column: 1 / -1;
}

.bc-landing-app .bc-label {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    min-width: 0;
    font-size: var(--ak-fs-sm);
    font-weight: 600;
    color: var(--ak-text);
}

.bc-landing-app .bc-radix {
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--ak-hover);
    color: var(--ak-muted);
    font-family: var(--ak-font-mono);
    font-size: 0.75rem;
    font-weight: 600;
}

.bc-landing-app .bc-base {
    width: 100%;
    min-width: 0;
    font-weight: 600;
}

.bc-landing-app .bc-input {
    width: 100%;
    min-width: 0;
    font-family: var(--ak-font-mono);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: left;
}

.bc-landing-app .bc-input[data-bc-field="dec"] {
    color: var(--ak-accent);
}

/* --- The character tile: control characters shown as their symbol, a little smaller -------------------------------- */

.bc-landing-app .bc-char.bc-char--control {
    font-size: 1.35rem;
}

/* --- The bit grid: bytes of two nibbles, the bit numbers above, the hex digit below -------------------------------- */

/* One byte per row, or two (16 bits) from 16 bits up, so 32 and 64 bits make even rows. */
.bc-landing-app .bc-grid {
    --bc-cell: 1.85rem;
    display: grid;
    grid-template-columns: max-content;
    justify-content: center;
    gap: 0.75rem 1.5rem;
    direction: ltr;
}

.bc-landing-app .bc-grid.bc-grid--pairs {
    grid-template-columns: repeat(2, max-content);
}

.bc-landing-app .bc-byte {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.bc-landing-app .bc-byte-head {
    display: flex;
    justify-content: space-between;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    color: var(--ak-muted);
    font-variant-numeric: tabular-nums;
}

.bc-landing-app .bc-nibbles {
    display: flex;
    gap: 0.5rem;
}

.bc-landing-app .bc-nibble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.bc-landing-app .bc-cells {
    display: flex;
    gap: 3px;
}

.bc-landing-app .bc-bit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--bc-cell);
    height: var(--bc-cell);
    padding: 0;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-field);
    color: var(--ak-muted);
    font-family: var(--ak-font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.bc-landing-app .bc-bit:hover {
    border-color: var(--ak-accent);
}

.bc-landing-app .bc-bit:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 2px;
}

.bc-landing-app .bc-bit[aria-pressed="true"] {
    border-color: var(--ak-accent);
    background: var(--ak-accent);
    color: var(--ak-on-accent);
}

/* The sign bit in signed mode. */
.bc-landing-app .bc-bit.bc-bit--sign {
    box-shadow: 0 0 0 2px var(--ak-danger);
}

.bc-landing-app .bc-hexdigit {
    font-family: var(--ak-font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ak-text);
}

.bc-landing-app .bc-kv {
    padding-top: 0.5rem;
    border-top: 1px solid var(--ak-border);
}

.bc-landing-app .bc-kv > dd {
    overflow-wrap: anywhere;
}

/* --- The steps ---------------------------------------------------------------------------------------------------- */

.bc-landing-app .bc-steps-head {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
}

.bc-landing-app .bc-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bc-landing-app .bc-step {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.bc-landing-app .bc-step + .bc-step {
    padding-top: 0.85rem;
    border-top: 1px solid var(--ak-border);
}

.bc-landing-app .bc-step-head {
    margin: 0;
    font-size: var(--ak-fs-sm);
    font-weight: 600;
    color: var(--ak-text);
}

.bc-landing-app .bc-step-line {
    margin: 0;
    font-size: var(--ak-fs-sm);
    color: var(--ak-text);
    overflow-wrap: anywhere;
}

.bc-landing-app .bc-step-line.ak-mono {
    text-align: left;
}

.bc-landing-app .bc-table th,
.bc-landing-app .bc-table td {
    text-align: right;
}

.bc-landing-app .bc-table td {
    font-family: var(--ak-font-mono);
    overflow-wrap: anywhere;
}

/* Values written left to right (a range with a minus sign) keep to the right on a right-to-left page. */
[dir="rtl"] .bc-landing-app .ak-stat-value[dir="ltr"] {
    text-align: right;
}

.bc-landing-app .bc-table td.bc-digit {
    color: var(--ak-accent);
    font-weight: 700;
}

.bc-landing-app .bc-table tr.bc-gap td {
    color: var(--ak-muted);
    font-family: inherit;
    text-align: center;
}

@media (max-width: 560px) {
    .bc-landing-app .bc-fields {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.25rem 0.5rem;
    }

    .bc-landing-app .bc-label {
        grid-column: 1 / -1;
        margin-top: 0.25rem;
    }

    .bc-landing-app .bc-label:has(.bc-base) {
        max-width: 12rem;
    }

    .bc-landing-app .bc-grid,
    .bc-landing-app .bc-grid.bc-grid--pairs {
        --bc-cell: 1.75rem;
        grid-template-columns: max-content;
        gap: 0.6rem 1rem;
    }
}
