/* ============================================================
   OPM.LLC — calculators.css
   Shared styles for all calculator pages (/calculators/*.html).
   Extends style.css — never duplicates its variables or resets.
   Linked AFTER style.css in every calculator HTML file:
     <link rel="stylesheet" href="../css/style.css">
     <link rel="stylesheet" href="../css/calculators.css">

   Sections:
     1.  Page wrapper & intro copy
     2.  Card container
     3.  Field groups & labels
     4.  Input row, dollar/pct/short inputs
     5.  Checkbox groups
     6.  Notes & error messages
     7.  Calculate button
     8.  Output section
     9.  DSCR color reference (applied by JS)
     10. Responsive — 480px, 640px
     11. Cost-as-percent-of-ARV color reference (applied by JS)
     12. Index card note
   ============================================================ */


/* ============================================================
   1. PAGE WRAPPER & INTRO COPY
   Constrains the card width and gives breathing room above
   and below. Max-width keeps line lengths readable on wide
   screens without centering the card unnaturally narrow.
   ============================================================ */

.calc-page {
  padding: 1.5rem 1rem 3rem;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
}

.calc-intro {
  margin-bottom: 1.5rem;
}

.calc-intro p {
  font-size: 0.92rem;
  color: var(--text-body);
  line-height: 1.65;
  margin-bottom: 0.6rem;
}

.calc-intro strong { color: var(--text-dark); }


/* ============================================================
   2. CARD CONTAINER
   White card, site-standard shadow and radius.
   overflow:hidden prevents any child from bleeding outside.
   ============================================================ */

.calc-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1rem;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
}

.calc-divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 1.25rem 0;
}


/* ============================================================
   3. FIELD GROUPS & LABELS
   .calc-field = one label + its input block.
   Mobile default: stacked column.
   640px+: label left (fixed width), input fills remainder.
   ============================================================ */

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

.calc-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--teal-dark);
}

.calc-sublabel {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  padding-left: 0.5rem;
}

/* Right-side slot — holds input row + side note */
.calc-field-right {
  width: 100%;
  box-sizing: border-box;
}

/* Monthly/annual equivalent shown after Calculate */
.calc-side-note {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.2rem;
}

.calc-side-note span {
  color: var(--teal-dark);
  font-weight: 700;
}


/* ============================================================
   4. INPUT ROW & INPUTS
   .calc-input-row uses flex (not inline-flex) so it stays
   fully contained within the card width.
   Dollar inputs fill available space; pct and short are
   capped narrower but never exceed their container.
   Cream background (#fffff0) is a locked design decision.
   Spinner arrows removed on all number inputs.
   ============================================================ */

.calc-input-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  box-sizing: border-box;
}

.calc-input {
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: right;
  padding: 0.55rem 0.6rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fffff0;
  color: var(--text-dark);
  outline: none;
  min-width: 0;          /* critical: allows flex children to shrink below content size */
  flex: 1;               /* fills available space in the row */
  max-width: 160px;      /* sized for 9-digit amounts: 222,222,222.22 */
  box-sizing: border-box;
  transition: border-color var(--transition);
  -moz-appearance: textfield;
}

.calc-input::-webkit-inner-spin-button,
.calc-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.calc-input:focus {
  border-color: var(--teal-primary);
  background: var(--white);
}

/* Percent fields — narrower, don't let them flex-grow as wide */
.calc-input.pct {
  flex: 0 0 80px;
  max-width: 80px;
}

/* Short numeric — Loan Term, Interest Rate */
.calc-input.short {
  flex: 0 0 70px;
  max-width: 70px;
}

/* $ prefix and %, Years suffix */
.calc-prefix,
.calc-suffix {
  font-size: 0.88rem;
  color: var(--gray-400);
  flex-shrink: 0;
}

/* [or] separator between dollar and pct in Loan/Down row */
.calc-or {
  font-size: 0.75rem;
  color: var(--gray-400);
  flex-shrink: 0;
  white-space: nowrap;
}


/* ============================================================
   5. CHECKBOX GROUPS
   Mutually exclusive pairs: Loan/Down, Amortized/IO.
   Wraps on very narrow screens so nothing gets clipped.
   ============================================================ */

