/*
 * Build Calc Guy - public_html/assets/css/main.css
 * Mobile first. Colors and type follow the brand manual (Manual de marca 2.0):
 * deep blue and white dominate, orange only for actions and highlights.
 * Contrast checked for WCAG 2.2 AA: body text 4.5:1 or better, controls 3:1 or better.
 * Orange and amber always carry deep-blue text, never white.
 */

/* ---------- Fonts (served from this site) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* brand palette */
  --ink: #021D37;            /* azul profundo: text, selected controls */
  --orange: #F97F0D;         /* actions, emphasis */
  --orange-dark: #E06F00;
  --amber: #FDB23D;          /* details, highlights */
  --steel: #37729C;          /* azul acero: links, icons, drawing lines */
  --sky: #A2D2E6;            /* celeste */
  --line: #D1DCE3;           /* gris claro: borders */

  /* derived from the palette */
  --bg: #F6F8FA;
  --white: #FFFFFF;
  --sky-tint: #EAF3F8;
  --amber-tint: #FFF3DC;
  --amber-text: #7A4A00;
  --line-strong: #7B8FA0;    /* control borders, 3:1 on white */
  --muted: #4A5B6C;

  /* code check states only */
  --green: #1E7E34;
  --green-tint: #E6F4E9;
  --red: #C62828;
  --red-tint: #FCEAEA;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --tap: 48px;
  --gap: 16px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 2.5rem; }
p { margin: 0; }
a { color: var(--steel); }
a:hover { color: var(--ink); }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

.nowrap { white-space: nowrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 var(--gap); }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--white); font-weight: 600;
}
.skip-link:focus { top: 8px; color: var(--white); }

/* ---------- Site header ---------- */
.site-header { background: var(--white); border-top: 6px solid var(--orange); border-bottom: 1px solid var(--line); }
.site-header__inner { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; padding-bottom: 0; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; align-self: flex-start; }
.brand:hover { color: var(--ink); }
.brand__mark { width: 64px; height: 64px; flex: none; }
.brand__name { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; letter-spacing: -0.01em; white-space: nowrap; color: var(--ink); }
.brand__accent { color: var(--orange); }

.site-nav { margin: 0 calc(var(--gap) * -1); }
.site-nav__list { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0 var(--gap); }
.site-nav__link {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 12px;
  color: var(--ink); font-weight: 600; font-size: 0.95rem; text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.site-nav__link:hover { border-bottom-color: var(--line-strong); color: var(--ink); }
.site-nav__link[aria-current="page"], .site-nav__link.is-current { border-bottom-color: var(--orange); }

/* menu groups: <details> dropdowns (nav.js keeps only one open) */
.site-nav__group { position: relative; }
.site-nav__summary { cursor: pointer; list-style: none; gap: 6px; }
.site-nav__summary::-webkit-details-marker { display: none; }
.site-nav__summary::after {
  content: ""; width: 7px; height: 7px; margin-top: -4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.site-nav__details[open] > .site-nav__summary::after { margin-top: 4px; transform: rotate(-135deg); }
.site-nav__summary:focus-visible { outline: 3px solid var(--steel); outline-offset: -3px; }
.site-nav__menu {
  position: absolute; top: 100%; left: 0; z-index: 30;
  min-width: 250px; margin: 0; padding: 6px; list-style: none;
  background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--orange);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); box-shadow: 0 10px 28px rgba(2, 29, 55, 0.18);
}
.site-nav__item {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 12px;
  color: var(--ink); font-weight: 600; text-decoration: none; border-radius: var(--radius-sm);
}
.site-nav__item:hover { background: var(--sky-tint); color: var(--ink); }
.site-nav__item[aria-current="page"] { box-shadow: inset 4px 0 0 var(--orange); }

