/* Shell for the calculator tools: /tools/*.
 *
 * Loaded after each page's own <style>, so it overrides at equal specificity.
 * It does not touch the JS: every tool keeps its own element ids and result
 * template. What it standardises is the frame around them — title block, input
 * card, result hierarchy, next step — so 21 separately built tools stop reading
 * like 21 different products.
 */

:root {
  --shell-ink: #1A1614;
  --shell-ink2: #4A403C;
  --shell-mute: #5B534C;
  --shell-line: #E7DFD5;
  --shell-red: #A3132B;
  --shell-bg: #FBF7F0;
}

/* ---------- page frame ---------- */

.tool-shell .container,
body > .container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.tool-shell header,
body > .container > header {
  text-align: left;
  margin: 0 0 28px;
  max-width: 720px;
}

.tool-shell header h1,
body > .container > header h1 {
  font-family: 'Archivo', 'Inter', system-ui, sans-serif;
  font-size: clamp(2.05rem, 4.4vw, 2.9rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.022em;
  margin: 0 0 10px;
}

.tool-shell header p,
body > .container > header p {
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--shell-mute);
  margin: 0;
  max-width: 62ch;
}

/* eyebrow / badge above the h1 */
.tool-shell .badge,
.tool-shell .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--shell-red);
  background: #F7E8EB;
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 14px;
}

/* tools whose hero is a <div class="header"> rather than a <header> element */
.tool-shell .header,
.tool-shell .hero {
  text-align: left;
  max-width: 720px;
  margin: 0 0 28px;
}

/* tools whose hero is not a <header> element */
.tool-shell h1 {
  font-family: 'Archivo', 'Inter', system-ui, sans-serif;
  /* some tools fade the last word of the h1 into white via a gradient; on the
     ivory page that word disappears, so the shell uses a solid ink headline */
  background: none !important;
  background-clip: border-box !important;
  -webkit-background-clip: border-box !important;
  -webkit-text-fill-color: currentColor !important;
  color: var(--shell-ink);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.022em;
  margin: 0 0 10px;
}

.tool-shell h1 em {
  font-style: normal;
  color: var(--shell-red);
}

.tool-shell .wrap { text-align: left; }
.tool-shell .wrap p { margin-left: 0; margin-right: auto; }

.tool-shell .auditor-header {
  text-align: left;
  max-width: 720px;
  margin: 0 0 28px;
}

.tool-shell .auditor-header p {
  color: var(--shell-mute);
  font-size: 1.05rem;
  max-width: 62ch;
  margin: 0;
}

/* dark input panels inside light tool pages */
.tool-shell .input-section p { color: rgba(245, 241, 234, 0.76) !important; }

/* an empty results column must not hold half the card open */
.tool-shell .auditor-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------- two-column working area ---------- */

.tool-shell .layout,
body > .container > .layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .tool-shell .layout,
  body > .container > .layout { grid-template-columns: 1fr; gap: 20px; }
}

/* ---------- input card ---------- */

.tool-shell .controls,
body > .container > .controls {
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  padding: 22px;
  box-shadow: none;
}

@media (min-width: 901px) {
  .tool-shell .controls,
  body > .container > .controls { position: sticky; top: 84px; }
}

.tool-shell .controls h2,
.tool-shell .controls h3 {
  font-family: 'Archivo', 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--shell-mute);
  margin: 0 0 16px;
}

.tool-shell .field,
.tool-shell .input-group { margin-bottom: 16px; }
.tool-shell .field:last-child,
.tool-shell .input-group:last-child { margin-bottom: 0; }

.tool-shell .field label,
.tool-shell .input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--shell-ink2);
  margin-bottom: 6px;
  letter-spacing: 0;
  text-transform: none;
}

.tool-shell select {
  padding-right: 34px;
  text-overflow: ellipsis;
}

.tool-shell .field input,
.tool-shell .field select,
.tool-shell .input-group input,
.tool-shell .input-group select {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: 8px;
}