.calc-cb-group {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.calc-cb-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--text-body);
  cursor: pointer;
}

.calc-cb-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal-primary);
  cursor: pointer;
  flex-shrink: 0;
}


/* ============================================================
   6. NOTES & ERROR MESSAGES
   Notes are small, muted, below checkbox groups.
   Errors are hidden by default; JS adds .visible to show.
   ============================================================ */

.calc-notes {
  margin-top: 0.5rem;
}

.calc-note {
  font-size: 0.75rem;
  color: var(--gray-400);
  line-height: 1.5;
  margin-bottom: 0.2rem;
}

.calc-error {
  font-size: 0.78rem;
  color: #c0392b;
  margin-top: 0.35rem;
  display: none;
}

.calc-error.visible { display: block; }


/* ============================================================
   7. CALCULATE BUTTON
   Full width on mobile — large tap target.
   Teal, site-standard.

   Manual trigger is the default across the calculator family.
   Documented exception: calculators with no either/or input
   pairs autocalculate instead, and carry no .calc-btn at all.
   Rehab MAO is the first of these. Every calculator states
   which behavior it uses on its index card.

   .calc-btn-secondary — ghost variant for Reset and for
   handoff links that are not yet available.
   .calc-btn-row       — stacks buttons on mobile, side by
                         side from 480px up.
   ============================================================ */

.calc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--teal-dark);
  color: var(--white);
  border: none;
  cursor: pointer;
  margin-top: 1rem;
  box-sizing: border-box;
  transition: background var(--transition), transform 0.08s;
}

.calc-btn:hover  { background: var(--teal-darkest); }
.calc-btn:active { transform: scale(0.98); }

/* Ghost variant — Reset, and handoff links that are not live yet */
.calc-btn-secondary {
  background: transparent;
  color: var(--teal-dark);
  border: 1.5px solid var(--gray-200);
}

.calc-btn-secondary:hover {
  background: var(--teal-pale);
  color: var(--teal-darkest);
}

/* Disabled handoff — no target page built yet, or MAO is not valid */
.calc-btn[aria-disabled="true"],
.calc-btn-secondary[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button row — stacked on mobile, side by side from 480px */
.calc-btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.calc-btn-row .calc-btn { margin-top: 0; }

@media (min-width: 480px) {
  .calc-btn-row { flex-direction: row; }
  .calc-btn-row .calc-btn { flex: 1; }
}

/* Anchor styled as a button — keeps text centered and undecorated */
a.calc-btn { text-decoration: none; }


/* ============================================================
   8. OUTPUT SECTION
   Hidden until JS adds .visible after Calculate Now.
   Teal rule separates inputs from results visually.

   Sub-components:
     .dscr-result-block  — large DSCR number + equation line
     .calc-table         — two-column label/value rows
     .calc-disclaimer    — small legal copy at bottom
   ============================================================ */

.calc-output {
  display: none;
  margin-top: 1.5rem;
  border-top: 2px solid var(--teal-pale);
  padding-top: 1.25rem;
}

.calc-output.visible { display: block; }

/* DSCR big number block */
.dscr-result-block { margin-bottom: 1.25rem; }

.dscr-result-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--teal-primary);
  margin-bottom: 0.2rem;
}

.dscr-result-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Color set by JS — see Section 9 */
.dscr-number {
  font-family: var(--font-heading);
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
}

.dscr-pipe {
  font-size: 1.4rem;
  color: var(--gray-200);
  font-weight: 300;
}