/* ---------- Site footer ---------- */
.site-footer { margin-top: 56px; background: var(--ink); color: var(--white); }
.site-footer__inner { display: grid; gap: 16px; padding-top: 32px; padding-bottom: 32px; }
.site-footer .brand__name { color: var(--white); }
.site-footer__brand p { color: var(--line); margin-top: 4px; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; margin: 0; padding: 0; }
.site-footer__links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--white); font-weight: 600; }
.site-footer__links a:hover { color: var(--amber); }
.site-footer__button { min-height: 44px; padding: 0; border: 0; background: none; color: var(--white); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.site-footer__button:hover { color: var(--amber); }
.site-footer__legal { color: var(--line); font-size: 0.875rem; max-width: 75ch; }
.site-footer__meta { grid-column: 1 / -1; border-top: 1px solid rgba(255, 255, 255, 0.18); padding-top: 8px; }
.site-footer__links--small a { font-weight: 500; font-size: 0.9rem; color: var(--line); }
.site-footer__links--small a[aria-current="page"] { color: var(--white); }
.legal-date { margin-top: 8px; font-size: 0.9rem; color: var(--muted); }
.page-head + .prose { margin-top: 8px; }

/* ---------- Page head ---------- */
.page-head { padding: 28px 0 20px; }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 62ch; font-size: 1.0625rem; }

/* ---------- Home ---------- */
.home-hero { display: grid; gap: 20px; align-items: center; padding: 36px 0 28px; }
.home-hero p { color: var(--muted); margin-top: 12px; max-width: 58ch; font-size: 1.125rem; }
.home-hero__accent { color: var(--orange-dark); display: block; }
.home-hero__mark { width: 140px; height: 140px; }
.home-title { font-size: 1.75rem; margin-bottom: 14px; }
.home-points { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; margin: 16px 0 0; padding: 0; font-weight: 600; font-size: 0.95rem; }
.home-points li { display: flex; align-items: center; gap: 8px; }
.home-points li::before {
  content: "\2713"; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--amber); color: var(--ink); font-size: 0.8rem; font-weight: 800; line-height: 1;
}
.home-group { font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); margin: 24px 0 8px; }
.home-title + .home-group { margin-top: 0; }

.cards { display: grid; gap: 14px; list-style: none; margin: 0; padding: 0; }
.card {
  display: grid; grid-template-rows: auto 1fr auto; gap: 8px; height: 100%; padding: 20px;
  background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--ink); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.card:hover { border-color: var(--ink); color: var(--ink); }
.card__title { font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; }
.card__text { color: var(--muted); }
.card__go {
  display: inline-flex; align-items: center; justify-self: start; align-self: end;
  min-height: var(--tap); margin-top: 6px; padding: 0 16px; border-radius: var(--radius-sm);
  background: var(--orange); color: var(--ink); font-weight: 700;
}
.card:hover .card__go { background: var(--orange-dark); }

/* ---------- Calculator layout ---------- */
.calc { display: grid; gap: 24px; }

.calc__inputs {
  display: grid;
  gap: 20px;
  align-content: start;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--ink);
  border-radius: var(--radius);
  padding: 20px var(--gap);
}

.calc__results { min-width: 0; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field--nested { margin-top: 12px; }

.field__label { font-weight: 600; font-size: 0.95rem; padding: 0; }
.field--hero .field__label { font-family: var(--font-display); font-size: 1.375rem; font-weight: 800; letter-spacing: -0.01em; }

.field__hint { color: var(--muted); font-size: 0.875rem; }

.field__control { position: relative; display: flex; }

.field__input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 52px 10px 14px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 1.125rem;      /* 16px+ stops iOS from zooming on focus */
  font-weight: 500;
}
.field--hero .field__input { min-height: 60px; font-size: 1.5rem; font-weight: 600; }
.field__input:focus { border-color: var(--ink); outline: 3px solid var(--sky); outline-offset: 0; }
.field__input[aria-invalid="true"] { border-color: var(--red); }

.field__unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.95rem; pointer-events: none;
}

.field__error { color: var(--red); font-size: 0.9rem; font-weight: 500; }
.field__error:empty { display: none; }
.field__error::before { content: "\2715  "; }

