/*
    "How codification works" guide (/codification/...) and the /dla, /nato and /cage explainers.
    Classes start with cod-. Colors come from the --nl-* tokens in nsn-dialog.css (loaded on every page by _Layout.cshtml).
    NSN parts use the same four colors in every picture and table:
      group = --cod-group (navy), class = --cod-class, country code = --cod-country (gold), item number = --cod-item.
    Text on each color meets 4.5:1. No per-page styles: pages only use these classes.
*/
.cod {
    --cod-group: var(--nl-navy, #0b2545);
    --cod-class: #3f6fa8;
    --cod-country: var(--nl-gold, #ffc233);
    --cod-item: #d8e4f3;
    --cod-ink: var(--nl-ink, #10233a);
    --cod-muted: var(--nl-muted, #51627a);
    --cod-line: var(--nl-line, #d8dee6);
    --cod-soft: var(--nl-soft, #f4f6f9);
    --cod-mono: "Roboto Mono", ui-monospace, Consolas, "Courier New", monospace;
    --cod-tap: var(--nl-tap, 44px);
    color: var(--cod-ink);
    font-family: var(--nl-font, Roboto, "Helvetica Neue", Arial, sans-serif);
    font-size: 1.0625rem;
    line-height: 1.6;
    max-width: 52rem;
    margin: 0 auto 2rem;
    overflow-wrap: break-word;
}

.cod a { color: var(--nl-blue, #13487a); }
.cod a:hover, .cod a:focus { color: var(--nl-navy, #0b2545); }
.cod h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); font-weight: 800; color: var(--nl-navy, #0b2545); margin: .5rem 0 .75rem; line-height: 1.2; }
.cod h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 700; color: var(--nl-navy, #0b2545); margin: 2.25rem 0 .75rem; line-height: 1.25; }
.cod h3 { font-size: 1.15rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
.cod p, .cod li { max-width: 46rem; }
.cod-mono, .cod code { font-family: var(--cod-mono); font-weight: 500; white-space: nowrap; color: var(--cod-ink); background: none; }

/* Breadcrumb and "Part of" strip */
.cod-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem .5rem; padding: 0; margin: .75rem 0 .25rem; font-size: .9375rem; }
.cod-crumbs li + li::before { content: "/"; color: var(--cod-muted); margin-right: .5rem; }
.cod-crumbs a { display: inline-block; min-height: var(--cod-tap); line-height: var(--cod-tap); }
.cod-crumbs [aria-current] { color: var(--cod-muted); line-height: var(--cod-tap); }
.cod-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding: .5rem .875rem; border-left: 4px solid var(--cod-country); background: var(--cod-soft); border-radius: 0 var(--nl-radius-sm, 8px) var(--nl-radius-sm, 8px) 0; font-size: .9375rem; }
.cod-strip a { font-weight: 700; display: inline-block; min-height: var(--cod-tap); line-height: var(--cod-tap); }
.cod-strip-label { font-weight: 700; color: var(--cod-muted); text-transform: uppercase; letter-spacing: .06em; font-size: .8125rem; }
.cod-strip-count { color: var(--cod-muted); }

/* First sentence and key facts */
.cod-lead { font-size: 1.1875rem; line-height: 1.55; }
.cod-keyfacts { border: 1px solid var(--cod-line); border-radius: var(--nl-radius, 12px); padding: 1rem 1.25rem; margin: 1.25rem 0; background: #fff; }
.cod-keyfacts h2 { margin: 0 0 .5rem; font-size: 1.125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cod-muted); }
.cod-keyfacts ul { margin: 0; padding-left: 1.25rem; }
.cod-keyfacts li { margin: .375rem 0; }
.cod-callout { border-left: 4px solid var(--cod-class); background: var(--cod-soft); padding: .75rem 1rem; margin: 1rem 0; border-radius: 0 var(--nl-radius-sm, 8px) var(--nl-radius-sm, 8px) 0; }

/* Citations: small superscripts, with padding so they are easier to tap */
.cod-ref { font-size: .75em; line-height: 0; }
.cod-ref a { padding: .25em .2em; text-decoration: none; font-weight: 700; }
.cod-ref a::before { content: "["; }
.cod-ref a::after { content: "]"; }

/* Pictures */
.cod-figure { margin: 1.25rem 0 1.5rem; }
.cod-figure svg { display: block; width: 100%; height: auto; max-width: 30rem; }
.cod-figure figcaption { margin-top: .5rem; font-size: .9375rem; color: var(--cod-muted); max-width: 30rem; }
.cod-svg-text { font-family: var(--nl-font, Roboto, Arial, sans-serif); font-size: 15px; fill: var(--cod-ink); }
.cod-svg-small { font-size: 13px; fill: var(--cod-ink); }
.cod-svg-code { font-family: var(--cod-mono); font-weight: 700; font-size: 26px; }
.cod-svg-mono { font-family: var(--cod-mono); font-weight: 500; }
.cod-svg-bold { font-weight: 700; }
.cod-svg-light { fill: #fff; }
.cod-svg-muted { fill: var(--cod-muted); }
.cod-fill-group { fill: var(--cod-group); }
.cod-fill-class { fill: var(--cod-class); }
.cod-fill-country { fill: var(--cod-country); }
.cod-fill-item { fill: var(--cod-item); }
.cod-fill-soft { fill: var(--cod-soft); }
.cod-fill-white { fill: #fff; }
.cod-stroke { stroke: var(--cod-line); stroke-width: 2; fill: none; }
.cod-stroke-ink { stroke: var(--cod-ink); stroke-width: 2; fill: none; }
.cod-stroke-blue { stroke: var(--cod-class); stroke-width: 2.5; fill: none; }
.cod-box { fill: #fff; stroke: var(--cod-line); stroke-width: 2; }
.cod-box-strong { fill: #fff; stroke: var(--cod-class); stroke-width: 2.5; }
.cod-arrowhead { fill: var(--cod-class); }

/* Color key under the NSN picture */
.cod-key { display: flex; flex-wrap: wrap; gap: .5rem 1rem; list-style: none; padding: 0; margin: .5rem 0 0; font-size: .9375rem; }
.cod-key li { display: flex; align-items: center; gap: .4rem; }
.cod-swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); }
.cod-swatch-group { background: var(--cod-group); }
.cod-swatch-class { background: var(--cod-class); }
.cod-swatch-country { background: var(--cod-country); }
.cod-swatch-item { background: var(--cod-item); }

/* NSN chips in text and tables (same colors as the pictures) */
.cod-nsn { font-family: var(--cod-mono); font-weight: 700; white-space: nowrap; }
.cod-nsn span { padding: .05em .2em; border-radius: 3px; }
.cod-nsn .g { background: var(--cod-group); color: #fff; }
.cod-nsn .c { background: var(--cod-class); color: #fff; }
.cod-nsn .n { background: var(--cod-country); color: var(--cod-ink); }
.cod-nsn .i { background: var(--cod-item); color: var(--cod-ink); }

/* Steps */
.cod-steps { list-style: none; counter-reset: cod-step; padding: 0; margin: 1rem 0; }
.cod-steps > li { counter-increment: cod-step; position: relative; padding: .25rem 0 .75rem 3rem; min-height: 2.5rem; }
.cod-steps > li::before { content: counter(cod-step); position: absolute; left: 0; top: .1rem; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--cod-group); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Cards (Go deeper) */
.cod-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .75rem; list-style: none; padding: 0; margin: 1rem 0; }
.cod-cards a { display: block; min-height: var(--cod-tap); padding: .875rem 1rem; border: 1px solid var(--cod-line); border-radius: var(--nl-radius, 12px); text-decoration: none; background: #fff; height: 100%; }
.cod-cards a:hover, .cod-cards a:focus { border-color: var(--cod-class); }
.cod-cards strong { display: block; color: var(--nl-navy, #0b2545); }
.cod-cards span { display: block; color: var(--cod-muted); font-size: .9375rem; }

/* Tables: rows stack on narrow screens, so the page never scrolls sideways */
.cod-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .9375rem; }
.cod-table caption { caption-side: top; text-align: left; color: var(--cod-muted); padding-bottom: .5rem; }
.cod-table th, .cod-table td { border-bottom: 1px solid var(--cod-line); padding: .5rem .5rem; text-align: left; vertical-align: top; }
.cod-table thead th { background: var(--cod-soft); font-weight: 700; }
.cod-table td a { display: inline-block; min-height: var(--cod-tap); line-height: var(--cod-tap); }
.cod-tier { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8125rem; font-weight: 700; white-space: nowrap; }
.cod-tier-nato { background: var(--cod-group); color: #fff; }
.cod-tier-2 { background: var(--cod-class); color: #fff; }
.cod-tier-1 { background: var(--cod-country); color: var(--cod-ink); }
@media (max-width: 575.98px) {
    .cod-table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .cod-table-stack tr { display: block; border: 1px solid var(--cod-line); border-radius: var(--nl-radius-sm, 8px); margin: 0 0 .5rem; padding: .25rem .5rem; }
    .cod-table-stack td, .cod-table-stack th[scope=row] { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 0; }
    .cod-table-stack td::before, .cod-table-stack th[scope=row]::before { content: attr(data-label); font-weight: 700; color: var(--cod-muted); }
}

/* FAQ */
.cod-faq { margin: 1rem 0; }
.cod-faq details { border: 1px solid var(--cod-line); border-radius: var(--nl-radius-sm, 8px); margin: 0 0 .5rem; background: #fff; }
.cod-faq summary { cursor: pointer; padding: .75rem 1rem; min-height: var(--cod-tap); font-weight: 700; color: var(--nl-navy, #0b2545); }
.cod-faq details > div { padding: 0 1rem .75rem; }
.cod-faq h3 { font-size: 1.0625rem; margin: 1.25rem 0 .25rem; color: var(--nl-navy, #0b2545); }

/* Previous / next and sources */
.cod-prevnext { display: flex; flex-wrap: wrap; gap: .75rem; margin: 2.5rem 0 1.5rem; }
.cod-prevnext a { flex: 1 1 14rem; display: block; min-height: var(--cod-tap); padding: .75rem 1rem; border: 1px solid var(--cod-line); border-radius: var(--nl-radius, 12px); text-decoration: none; background: #fff; }
.cod-prevnext a:hover, .cod-prevnext a:focus { border-color: var(--cod-class); }
.cod-next { text-align: right; }
.cod-pn-label { display: block; font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cod-muted); font-weight: 700; }
.cod-pn-title { display: block; font-weight: 700; color: var(--nl-navy, #0b2545); }
.cod-sources { border-top: 2px solid var(--cod-line); margin-top: 2rem; padding-top: .5rem; font-size: .875rem; color: var(--cod-ink); }
.cod-sources h2 { font-size: 1.125rem; margin-top: .75rem; }
.cod-sources li { margin: .4rem 0; scroll-margin-top: 5rem; }
.cod-sources li:target { background: #fff6d6; }
.cod-src-url { overflow-wrap: anywhere; word-break: break-word; }
.cod-note { color: var(--cod-muted); font-size: .875rem; }

/* Older explainer pages: their content sits in Bootstrap rows; keep wide tables inside the page */
.cod-scroll { overflow-x: auto; max-width: 100%; }

/* Definition lists (management codes) */
.cod dl { margin: 1rem 0; }
.cod dt { font-weight: 700; color: var(--nl-navy, #0b2545); margin-top: 1rem; }
.cod dd { margin: .25rem 0 0; max-width: 46rem; }
.cod-keyfacts p a { display: inline-block; min-height: var(--cod-tap); line-height: var(--cod-tap); }

/* The header and footer partials wrap themselves in .cod so they also work on older pages; no extra width or margin there */
.cod-embed { max-width: none; margin: 0; }

/* NSN data dictionary (/codification/data-dictionary and one page per field) */
.cod-dd-status { display: inline-block; padding: .125rem .5rem; border-radius: 999px; border: 1px solid var(--cod-line); font-size: .8125rem; font-weight: 700; line-height: 1.4; white-space: nowrap; background: var(--cod-soft); color: var(--cod-muted); }
.cod-dd-status--official { background: #e7f2ea; border-color: #b9d9c0; color: #1d5b2c; }
.cod-dd-status--derived { background: #e8eef7; border-color: #c4d3ea; color: #24467a; }
.cod-dd-status--notfound { background: #fff6d6; border-color: #f0dc9c; color: #6b4e00; }
.cod-dd-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; list-style: none; margin: 1rem 0; padding: 0; }
.cod-dd-counts li { border: 1px solid var(--cod-line); border-radius: var(--nl-radius, 12px); padding: .75rem 1rem; background: #fff; }
.cod-dd-counts strong { display: block; font-size: 1.75rem; line-height: 1.2; color: var(--nl-navy, #0b2545); }
.cod-dd-toc ul { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; list-style: none; padding: 0; margin: .5rem 0 1rem; }
.cod-dd-toc a { display: inline-block; min-height: var(--cod-tap); line-height: var(--cod-tap); }
.cod-dd-related li { break-inside: avoid; padding: .375rem 0; }
.cod-dd-table th[scope=row] a { line-height: 1.4; min-height: 0; padding: .5rem 0; display: inline-block; }
.cod-dd-table td:nth-child(3), .cod-dd-table td:nth-child(4) { white-space: nowrap; }
.cod-dd-facts dt { margin-top: .75rem; }
.cod-dd-facts dt:first-child { margin-top: 0; }
.cod-dd-example { white-space: normal; overflow-wrap: anywhere; }
.cod-dd-quote { margin: 1rem 0; padding: .75rem 1rem; border-left: 4px solid var(--cod-group); background: var(--cod-soft); border-radius: 0 var(--nl-radius-sm, 8px) var(--nl-radius-sm, 8px) 0; }
.cod-dd-quote--nato { border-left-color: var(--cod-class); }
.cod-dd-quote p { margin: 0 0 .5rem; max-width: 46rem; overflow-wrap: anywhere; }
.cod-dd-quote footer { font-size: .875rem; color: var(--cod-muted); }
.cod-dd-api { margin: .25rem 0 .5rem; padding-left: 1.25rem; }
.cod-dd-api .cod-mono { white-space: normal; overflow-wrap: anywhere; }
.cod-dd-related ul { columns: 2 16rem; padding-left: 1.25rem; }
@media (max-width: 767.98px) {
    .cod-dd-table td, .cod-dd-table th[scope=row] { flex-direction: column; justify-content: flex-start; gap: .125rem; }
    .cod-dd-table td:nth-child(3), .cod-dd-table td:nth-child(4) { white-space: normal; }
}