.dscr-equation {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* Output tables — PITIA breakdown and Loan Summary */
.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

.calc-table td {
  padding: 0.3rem 0;
  color: var(--text-body);
  vertical-align: top;
}

.calc-table td:last-child {
  text-align: right;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  padding-left: 0.5rem;
}

/* Rent and PITIA summary rows */
.calc-table .tbl-summary td {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

/* Section header rows */
.calc-table .tbl-head td {
  font-size: 0.63rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--teal-primary);
  padding-top: 0.9rem;
  padding-bottom: 0.2rem;
}

/* Muted detail rows */
.calc-table .tbl-detail td            { color: var(--gray-600); }
.calc-table .tbl-detail td:last-child { color: var(--gray-600); font-weight: 400; }

/* ---- Live results ----
   Calculators that autocalculate show results inline rather
   than inside .calc-output. The block is always visible; its
   values sit empty until enough inputs are present. */

.calc-live {
  margin: 0.25rem 0 1.1rem;
  padding-left: 0.5rem;
}

.calc-live-lead {
  font-size: 0.88rem;
  font-style: italic;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}

/* Headline number — the one figure the page exists to produce */
.calc-headline {
  margin: 1rem 0 0.5rem;
  text-align: center;
}

.calc-headline-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--teal-primary);
  margin-bottom: 0.25rem;
}

.calc-headline-value {
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--teal-dark);
  word-break: break-word;
}

.calc-headline-sub {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 0.15rem;
}

/* Show-the-math line — wraps rather than overflows on narrow screens */
.calc-math {
  font-size: 0.78rem;
  color: var(--gray-400);
  line-height: 1.7;
  margin-top: 0.4rem;
  overflow-wrap: break-word;
}

/* Guard message — negative MAO, already under the max, and similar */
.calc-flag {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--teal-pale);
  border-left: 3px solid var(--teal-primary);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  display: none;
}

.calc-flag.visible { display: block; }

/* Legal disclaimer below output */
.calc-disclaimer {
  font-size: 0.72rem;
  color: var(--gray-400);
  line-height: 1.5;
  margin-top: 1.25rem;
  border-top: 1px solid var(--gray-200);
  padding-top: 0.75rem;
}


/* ============================================================
   9. DSCR COLOR REFERENCE
   These values are applied inline by JS — not as CSS classes —
   because the color depends on a calculated number at runtime.
   Documented here as the single source of truth.
   Keep the JS color blocks in every calculator in sync with this.

   < 0.750      #8B0000   dark red    — well below coverage
   0.750–0.999  #996600   dark yellow — below coverage
   1.000–1.200  #3a7d44   light green — at/just above breakeven
   1.201–1.499  #2d6a35   medium green — solid coverage
   1.500+       #1a4a25   dark green  — strong coverage
   ============================================================ */


/* ============================================================
   10. RESPONSIVE
   Mobile is the default above.
   480px: inputs breathe a little more.
   640px: switch to side-by-side label/input layout.
   ============================================================ */

@media (min-width: 480px) {
  .calc-page { padding: 1.5rem 1.25rem 3rem; }
  .calc-card { padding: 1.5rem 1.25rem; }
  .calc-input { max-width: 160px; }   /* holds at 9-digit width on wider screens too */
}

@media (min-width: 640px) {
  .calc-card { padding: 2rem 1.75rem; }

  .calc-field {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
  }

  .calc-label,
  .calc-sublabel {
    width: 170px;
    min-width: 170px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 1rem;
    padding-top: 0.6rem;
    padding-left: 0;
  }

  .calc-field-right { flex: 1; min-width: 0; }
}

/* ============================================================
   11. COST-AS-PERCENT-OF-ARV COLOR REFERENCE
   Applied inline by JS — see costArvColor() in calculators.js.
   Reuses the Section 9 palette so the calculator family reads
   consistently. Documented here as the single source of truth.

   < 70.00%        #1a4a25   dark green   — strong basis
   70.00–74.99%    #3a7d44   light green  — normal flip territory
   75.00–80.00%    #996600   dark yellow  — tight; workable on a
                                            DSCR refinance exit
   > 80.00%        #8B0000   dark red     — most lenders decline
   ============================================================ */


/* ============================================================
   12. INDEX CARD NOTE
   Small line on a .subtype-card in calculators.html stating
   whether the tool autocalculates or needs Calculate Now.
   calculators.html must link calculators.css for this to apply.
   ============================================================ */

/* Scoped to .subtype-card so it outranks `.subtype-card p` in style.css */

.subtype-card .sc-note {
  font-size: 0.7rem;
  font-style: italic;
  color: var(--gray-400);
  margin-top: 0.3rem;
}


/* ============================================================
   END: calculators.css
   ============================================================ */
