/* NetSheet.org — public calculator (try-it.html)
   Builds on site.css: .field/.input/.input-affix, .sheet/.ledger, .btn, .notice.
   This page is the reference layout for the in-app calculator. */

.calc-page { padding-block: clamp(2rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem); }

.calc-intro { margin-bottom: clamp(1.75rem, 3vw, 2.5rem); }
.calc-intro h1 { font-size: var(--step-3); margin-bottom: 0.4rem; }
.calc-intro .lede { font-size: var(--step-0); max-width: 60ch; margin: 0; color: var(--ink-2); }

.calc-workspace {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "form result" "upsell result";
  gap: 0 clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}
.calc-form { grid-area: form; }
.calc-result { grid-area: result; align-self: stretch; }
.account-upsell { grid-area: upsell; }

/* ------------------------------------------------------------- the form */

.calc-form { min-width: 0; }

.form-section { padding-block: 1.5rem 0.5rem; border-top: 1px solid var(--rule); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section h2 {
  font-size: var(--step-1); margin-bottom: 1rem;
  font-stretch: 90%; font-variation-settings: "wdth" 90; letter-spacing: -0.005em;
}

.label-note { font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-left: 0.25rem; }

.input.money, .money { font-variant-numeric: tabular-nums; }

/* Number inputs: no spinners, they fight with the $ affix and are useless on touch */
input[type="number"].input { -moz-appearance: textfield; appearance: textfield; }
input[type="number"].input::-webkit-outer-spin-button,
input[type="number"].input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="date"].input { appearance: none; -webkit-appearance: none; }
textarea.input { resize: vertical; min-height: 4.5rem; }

/* Jurisdiction block (county, city, NYC) injected by try-it.js */
.jurisdiction {
  margin: 0 0 1.1rem; padding: 1rem 1rem 0.1rem;
  background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--leaf);
  border-radius: var(--radius-sm);
}
.jurisdiction .check { min-height: 48px; align-items: center; margin-bottom: 0.9rem; cursor: pointer; }
.jurisdiction .check input { margin-top: 0; }
.tag {
  display: inline-block; margin-left: 0.4rem; font-size: 0.75rem; font-weight: 600;
  color: var(--green); background: var(--green-soft); padding: 0.1rem 0.5rem; border-radius: 999px;
  vertical-align: 0.1em;
}

/* Commission slider */
.commission-slide { margin-top: -0.35rem; }
.range {
  display: block; width: 100%; height: 48px; margin: 0; accent-color: var(--green);
  background: transparent; cursor: pointer;
}
.range:focus-visible { outline-offset: -8px; }
.range-scale { display: flex; justify-content: space-between; margin-top: -0.6rem; font-variant-numeric: tabular-nums; }
.range-scale > span:nth-child(2) { color: var(--ink-2); font-weight: 600; }

/* Custom fee rows */
.custom-fees { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.custom-fees:empty { display: none; }
.custom-fee-item {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 48px; gap: 0.75rem; align-items: end;
}
.custom-fee-item label { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.3rem; }
.fee-remove {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper);
  color: var(--muted); cursor: pointer;
}
.fee-remove:hover { color: var(--danger); border-color: var(--danger); }
.fee-remove svg { width: 18px; height: 18px; }

#add-custom-fee-btn { min-height: 48px; margin-bottom: 1rem; }

