/* =====================================================================
   Survival Master Guide — shared styles for the tool pages (inc/tool.php).
   Built on the tokens in site.css. No external libraries.
   ===================================================================== */

/* ---- page frame ---------------------------------------------------- */
.calc-head { padding: 58px 0 4px; }
.calc-head .section-head { margin-bottom: 0; max-width: 820px; }
.tool-from { margin: 14px 0 0; font-size: .9rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.tool-from span { font-family: var(--mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; }
.tool-from a { color: var(--ink); font-weight: 650; text-decoration: none; border-bottom: 1.5px solid var(--amber); }
.tool-from a:hover { color: var(--amber-d); }

.calc { padding: 30px 0; }
.calc + .calc { padding-top: 6px; }
.calc-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-1); padding: 28px 28px;
}
.calc-card + .calc-card { margin-top: 18px; }
.calc-card > h2, .calc-card > header h2 { margin: 0 0 6px; font-size: clamp(1.2rem, 2.1vw, 1.5rem); letter-spacing: -.015em; line-height: 1.25; }
.calc-card h3 { margin: 22px 0 8px; font-size: 1.05rem; letter-spacing: -.01em; }
.calc-lead { margin: 0 0 20px; color: var(--ink-2); font-size: .97rem; max-width: 74ch; }
.calc-card p { max-width: 78ch; }
.calc-note { font-size: .86rem; color: var(--ink-3); margin: 14px 0 0; max-width: 80ch; }
.calc-card a { color: var(--ink); text-decoration-color: var(--amber); text-underline-offset: 2px; }

/* two-column layout: inputs | results */
.tool-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 26px; align-items: start; }
.tool-split > .sticky { position: sticky; top: 84px; }
@media (max-width: 900px) { .tool-split { grid-template-columns: 1fr; } .tool-split > .sticky { position: static; } }

/* ---- form controls ------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px 18px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .form-grid.cols-2 { grid-template-columns: 1fr; } }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label, .lab {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3);
}
.field-hint { font-size: .8rem; color: var(--ink-3); line-height: 1.4; }
.ctl {
  font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; line-height: 1.25; width: 100%; min-width: 0;
}
textarea.ctl { resize: vertical; min-height: 64px; line-height: 1.45; }
select.ctl { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2366727e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px;
}
.ctl:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(224,138,0,.18); }
.ctl[aria-invalid="true"] { border-color: var(--alert); }
.with-unit { display: flex; align-items: stretch; }
.with-unit .ctl { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.with-unit .unit { display: inline-flex; align-items: center; padding: 0 11px; border: 1.5px solid var(--line-2); border-left: 0;
  border-radius: 0 10px 10px 0; background: var(--paper); color: var(--ink-2); font-size: .88rem; white-space: nowrap; }
.with-unit select.unit { cursor: pointer; font-family: var(--sans); appearance: none; padding-right: 11px; }

/* number with − / + buttons */
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--card); }
.stepper:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(224,138,0,.18); }
.stepper button { flex: none; width: 42px; border: 0; background: var(--paper); color: var(--ink); font-size: 1.25rem; font-weight: 700; cursor: pointer; line-height: 1; }
.stepper button:hover { background: var(--paper-2); }
.stepper input { flex: 1; min-width: 0; width: 100%; border: 0; text-align: center; font: 700 1.05rem var(--mono); color: var(--ink); padding: 10px 4px; background: transparent; -moz-appearance: textfield; }
.stepper input:focus { outline: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* segmented radio buttons */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-block; padding: 8px 13px; border: 1.5px solid var(--line-2); border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--ink-2); background: var(--card); line-height: 1.2; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(224,138,0,.4); }

.check { display: flex; gap: 9px; align-items: flex-start; font-size: .93rem; color: var(--ink-2); cursor: pointer; line-height: 1.4; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); flex: none; }
.checks { display: grid; gap: 9px; }
.checks.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; }
@media (max-width: 560px) { .checks.cols-2 { grid-template-columns: 1fr; } }