/* ---------- result hierarchy ---------- */

.tool-shell .results { min-width: 0; }

.tool-shell .result-card {
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  padding: 22px;
  margin: 0 0 12px;
}

.tool-shell .result-card.big { border-left: 3px solid var(--shell-red); }

.tool-shell .rc-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--shell-mute);
  margin: 0 0 8px;
}

.tool-shell .rc-value {
  font-family: 'Archivo', 'Inter', system-ui, sans-serif;
  font-size: clamp(2.6rem, 6vw, 3.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--shell-red);
  font-variant-numeric: tabular-nums;
}

.tool-shell .rc-sub {
  font-size: 0.875rem;
  color: var(--shell-mute);
  margin-top: 10px;
}

/* a breakdown that is not inside a result card carries its own card */
.tool-shell .results > .breakdown {
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  padding: 18px 22px;
  margin: 0 0 12px;
}

/* only the stat-strip variant (the one with .bd-item children) becomes a grid;
   other tools reuse the .breakdown class for a label/value list */
.tool-shell .breakdown:has(.bd-item) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0;
  margin: 0;
}

/* label/value rows (valuation, margin tools) */
.tool-shell .break-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--shell-line);
  font-size: 0.9rem;
  color: var(--shell-ink2);
}
.tool-shell .breakdown > h4 + .break-row { border-top: 0; padding-top: 0; }
.tool-shell .breakdown h4 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--shell-mute);
  margin: 0 0 6px;
}
.tool-shell .break-val { font-weight: 600; color: var(--shell-ink); white-space: nowrap; }

.tool-shell .bd-item {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--shell-line);
  border-radius: 0;
  text-align: left;
  padding: 2px 16px;
}

.tool-shell .bd-item:first-child { border-left: 0; padding-left: 0; }

.tool-shell .bd-val {
  font-family: 'Archivo', 'Inter', system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--shell-ink);
  font-variant-numeric: tabular-nums;
}

.tool-shell .bd-label {
  font-size: 0.72rem;
  color: var(--shell-mute);
  margin-top: 3px;
  line-height: 1.3;
}


/* ---------- quiz / option buttons ---------- */

.tool-shell .q {
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 0 0 12px;
}

.tool-shell .q h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--shell-ink);
}

.tool-shell .opt {
  background: #FFFFFF;
  border: 1px solid #C9C1B8;
  color: var(--shell-ink2);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 40px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.tool-shell .opt:hover { border-color: var(--shell-red); }

.tool-shell .opt.sel {
  background: #F7E8EB;
  border-color: var(--shell-red);
  color: var(--shell-red);
  font-weight: 600;
}


/* the shared header carries its own tokens: tool pages do not define them */
.tool-shell .nav {
  --ink: #1A1614;
  --ink2: #3D3733;
  --line: #E7DFD5;
  --c2: #A3132B;
}

/* the site header keeps its own colours on tools with a themed page palette */
.tool-shell .nav .logo,
.tool-shell .nav .nav-links a,
.tool-shell .nav .hamburger { color: #1A1614 !important; }

.tool-shell .nav .logo img { display: block; }

/* ---------- dark tools ---------- */

body.tool-shell.tool-dark {
  --shell-ink: #F7F3EC;
  --shell-ink2: #E6DED4;
  --shell-mute: #BCB2A7;
  --shell-line: rgba(255, 255, 255, 0.16);
  --shell-red: #F2B21A;
}

body.tool-shell.tool-dark h1,
body.tool-shell.tool-dark h2,
body.tool-shell.tool-dark h3 { color: var(--shell-ink); }

body.tool-shell.tool-dark .next-step {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--shell-line);
}

body.tool-shell.tool-dark .next-step p { color: var(--shell-mute); }

body.tool-shell.tool-dark .next-step a {
  background: var(--shell-red);
  color: #1A1614;
}

/* ---------- data tables ---------- */

.tool-shell table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  overflow: hidden;
}

