/* =====================================================================
   Rupeevalley — calculator styles
   ===================================================================== */

.calc-section { padding-top: clamp(40px, 5vw, 64px); }
.calc-shell {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow);
  overflow: hidden;
}
.calc-form { padding: clamp(22px, 3.5vw, 40px); border-right: 1px solid var(--line); }
.calc-results { padding: clamp(22px, 3.5vw, 40px); background: linear-gradient(180deg, var(--light-blue-2), #fff 60%); }

.calc-field { margin-bottom: 26px; }
.calc-field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.calc-field-head label { font-weight: 650; color: var(--navy); font-size: var(--fs-sm); }
.calc-input {
  display: flex; align-items: center; gap: 4px; flex: none;
  border: 1.5px solid var(--line-strong); border-radius: 12px; background: #fff; padding: 0 12px; min-height: 46px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.calc-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(23, 105, 232, .16); }
.calc-input .affix { color: var(--muted); font-weight: 650; }
.calc-input input[type="text"] {
  border: 0; background: transparent; width: 9.5ch; text-align: right; font-weight: 700; color: var(--navy);
  font-size: 1.05rem; padding: 8px 0; font-variant-numeric: tabular-nums;
}
.calc-input input:focus { outline: none; }
.calc-input input[aria-invalid="true"] { color: var(--error); }
.calc-field:has([aria-invalid="true"]) .calc-input { border-color: var(--error); }
.tenure-input input[type="text"] { width: 4ch; }
.unit-toggle { display: inline-flex; border: 0; margin: 0 -6px 0 6px; padding: 3px; background: var(--light-blue); border-radius: 9px; }
.unit-toggle label { position: relative; }
.unit-toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.unit-toggle span { display: block; padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--muted); transition: background-color .2s, color .2s; }
.unit-toggle input:checked + span { background: #fff; color: var(--navy); box-shadow: var(--shadow-sm); }
.unit-toggle input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }

/* Range slider */
.calc-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; cursor: pointer;
  --fill: 50%;
}
.calc-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--blue) 0 var(--fill), #DCE5F5 var(--fill) 100%);
}
.calc-range::-moz-range-track { height: 6px; border-radius: 6px; background: #DCE5F5; }
.calc-range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--blue); }
.calc-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue); box-shadow: 0 2px 8px rgba(7, 19, 79, .2);
  transition: transform .15s var(--ease);
}
.calc-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--blue); box-shadow: 0 2px 8px rgba(7, 19, 79, .2); }
.calc-range:active::-webkit-slider-thumb { transform: scale(1.15); }
.calc-range:focus-visible { outline: none; }
.calc-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(23, 105, 232, .25); }
.calc-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px rgba(23, 105, 232, .25); }
.range-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 2px; }
.calc-derived { background: var(--cream-2); border-radius: 12px; padding: 12px 14px; font-size: var(--fs-sm); margin: -8px 0 24px; }
.calc-derived strong { color: var(--navy); font-variant-numeric: tabular-nums; }

.calc-fees { border: 1px dashed var(--line-strong); border-radius: 14px; padding: 4px 16px; margin-bottom: 8px; }
.calc-fees summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 12px 0; font-weight: 650; color: var(--navy); font-size: var(--fs-sm); }
.calc-fees summary::-webkit-details-marker { display: none; }
.calc-fees[open] summary .icon { transform: rotate(45deg); }
.calc-fees summary .icon { transition: transform .25s var(--ease); color: var(--blue); }
.calc-fees .field-row { padding-bottom: 4px; }
.js .calc-submit { display: none; }

