/* Calculator widgets. Uses the tokens and components of /assets/hga/hga.css; everything here is namespaced .hga-* */

/* compact hero on tool pages: the calculator has to reach the first screen */
.page-hero--tool{padding-block:clamp(1.25rem,3.5vw,2.25rem) clamp(1.75rem,3.5vw,2.5rem)}
.page-hero--tool h1{font-size:clamp(1.85rem,1.3rem + 2vw,2.75rem)}
.page-hero--tool .lead{font-size:clamp(.98rem,.93rem + .25vw,1.1rem);line-height:1.55;max-width:46rem}
.page-hero--tool .eyebrow{margin-bottom:.15rem}
.page-hero--tool + .page-body{padding-top:1.5rem}
.page-body > .tool-card{scroll-margin-top:calc(var(--header-h) + .5rem)}
.page-body > .ruler{margin:clamp(1.5rem,4vw,2.5rem) 0}
.tool-card__head{padding-block:.85rem .75rem}
.tool-card__head h2{font-size:clamp(1.15rem,1.05rem + .5vw,1.4rem)}
.hga-loading{margin:0;color:var(--ink-soft)}

/* layout: headline answer, inputs, list. On phones the answer sits above the inputs. */
.hga-calc__grid{display:grid;gap:1.25rem 2.25rem;grid-template-columns:minmax(0,1fr);grid-template-areas:"head" "form" "out"}
.hga-calc__head{grid-area:head;min-width:0}
.hga-calc__form{grid-area:form;min-width:0}
.hga-calc__out{grid-area:out;min-width:0}
@media(min-width:920px){
  .hga-calc__grid{grid-template-columns:minmax(0,5fr) minmax(0,6fr);grid-template-areas:"form head" "form out";align-items:start}
  .hga-calc__out{position:static}
}
.tool-card__body{padding:1.1rem 1.1rem 1.4rem}
@media(min-width:720px){.tool-card__body{padding:1.5rem}}

.hga-calc__head .stat-grid{grid-template-columns:repeat(auto-fit,minmax(8.5rem,1fr))}
.hga-calc__head .stat--key{box-shadow:3px 3px 0 var(--ink)}
.hga-calc__head .stat__label{font-size:.85rem}
.hga-msg{margin:0;padding:.9rem 1rem;background:var(--tape-wash);border:2px solid var(--ink);border-left-width:8px;border-left-color:var(--tape-deep);border-radius:var(--r-sm) var(--r) var(--r) var(--r-sm);font-weight:600;color:var(--ink)}

.hga-calc__form .segmented{margin-bottom:1.1rem}
.hga-calc .field{margin-bottom:.9rem}
.hga-calc .field-row{gap:0 1rem}
.hga-calc .input-unit__u{max-width:5.5rem;overflow:hidden;white-space:nowrap}
.hga-calc .input-unit input{padding-right:3.6rem}
.hga-calc .field.is-invalid input,.hga-calc .field.is-invalid select{border-color:var(--rust);background:var(--rust-wash)}
.hga-check{display:flex;align-items:flex-start;gap:.6rem;min-height:44px;font-weight:600;margin:0;cursor:pointer}
.hga-check input{margin:.15rem 0 0;flex:none}

/* repeatable rows (several beds, several areas) */
.hga-row{margin:0 0 1rem;padding:.7rem .9rem .9rem;border:2px solid var(--line);border-radius:var(--r);background:var(--paper)}
.hga-row legend{padding:0 .4rem;font:800 .85rem/1.2 var(--font-sans);letter-spacing:.08em;text-transform:uppercase;color:var(--rust-deep)}
.hga-row__fields{display:grid;gap:0 .9rem;grid-template-columns:repeat(2,minmax(0,1fr))}
.hga-row__fields .field{margin-bottom:.7rem}
.hga-row .button--quiet{min-height:40px;padding-block:.25rem}
.hga-add{margin-bottom:1rem}
.hga-shape{grid-column:1 / -1}

/* results */
.hga-calc__out .result{margin-top:0;padding:.9rem 1rem 1rem}
.hga-calc .shopping-list{font-size:.93rem}
.hga-calc .shopping-list caption{font-size:1.05rem}
.hga-calc .shopping-list th[scope=row]{font-weight:600}
.hga-calc .shopping-list td:last-child{color:var(--ink-soft);font-size:.86rem}
@media(max-width:560px){
  .hga-calc .shopping-list thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  .hga-calc .shopping-list tr{display:grid;grid-template-columns:1fr auto;column-gap:.75rem;padding:.55rem 0;border-bottom:1px solid var(--line)}
  .hga-calc .shopping-list th,.hga-calc .shopping-list td{border:0;padding:.05rem 0}
  .hga-calc .shopping-list td.num{font-weight:700}
  .hga-calc .shopping-list td:last-child{grid-column:1 / -1}
  .hga-calc .shopping-list td:last-child:empty{display:none}
}
.hga-actions{margin-top:1rem;align-items:center}
.hga-toast{flex:1 1 100%;min-height:1.3em;font-size:.88rem;font-weight:600;color:var(--denim-deep)}
.hga-calc .actions .button[disabled]{opacity:.45;cursor:not-allowed;transform:none;box-shadow:0 3px 0 var(--ink)}
.hga-range{font-size:.9rem;color:var(--ink-soft);margin:.25rem 0 .9rem}

/* source lists on the pages */
.wd-sources{font-size:.92rem;color:var(--ink-soft)}
.wd-sources li{margin-bottom:.35rem}
.prose .table-wrap table.compare th[scope=row]{background:transparent}
.prose .table-wrap{margin:1.25rem 0}

/* printing: only the list (#hga-print) */
#hga-print{display:none}
@media print{
  body.hga-printing > *:not(#hga-print){display:none!important}
  body.hga-printing #hga-print{display:block!important;color:#000;background:#fff;padding:0;font:11pt/1.4 var(--font-sans)}
  #hga-print h2{font:800 20pt/1.2 var(--font-head);margin:0 0 .25rem}
  #hga-print h3{font:800 12pt/1.2 var(--font-head);margin:1rem 0 .3rem}
  #hga-print .hga-print__meta{margin:0 0 .5rem;font-size:9.5pt;color:#333}
  #hga-print table{width:100%;border-collapse:collapse;margin:.4rem 0 .8rem}
  #hga-print th,#hga-print td{border:1px solid #555;padding:4pt 6pt;text-align:left;vertical-align:top;font-size:10.5pt}
  #hga-print caption{text-align:left;font-weight:800;padding-bottom:3pt}
  #hga-print td.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
  #hga-print thead th{background:#eee;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  #hga-print ul{margin:.2rem 0 .6rem;padding-left:1.1rem;font-size:10pt}
  #hga-print .hga-print__foot{margin-top:1rem;font-size:9pt;color:#333}
}

/* grid items must be allowed to shrink, or a wide table inside the text column widens the page on phones */
.page-layout > *{min-width:0}

.hga-calc .shopping-list td.num{white-space:nowrap}
@media(max-width:560px){
  .hga-calc__head .stat-grid{grid-template-columns:repeat(auto-fit,minmax(5.4rem,1fr));gap:.5rem}
  .hga-calc__head .stat{padding:.6rem .6rem}
  .hga-calc__head .stat__value{font-size:1.45rem}
  .hga-calc__head .stat__label{font-size:.78rem}
}