.tool-shell thead th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--shell-mute);
  background: #FAF7F2;
  padding: 10px 14px;
  border-bottom: 1px solid var(--shell-line);
  white-space: nowrap;
}

.tool-shell tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #EFE8DF;
  color: var(--shell-ink2);
  vertical-align: top;
}

.tool-shell tbody tr:last-child td { border-bottom: 0; }
.tool-shell tbody tr:hover td { background: #FBF7F0; }

.tool-shell .table-wrap { overflow-x: auto; }

body.tool-shell.tool-dark table { background: rgba(255, 255, 255, 0.04); }
body.tool-shell.tool-dark thead th { background: rgba(255, 255, 255, 0.06); color: var(--shell-mute); }
body.tool-shell.tool-dark tbody td { border-bottom-color: rgba(255, 255, 255, 0.1); color: var(--shell-ink2); }
body.tool-shell.tool-dark tbody tr:hover td { background: rgba(255, 255, 255, 0.05); }

/* ---------- next step ---------- */

.tool-shell .next-step {
  margin-top: 16px;
  padding: 16px 18px;
  background: #FFFFFF;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tool-shell .next-step p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--shell-mute);
  flex: 1 1 240px;
}

.tool-shell .next-step a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--shell-red);
  text-decoration: none;
  padding: 10px 16px;
  border: 1px solid currentColor;
  border-radius: 999px;
  white-space: nowrap;
}

.tool-shell .next-step a:hover { background: #F7E8EB; }

/* the pill is nowrap by design, but several CTAs are longer than a 390px
   viewport and were clipped at the right edge */
@media (max-width: 640px) {
  .tool-shell .next-step {
    flex-direction: column;
    align-items: stretch;
  }
  .tool-shell .next-step a {
    white-space: normal;
    justify-content: space-between;
  }
}

/* 8 nav links need more room than the 2-link city nav this CSS came from;
   between 769 and 900px they ran past the right edge instead of collapsing */
@media (max-width: 900px) {
  body.tool-shell .nav .hamburger { display: block; }
  body.tool-shell .nav .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-bottom: 1px solid var(--shell-line);
    flex-direction: column;
    padding: 16px;
    gap: 4px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  }
  body.tool-shell .nav .nav-links.open { display: flex; }
  body.tool-shell .nav .nav-links a { width: 100%; padding: 12px 16px; }
}

/* ---------- footer ---------- */

.tool-shell footer,
body > .container ~ footer {
  text-align: center;
  padding: 36px 20px 48px;
  border-top: 1px solid var(--shell-line);
  color: var(--shell-mute);
  font-size: 0.85rem;
  margin-top: 48px;
}

@media (max-width: 600px) {
  /* pair the numeric fields so the answer is not a full screen away */
  .tool-shell .controls,
  body > .container > .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
    padding: 18px;
  }
  .tool-shell .field,
  .tool-shell .input-group,
  .tool-shell .field:last-child,
  .tool-shell .input-group:last-child { margin-bottom: 0; }
  .tool-shell .controls h2,
  .tool-shell .controls h3 { grid-column: 1 / -1; margin-bottom: 4px; }

  /* label/value rows (valuation, margin tools) */
.tool-shell .break-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--shell-line);
  font-size: 0.9rem;
  color: var(--shell-ink2);
}
.tool-shell .breakdown > h4 + .break-row { border-top: 0; padding-top: 0; }
.tool-shell .breakdown h4 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--shell-mute);
  margin: 0 0 6px;
}
.tool-shell .break-val { font-weight: 600; color: var(--shell-ink); white-space: nowrap; }

.tool-shell .bd-item { border-left: 0; padding: 10px 0; border-top: 1px solid var(--shell-line); }
  .tool-shell .bd-item:first-child { padding-top: 0; border-top: 0; }
  .tool-shell .next-step { flex-direction: column; align-items: flex-start; }
}
