/* Mortar Calculator – styled to match the TFR theme (dark panels, red accent).
   The tool is wrapped in .mortar-tool so its local variables stay scoped. */
.mortar-tool {
    --m-accent: #7d2128;
    --m-accent-hi: #a02a33;
    --m-line: rgba(125, 33, 40, 0.45);
    --m-field: rgba(4, 5, 5, 0.85);
    --m-field-line: rgba(125, 33, 40, 0.55);
    --m-muted: #fff;
    --m-good: #8dff9a;
    --m-bad: #ff8f8f;
    text-align: left;
    width: 100%;
}

.mortar-note {
    padding: 14px 18px;
    margin: 0 auto 18px;
    color: var(--m-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.mortar-note__training {
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--m-line);
}

/* Inline accent link that matches the tool's red theme */
.mortar-link {
    display: inline-block;
    margin-left: 6px;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 2px solid var(--m-accent);
    padding-bottom: 1px;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.mortar-link::after {
    content: " →";
    color: var(--m-accent-hi);
}

.mortar-link:hover,
.mortar-link:focus {
    color: var(--m-accent-hi);
    border-color: var(--m-accent-hi);
}

/* Three-column layout: inputs / result / saved. Collapses on narrow screens. */
.mortar-grid {
    display: grid;
    grid-template-columns: minmax(240px, 340px) minmax(320px, 1fr) minmax(300px, 380px);
    gap: 16px;
    align-items: stretch;
}

@media (max-width: 1050px) {
    .mortar-grid {
        grid-template-columns: 1fr;
    }
}

.mortar-panel {
    padding: 18px;
    text-align: left;
}

.mortar-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-content: start;
}

.mortar-field label,
.mortar-panel > label {
    display: block;
    margin: 0 0 6px;
    color: var(--m-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mortar-tool input,
.mortar-tool select {
    width: 100%;
    font-size: 1rem;
    padding: 11px 13px;
    border-radius: 8px;
    border: 1px solid var(--m-field-line);
    background: var(--m-field);
    color: #fff;
    outline: none;
}

.mortar-tool input:focus,
.mortar-tool select:focus {
    border-color: var(--m-accent-hi);
    box-shadow: 0 0 0 3px rgba(125, 33, 40, 0.28);
}

/* Drop the native OS select chrome so the control lines up with the inputs and
   the open list renders as a clean dark dropdown below the field. */
.mortar-tool select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 38px;
    cursor: pointer;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c7b3b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
}

.mortar-tool select::-ms-expand {
    display: none;
}

/* Dark option list where the browser honours it (Chrome/Firefox on Win/Linux) */
.mortar-tool select option {
    background-color: #140f0f;
    color: #fff;
}

.mortar-tool button {
    width: 100%;
    font-size: 1rem;
    padding: 12px 14px;
    border-radius: 8px;
    border: 2px solid var(--m-accent);
    background: var(--m-accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.mortar-tool button:hover,
.mortar-tool button:focus {
    background: var(--m-accent-hi);
    border-color: var(--m-accent-hi);
    transform: translateY(-1px);
}

.mortar-hint {
    color: var(--m-muted);
    font-size: 12px;
    margin-top: 6px;
    line-height: 1.4;
}

/* Result / fire solution panel */
.mortar-result {
    display: flex;
    flex-direction: column;
}

.mortar-out {
    font-size: 1rem;
    line-height: 1.6;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mortar-fire-header {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
    margin-bottom: 12px;
}

.mortar-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mortar-metric {
    border: 1px solid var(--m-line);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(4, 5, 5, 0.6);
}

.mortar-metric--charge {
    background: linear-gradient(180deg, rgba(125, 33, 40, 0.95), rgba(70, 18, 22, 0.95));
    border-color: rgba(160, 42, 51, 0.85);
}

.mortar-metric .name {
    color: var(--m-muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.mortar-metric .value {
    font-size: 30px;
    font-weight: 800;
    margin-top: 5px;
    color: #fff;
    line-height: 1.1;
}

.mortar-metric .unit {
    font-size: 14px;
    font-weight: 700;
    opacity: 0.85;
    margin-left: 3px;
}

.mortar-bad {
    color: var(--m-bad);
}

/* Save box under the result */
.mortar-savebox {
    margin-top: 16px;
    border-top: 1px solid var(--m-line);
    padding-top: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

.mortar-savebox button {
    background: rgba(4, 5, 5, 0.85);
    border-color: var(--m-field-line);
    white-space: nowrap;
}

.mortar-savebox button:hover,
.mortar-savebox button:focus {
    background: var(--m-accent);
    border-color: var(--m-accent);
}

@media (max-width: 760px) {
    .mortar-savebox {
        grid-template-columns: 1fr;
    }
}

/* Saved positions list */
.mortar-saved-heading {
    margin: 0 0 12px;
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
}

.mortar-saved-list {
    display: grid;
    gap: 9px;
}

.mortar-saved-item {
    position: relative;
    background: rgba(4, 5, 5, 0.85);
    border: 1px solid var(--m-field-line);
    border-radius: 8px;
    padding: 10px 40px 10px 12px;
    overflow: hidden;
}

.mortar-saved-compact {
    display: flex;
    gap: 10px;
    align-items: center;
    line-height: 1.15;
    flex-wrap: wrap;
}

.mortar-saved-name {
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 32px;
    max-width: 120px;
}

.mortar-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.mortar-tag .lbl {
    font-size: 11px;
    font-weight: 800;
    color: var(--m-muted);
    letter-spacing: 0.04em;
}

.mortar-tag .num {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
}

.mortar-tag--charge .num {
    color: #ffb6b6;
}

.mortar-tool .mortar-delete {
    position: absolute;
    right: 7px;
    top: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    background: rgba(59, 21, 24, 0.9);
    border: 1px solid rgba(125, 33, 40, 0.9);
    color: #fff;
    font-size: 18px;
    line-height: 1;
}

.mortar-tool .mortar-delete:hover,
.mortar-tool .mortar-delete:focus {
    background: var(--m-accent-hi);
    border-color: var(--m-accent-hi);
}

.mortar-empty {
    color: var(--m-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

/* Detail tables */
.mortar-tables {
    margin-top: 18px;
    padding: 18px;
    text-align: left;
}

.mortar-tables details {
    margin-top: 4px;
}

.mortar-tables summary {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--m-field-line);
    border-radius: 8px;
    background: rgba(4, 5, 5, 0.85);
    font-weight: 700;
    color: #fff;
}

.mortar-tables summary:hover {
    border-color: var(--m-accent-hi);
}

.mortar-tables h3 {
    margin: 16px 0 6px;
    color: #fff;
    font-size: 1rem;
}

.mortar-tables table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    font-size: 0.85rem;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--m-line);
}

.mortar-tables th,
.mortar-tables td {
    border-bottom: 1px solid var(--m-line);
    padding: 7px;
    text-align: right;
    color: #efe4e5;
}

.mortar-tables tr:last-child td {
    border-bottom: none;
}

.mortar-tables th {
    background: rgba(125, 33, 40, 0.35);
    color: #fff;
}

.mortar-tables .picked {
    background: rgba(125, 33, 40, 0.55);
    color: #fff;
}

/* Print bar (screen): the "Print / Save as PDF" trigger sits above the tables */
.mortar-printbar {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}

.mortar-tool .mortar-printbar button {
    width: auto;
    padding: 10px 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mortar-tool .mortar-print-btn::before {
    content: "\2399"; /* printer glyph */
    font-size: 1.1em;
    line-height: 1;
}

/* Printable A4 firing tables. Hidden on screen; only shown when printing.
   Each mortar is its own landscape A4 page with charges laid out in columns. */
.mortar-print {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 8mm;
    }

    html,
    body {
        background: #fff !important;
    }

    /* Hide the whole live page, show only the print booklet */
    body > *:not(.mortar-print) {
        display: none !important;
    }

    .mortar-print {
        display: block !important;
        color: #000;
        font-family: Arial, Helvetica, sans-serif;
    }

    .mp-page {
        page-break-after: always;
        break-after: page;
    }

    .mp-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    .mp-head {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        border-bottom: 2pt solid #7d2128;
        padding-bottom: 2mm;
        margin-bottom: 3mm;
    }

    .mp-title {
        font-size: 17pt;
        font-weight: 800;
        letter-spacing: 0.02em;
    }

    .mp-sub {
        font-size: 8pt;
        color: #000;
    }

    .mp-cols {
        display: flex;
        gap: 4mm;
        align-items: flex-start;
    }

    .mp-col {
        flex: 1 1 0;
        min-width: 0;
        break-inside: avoid;
    }

    .mp-charge {
        font-size: 9pt;
        font-weight: 800;
        text-align: center;
        background: #7d2128;
        color: #fff;
        padding: 1mm 0;
        border-radius: 2px;
        margin-bottom: 1mm;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .mp-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 7.5pt;
        line-height: 1.15;
    }

    .mp-table th,
    .mp-table td {
        border: 0.4pt solid #999;
        padding: 0.5mm 1.2mm;
        text-align: right;
    }

    .mp-table thead th {
        background: #eee;
        font-weight: 700;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .mp-table tbody tr:nth-child(even) td {
        background: #f4f4f4;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Intro split: text on the left, "Created by" credits on the right.
   The credit column never shrinks below the width of the two author cards. */
.mortar-intro {
    grid-template-columns: minmax(0, 7fr) minmax(320px, 3fr);
    align-items: start;
    gap: 24px;
}

.mortar-intro__text {
    display: grid;
    gap: 16px;
}

.mortar-intro__credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-left: 22px;
    border-left: 1px solid rgba(125, 33, 40, 0.4);
    align-self: stretch;
}

.mortar-credit__label {
    color: var(--m-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    text-align: center;
}

/* Lay the author cards next to each other, wrapping only if there is no room */
#mortarCreditCard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Shrink the reused member card so the credit stays visually minor, but keep
   it wide enough for the longest author name to sit on a single line. */
#mortarCreditCard .member-card {
    width: 138px;
    padding: 8px 6px;
    border: 1px solid rgba(226, 133, 11, 0.7);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.3);
}

#mortarCreditCard .member-card img {
    width: 52px;
    height: 52px;
}

#mortarCreditCard .member-card h3 {
    font-size: 0.85rem;
    margin-bottom: 3px;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.15;
}

#mortarCreditCard .member-card p {
    font-size: 0.62rem;
    margin: 0;
    color: var(--m-muted);
}

#mortarCreditCard .member-card .mortar-credit__role {
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Stack the credit under the text on narrow screens */
@media (max-width: 720px) {
    .mortar-intro {
        grid-template-columns: 1fr;
    }

    .mortar-intro__credit {
        flex-direction: row;
        justify-content: center;
        gap: 14px;
        padding-left: 0;
        padding-top: 16px;
        border-left: 0;
        border-top: 1px solid rgba(125, 33, 40, 0.4);
    }
}

@media (max-width: 700px) {
    .mortar-metrics {
        grid-template-columns: 1fr;
    }

    .mortar-metric {
        min-height: 78px;
    }
}