/* ---------- Choices ---------- */
.choice { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 6px; }
.choice > legend { margin-bottom: 6px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; }
.segmented__item { position: relative; display: block; }
.segmented__item input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented__item span {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  padding: 8px 6px;
  border: 2px solid var(--line-strong);
  margin-left: -2px;
  background: var(--white);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}
.segmented__item:first-child span { margin-left: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segmented__item:last-child span { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.segmented__item input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--white); position: relative; z-index: 1; }
.segmented__item input:focus-visible + span { outline: 3px solid var(--steel); outline-offset: 2px; z-index: 2; position: relative; }

.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--ink); flex: none; }

/* ---------- More options ---------- */
.more { border-top: 1px solid var(--line); }
.more__summary {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--tap);
  cursor: pointer;
  font-weight: 600;
  color: var(--steel);
  list-style: none;
}
.more__summary::-webkit-details-marker { display: none; }
.more__summary::after { content: "+"; font-size: 1.5rem; font-weight: 400; line-height: 1; }
.more[open] .more__summary::after { content: "\2212"; }
.more__body { display: grid; gap: 20px; padding: 8px 0 4px; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 10px 18px;
  border: 2px solid var(--orange);
  border-radius: var(--radius-sm);
  background: var(--orange);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn--quiet { background: var(--white); color: var(--ink); border-color: var(--line-strong); font-weight: 600; }
.btn--quiet:hover { background: var(--sky-tint); border-color: var(--ink); }

.link { padding: 0; border: 0; background: none; color: var(--steel); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 24px; }

/* ---------- Results: empty ---------- */
.results-empty {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  color: var(--muted);
  background-image:
    linear-gradient(var(--sky-tint) 1px, transparent 1px),
    linear-gradient(90deg, var(--sky-tint) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--white);
}
.results-empty__title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--ink); margin-bottom: 6px; }

/* ---------- Results: hero ---------- */
.hero {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 8px solid var(--orange);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
}
.hero__main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-family: var(--font-display); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; margin-top: 12px; }
.hero__count { font-size: 2.25rem; }
.hero__at { font-size: 1.25rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.hero__value {
  font-size: 2.25rem;
  white-space: nowrap;
  background: linear-gradient(transparent 62%, var(--amber) 62%, var(--amber) 92%, transparent 92%);
  padding: 0 4px;
}
.hero__sub { font-size: 1.125rem; font-weight: 500; margin-top: 10px; }
.hero__note { font-size: 0.9rem; color: var(--muted); margin-top: 8px; }
.hero__note--warn { color: var(--amber-text); font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  font-size: 0.9rem; font-weight: 600;
}
.badge__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  color: var(--white); font-size: 0.8rem; line-height: 1;
}
.badge--pass { background: var(--green-tint); color: var(--green); }
.badge--pass .badge__icon { background: var(--green); }
.badge--fail { background: var(--red-tint); color: var(--red); }
.badge--fail .badge__icon { background: var(--red); }
.badge--info { background: var(--sky-tint); color: var(--ink); }
.badge--info .badge__icon { background: var(--steel); font-size: 0.7rem; }

