/* =========================================
   Shared table base styles (Risk + Trace)
   ========================================= */

.md-typeset .risk-table table,
.md-typeset .trace-table table {
    table-layout: auto;
    width: 100%;
    border-collapse: collapse;
}

/* Top-align, comfortable padding, and sane wrapping */
.md-typeset .risk-table th,
.md-typeset .risk-table td,
.md-typeset .trace-table th,
.md-typeset .trace-table td {
    padding: 0.45rem 0.55rem;
    vertical-align: top;
    word-break: normal;
    /* avoid chopping words */
    overflow-wrap: break-word;
    hyphens: auto;
    /* soft hyphenation (needs lang attr) */
}

/* =========================================
   Risk table specific
   ========================================= */

/* Remove Material’s default min-width on headers inside wrapped tables */
.md-typeset .risk-table :is(.md-typeset__table, .md-typeset__scrollwrap)>table th,
.md-typeset .risk-table>table th {
    min-width: 0 !important;
}

/* Compact ID column */
.md-typeset .risk-table table th:nth-child(1),
.md-typeset .risk-table table td:nth-child(1) {
    width: 8rem;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Keep L / I tight and centered */
.md-typeset .risk-table table th:nth-child(4),
.md-typeset .risk-table table td:nth-child(4),
.md-typeset .risk-table table th:nth-child(5),
.md-typeset .risk-table table td:nth-child(5) {
    min-width: 0 !important;
    width: 3.5ch !important;
    /* just enough for L/M/H */
    white-space: nowrap;
    text-align: center !important;
}

/* Exposure a bit wider, still centered */
.md-typeset .risk-table table th:nth-child(6),
.md-typeset .risk-table table td:nth-child(6) {
    min-width: 0 !important;
    width: 6ch !important;
    /* fits 1–3 digits */
    white-space: nowrap;
    text-align: center !important;
}

/* Long-text columns: wrap at spaces (no mid-word cuts) and give room */
.md-typeset .risk-table table th:nth-child(7),
.md-typeset .risk-table table td:nth-child(7),
.md-typeset .risk-table table th:nth-child(8),
.md-typeset .risk-table table td:nth-child(8),
.md-typeset .risk-table table th:nth-child(9),
.md-typeset .risk-table table td:nth-child(9) {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    min-width: 22ch;
    /* tweak to taste (18–26ch works well) */
}

/* =========================================
   Traceability table specific
   ========================================= */

.md-typeset .trace-table :is(.md-typeset__table, .md-typeset__scrollwrap)>table,
.md-typeset .trace-table>table {
    table-layout: auto;
    width: 100%;
    border-collapse: collapse;
}

/* Reassert top-align + no mid-word chops for trace rows */
.md-typeset .trace-table th,
.md-typeset .trace-table td {
    padding: 0.45rem 0.55rem;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

/* Story ID compact */
.md-typeset .trace-table table th:nth-child(1),
.md-typeset .trace-table table td:nth-child(1) {
    width: 8ch;
    /* US-08, etc. */
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Status column (always last) */
.md-typeset .trace-table table th:last-child,
.md-typeset .trace-table table td:last-child {
    width: 9ch;
    white-space: nowrap;
    text-align: center;
    font-weight: 600;
}

/* Long-text columns (2–7): breathing room + no mid-word cuts */
.md-typeset .trace-table table th:nth-child(2),
.md-typeset .trace-table table td:nth-child(2),
.md-typeset .trace-table table th:nth-child(3),
.md-typeset .trace-table table td:nth-child(3),
.md-typeset .trace-table table th:nth-child(4),
.md-typeset .trace-table table td:nth-child(4),
.md-typeset .trace-table table th:nth-child(5),
.md-typeset .trace-table table td:nth-child(5),
.md-typeset .trace-table table th:nth-child(6),
.md-typeset .trace-table table td:nth-child(6),
.md-typeset .trace-table table th:nth-child(7),
.md-typeset .trace-table table td:nth-child(7) {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    min-width: 22ch;
    /* tweak 20–26ch to taste */
}

/* Allow long code/URLs to break safely in Evidence */
.md-typeset .trace-table td code,
.md-typeset .trace-table td a {
    overflow-wrap: anywhere;
}

/* =========================================
   Smoke Checklist table (no mid-word breaks)
   ========================================= */

/* Base + defeat theme constraints */
.md-typeset .smoke-table :is(.md-typeset__table, .md-typeset__scrollwrap)>table,
.md-typeset .smoke-table>table {
    table-layout: auto !important;
    width: 100% !important;
    border-collapse: collapse !important;
}

.md-typeset .smoke-table :is(.md-typeset__table, .md-typeset__scrollwrap)>table th,
.md-typeset .smoke-table :is(.md-typeset__table, .md-typeset__scrollwrap)>table td,
.md-typeset .smoke-table>table th,
.md-typeset .smoke-table>table td {
    min-width: 0 !important;
    padding: 0.45rem 0.55rem !important;
    vertical-align: top !important;

    /* 🔒 No mid-word cutting anywhere by default */
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
    -ms-hyphens: none !important;
}

/* --- Control widths via <colgroup> so changes actually apply --- */
.md-typeset .smoke-table table colgroup col {
    width: auto !important;
}

/* Column map:
   1 ID | 2 Account | 3 Area | 4 Scenario | 5 URL | 6 Platform | 7 Quick Steps | 8 Result | 9 Evidence */

/* Skinny columns – keep truly skinny to close gaps */
.md-typeset .smoke-table table colgroup col:nth-child(1) {
    width: 7ch !important;
}

/* ID */
.md-typeset .smoke-table table colgroup col:nth-child(2) {
    width: 11ch !important;
}

/* Account */
.md-typeset .smoke-table table colgroup col:nth-child(3) {
    width: 9ch !important;
}

/* Let the URL column expand as needed */
.md-typeset .smoke-table table colgroup col:nth-child(5) {
    width: auto !important;
    /* allow it to grow to fit */
}

/* Ensure the URL cell itself doesn't clip or force breaks */
.md-typeset .smoke-table th:nth-child(5),
.md-typeset .smoke-table td:nth-child(5) {
    min-width: 0 !important;
    white-space: normal !important;
    /* allow wrapping only at spaces/slashes */
    word-break: normal !important;
    /* do NOT break mid-word */
    overflow-wrap: normal !important;
    /* do NOT insert arbitrary breaks */
    overflow: visible !important;
}

/* Critical: MkDocs Material makes inline <code> break words. Override that here. */
.md-typeset .smoke-table td:nth-child(5) code {
    display: inline !important;
    white-space: normal !important;
    /* not pre, not pre-wrap */
    word-break: normal !important;
    /* keep tokens intact */
    overflow-wrap: normal !important;
    /* don't force breaks */
    hyphens: none !important;
}

/* URL */
.md-typeset .smoke-table table colgroup col:nth-child(6) {
    width: 10ch !important;
}

/* Platform */
.md-typeset .smoke-table table colgroup col:nth-child(8) {
    width: 10ch !important;
}

/* Result */

/* Content columns – take remaining space, wrap only at spaces */
.md-typeset .smoke-table table colgroup col:nth-child(4) {
    width: auto !important;
}

/* Scenario */
.md-typeset .smoke-table table colgroup col:nth-child(7) {
    width: auto !important;
}

/* Quick Steps */
.md-typeset .smoke-table table colgroup col:nth-child(9) {
    width: auto !important;
}

/* Evidence */

/* Pill column centering */
.md-typeset .smoke-table td:nth-child(8) {
    text-align: center !important;
    white-space: nowrap !important;
}

.md-typeset .smoke-table td:nth-child(8) .pill {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.md-typeset .smoke-table td:nth-child(9) a,
.md-typeset .smoke-table td:nth-child(9) code {
    overflow-wrap: anywhere !important;
    /* last resort for super-long URLs */
}

/* Optional: light zebra rows */
.md-typeset .smoke-table tbody tr:nth-child(odd) td {
    background: color-mix(in oklab, var(--md-default-bg-color) 96%, black);
}

/* Narrow screens: shave skinny columns slightly more */
@media (max-width: 900px) {
    .md-typeset .smoke-table table colgroup col:nth-child(2) {
        width: 10ch !important;
    }

    .md-typeset .smoke-table table colgroup col:nth-child(3) {
        width: 8ch !important;
    }

    .md-typeset .smoke-table table colgroup col:nth-child(5) {
        width: 7ch !important;
    }

    .md-typeset .smoke-table table colgroup col:nth-child(6) {
        width: 7ch !important;
    }
}

/* =========================================
   Colored Pills (Traceability + Risk)
   Usage:
     <span class="pill planned">Planned</span>
     <span class="pill progress">In&nbsp;Progress</span>
     <span class="pill blocked">Blocked</span>
     <span class="pill done">Done</span>
     <span class="pill open">Open</span>
     <span class="pill mitigating">Mitigating</span>
     <span class="pill accepted">Accepted</span>
     <span class="pill closed">Closed</span>
   ========================================= */

/* Base pill */
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78em;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid currentColor;
    text-transform: none;
    white-space: nowrap;
}

/* Map colors using Material theme vars with sensible fallbacks */
:root,
[data-md-color-scheme="default"] {
    --pill-gray: #9aa0a6;
    --pill-blue: #1e88e5;
    --pill-green: #43a047;
    --pill-red: #e53935;
    --pill-amber: #fb8c00;
    --pill-indigo: #3f51b5;
}

[data-md-color-scheme="slate"] {
    /* Slightly brighter for dark mode contrast */
    --pill-gray: #b0b6bb;
    --pill-blue: #64b5f6;
    --pill-green: #66bb6a;
    --pill-red: #ef5350;
    --pill-amber: #ffb74d;
    --pill-indigo: #7986cb;
}

/* Traceability */
.pill.planned {
    color: var(--pill-gray);
    background: color-mix(in oklab, var(--pill-gray) 18%, transparent);
}

.pill.notrun {
    color: var(--pill-gray);
    background: color-mix(in oklab, var(--pill-gray) 18%, transparent);
}

.pill.deferred {
    color: var(--pill-gray);
    background: color-mix(in oklab, var(--pill-gray) 18%, transparent);
}

.pill.progress {
    color: var(--pill-blue);
    background: color-mix(in oklab, var(--pill-blue) 18%, transparent);
}

.pill.blocked {
    color: var(--pill-red);
    background: color-mix(in oklab, var(--pill-red) 18%, transparent);
}

.pill.fail {
    color: var(--pill-red);
    background: color-mix(in oklab, var(--pill-red) 18%, transparent);
}

.pill.done {
    color: var(--pill-green);
    background: color-mix(in oklab, var(--pill-green) 18%, transparent);
}

.pill.pass {
    color: var(--pill-green);
    background: color-mix(in oklab, var(--pill-green) 18%, transparent);
}

/* Risk */
.pill.open {
    color: var(--pill-amber);
    background: color-mix(in oklab, var(--pill-amber) 18%, transparent);
}

.pill.mitigating {
    color: var(--pill-indigo);
    background: color-mix(in oklab, var(--pill-indigo) 18%, transparent);
}

.pill.accepted {
    color: var(--pill-gray);
    background: color-mix(in oklab, var(--pill-gray) 18%, transparent);
}

.pill.closed {
    color: var(--pill-green);
    background: color-mix(in oklab, var(--pill-green) 18%, transparent);
}

.pill.in-progress {
    color: var(--pill-blue);
    background: color-mix(in oklab, var(--pill-blue) 18%, transparent);
}

.pill.fixed {
    /* resolved but pending verification – give it a distinct tone (indigo) */
    color: var(--pill-indigo);
    background: color-mix(in oklab, var(--pill-indigo) 18%, transparent);
}

.pill.verified {
    color: var(--pill-green);
    background: color-mix(in oklab, var(--pill-green) 18%, transparent);
}

.pill.deferred {
    color: var(--pill-gray);
    background: color-mix(in oklab, var(--pill-gray) 18%, transparent);
}

.pill.wontfix {
    color: var(--pill-red);
    background: color-mix(in oklab, var(--pill-red) 18%, transparent);
}

.pill.duplicate {
    /* slight blue bias to differentiate from plain gray */
    color: var(--pill-blue);
    background: color-mix(in oklab, var(--pill-blue) 12%, transparent);
}



/* Fallback for browsers without color-mix (older Safari/Chromium) */
@supports not (background: color-mix(in oklab, black 10%, white)) {
    .pill.planned {
        background: #9aa0a61f;
    }

    .pill.progress {
        background: #1e88e51f;
    }

    .pill.blocked {
        background: #e539351f;
    }

    .pill.done {
        background: #43a0471f;
    }

    .pill.open {
        background: #fb8c001f;
    }

    .pill.mitigating {
        background: #3f51b51f;
    }

    .pill.accepted {
        background: #9aa0a61f;
    }

    .pill.closed {
        background: #43a0471f;
    }
    .pill.in-progress {
        background: #1e88e51f;
    }

    .pill.fixed {
        background: #3f51b51f;
    }

    .pill.verified {
        background: #43a0471f;
    }

    .pill.deferred {
        background: #9aa0a61f;
    }

    .pill.wontfix {
        background: #e539351f;
    }

    .pill.duplicate {
        background: #1e88e512;
    }
}