fieldset.group { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; margin: 0 0 16px; min-width: 0; }
fieldset.group legend { padding: 0 6px; font-weight: 700; font-size: .95rem; }

/* ---- buttons row --------------------------------------------------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.actions .spacer { flex: 1; }
.btn-danger { --bg: transparent; --fg: var(--alert); --bd: rgba(198,47,36,.4); }
.btn-danger:hover { --bd: var(--alert); background: rgba(198,47,36,.05); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---- results ------------------------------------------------------- */
.res-hero { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.res-hero .big { display: block; font: 800 clamp(1.9rem, 4.4vw, 2.6rem)/1.1 var(--mono); color: var(--ink); margin: 6px 0 4px; letter-spacing: -.02em; }
.res-hero .big small { font-size: .45em; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.res-hero p { margin: 4px 0 0; color: var(--ink-2); font-size: .93rem; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.res-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.res-card b { display: block; font: 800 1.3rem/1.15 var(--mono); color: var(--ink); margin-top: 3px; }
.res-card b small { font-size: .62em; font-weight: 600; color: var(--ink-2); }
.res-card span:not(.lab) { display: block; font-size: .82rem; color: var(--ink-3); margin-top: 3px; line-height: 1.35; }

/* traffic-light bands */
.band { --c: var(--ink-3); --bg: var(--paper); border-left: 5px solid var(--c); background: var(--bg); border-radius: 12px; padding: 16px 18px; }
.band h3 { margin: 0 0 4px; color: var(--c); font-size: 1.15rem; }
.band p, .band li { color: var(--ink); font-size: .94rem; }
.band p { margin: 6px 0 0; }
.band ul { margin: 6px 0 0; padding-left: 20px; }
.band-green { --c: #1f8a4c; --bg: #eaf6ef; }
.band-amber { --c: #a35f00; --bg: #fff4e0; }
.band-red   { --c: #c62f24; --bg: #fdecea; }
.band-black { --c: #7a1410; --bg: #f9dcd8; }
.band-grey  { --c: var(--ink-3); --bg: var(--paper); }
.dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: currentColor; vertical-align: .02em; }

/* messages */
.callout { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 10px; padding: 14px 16px; margin-top: 18px; }
.callout.warn { border-left-color: var(--alert); background: #fff7f6; }
.callout.ok { border-left-color: var(--safe); }
.callout h3, .callout h4 { margin: 0 0 6px; font-size: 1rem; }
.callout p { margin: 0; color: var(--ink-2); font-size: .92rem; line-height: 1.6; }
.callout p + p { margin-top: 6px; }
.callout ul { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); font-size: .92rem; }
.callout li + li { margin-top: 3px; }

/* tables */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0 0; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); background: var(--paper); font-weight: 600; white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.n, table.data th.n { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.data tr.hl td { background: var(--amber-soft); }

.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.print-only { display: none; }

/* related tools strip at the bottom of each tool */
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.related a { display: block; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-decoration: none; color: var(--ink); }
.related a:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.related b { display: block; font-size: .95rem; }
.related span { display: block; font-size: .83rem; color: var(--ink-3); margin-top: 2px; line-height: 1.4; }

@media (max-width: 560px) {
  .calc-head { padding-top: 40px; }
  .calc-card { padding: 20px 16px; }
  .calc { padding: 20px 0; }
}

/* ---- print --------------------------------------------------------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .nav, .foot, .no-print, .tool-from, .actions, .related, .calc-head .eyebrow { display: none !important; }
  .print-only { display: block; }
  .calc-head { padding: 0; }
  .calc { padding: 8px 0; }
  .calc-card { box-shadow: none; border: 0; padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .tool-split { display: block; }
  .tw { overflow: visible; border: 0; }
  table.data th, table.data td { padding: 4px 6px; }
  a { text-decoration: none; }
  .band, .callout, .res-hero, .res-card { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