/* ---------- Results: diagram (drawn by stair-diagram.js) ---------- */
.diagram { margin: 16px 0 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.diagram svg { display: block; width: 100%; height: auto; }
.diagram__caption { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }

.dg-grid { fill: none; stroke: var(--sky-tint); stroke-width: 1; }
.dg-ground { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.dg-deck { fill: #EEF2F5; stroke: var(--ink); stroke-width: 1; }
.dg-deck--surface { fill: var(--line); }
.dg-stringer { fill: var(--sky-tint); stroke: var(--steel); stroke-width: 1.5; stroke-linejoin: round; }
.dg-tread { fill: var(--white); stroke: var(--steel); stroke-width: 1.25; }
.dg-riser { fill: var(--white); stroke: var(--steel); stroke-width: 1; }
.dg-dim { fill: none; stroke: var(--ink); stroke-width: 1; }
.dg-dim--ext { stroke: var(--line-strong); }
.dg-dim--tick { stroke-width: 1.5; }
.dg-hl-under { stroke: var(--amber); stroke-width: 7; stroke-linecap: round; }
.dg-hl { stroke: var(--ink); stroke-width: 1.75; stroke-linecap: round; }
.dg-dot { fill: var(--ink); }
.dg-text {
  font-family: var(--font-body); font-size: 12px; fill: var(--ink);
  paint-order: stroke; stroke: var(--white); stroke-width: 3px; stroke-linejoin: round;
}
.dg-text__word { font-weight: 500; fill: var(--muted); }
.dg-text__value { font-weight: 700; }

/* guide diagrams (includes/diagrams/*.php) share the dg-* classes above */
.dg-label { font-family: var(--font-body); font-size: 13px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--white); stroke-width: 3px; stroke-linejoin: round; }
.dg-label--quiet { font-weight: 500; fill: var(--muted); }
.dg-label--wrong { fill: var(--red); }
.dg-ghost { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 3; }
.dg-dash { fill: none; stroke: var(--steel); stroke-width: 1.25; stroke-dasharray: 6 4; }
.dg-board { fill: var(--sky-tint); stroke: var(--steel); stroke-width: 1.5; }
.dg-waste { fill: var(--amber-tint); stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.dg-square { fill: #E3E9EE; fill-opacity: 0.9; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.dg-gauge { fill: var(--amber); stroke: var(--ink); stroke-width: 1.5; }
.dg-rail { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.dg-post { stroke: var(--ink); stroke-width: 1.5; }
.dg-concrete { fill: var(--line); stroke: var(--ink); stroke-width: 1; }
.dg-earth { fill: #EEF2F5; stroke: none; }
.dg-level { fill: var(--amber); stroke: var(--ink); stroke-width: 1; }
.dg-wrong { stroke: var(--red); stroke-width: 2; stroke-dasharray: 5 4; }

/* ---------- Print buttons ---------- */
.print-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.print-actions .btn { flex: 1 1 180px; }
.print-actions__note { flex: 1 1 100%; font-size: 0.875rem; color: var(--muted); }

/* ---------- Feedback prompt ---------- */
.fb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 16px; padding: 10px 14px; background: var(--sky-tint); border-radius: var(--radius-sm); }
.fb__question { font-weight: 600; }
.fb__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.fb__button { min-width: 72px; min-height: 44px; padding: 6px 14px; }
.fb .link { min-height: 44px; }
.fb--done { font-weight: 600; color: var(--green); background: var(--green-tint); }

/* ---------- Feedback dialog ---------- */
.fbd { width: calc(100% - 24px); max-width: 440px; max-height: calc(100% - 24px); padding: 0; border: 0; border-radius: var(--radius); background: var(--white); color: var(--ink); box-shadow: 0 12px 40px rgba(2, 29, 55, 0.35); }
.fbd::backdrop { background: rgba(2, 29, 55, 0.6); }
.fbd__form, .fbd__done { display: grid; gap: 16px; padding: 20px; border-top: 6px solid var(--orange); }
.fbd__title { font-size: 1.375rem; }
.fbd__optional { font-weight: 400; color: var(--muted); }
.fbd__textarea { padding: 10px 14px; min-height: 104px; resize: vertical; font-size: 1rem; line-height: 1.45; }
.fbd__email { padding-right: 14px; font-size: 1rem; }
.fbd__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fbd__note { font-size: 0.85rem; color: var(--muted); }
.fbd__status { font-size: 0.9rem; font-weight: 600; min-height: 1.3em; }
.fbd__status:empty { display: none; }
.fbd__status--error { color: var(--red); }
.fbd__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fbd__actions .btn { flex: 1 1 140px; }
.fbd .btn[disabled] { opacity: 0.6; cursor: default; }

/* ---------- Results: key numbers ---------- */
.keys { display: grid; grid-template-columns: 1fr; gap: 0; margin: 16px 0 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.keys__item { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-width: 0; }
.keys__item:first-child { border-top: 0; }
.keys__label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); }
.keys__value { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; line-height: 1.1; text-align: right; white-space: nowrap; }
.keys__sub { display: block; font-family: var(--font-body); font-weight: 500; font-size: 0.8rem; color: var(--muted); margin-top: 4px; line-height: 1.3; white-space: normal; }

/* roof pitch: rafter length makes a fourth key number */
@media (min-width: 640px) {
  .keys.keys--four { grid-template-columns: repeat(2, 1fr); }
  .keys--four .keys__item:nth-child(odd) { border-left: 0; }
  .keys--four .keys__item:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Roof pitch: input modes ---------- */
.mode-panel { display: grid; gap: 20px; }
.mode-panel[hidden] { display: none; }
.segmented--wrap { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.segmented--wrap .segmented__item span { margin: -1px 0 0 -2px; border-radius: 0; }
.segmented--wrap .segmented__item:nth-child(odd) span { margin-left: 0; }
.segmented--wrap .segmented__item:nth-child(1) span { border-radius: var(--radius-sm) 0 0 0; }
.segmented--wrap .segmented__item:nth-child(2) span { border-radius: 0 var(--radius-sm) 0 0; }
.segmented--wrap .segmented__item:nth-child(3) span { border-radius: 0 0 0 var(--radius-sm); }
.segmented--wrap .segmented__item:nth-child(4) span { border-radius: 0 0 var(--radius-sm) 0; }

/* roof pitch chart guide */
.dg-zone { stroke: none; }
.dg-zone--flat { fill: var(--line); fill-opacity: 0.55; }
.dg-zone--low { fill: var(--amber-tint); }
.dg-zone--edge { stroke: var(--amber); stroke-width: 1; }
.chart-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.chart-actions__note { margin: 0 !important; font-size: 0.9rem; color: var(--muted); }
.data-table--chart { font-variant-numeric: tabular-nums; }
.data-table--chart tbody th { font-weight: 800; white-space: nowrap; text-align: left; }
.data-table--chart td { white-space: nowrap; }
.data-table--chart tr.is-major th { box-shadow: inset 4px 0 0 var(--orange); }
/* keep the pitch column in view while the chart scrolls sideways on phones */
.data-table--chart thead th:first-child, .data-table--chart tbody th { position: sticky; left: 0; z-index: 1; }
.data-table--chart tbody th { background: var(--white); }
.data-table--chart tbody tr:nth-child(even) th { background: var(--bg); }

/* rafter calculator */
.diagram__label { padding: 8px 12px 0; border-top: 1px solid var(--line); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); }
.steps-list { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 8px; }
.steps-list__item { position: relative; padding: 10px 14px 10px 48px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); counter-increment: step; }
.steps-list__item::before {
  content: counter(step); position: absolute; left: 12px; top: 10px;
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--ink); color: var(--white); font-size: 0.8rem; font-weight: 800;
}

/* roof pitch: compact roofing list */
.mats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mat { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; background: var(--white); border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-sm); }
.mat__icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; color: var(--white); font-size: 0.75rem; font-weight: 700; line-height: 1; }
.mat__name { font-weight: 600; font-size: 0.95rem; line-height: 1.35; }
.mat__detail { font-size: 0.8rem; color: var(--muted); }
.mat--pass { border-left-color: var(--green); }
.mat--pass .mat__icon { background: var(--green); }
.mat--warn { border-left-color: var(--amber); background: var(--amber-tint); }
.mat--warn .mat__icon { background: var(--amber); color: var(--ink); }
.mat--warn .mat__detail { color: var(--amber-text); font-weight: 500; }
.mat--fail { border-left-color: var(--line-strong); background: var(--bg); }
.mat--fail .mat__icon { background: var(--line-strong); }
.mat--fail .mat__name { color: var(--muted); }
@media (min-width: 640px) { .mats { grid-template-columns: 1fr 1fr; } }

/* ---------- Results: blocks ---------- */
.block { margin-top: 32px; }
.block__title { font-size: 1.5rem; padding-bottom: 8px; border-bottom: 2px solid var(--ink); margin-bottom: 12px; }
.block__subtitle { font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); margin: 20px 0 8px; }
.block__note { font-size: 0.9rem; color: var(--muted); margin-bottom: 10px; }