/* Results */
.calc-kicker { margin: 0; font-size: var(--fs-sm); font-weight: 650; color: var(--muted); }
.calc-hero-value { font-size: clamp(2.3rem, 1.6rem + 2.6vw, 3.4rem); font-weight: 700; color: var(--navy); letter-spacing: -.035em; line-height: 1.1; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.calc-hero-value[data-tone="good"] { color: var(--success); }
.calc-hero-value[data-tone="bad"] { color: var(--error); }
.emi-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.donut { position: relative; width: 128px; height: 128px; margin: 0; flex: none; }
.donut svg { width: 100%; height: 100%; }
.donut figcaption { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-weight: 700; color: var(--navy); font-size: 1.25rem; line-height: 1.1; }
.donut figcaption small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.result-list { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.result-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.result-list dt { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 8px; }
.result-list dd { margin: 0; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.result-list .total dt { color: var(--navy); font-weight: 650; }
.result-list .total dd { font-size: 1.15rem; }
.result-list.two-col { grid-template-columns: 1fr 1fr; column-gap: 24px; }
.result-list.two-col > div { flex-direction: column; gap: 2px; }
.key { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.key-principal { background: var(--blue); }
.key-interest { background: var(--yellow); }
.assumptions { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.assumptions li { font-size: 12.5px; color: var(--muted); padding-left: 16px; position: relative; line-height: 1.5; }
.assumptions li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }

.bt-bars { display: grid; gap: 10px; margin: 18px 0 20px; }
.bt-bar { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.bt-track { height: 14px; border-radius: 8px; background: #E9EEF8; overflow: hidden; }
.bt-track .bar-fill { display: block; height: 100%; border-radius: 8px; }
.bar-fill.cur { background: var(--navy); }
.bar-fill.new { background: var(--blue-bright); }

/* Amortisation */
.amort { margin-top: 22px; border-top: 1px solid var(--line); }
.amort > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 16px 0 6px; font-weight: 650; color: var(--blue); font-size: var(--fs-sm); }
.amort > summary::-webkit-details-marker { display: none; }
.amort-table { max-height: 420px; overflow: auto; margin-top: 8px; }
.amort-table table { font-size: 13px; min-width: 620px; }
.amort-table thead th { position: sticky; top: 0; z-index: 1; }
.amort-table td, .amort-table th { white-space: nowrap; font-variant-numeric: tabular-nums; }
.amort-table td { text-align: right; }
.year-row { background: #fff; }
.year-row th, .year-row td { font-weight: 650; color: var(--navy); }
.month-rows tr { background: var(--light-blue-2); }
.month-rows th { font-weight: 500; color: var(--muted); padding-left: 34px !important; }
.year-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font-weight: 700; color: var(--navy); }
.year-toggle .icon { transition: transform .25s var(--ease); color: var(--blue); }
.year-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }

.calc-disclaimer { display: flex; gap: 10px; align-items: flex-start; margin: 18px 4px 0; font-size: var(--fs-xs); color: var(--muted); }
.calc-disclaimer .icon { color: var(--blue); margin-top: 1px; }
.calc-faq { margin-top: 32px; }

/* Calculator directory */
.calc-directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.calc-directory .calc-card { flex-direction: row; align-items: center; gap: 18px; padding: 24px; }
.calc-directory .calc-card .mini-bars { display: none; }
.calc-directory .dir-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--light-blue); color: var(--blue); flex: none; }

@media (max-width: 980px) {
  .calc-shell { grid-template-columns: 1fr; }
  .calc-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .calc-directory { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .calc-shell { border-radius: var(--r-lg); }
  .calc-field-head { flex-direction: column; align-items: stretch; }
  .calc-input input[type="text"] { width: 100%; text-align: left; }
  .emi-top { flex-direction: column; align-items: flex-start; }
  .donut { width: 110px; height: 110px; align-self: center; }
  .result-list.two-col { grid-template-columns: 1fr; }
  .bt-bar { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------------------------------------------- Calculating / settling states */
.calc-results { position: relative; }
.calc-status {
  position: absolute; left: 0; right: 0; top: 0; height: 0; display: flex; justify-content: flex-end;
  pointer-events: none; z-index: 2;
}
.calc-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; overflow: hidden; opacity: 0; transition: opacity .2s var(--ease); }
.calc-progress span { position: absolute; top: 0; bottom: 0; width: 38%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--blue-bright), var(--blue), transparent); }
.calc-status-label {
  margin: 12px 14px 0 0; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: #fff; color: var(--blue-deep); font-size: 12px; font-weight: 700; box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(-4px); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.calc-dots { display: inline-flex; gap: 3px; }
.calc-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .3; }
.is-calculating .calc-progress, .is-calculating .calc-status-label { opacity: 1; transform: none; }
/* Figures currently shown are from the previous inputs: dim them until the new result lands. */
.calc-results [data-results-body] { transition: opacity .2s var(--ease); }
.calc-results.is-calculating [data-results-body] [data-out], .calc-results.is-calculating .donut { opacity: .45; transition: opacity .15s var(--ease); }
[data-out] { transition: opacity .25s var(--ease), color .3s var(--ease); }
[data-out].is-tweening { color: var(--blue-deep); }
.calc-hero-value[data-tone="good"].is-tweening { color: var(--success); }
.calc-hero-value[data-tone="bad"].is-tweening { color: var(--error); }
.calc-field.is-changing .calc-input, .field.is-changing input { box-shadow: 0 0 0 4px rgba(45, 131, 246, .22); border-color: var(--blue); }

/* ------------------------------------------------------------ Reach out CTA */
.reach-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 20px; padding: 18px 20px; border-radius: 18px;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-3) 100%); color: var(--muted-light);
}
.reach-copy { display: grid; gap: 2px; flex: 1 1 220px; }
.reach-copy strong { color: #fff; font-size: 1.02rem; }
.reach-copy span { font-size: 13px; }
.reach-btn .icon { transition: transform .2s var(--ease); }
.reach-btn:hover .icon { transform: translateX(3px); }
.reach-btn[aria-disabled="true"] { opacity: .6; cursor: progress; }
.reach-btn[aria-busy="true"] { cursor: progress; }

/* ------------------------------------------------------------- Reach dialog */
.reach-modal {
  width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--r-lg);
  background: #fff; color: var(--text); box-shadow: var(--shadow-lg); overflow: auto; overscroll-behavior: contain;
}
.reach-modal::backdrop { background: rgba(7, 19, 79, .55); backdrop-filter: blur(3px); }
.reach-inner { position: relative; padding: clamp(22px, 4vw, 34px); }
.reach-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--navy); display: grid; place-items: center; }
.reach-close:hover { background: var(--light-blue); }
.reach-snapshot { margin: 16px 0 20px; padding: 14px 16px; border-radius: 14px; background: var(--light-blue-2); border: 1px solid #D6E3FB; }
.reach-snapshot-title { margin: 0 0 8px; font-weight: 700; color: var(--navy); font-size: 14px; }
.reach-snapshot dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.reach-snapshot dl div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; border-bottom: 1px dashed #D6E3FB; padding-bottom: 5px; }
.reach-snapshot dt { color: var(--muted); }
.reach-snapshot dd { margin: 0; font-weight: 700; color: var(--navy); text-align: right; font-variant-numeric: tabular-nums; }
body.modal-open { overflow: hidden; }
@media (max-width: 640px) {
  .reach-snapshot dl { grid-template-columns: 1fr; }
  .reach-cta { padding: 16px; }
  .reach-cta .btn { width: 100%; }
  .calc-status-label { margin-right: 8px; }
}
