/* ==========================================================================
   ma-tool.css — URN Meta-Analysis Online
   Two-pane research tool: sticky option rail + results canvas.
   Mobile-first; the rail stacks above the results below 992px.
   ========================================================================== */

.ma-page {
    --ma-ink: #10202e;
    --ma-muted: #5a6b7c;
    --ma-line: #dde5ec;
    --ma-line-soft: #eef3f7;
    --ma-surface: #ffffff;
    --ma-canvas: #f4f7fa;
    --ma-brand: var(--primary, #00629F);
    --ma-brand-dark: #004d7a;
    --ma-accent: var(--accent, #EC7E31);
    --ma-ok: #1f7a4d;
    --ma-warn: #a9631a;
    --ma-danger: #b3261e;
    --ma-step: #c62828;
    --ma-radius: 10px;
    background: var(--ma-canvas);
    color: var(--ma-ink);
    font-size: 15px;
}

/* ── masthead ─────────────────────────────────────────────────────────── */

.ma-masthead {
    background: linear-gradient(135deg, #0b2b45 0%, #0d3c60 55%, #00629F 100%);
    color: #fff;
    padding: 30px 0 26px;
    position: relative;
    overflow: hidden;
}
.ma-masthead::after {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 88% 12%, rgba(236,126,49,0.22), transparent 45%);
    pointer-events: none;
}
.ma-masthead .container { position: relative; z-index: 1; }
/* style.css sets a dark colour on every h1-h5, so the masthead restates it. */
.ma-masthead h1 {
    font-size: clamp(1.55rem, 1.1rem + 2.1vw, 2.5rem);
    font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px;
    line-height: 1.15;
    color: #ffffff;
}
.ma-masthead h1 .ma-hl { color: #ffb877; }
.ma-masthead p { color: #cfe0ee; margin: 0; max-width: 60ch; font-size: 0.98rem; }
.ma-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ma-badges span {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 999px; padding: 4px 12px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}

/* ── layout ───────────────────────────────────────────────────────────── */

.ma-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 22px 0 60px;
    align-items: start;
}
@media (min-width: 992px) {
    .ma-layout { grid-template-columns: 288px minmax(0, 1fr); gap: 26px; }
    .ma-panel { position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto; }
}

.ma-panel {
    background: var(--ma-surface);
    border: 1px solid var(--ma-line);
    border-radius: var(--ma-radius);
    padding: 16px 15px 20px;
    box-shadow: 0 1px 3px rgba(16,32,46,0.05);
    scrollbar-width: thin;
}
.ma-panel::-webkit-scrollbar { width: 8px; }
.ma-panel::-webkit-scrollbar-thumb { background: #cfd9e2; border-radius: 8px; }

.ma-step-title {
    color: var(--ma-step);
    font-weight: 800; font-size: 0.86rem;
    letter-spacing: 0.01em;
    margin: 20px 0 9px;
    display: flex; align-items: baseline; gap: 6px;
}
.ma-step-title:first-child { margin-top: 0; }
.ma-step-title .ma-step-n { font-variant-numeric: tabular-nums; }

.ma-type-option {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 7px 9px; border-radius: 8px;
    cursor: pointer; border: 1px solid transparent;
    transition: background .15s ease, border-color .15s ease;
    font-size: 0.855rem; line-height: 1.35;
}
.ma-type-option:hover { background: #f2f7fb; }
.ma-type-option.is-active { background: #e9f3fa; border-color: #b7d7ec; font-weight: 600; }
.ma-type-option input { margin-top: 3px; flex-shrink: 0; accent-color: var(--ma-brand); }
.ma-type-blurb {
    font-size: 0.76rem; color: var(--ma-muted);
    margin: 8px 2px 0; line-height: 1.45;
}

.ma-field { margin-bottom: 11px; }
.ma-field > label {
    display: block; font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.045em;
    color: var(--ma-muted); margin-bottom: 4px;
}
.ma-field select,
.ma-field input[type="text"],
.ma-field input[type="number"] {
    width: 100%; padding: 7px 9px;
    border: 1px solid var(--ma-line); border-radius: 7px;
    font-size: 0.86rem; font-family: inherit; color: var(--ma-ink);
    background: #fff;
}
.ma-field select:focus,
.ma-field input:focus {
    outline: 2px solid rgba(0,98,159,0.35); outline-offset: 1px;
    border-color: var(--ma-brand);
}
.ma-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.ma-check {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 0.845rem; padding: 4px 2px; cursor: pointer; line-height: 1.35;
}
.ma-check input { margin-top: 2.5px; flex-shrink: 0; accent-color: var(--ma-brand); }
.ma-check .ma-hintmark {
    color: var(--ma-brand); font-size: 0.72rem; cursor: help;
    border: 1px solid currentColor; border-radius: 50%;
    width: 13px; height: 13px; line-height: 11px; text-align: center;
    display: inline-block; flex-shrink: 0; margin-top: 3px;
}

/* accordion buttons for the option groups */
.ma-acc { margin-top: 12px; }
.ma-acc-btn {
    width: 100%; text-align: left;
    border: 0; border-radius: 8px;
    padding: 9px 12px; font-weight: 700; font-size: 0.82rem;
    color: #fff; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    background: var(--ma-brand);
}
.ma-acc-btn.is-amber { background: #d98324; }
.ma-acc-btn.is-slate { background: #4a5b6b; }
.ma-acc-btn:hover { filter: brightness(1.07); }
.ma-acc-btn::after { content: '\25BE'; font-size: 0.7rem; transition: transform .18s ease; }
.ma-acc-btn[aria-expanded="false"]::after { transform: rotate(-90deg); }
.ma-acc-body {
    padding: 12px 4px 4px;
    border-bottom: 1px solid var(--ma-line-soft);
}

.ma-btn-block {
    display: block; width: 100%; text-align: center;
    padding: 9px 12px; border-radius: 8px; border: 1px solid var(--ma-line);
    background: #fff; color: var(--ma-ink); font-weight: 600; font-size: 0.85rem;
    cursor: pointer; margin-top: 10px;
}
.ma-btn-block:hover { background: #f3f7fa; border-color: #bcd3e3; }
.ma-btn-block.is-danger { color: var(--ma-danger); border-color: #edc9c6; }
.ma-btn-block.is-danger:hover { background: #fdf3f2; }

/* ── main column ──────────────────────────────────────────────────────── */

.ma-main { min-width: 0; }

.ma-card {
    background: var(--ma-surface);
    border: 1px solid var(--ma-line);
    border-radius: var(--ma-radius);
    padding: 16px 16px 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(16,32,46,0.05);
}
.ma-card > h2, .ma-card > h3 {
    font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em;
    margin: 0 0 4px; color: var(--ma-ink);
}
.ma-card > h2 { font-size: 1.16rem; }
.ma-card-sub {
    font-size: 0.82rem; color: var(--ma-muted); margin: 0 0 14px; line-height: 1.5;
}
.ma-card-head {
    display: flex; flex-wrap: wrap; gap: 10px;
    align-items: baseline; justify-content: space-between;
    margin-bottom: 12px;
}
.ma-card-head > div { min-width: 0; }
.ma-card-head h2, .ma-card-head h3 { margin-bottom: 2px; }

/* ── data grid ────────────────────────────────────────────────────────── */

.ma-grid-wrap { overflow-x: auto; border: 1px solid var(--ma-line); border-radius: 8px; }
table.ma-grid { border-collapse: collapse; width: 100%; font-size: 0.83rem; background: #fff; }
table.ma-grid th, table.ma-grid td {
    border: 1px solid var(--ma-line); padding: 5px 8px;
    text-align: right; white-space: nowrap; vertical-align: middle;
}
table.ma-grid thead th {
    background: #f1f5f9; font-weight: 700; text-align: center;
    position: sticky; top: 0; z-index: 1; padding: 7px 8px;
}
.ma-grid-h1 { display: block; font-size: 0.8rem; }
.ma-grid-h2 { display: block; font-size: 0.68rem; font-weight: 500; color: var(--ma-muted); margin-top: 1px; }
table.ma-grid td.ma-cell { min-width: 74px; cursor: text; background: #fff; }
table.ma-grid td.ma-cell-text { text-align: left; min-width: 130px; }
table.ma-grid td.ma-cell:focus,
table.ma-grid td.ma-cell-active {
    outline: 2px solid var(--ma-brand); outline-offset: -2px; background: #f0f7fc;
}
.ma-grid-num { background: #f8fafc; color: var(--ma-muted); font-size: 0.76rem; width: 34px; text-align: center !important; }
.ma-grid-inc, .ma-grid-del { text-align: center !important; width: 62px; }
.ma-grid-del { width: 34px; }
tr.ma-row-invalid td.ma-cell { background: #fff6f5; }
tr.ma-row-invalid .ma-grid-num { background: #fdeceb; color: var(--ma-danger); font-weight: 700; }
.ma-row-del {
    border: 0; background: transparent; color: #9aa8b5;
    font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px;
}
.ma-row-del:hover { color: var(--ma-danger); background: #fdeceb; }

.ma-grid-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; align-items: center; }
.ma-tool-btn {
    border: 1px solid var(--ma-line); background: #fff; color: var(--ma-ink);
    border-radius: 7px; padding: 7px 13px; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.ma-tool-btn:hover { background: #f3f7fa; border-color: #bcd3e3; }
.ma-tool-btn.is-primary { background: var(--ma-brand); border-color: var(--ma-brand); color: #fff; }
.ma-tool-btn.is-primary:hover { background: var(--ma-brand-dark); }
.ma-tool-btn.is-demo { background: #e8f4fb; border-color: #b7d7ec; color: var(--ma-brand-dark); }
.ma-count { margin-left: auto; font-size: 0.8rem; color: var(--ma-muted); font-weight: 600; }

.ma-warn {
    margin-top: 10px; padding: 9px 12px; border-radius: 7px;
    background: #fff8ec; border: 1px solid #f0d9b5; color: #7a4f12;
    font-size: 0.82rem;
}
.ma-paste-hint { font-size: 0.79rem; color: var(--ma-muted); margin: 0 0 10px; line-height: 1.5; }

/* ── plots ────────────────────────────────────────────────────────────── */

.ma-plot { overflow-x: auto; padding: 4px 0 2px; }
.ma-plot canvas { display: block; max-width: 100%; height: auto; }

/* On a phone a full forest plot scaled to fit is unreadable, so let it keep its
   natural size and pan inside the card instead. */
@media (max-width: 767px) {
    .ma-plot { -webkit-overflow-scrolling: touch; }
    .ma-plot canvas { max-width: none; }
    .ma-plot::after {
        content: 'Swipe the plot sideways to see all of it';
        display: block; position: sticky; left: 0;
        font-size: 0.72rem; color: var(--ma-muted); padding-top: 6px;
    }
}
.ma-plot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ma-dl-btn {
    border: 1px solid var(--ma-line); background: #fff; color: var(--ma-ink);
    border-radius: 7px; padding: 6px 12px; font-size: 0.79rem; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.ma-dl-btn:hover { background: #f3f7fa; border-color: #bcd3e3; }
.ma-dl-btn i { color: var(--ma-brand); }

.ma-conclusion {
    margin-top: 14px; padding: 13px 15px;
    background: #f7fafc; border-left: 3px solid var(--ma-brand);
    border-radius: 0 8px 8px 0; font-size: 0.87rem; line-height: 1.62;
}
.ma-conclusion ul { margin: 0; padding-left: 18px; }
.ma-conclusion li + li { margin-top: 6px; }
.ma-conclusion p { margin: 0 0 8px; }
.ma-conclusion p:last-child { margin-bottom: 0; }
.ma-conclusion-title {
    font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--ma-brand); margin-bottom: 6px;
}
.ma-note { font-size: 0.8rem; color: var(--ma-muted); line-height: 1.55; margin: 10px 0 0; }
.ma-hint { font-size: 0.85rem; color: var(--ma-muted); padding: 22px 4px; text-align: center; }

/* ── results tables ───────────────────────────────────────────────────── */

.ma-table-wrap { overflow-x: auto; }
table.ma-table {
    border-collapse: collapse; width: 100%;
    font-size: 0.83rem; margin-bottom: 4px; background: #fff;
}
table.ma-table th, table.ma-table td {
    border: 1px solid var(--ma-line); padding: 6px 10px; text-align: right; white-space: nowrap;
}
table.ma-table thead th { background: #f1f5f9; font-weight: 700; text-align: center; }
table.ma-table tbody th[scope="row"] { text-align: left; font-weight: 500; background: #fbfdfe; }
table.ma-table tbody tr:last-child th[scope="row"],
table.ma-table tbody tr:last-child td { font-weight: 700; background: #f5f9fc; }
table.ma-table-wide tbody tr:last-child th[scope="row"] { background: #f5f9fc; }

.ma-subcard + .ma-subcard { margin-top: 18px; }
.ma-subcard h3 {
    font-size: 0.92rem; font-weight: 700; margin: 0 0 8px; color: var(--ma-ink);
}

.ma-grid-2 { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .ma-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Grid and flex children default to min-width:auto, which lets a wide table or
   canvas stretch the page instead of scrolling inside its own container. */
.ma-layout > *, .ma-grid-2 > *, .ma-card { min-width: 0; }
.ma-card > * { max-width: 100%; }

/* ── empty state ──────────────────────────────────────────────────────── */

.ma-empty-msg {
    background: #fff; border: 1px dashed #c3d4e0; border-radius: var(--ma-radius);
    padding: 40px 22px; text-align: center; color: var(--ma-muted); font-size: 0.9rem;
}
.ma-empty-msg strong { color: var(--ma-ink); display: block; margin-bottom: 6px; font-size: 1rem; }

/* ── guide strip ──────────────────────────────────────────────────────── */

.ma-guide { background: #fff; border-top: 1px solid var(--ma-line); padding: 34px 0 40px; }
.ma-guide h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; }
.ma-guide-grid { display: grid; gap: 18px; grid-template-columns: 1fr; margin-top: 20px; }
@media (min-width: 700px) { .ma-guide-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .ma-guide-grid { grid-template-columns: repeat(4, 1fr); } }
.ma-guide-item h3 {
    font-size: 0.9rem; font-weight: 700; margin: 0 0 6px;
    display: flex; align-items: center; gap: 7px;
}
.ma-guide-item h3 i { color: var(--ma-brand); }
.ma-guide-item p { font-size: 0.83rem; color: var(--ma-muted); line-height: 1.6; margin: 0; }

.ma-cite {
    margin-top: 26px; padding: 14px 16px; background: #f7fafc;
    border-radius: 8px; font-size: 0.82rem; color: var(--ma-muted); line-height: 1.6;
}
.ma-cite strong { color: var(--ma-ink); }

@media print {
    .ma-panel, .ma-masthead, .ma-grid-toolbar, .ma-plot-actions, .ma-guide,
    header, footer, .navbar { display: none !important; }
    .ma-layout { grid-template-columns: 1fr; }
    .ma-card { border: 0; box-shadow: none; page-break-inside: avoid; }
}
