/* Roof Pitch Calculator: measurements, every form of the pitch, a to-scale diagram, the
   IRC coverings check, rafters, a materials list and a pitch chart. Colours come from the
   shared tokens, so the panel follows the light and dark themes. */
.rpc {
  display: grid;
  gap: 1.25rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
}
.rpc *, .rpc *::before, .rpc *::after { box-sizing: border-box; }
.rpc [hidden] { display: none !important; }
.rpc h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.rpc h3 { margin: 0 0 .6rem; font-size: 1.15rem; }
.rpc p { margin: 0; color: var(--ink-soft); }
.rpc .rpc-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.rpc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .9rem 1.5rem; }
.rpc-head > div { flex: 1 1 22rem; min-width: 0; }
.rpc-head p { max-width: 70ch; }

/* Pill switches: a visually hidden radio inside each label. */
.rpc-pills { display: flex; flex-wrap: wrap; gap: .5rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.rpc-pills legend { width: 100%; margin-bottom: .45rem; padding: 0; font-weight: 700; }
.rpc-pills label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .45rem .9rem; font-weight: 650; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.rpc-pills input { position: absolute; opacity: 0; pointer-events: none; }
.rpc-pills label:has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.rpc-pills label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.rpc-units label { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }

.rpc-panel { display: grid; gap: .9rem; min-width: 0; padding: 1rem; background: var(--blue-tint); border: 2px solid var(--line); border-radius: 10px; }
.rpc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .4rem 1.25rem; align-items: start; }
.rpc-field { display: grid; gap: .3rem; min-width: 0; }
.rpc-field label { font-size: .88rem; font-weight: 650; }
.rpc-unit { font-weight: 500; color: var(--ink-soft); }
.rpc input[type="text"], .rpc select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.rpc input[type="text"] { font-family: var(--font-mono); font-size: .95rem; }
.rpc input[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 2px var(--error-soft); }
.rpc :is(input, select, button, summary, a):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.rpc .rpc-note { min-height: 1.25em; font-size: .8rem; line-height: 1.35; color: var(--ink-soft); overflow-wrap: anywhere; }
.rpc .rpc-note.rpc-note-error { font-weight: 650; color: var(--error); }
.rpc .rpc-sub { font-size: .88rem; max-width: 90ch; }
.rpc .rpc-check { display: flex; align-items: center; gap: .55rem; min-height: 42px; font-size: .95rem; font-weight: 500; }
.rpc .rpc-check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }

.rpc button {
  min-height: 42px;
  padding: .5rem .95rem;
  font: inherit;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.rpc button:disabled { opacity: .5; cursor: default; }
.rpc .rpc-primary { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.rpc .rpc-primary:hover:not(:disabled) { background: var(--primary-dark); }
.rpc-quick { display: flex; flex-wrap: wrap; gap: .5rem; }
.rpc .rpc-small { min-height: 38px; padding: .35rem .8rem; font-size: .88rem; border-width: 1.5px; }
.rpc-quick button { min-height: 38px; padding: .35rem .8rem; font-size: .88rem; border-width: 1.5px; border-radius: 999px; }
.rpc-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Result: the answer and its forms beside the diagram. */
.rpc-result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; padding: 1rem 1.1rem 1.1rem; background: var(--pastel-green); border: 2px solid var(--line); border-radius: 10px; }
.rpc-result-main { display: grid; gap: .6rem; align-content: start; min-width: 0; }
.rpc-result h3 { margin: 0; }
.rpc .rpc-answer { font-size: clamp(1.45rem, 4vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--ink); overflow-wrap: anywhere; }
.rpc .rpc-answer[data-state="empty"] { font-size: 1.1rem; font-weight: 650; }
.rpc .rpc-answer[data-state="error"] { padding: .5rem .75rem; font-size: 1rem; font-weight: 650; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }
.rpc .rpc-class { color: var(--ink); font-size: .92rem; }
.rpc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .55rem; margin: 0; }
.rpc-stats:empty { display: none; }
.rpc-stats div { display: grid; align-content: start; gap: .15rem; min-width: 0; padding: .5rem .65rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 6px; }
.rpc-stats .rpc-key { border: 2px solid var(--line); }
.rpc-stats dt { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.rpc-stats dd { margin: 0; font: 600 1.02rem var(--font-mono); overflow-wrap: anywhere; }
.rpc-stats .rpc-key dd { font-size: 1.1rem; font-weight: 700; }
.rpc-stats dd.rpc-note { font: inherit; font-size: .75rem; line-height: 1.3; color: var(--ink-soft); }

.rpc-figure { display: grid; gap: .5rem; align-content: start; align-self: start; min-width: 0; margin: 0; padding: .6rem; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 8px; }
.rpc-figure figcaption { font-size: .82rem; line-height: 1.4; color: var(--ink-soft); }
.rpc-diagram { min-width: 0; }
.rpc-svg { display: block; width: 100%; height: auto; }
.rpc-d-fill { fill: var(--blue-tint); }
.rpc-d-wall { fill: var(--paper-3); stroke: var(--line); stroke-width: 1.5; }
.rpc-d-guide { stroke: var(--ink-soft); stroke-width: 1.5; stroke-dasharray: 5 4; }
.rpc-d-rafter { stroke: var(--action); stroke-width: 6; stroke-linecap: round; }
.rpc-d-arc { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.rpc-d-dim { stroke: var(--ink); stroke-width: 1.25; }
.rpc-d-soft { stroke-dasharray: 3 3; }
.rpc-d-text { font: 600 13px var(--font-body); fill: var(--ink); }
.rpc-d-strong { font-weight: 700; }
.rpc-d-muted { fill: var(--ink-soft); }
.rpc-d-angle { font-weight: 700; }

.rpc-section { display: grid; gap: .75rem; min-width: 0; }
.rpc-section > h3 { margin: 0; }
.rpc-msg { min-height: 0; font-size: .92rem; font-weight: 600; color: var(--ink) !important; }
.rpc-msg:empty { display: none; }
.rpc-msg[data-error="true"] { padding: .5rem .75rem; background: var(--error-soft); border-left: 4px solid var(--error); border-radius: 6px; }

.rpc-table-wrap { max-width: 100%; overflow: auto; background: var(--bg-2); border: 1.5px solid var(--border-soft); border-radius: 6px; }
.rpc table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rpc th, .rpc td { padding: .45rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-faint); }
.rpc thead th { position: sticky; top: 0; z-index: 1; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: var(--paper-3); }
.rpc tbody th { font-weight: 600; }
.rpc tfoot th, .rpc tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.rpc .rpc-num { font-family: var(--font-mono); white-space: nowrap; }

.rpc .rpc-ref { display: block; margin-top: .15rem; font-size: .8rem; font-weight: 450; color: var(--ink-soft); }
.rpc-codes td:nth-child(2) { white-space: nowrap; }
.rpc-codes td:nth-child(3) strong { display: block; }
.rpc-codes td:nth-child(3) span { display: block; margin-top: .15rem; font-size: .8rem; color: var(--ink-soft); }
.rpc-codes tr.rpc-ok td:nth-child(3) strong { color: var(--success-strong); }
.rpc-codes tr.rpc-no { background: var(--paper-3); }
.rpc-codes tr.rpc-no td:nth-child(3) strong { color: var(--error); }
.rpc-local { padding: .75rem 1rem; border: 1.5px solid var(--border-soft); border-radius: 10px; }
.rpc-local[open] { display: grid; gap: .75rem; }
.rpc-local summary, .rpc-settings summary, .rpc-prices summary { font-weight: 700; cursor: pointer; }
.rpc-overrides { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.rpc-settings, .rpc-prices { background: var(--paper-3); }
.rpc-settings:not([open]), .rpc-prices:not([open]) { gap: 0; }

.rpc-materials td { width: 1%; }

.rpc-chart { max-height: 30rem; }
.rpc-chart table { min-width: 30rem; }
.rpc-chart td { font-family: var(--font-mono); white-space: nowrap; }
.rpc-chart tbody th button { min-height: 32px; padding: .15rem .6rem; font-family: var(--font-mono); font-size: .88rem; border-width: 1.5px; border-radius: 6px; }
.rpc-chart tr.rpc-current { background: var(--pastel-yellow); }
.rpc-chart tr.rpc-current th, .rpc-chart tr.rpc-current td { font-weight: 700; }
.rpc-you { display: inline-block; margin-left: .5rem; padding: .05rem .4rem; font-size: .72rem; font-weight: 700; color: var(--on-action); background: var(--action); border-radius: 999px; white-space: nowrap; }

.rpc-reset { padding-top: .25rem; border-top: 1.5px solid var(--border-faint); }
.rpc-foot { font-size: .85rem; }

@media (max-width: 860px) {
  .rpc-result { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .rpc-grid { grid-template-columns: minmax(0, 1fr); }
  .rpc th, .rpc td { padding: .4rem .5rem; }
  .rpc-codes td:nth-child(2) { white-space: normal; }
  .rpc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rpc-actions button { flex: 1 1 auto; }
  .rpc-result { padding: .85rem; }
}

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply roof-pitch-calculator. */
.tool-view-placeholder[data-tool="roof-pitch-calculator"] { min-height: 4471px; }
@media (max-width: 1496px) { .tool-view-placeholder[data-tool="roof-pitch-calculator"] { min-height: 4494px; } }
@media (max-width: 760px) { .tool-view-placeholder[data-tool="roof-pitch-calculator"] { min-height: 5599px; } }
@media (max-width: 472px) { .tool-view-placeholder[data-tool="roof-pitch-calculator"] { min-height: 6994px; } }