/* ---------- Compare options ---------- */
.options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.option {
  display: grid; gap: 4px; align-content: start;
  min-height: var(--tap);
  padding: 12px 8px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.option:hover { border-color: var(--ink); }
.option.is-selected { border-color: var(--ink); background: var(--sky-tint); box-shadow: inset 0 0 0 1px var(--ink); }
.option__count { font-family: var(--font-display); font-weight: 800; font-size: 1.0625rem; line-height: 1.1; }
.option__value { font-weight: 600; font-size: 0.9rem; }
.option__run { font-size: 0.8rem; color: var(--muted); }
.option__tag { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }
.option__tag--best { color: var(--ink); background: var(--amber); padding: 2px 6px; border-radius: 3px; justify-self: start; }
.option__tag--ok { color: var(--green); }
.option__tag--fail { color: var(--red); }

/* ---------- Code check ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-item { display: flex; gap: 12px; padding: 12px; background: var(--white); border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--radius-sm); }
.check-item__icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--white); font-weight: 700; font-size: 0.85rem; line-height: 1;
}
.check-item__label { font-weight: 600; }
.check-item__message { font-size: 0.95rem; }
.check-item__source { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.check-item--pass { border-left-color: var(--green); }
.check-item--pass .check-item__icon { background: var(--green); }
.check-item--pass .check-item__status { color: var(--green); }
.check-item--fail { border-left-color: var(--red); background: var(--red-tint); }
.check-item--fail .check-item__icon { background: var(--red); }
.check-item--fail .check-item__status { color: var(--red); }
.check-item--warn { border-left-color: var(--amber); background: var(--amber-tint); }
.check-item--warn .check-item__icon { background: var(--amber); color: var(--ink); }
.check-item--warn .check-item__status { color: var(--amber-text); }
.check-item--info { border-left-color: var(--steel); }
.check-item--info .check-item__icon { background: var(--steel); font-family: Georgia, serif; font-style: italic; }
.check-item--info .check-item__status { color: var(--steel); }

/* ---------- Cutting rows ---------- */
.rows { margin: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.rows__item { padding: 12px 14px; border-top: 1px solid var(--line); }
.rows__item:first-child { border-top: 0; }
.rows__label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); }
.rows__value { margin: 2px 0 0; font-size: 1.2rem; font-weight: 600; }
.rows__note { display: block; font-size: 0.875rem; font-weight: 400; color: var(--muted); margin-top: 2px; }