.form-submit { padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.form-submit .btn { min-height: 52px; font-size: 1.05rem; }
.form-submit .hint { margin-top: 0.6rem; }

/* ------------------------------------------------------- the result sheet */

.calc-result { min-width: 0; }
.result-sticky { position: sticky; top: 5rem; }
/* try-it.js lowers `top` when the sheet is taller than the viewport, so the
   bottom of the sheet (the net line) stays reachable instead of clipping. */

.result-sheet:focus { outline: none; }
.result-sheet .sheet-title { font-size: 1.1rem; font-stretch: 100%; font-variation-settings: "wdth" 100; line-height: 1.3; }
.result-sheet .sheet-head > div { min-width: 0; }
#preview-address { overflow-wrap: anywhere; }
.result-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.result-date:empty { display: none; }

.result-sheet .sheet-body { padding-top: 0.25rem; }
.ledger td:first-child { padding-right: 0.5rem; }
.ledger .subtle td { text-align: left; padding-left: 0; }
.ledger .rate { color: var(--muted); font-size: var(--step--1); }
.ledger .lead td { font-weight: 600; }
.ledger .credit td:last-child::before { content: "+\00a0"; color: var(--muted); }
.ledger tfoot .subtotal td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; padding-top: 0.65rem; }
.ledger tfoot .total td { border-top: 1px solid var(--rule); }
.ledger-empty td { color: var(--muted); }
.ledger-empty td:last-child { color: #9aa8a0; }
.ledger-empty .total td { color: var(--ink-2); }
.ledger-empty .total td:last-child { color: #9aa8a0; font-weight: 400; }

.empty-note { font-size: var(--step--1); color: var(--muted); margin: 0.9rem 0 0.25rem; }

.sheet-foot { padding: 1rem 1.5rem 1.15rem; border-top: 1px solid var(--rule); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.sheet-actions .btn { min-height: 48px; }
.sheet-actions .btn-secondary { flex: 1 1 auto; }
.sheet-disclaimer { font-size: var(--step--1); color: var(--muted); margin: 0; }

.send-panel { padding: 1rem 0 0.25rem; margin-bottom: 1rem; border-top: 1px dashed var(--rule); }
.send-panel h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.send-panel > .hint { margin: 0 0 1rem; }
.send-panel .field { margin-bottom: 0.85rem; }
.send-panel .btn { min-height: 48px; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Account upsell under the sheet */
.account-upsell { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); max-width: 40rem; }
.account-upsell h2 { font-size: var(--step-1); font-stretch: 90%; font-variation-settings: "wdth" 90; margin-bottom: 0.75rem; }
.upsell-list { list-style: none; margin: 0 0 1.1rem; padding: 0; font-size: 0.95rem; color: var(--ink-2); }
.upsell-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 1rem;
  padding: 0.5rem 0; border-bottom: 1px dashed var(--rule);
}
.plan-tag {
  font-size: 0.78rem; font-weight: 600; color: var(--green); background: var(--green-soft);
  padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
.account-upsell .cluster { gap: 1rem; }
.account-upsell .btn { min-height: 48px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 960px) {
  .calc-workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "form" "result" "upsell"; }
  .calc-result { margin-top: 2.5rem; }
  .result-sticky { position: static; }
}
@media (max-width: 560px) {
  .result-sheet .sheet-head, .result-sheet .sheet-body, .sheet-foot { padding-inline: 1rem; }
  .result-sheet .sheet-head { flex-direction: column; gap: 0.25rem; }
  .custom-fee-item { grid-template-columns: minmax(0, 1fr) 48px; }
  .custom-fee-item .fee-name { grid-column: 1 / -1; }
  .sheet-stack::before { inset: 8px -6px -8px 6px; }
}

/* ------------------------------------------------ rules-engine additions (2026-09) */

/* Seller / buyer sheet type switch */
.seg {
  display: inline-flex; margin-top: 1rem; padding: 3px; gap: 2px;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 999px;
}
.seg-item { position: relative; cursor: pointer; }
.seg-item input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg-item span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 1.1rem;
  border-radius: 999px; font-weight: 600; font-size: 0.95rem; color: var(--ink-2); white-space: nowrap;
}
.seg-item input:checked + span { background: var(--green); color: #fff; }
.seg-item input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

.customs-note { margin: 0 0 0.9rem; color: var(--ink-2); }
.jurisdiction .check { margin-bottom: 0.9rem; }

/* Optional override fields: blank = auto */
.auto-field::placeholder { color: var(--muted); font-style: italic; }
.auto-hint:empty { display: none; }

/* Grouped ledger */
.ledger .group td {
  padding: 0.9rem 0 0.25rem; border-bottom: 1px solid var(--rule-strong);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.ledger .group td:first-child { text-align: left; }
.ledger tr.clickable { cursor: pointer; }
.ledger tr.clickable:hover td { background: var(--green-soft); }

#preview-warnings { margin-top: 0.9rem; }
.assumptions { margin-top: 0.9rem; font-size: var(--step--1); color: var(--ink-2); }
.assumptions summary { cursor: pointer; font-weight: 600; color: var(--green); }
.assumptions ul { margin: 0.5rem 0 0 1.1rem; padding: 0; }
.assumptions li { margin-bottom: 0.3rem; }
.assumptions .hint { margin-top: 0.6rem; }

.btn.is-loading { opacity: 0.7; pointer-events: none; }

/* Both-sheets view and extra options (2026-09-29) */
.result-sheet-secondary { margin: 1.5rem -1.5rem 0; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; box-shadow: none; }
.result-sheet-secondary .sheet-head { padding-top: 1.25rem; }
.result-sheet-secondary .sheet-foot { padding-bottom: 0; }
.more-options summary { cursor: pointer; font-weight: 600; color: var(--green); margin-bottom: 1rem; }
.more-options .check { margin: 0.25rem 0 1.1rem; }

/* ---------------------------------------------------- auto-fill and address animations (2026-09-29) */
.autofill .autofill-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem; align-items: stretch; }
.autofill .autofill-row .btn { white-space: nowrap; }
.autofill .autofill-row svg { width: 18px; height: 18px; margin-right: 0.35rem; }
.autofill-paste { margin-top: 0.75rem; }
.autofill-paste summary { cursor: pointer; color: var(--green); font-weight: 600; margin-bottom: 0.6rem; }
.autofill-paste textarea { margin-bottom: 0.6rem; }
.autofill-status:empty { display: none; }
.autofill-status.is-error { color: var(--danger); }
@keyframes ns-fill-flash { 0% { box-shadow: 0 0 0 0 rgba(30, 91, 66, 0.55); background: var(--green-soft); } 100% { box-shadow: 0 0 0 10px rgba(30, 91, 66, 0); background: var(--paper); } }
.input.is-filled { animation: ns-fill-flash 900ms ease-out; }
@keyframes ns-pop { 0% { opacity: 0; transform: translateY(6px) scale(0.98); } 60% { transform: translateY(0) scale(1.01); } 100% { opacity: 1; transform: none; } }
@keyframes ns-zoom-badge { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
.jurisdiction.is-located { animation: ns-pop 420ms cubic-bezier(.2,.8,.2,1); }
.tag.is-zoom { display: inline-block; animation: ns-zoom-badge 520ms cubic-bezier(.2,.9,.3,1.3); }
@keyframes ns-address-glow { 0% { box-shadow: 0 0 0 0 rgba(30, 91, 66, 0.45); } 100% { box-shadow: 0 0 0 14px rgba(30, 91, 66, 0); } }
#property-address.is-located { animation: ns-address-glow 800ms ease-out; border-color: var(--green); }
.address-map { height: 0; overflow: hidden; border-radius: var(--radius-sm); border: 1px solid var(--rule); margin-top: 0.6rem; transition: height 480ms cubic-bezier(.2,.8,.2,1), opacity 300ms; opacity: 0; position: relative; }
.address-map.is-open { height: 220px; opacity: 1; }
.address-map .leaflet-container { height: 100%; width: 100%; font: inherit; }
.address-map .map-caption { position: absolute; left: 0.6rem; bottom: 0.5rem; z-index: 500; background: rgba(255,255,255,0.92); border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.8rem; font-weight: 600; color: var(--green); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
@keyframes ns-pin-drop { 0% { transform: translateY(-40px); opacity: 0; } 70% { transform: translateY(4px); opacity: 1; } 100% { transform: none; } }
.address-map .leaflet-marker-icon { animation: ns-pin-drop 600ms cubic-bezier(.2,.8,.2,1) both; }
@media (prefers-reduced-motion: reduce) { .input.is-filled, .jurisdiction.is-located, .tag.is-zoom, #property-address.is-located, .address-map .leaflet-marker-icon { animation: none; } .address-map { transition: none; } }

/* ------------------------------------------ calculation animations (2026-09-29) */
@keyframes ns-row-changed { 0% { background: #fff6bf; } 100% { background: transparent; } }
@keyframes ns-row-new { 0% { background: var(--green-soft); transform: translateX(-4px); opacity: 0; } 30% { opacity: 1; } 100% { background: transparent; transform: none; } }
.ledger tr.is-changed td { animation: ns-row-changed 1100ms ease-out; }
.ledger tr.is-new td { animation: ns-row-new 700ms cubic-bezier(.2,.8,.2,1); }
@keyframes ns-sheet-pulse { 0% { box-shadow: 0 0 0 0 rgba(30, 91, 66, 0.35); } 100% { box-shadow: 0 0 0 16px rgba(30, 91, 66, 0); } }
.result-sheet.is-calculating { animation: ns-sheet-pulse 700ms ease-out; }
@keyframes ns-count { 0% { color: var(--green); transform: scale(1.04); } 100% { color: inherit; transform: none; } }
.ledger .total td:last-child span.is-counting, .subtotal td.is-counting { display: inline-block; animation: ns-count 500ms ease-out; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .ledger tr.is-changed td, .ledger tr.is-new td, .result-sheet.is-calculating, .is-counting { animation: none; } }
