/* =====================================================================
   Emergency communications page (emergency-communications.php).
   A long guide with a contents rail, plus the range and power planners.
   Built on site.css + tools.css tokens. No external libraries.
   ===================================================================== */

/* ---- layout: contents rail | article ------------------------------- */
.cm-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 38px; align-items: start; padding-top: 22px; padding-bottom: 46px; }
.cm-main { min-width: 0; }
.cm-toc { position: sticky; top: 80px; max-height: calc(100vh - 96px); overflow: auto; font-size: .86rem; padding-right: 4px; }
.cm-toc > summary { list-style: none; cursor: pointer; font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); padding: 4px 0 8px; }
.cm-toc > summary::-webkit-details-marker { display: none; }
.cm-toc ol { list-style: none; margin: 0; padding: 0; }
.cm-toc li.grp { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--amber-d); margin: 12px 0 3px; }
.cm-toc li.grp:first-child { margin-top: 0; }
.cm-toc a { display: block; padding: 3px 10px; border-left: 2px solid var(--line); color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.cm-toc a:hover { color: var(--ink); border-left-color: var(--line-2); }
.cm-toc a.on { color: var(--ink); border-left-color: var(--amber); font-weight: 650; }
@media (max-width: 980px) {
  .cm-layout { grid-template-columns: 1fr; gap: 10px; padding-top: 12px; }
  .cm-toc { position: static; max-height: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
  .cm-toc > summary { padding: 4px 0; font-size: .74rem; }
  .cm-toc > summary::after { content: ' ▾'; }
  .cm-toc[open] > summary { padding-bottom: 8px; }
  .cm-toc ol { columns: 2 180px; column-gap: 18px; }
  .cm-toc li { break-inside: avoid; }
}

/* ---- article typography -------------------------------------------- */
.cm-sec { scroll-margin-top: 78px; border-top: 1px solid var(--line); padding: 6px 0 24px; }
.cm-sec:first-child { border-top: 0; }
.cm-sec > h2 { font-size: clamp(1.32rem, 2.3vw, 1.7rem); letter-spacing: -.016em; line-height: 1.22; margin: 22px 0 8px; }
.cm-sec h3 { font-size: 1.08rem; letter-spacing: -.01em; margin: 24px 0 6px; }
.cm-sec h4 { font-size: .98rem; margin: 16px 0 4px; }
.cm-sec p, .cm-sec li { color: var(--ink-2); line-height: 1.66; }
.cm-sec p { margin: 0 0 12px; max-width: 80ch; }
.cm-sec ul, .cm-sec ol { margin: 0 0 12px; padding-left: 22px; max-width: 80ch; }
.cm-sec li + li { margin-top: 4px; }
.cm-sec a { color: var(--ink); text-decoration-color: var(--amber); text-underline-offset: 2px; }
.cm-sec strong { color: var(--ink); }
.cm-lead { font-size: 1.04rem; color: var(--ink) !important; }
.cm-part { margin: 34px 0 0; padding: 16px 18px; border-radius: 12px; background: var(--ink); color: #fff; scroll-margin-top: 78px; }
.cm-part .k { font-family: var(--mono); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--amber); }
.cm-part b { display: block; font-size: 1.22rem; letter-spacing: -.01em; margin-top: 2px; }
.cm-part span { display: block; color: #c9d2dc; font-size: .9rem; margin-top: 3px; }
.freq, .cm-sec code { font-family: var(--mono); font-size: .92em; white-space: nowrap; color: var(--ink); }
.cm-src { font-size: .8rem !important; color: var(--ink-3) !important; margin-top: 10px !important; line-height: 1.5 !important; }
.cm-src a { color: var(--ink-3); }

/* cards, grids and boxes */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin: 10px 0 16px; }
.cm-grid.three { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cm-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.cm-card h3, .cm-card h4 { margin: 0 0 6px; font-size: 1rem; }
.cm-card p, .cm-card li { font-size: .91rem; }
.cm-card p:last-child, .cm-card ul:last-child { margin-bottom: 0; }
.cm-card ul { padding-left: 18px; }
.cm-key { background: var(--amber-soft); border: 1px solid #f3d9a8; border-radius: 12px; padding: 14px 16px; margin: 12px 0 16px; }
.cm-key > :last-child { margin-bottom: 0; }
.cm-key h3, .cm-key h4 { margin: 0 0 6px; }
.cm-warn { background: #fff7f6; border: 1px solid #f1c9c4; border-left: 4px solid var(--alert); border-radius: 10px; padding: 12px 15px; margin: 12px 0 16px; }
.cm-warn > :last-child, .cm-law > :last-child { margin-bottom: 0; }
.cm-law { background: #f2f5fb; border: 1px solid #d3dcea; border-left: 4px solid #3d5a80; border-radius: 10px; padding: 12px 15px; margin: 12px 0 16px; }
.cm-law::before { content: 'UK law'; display: block; font-family: var(--mono); font-size: .62rem; letter-spacing: .15em; text-transform: uppercase; color: #3d5a80; margin-bottom: 4px; }

/* verdict pills */
.pill { display: inline-block; font-family: var(--mono); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; vertical-align: .12em; white-space: nowrap; }
.pill.yes { background: #e3f3ea; color: #17673a; }
.pill.maybe { background: #fff0d6; color: #8a5200; }
.pill.no { background: #fbe3e0; color: #a3261d; }
.pill.lic { background: #e6ecf5; color: #2e4a6e; }
.vd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.vd { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
a.vd:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.vd b { display: block; font-size: .97rem; margin: 6px 0 2px; }
.vd span { display: block; font-size: .84rem; color: var(--ink-3); line-height: 1.45; }
.vd span.pill { display: inline-block; font-size: .62rem; line-height: 1.3; }

/* timeline of what fails */
.cm-tl { list-style: none; padding: 0 !important; margin: 12px 0 16px; border-left: 3px solid var(--line); }
.cm-tl li { position: relative; padding: 0 0 12px 18px; margin: 0 !important; }
.cm-tl li::before { content: ''; position: absolute; left: -8px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--card); border: 3px solid var(--amber); }
.cm-tl b.t { display: block; font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--amber-d); }

/* checklists */
.cm-check { list-style: none; padding-left: 0 !important; }
.cm-check li { position: relative; padding-left: 28px; }
.cm-check li::before { content: ''; position: absolute; left: 2px; top: .3em; width: 14px; height: 14px; border: 2px solid var(--line-2); border-radius: 4px; background: var(--card); }

/* tables inside the article */
.cm-sec .tw { margin: 10px 0 14px; }
.cm-sec table.data { font-size: .87rem; }
.cm-sec table.data td, .cm-sec table.data th { padding: 8px 11px; }
.cm-sec table.data td { color: var(--ink-2); line-height: 1.5; }
.cm-sec table.data td b { color: var(--ink); }
.cm-sec table.data td.hl { background: var(--amber-soft); }
.cm-sec .tw.wide table.data { min-width: 720px; }
.cm-sec .tw.mid table.data { min-width: 560px; }

/* ---- the planners --------------------------------------------------- */
.cm-tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); padding: 22px 22px; margin: 16px 0 20px; }
.cm-tool > h3 { margin: 0 0 4px; font-size: 1.15rem; }
.cm-tool > p { font-size: .92rem; }
.cm-tool .form-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; }
#rc .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.cm-ends { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.cm-end { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--paper); }
.cm-end > b { display: block; font-size: .9rem; margin-bottom: 8px; }
.cm-end .field + .field { margin-top: 8px; }
@media (max-width: 640px) { .cm-ends { grid-template-columns: 1fr; } .cm-tool { padding: 18px 14px; } }
.cm-ex { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.cm-ex button { font: inherit; font-size: .8rem; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); cursor: pointer; }
.cm-ex button:hover { border-color: var(--amber); color: var(--ink); }
.cm-out { margin-top: 14px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); padding: 14px 16px; }
.cm-out .big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1.15; }
.cm-out .big small { font-size: .9rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.cm-out .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 10px; }
.cm-out .stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; }
.cm-out .stat .lab { display: block; }
.cm-out .stat b { font-size: 1.05rem; }
.cm-out ul { margin: 10px 0 0; padding-left: 20px; font-size: .88rem; color: var(--ink-2); }
.cm-out li + li { margin-top: 3px; }
.cm-bar { position: relative; height: 12px; border-radius: 99px; background: var(--line); margin-top: 10px; overflow: hidden; }
.cm-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--amber); border-radius: 99px; }
.cm-bar i.los { background: #3d5a80; opacity: .35; }

/* power planner rows */
.pw-list { display: grid; gap: 6px; margin-top: 12px; }
.pw-row { display: grid; grid-template-columns: minmax(0, 1fr) 74px 84px 84px 74px; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.pw-row.off { opacity: .7; background: var(--paper); grid-template-columns: 1fr !important; padding-top: 5px; padding-bottom: 5px; }
.pw-row.off .pw-cell, .pw-row.off .wh { display: none; }
.pw-row.off label.nm small { display: none; }
.pw-row label.nm { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--ink); cursor: pointer; line-height: 1.35; }
.pw-row label.nm small { display: block; color: var(--ink-3); font-size: .76rem; }
.pw-row input[type=number] { width: 100%; font: inherit; font-size: .88rem; padding: 6px 7px; border: 1.5px solid var(--line-2); border-radius: 8px; background: var(--card); color: var(--ink); }
.pw-row .wh { text-align: right; font-family: var(--mono); font-size: .86rem; color: var(--ink); }
.pw-head { display: grid; grid-template-columns: minmax(0, 1fr) 74px 84px 84px 74px; gap: 8px; padding: 0 10px; font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.pw-head span:last-child { text-align: right; }
.pw-cell { display: flex; flex-direction: column; gap: 2px; }
.pw-cell .lab { display: none; }
@media (max-width: 640px) {
  .pw-head { display: none; }
  .pw-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pw-row label.nm { grid-column: 1 / -1; }
  .pw-row .wh { grid-column: 1 / -1; text-align: left; }
  .pw-cell .lab { display: block; font-size: .56rem; }
}

/* ---- the printable frequency card ---------------------------------- */
.fc-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px; margin: 12px 0; }
.fc { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; background: var(--card); font-size: .8rem; }
.fc h4 { margin: 0 0 6px; font-size: .9rem; display: flex; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--amber); padding-bottom: 4px; }
.fc table { width: 100%; border-collapse: collapse; }
.fc td { padding: 2px 4px 2px 0; vertical-align: top; color: var(--ink-2); line-height: 1.35; }
.fc td:first-child { color: var(--ink); font-weight: 600; }
.fc td.f { font-family: var(--mono); color: var(--ink); text-align: right; }
.fc .blank { display: inline-block; width: 92px; border-bottom: 1px solid var(--ink-3); height: .95em; vertical-align: -2px; }
.fc .blank.sm { width: 30px; }

/* ---- print ---------------------------------------------------------- */
@media print {
  .cm-layout { display: block; padding: 0; }
  .cm-toc, .cm-tool .cm-ex, .no-print { display: none !important; }
  .cm-sec { break-inside: auto; padding-bottom: 8px; }
  .cm-sec > h2 { break-after: avoid; margin-top: 10px; }
  .cm-sec p, .cm-sec li { font-size: 10pt; line-height: 1.45; }
  .cm-card, .cm-key, .cm-warn, .cm-law, .vd, .fc, .cm-out, tr { break-inside: avoid; }
  .cm-part { background: #fff; color: #000; border: .4mm solid #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cm-part span { color: #333; }
  .cm-tool { box-shadow: none; border: .3mm solid #999; }
  .cm-sec .tw.wide table.data, .cm-sec .tw.mid table.data { min-width: 0; }
  .pill, .cm-key, .cm-warn, .cm-law { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.print-card > *:not(#fc-print) { display: none !important; }
  body.print-card #fc-print { display: block !important; }
  #fc-print .fc-wrap { grid-template-columns: 1fr 1fr; gap: 4mm; }
  #fc-print .fc { font-size: 7.4pt; padding: 2.5mm 3mm; border: .3mm dashed #777; border-radius: 2mm; }
  #fc-print .fc h4 { font-size: 8.6pt; }
}
#fc-print { display: none; }