.marks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.marks__item { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.marks__step { font-size: 0.75rem; font-weight: 600; color: var(--muted); min-width: 1.6em; }
.marks__value { font-weight: 600; white-space: nowrap; }
.marks__item--top { border-color: var(--ink); }

/* ---------- Materials ---------- */
.materials { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.materials__item { display: flex; gap: 14px; align-items: baseline; padding: 12px 14px; border-top: 1px solid var(--line); }
.materials__item:first-child { border-top: 0; }
.materials__qty { flex: none; min-width: 2.8em; font-family: var(--font-display); font-weight: 800; font-size: 1.375rem; line-height: 1; text-align: right; }
.materials__text { font-weight: 500; }
.materials__note { display: block; font-size: 0.875rem; font-weight: 400; color: var(--muted); }

.notice { margin-top: 24px; padding: 12px 14px; border-left: 5px solid var(--ink); background: var(--white); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.9rem; font-weight: 500; }

/* ---------- Article text under the calculators ---------- */
.prose { max-width: 74ch; margin-top: 56px; font-size: 1.0625rem; line-height: 1.6; }
.prose h2 { font-size: 1.75rem; margin: 40px 0 12px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.1875rem; font-weight: 700; margin: 24px 0 6px; letter-spacing: 0; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 1.3em; }
.prose li { margin-bottom: 8px; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--sky-tint); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.prose a { font-weight: 600; }
.page-pin { max-width: 340px; margin: 40px 0 0; }
.page-pin img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.page-pin figcaption { margin-top: 8px; font-size: 0.875rem; color: var(--muted); }
.prose__related { margin-top: 28px; padding: 14px 16px; background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--orange); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.sources { font-size: 0.95rem; }

.table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; line-height: 1.4; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.data-table thead th { border-top: 0; background: var(--ink); color: var(--white); font-weight: 600; white-space: nowrap; }
.data-table td small { display: block; margin-top: 2px; font-size: 0.8rem; color: var(--muted); }
.data-table tbody tr:nth-child(even) { background: var(--bg); }

/* ---------- Guides ---------- */
.prose--guide { margin-top: 8px; }
.figure { margin: 22px 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.figure svg { display: block; width: 100%; height: auto; }
.figure figcaption { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 0.9rem; line-height: 1.45; color: var(--muted); }
.prose .step { margin-top: 28px; }
.prose .step__n { display: inline-flex; align-items: center; justify-content: center; width: 1.9em; height: 1.9em; margin-right: 8px; border-radius: 50%; background: var(--ink); color: var(--white); font-size: 0.85em; font-weight: 800; vertical-align: 0.05em; }
.callout { margin: 0 0 14px; padding: 14px 16px; background: var(--amber-tint); border-left: 5px solid var(--amber); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.callout p:last-child { margin-bottom: 0; }
.cta { display: inline-block; margin: 4px 0 14px; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--orange); color: var(--ink); font-weight: 700; text-decoration: none; }
.cta:hover { background: var(--orange-dark); color: var(--ink); }
.home-title--next { margin-top: 40px; }
.card--guide { border-top-color: var(--steel); }
.card__more { justify-self: start; align-self: end; margin-top: 6px; font-weight: 700; color: var(--steel); text-decoration: underline; }

/* ---------- Wider screens ---------- */
@media (min-width: 480px) {
  .hero__count, .hero__value { font-size: 2.75rem; }
  .option { padding: 14px 12px; }
  .option__count { font-size: 1.25rem; }
  .option__value { font-size: 0.95rem; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

@media (min-width: 640px) {
  .keys { grid-template-columns: repeat(3, 1fr); }
  .keys__item { display: block; padding: 14px 16px; border-top: 0; border-left: 1px solid var(--line); }
  .keys__item:first-child { border-left: 0; }
  .keys__value { margin-top: 4px; text-align: left; font-size: 1.5rem; }
  .home-hero { grid-template-columns: minmax(0, 1fr) auto; }
  .home-hero__mark { width: 200px; height: 200px; }
  .site-footer__inner { grid-template-columns: 1fr auto; align-items: start; }
  .site-footer__legal { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  h1 { font-size: 3rem; }
  .site-header__inner { flex-direction: row; align-items: center; justify-content: space-between; padding-top: 10px; padding-bottom: 10px; }
  .site-nav { margin: 0; }
  .site-nav__list { padding: 0; }
  .site-nav__menu { left: auto; right: 0; }   /* menu sits at the right edge of the header */
  .brand__name { font-size: 1.625rem; }
  .block__title { font-size: 1.75rem; }
  .home-title { font-size: 2rem; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calc { grid-template-columns: 360px minmax(0, 1fr); gap: 32px; align-items: start; }
  .calc__inputs { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
  .rows { display: grid; grid-template-columns: 1fr 1fr; }
  .rows__item:nth-child(2) { border-top: 0; }
  .rows__item:nth-child(odd) { border-right: 1px solid var(--line); }
}

@media (prefers-reduced-motion: no-preference) {
  .option, .btn, .segmented__item span, .card, .card__go { transition: background-color 0.12s, border-color 0.12s; }
}

/* ---------- Baluster spacing calculator ---------- */
.segmented--three { align-items: stretch; }
.segmented--three .segmented__item span { height: 100%; font-size: 0.875rem; line-height: 1.2; padding: 6px 4px; }
.dg-ball { fill: var(--amber-tint); fill-opacity: 0.85; stroke: var(--orange-dark); stroke-width: 1.5; }
.sections { display: grid; gap: 10px; }
.sections__row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.sections__length { gap: 0; }
.sections__qty { display: flex; align-items: center; gap: 6px; }
.sections__times { font-weight: 700; color: var(--muted); }
.sections__qty-input { width: 64px; padding: 10px; text-align: center; }
.sections__remove { width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); font: inherit; font-size: 1.1rem; cursor: pointer; }
.sections__remove:hover { background: var(--red-tint); color: var(--red); }
.sections__error { grid-column: 1 / -1; }
.sections__add { justify-self: start; min-height: 44px; }
.choice--inline { margin-bottom: 12px; }
.choice--inline > legend { margin-bottom: 8px; }
.choice--inline .segmented { max-width: 320px; }
.next-step { margin: 12px 0 0; }
.next-step .cta { margin: 0; }

/* feedback: thumbs on Yes / No, and the prompt at the end of each guide */
.fb__button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.fb__thumb { width: 18px; height: 18px; flex: none; fill: var(--steel); }
.fb__thumb--down { transform: rotate(180deg); }
.fb__button:hover .fb__thumb { fill: var(--ink); }
.fb--guide { max-width: 74ch; margin-top: 40px; }

/* baluster layout sheet (print.css shows only #bcg-print while html[data-print] is set) */
@media print {
  #bcg-print .marks { margin-bottom: 3pt; }
  #bcg-print .block__subtitle { margin: 4pt 0 2pt; font-size: 7.5pt; }
  #bcg-print .checks { display: block; }
  #bcg-print .diagram { max-width: 6.5in; margin-top: 5pt; }
  #bcg-print .keys { display: grid; grid-template-columns: repeat(3, 1fr); }
  #bcg-print .keys__item { display: block; border-top: 0; border-left: 0.5pt solid #D1DCE3; }
  #bcg-print .keys__item:first-child { border-left: 0; }
  #bcg-print .keys__value { text-align: left; }
}

/* ---------- Roofing calculator ---------- */
.planes { display: grid; gap: 12px; }
.planes__row { display: grid; gap: 8px; padding: 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.planes__head { display: flex; align-items: center; gap: 8px; }
.planes__name { font-weight: 700; margin-right: auto; white-space: nowrap; }
.planes__shape { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--white); color: var(--ink); font: inherit; }
.planes__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.planes__field { gap: 4px; }
.planes__label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.planes__error:empty { display: none; }
.rc-edges-title { margin-top: 8px; }
.field__control--money { position: relative; }
.field__prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--muted); pointer-events: none; }
.field__control--money .field__input { padding-left: 28px; }
.materials__cost { margin-left: auto; font-weight: 700; white-space: nowrap; }
.materials__item--total { background: var(--sky-tint); }
.materials__item--total .materials__text { font-weight: 700; }
.dg-roof { fill: var(--sky-tint); stroke: none; }
.dg-wall { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 5 4; }
.dg-eave { stroke: var(--steel); stroke-width: 4; stroke-linecap: round; }
.dg-rake { stroke: var(--steel); stroke-width: 4; stroke-dasharray: 9 6; }
.dg-high { stroke: var(--line-strong); stroke-width: 3; stroke-linecap: round; }
.dg-ridge { stroke: var(--orange); stroke-width: 4; stroke-linecap: round; }
.dg-hip { stroke: var(--orange); stroke-width: 3; stroke-linecap: round; }

/* roofing shopping list sheet (print.css shows only #bcg-print while html[data-print] is set) */
@media print {
  html[data-print="roofing"] #bcg-print .diagram { max-width: 5.5in; margin-top: 5pt; }
  html[data-print="roofing"] #bcg-print .keys { display: grid; grid-template-columns: repeat(2, 1fr); }
  html[data-print="roofing"] #bcg-print .keys__item { display: block; border-top: 0.5pt solid #D1DCE3; border-left: 0; }
  html[data-print="roofing"] #bcg-print .keys__value { text-align: left; }
  html[data-print="roofing"] #bcg-print .materials__cost { font-size: 9pt; }
  html[data-print="roofing"] #bcg-print .rows { grid-template-columns: repeat(4, 1fr); }
}
