/* Total Trust Home Loans — HELOC vs Mortgage explainer page.
   Additive only: this file never overrides styles.css, it extends it.
   Inherits --navy #113a5c, --sky #3f93d1, Manrope/Inter from styles.css. */

:root {
  --good: #1e6b3a;
  --good-soft: #eaf5ee;
  --warn: #a3401e;
  --warn-soft: #fdf0ea;
  --bad: #a31e1e;
  --bad-soft: #fceaea;
}

/* ---------- page hero ---------- */
.ex-hero {
  background: linear-gradient(170deg, var(--navy-deep) 0%, var(--navy) 62%, #17507c 100%);
  color: #fff;
  padding: var(--band) 0;
}
.ex-hero h1 { color: #fff; max-width: 22ch; }
.ex-hero .eyebrow { color: #8fc4ea; }
.ex-hero .lede {
  font-size: clamp(1.02rem, 1.9vw, 1.2rem);
  color: #dbe9f5; max-width: 62ch; margin-top: 1rem;
}
.ex-hero .accent { color: #7dc0ee; }

/* ---------- reading-level rail ---------- */
.levels {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin: 1.7rem 0 0;
}
.levels a {
  font-family: var(--font-head); font-weight: 700; font-size: .78rem;
  letter-spacing: .04em; text-transform: uppercase;
  color: #cfe4f4; border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px; padding: .42rem .85rem; text-decoration: none;
}
.levels a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }

/* ---------- level badge ---------- */
.lvl {
  display: inline-flex; align-items: baseline; gap: .55rem;
  font-family: var(--font-head); font-weight: 800; font-size: .74rem;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--sky); margin-bottom: .55rem;
}
.lvl .lvl-num {
  background: var(--sky); color: #fff; border-radius: 6px;
  padding: .16rem .48rem; font-size: .72rem; letter-spacing: .06em;
}
.lvl.is-deep { color: var(--muted); }
.lvl.is-deep .lvl-num { background: var(--navy); }

.ex-section { padding: var(--band) 0; border-top: 1px solid var(--line); }
.ex-section:nth-of-type(even) { background: var(--bg-alt); }
.ex-section > .container > h2 { margin-bottom: .9rem; }
.ex-lede { font-size: 1.08rem; color: var(--muted); max-width: 70ch; margin-bottom: 1.5rem; }

/* ---------- plain-English cards ---------- */
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 780px) { .two-up { grid-template-columns: 1fr; } }

.thing {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad-card); box-shadow: var(--shadow);
}
.thing h3 { font-size: 1.25rem; margin-bottom: .1rem; }
.thing .thing-sub {
  font-family: var(--font-head); font-weight: 700; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .09em; color: var(--sky);
  margin-bottom: .9rem;
}
.thing p { margin-bottom: .8rem; }
.thing p:last-child { margin-bottom: 0; }
.thing .plain {
  background: var(--sky-soft); border-left: 4px solid var(--sky);
  border-radius: 0 8px 8px 0; padding: .85rem 1rem; font-size: .97rem;
}
.thing .plain strong { color: var(--navy); }

/* ---------- callouts ---------- */
.note {
  border-left: 5px solid var(--sky); background: var(--sky-soft);
  border-radius: 0 10px 10px 0; padding: var(--s-3) var(--s-4); margin: var(--s-4) 0;
}
.note.good { border-color: var(--good); background: var(--good-soft); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad  { border-color: var(--bad);  background: var(--bad-soft); }
.note .note-title {
  font-family: var(--font-head); font-weight: 800; font-size: .78rem;
  letter-spacing: .11em; text-transform: uppercase; color: var(--navy);
  margin-bottom: .4rem;
}
.note.good .note-title { color: var(--good); }
.note.warn .note-title { color: var(--warn); }
.note.bad  .note-title { color: var(--bad); }
.note p:last-child { margin-bottom: 0; }

/* ---------- big number strip ---------- */
.bignums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; margin: 1.6rem 0; }
@media (max-width: 780px) { .bignums { grid-template-columns: 1fr; } }
.bignum {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s-4) var(--s-3); text-align: center;
}
.bignum .bn-fig {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.05; letter-spacing: -.02em;
}
.bignum .bn-fig.is-bad { color: var(--bad); }
.bignum .bn-fig.is-good { color: var(--good); }
.bignum .bn-label { font-size: .9rem; color: var(--muted); margin-top: .45rem; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 1.3rem 0; }
table.ex {
  width: 100%; border-collapse: collapse; font-size: .95rem;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; min-width: 560px;
}
table.ex thead th {
  background: var(--navy); color: #fff; text-align: left;
  font-family: var(--font-head); font-weight: 700; font-size: .84rem;
  letter-spacing: .04em; padding: .72rem .85rem;
}
table.ex td { padding: .68rem .85rem; border-top: 1px solid var(--line); vertical-align: top; }
table.ex tbody tr:nth-child(even) { background: var(--bg-alt); }
table.ex tr.row-good td { background: var(--good-soft); }
table.ex tr.row-bad  td { background: var(--bad-soft); }
table.ex td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.ex .win { color: var(--good); font-weight: 700; }
table.ex .lose { color: var(--bad); font-weight: 700; }

/* ---------- calculator ---------- */
.calcbox {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--pad-card); margin-top: var(--s-3);
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem 1.2rem; }
@media (max-width: 860px) { .calc-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .calc-grid { grid-template-columns: 1fr; } }
.calc-grid label {
  display: block; font-family: var(--font-head); font-weight: 700;
  font-size: .82rem; color: var(--navy); margin-bottom: .32rem;
}
.calc-grid .fld small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }
.calc-grid input {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 9px; font: inherit; font-size: .98rem; color: var(--ink);
  font-variant-numeric: tabular-nums; background: #fff;
}
.calc-grid input:focus { outline: 2px solid var(--sky); outline-offset: 1px; border-color: var(--sky); }
.calc-out { margin-top: 1.5rem; }
.verdict {
  border-radius: 12px; padding: 1.1rem 1.25rem; margin-bottom: 1.2rem;
  font-size: 1.04rem; border-left: 5px solid var(--navy); background: var(--sky-soft);
}
.verdict strong { color: var(--navy); }
.verdict.good { border-color: var(--good); background: var(--good-soft); }
.verdict.bad  { border-color: var(--bad);  background: var(--bad-soft); }
.calc-note { font-size: .86rem; color: var(--muted); margin-top: .9rem; }

/* ---------- formulas ---------- */
details.math {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  margin: 1rem 0; overflow: hidden;
}
details.math > summary {
  cursor: pointer; list-style: none; padding: .95rem 1.2rem;
  font-family: var(--font-head); font-weight: 700; color: var(--navy);
  background: var(--bg-alt); display: flex; align-items: center; gap: .6rem;
}
details.math > summary::-webkit-details-marker { display: none; }
details.math > summary::before {
  content: "+"; font-size: 1.15rem; line-height: 1; color: var(--sky);
  font-weight: 800; width: 1rem; display: inline-block;
}
details.math[open] > summary::before { content: "\2013"; }
details.math > summary:hover { background: var(--sky-soft); }
.math-body { padding: 1.1rem 1.2rem 1.3rem; }
pre.formula {
  background: #0c2b45; color: #dbe9f5; border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto; font-size: .87rem; line-height: 1.55;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  margin: .7rem 0;
}
pre.formula .c { color: #7fb6dd; }
.math-body p { margin-bottom: .7rem; }
.math-body p:last-child { margin-bottom: 0; }

/* ---------- who it's for ---------- */
.fit { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 780px) { .fit { grid-template-columns: 1fr; } }
.fit ul { list-style: none; }
.fit li { padding-left: 1.6rem; position: relative; margin-bottom: .55rem; }
.fit li::before {
  position: absolute; left: 0; top: -.05rem; font-weight: 800;
  font-family: var(--font-head);
}
.fit .yes li::before { content: "\2713"; color: var(--good); }
.fit .no li::before { content: "\2715"; color: var(--bad); }

/* ---------- disclaimer ---------- */
.disclaimer {
  font-size: .84rem; color: var(--muted); background: var(--bg-alt);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad-card); margin-top: var(--s-5);
}
.disclaimer strong { color: var(--navy); }
.disclaimer p { margin-bottom: .6rem; }
.disclaimer p:last-child { margin-bottom: 0; }

/* ---------- final CTA ---------- */
.ex-cta { background: var(--navy); color: #fff; padding: var(--band) 0; text-align: center; }
.ex-cta h2 { color: #fff; }
.ex-cta p { color: #cfe0ee; max-width: 58ch; margin: 0 auto 1.5rem; }
.ex-cta .btn-ghost { border-color: #fff; color: #fff; }
.ex-cta .btn-ghost:hover { background: #fff; color: var(--navy); }
.ex-cta-btns { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

/* =====================================================================
   SCROLL EFFECTS & RHYTHM POLISH
   Reuses the .reveal / .is-visible vocabulary already used on the home
   page so both pages animate identically. heloc.js runs its own observer
   rather than relying on main.js, which only wires home-page selectors.
   ===================================================================== */

/* consistent vertical rhythm inside every section */
.ex-section > .container > * + * { margin-top: var(--s-3); }
.ex-section > .container > h2 { margin-top: 0; margin-bottom: var(--s-2); }
.ex-section > .container > .lvl { margin-bottom: var(--s-1); }
.ex-section > .container > .ex-lede { margin-bottom: var(--s-4); }
.ex-section > .container > h3 { margin-top: var(--s-5); }
.two-up { gap: var(--s-3); margin-top: var(--s-4); }
.bignums { gap: var(--s-3); margin: var(--s-4) 0; }
.tbl-wrap { margin: var(--s-4) 0; }
.fit { gap: var(--s-3); margin-top: var(--s-4); }
details.math { margin: var(--s-2) 0; }
.calc-out { margin-top: var(--s-5); }
.verdict { padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); }
.math-body { padding: var(--s-3) var(--s-4) var(--s-4); }

/* heading underline sweep, matching .section h2::after on the home page */
.ex-section h2 { position: relative; }
.ex-section > .container > h2::after {
  content: ""; display: block; height: 4px; width: 0; margin-top: .6rem;
  border-radius: 2px; background: linear-gradient(90deg, var(--sky), var(--navy));
  transition: width .7s ease .15s;
}
.ex-section.is-visible > .container > h2::after { width: 84px; }

/* reveal-on-scroll */
.js-anim .ex-reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
  transition-delay: var(--d, 0s);
}
.js-anim .ex-reveal.is-visible { opacity: 1; transform: none; }
/* Failsafe: if the observer never fires (throttled/background tab, odd browser),
   this class is set by a timer and forces everything back into view. */
.ex-reveal-off .ex-reveal,
.ex-reveal-off .ex-hero .eyebrow,
.ex-reveal-off .ex-hero h1,
.ex-reveal-off .ex-hero .lede,
.ex-reveal-off .ex-hero .levels,
.ex-reveal-off table.ex tbody tr.row-in {
  opacity: 1 !important; transform: none !important; animation: none !important;
}

/* hero entrance */
.js-anim .ex-hero .eyebrow, .js-anim .ex-hero h1,
.js-anim .ex-hero .lede, .js-anim .ex-hero .levels {
  animation: exRise .7s cubic-bezier(.22,.9,.3,1) both;
}
.ex-hero h1     { animation-delay: .06s; }
.ex-hero .lede  { animation-delay: .14s; }
.ex-hero .lede + .lede { animation-delay: .2s; }
.ex-hero .levels{ animation-delay: .28s; }
@keyframes exRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* reading-progress bar */
.ex-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--sky), #7dc0ee);
  z-index: 60; transition: width .1s linear;
}

/* sticky level rail — shows where you are in the 8 levels */
.ex-rail {
  position: fixed; right: max(1.1rem, 2vw); top: 50%; transform: translateY(-50%);
  z-index: 40; display: flex; flex-direction: column; gap: .55rem;
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
.ex-rail.is-on { opacity: 1; pointer-events: auto; }
.ex-rail a {
  display: flex; align-items: center; gap: .5rem; justify-content: flex-end;
  text-decoration: none; color: var(--muted); font-size: .72rem;
  font-family: var(--font-head); font-weight: 700;
}
.ex-rail .rail-label {
  opacity: 0; transform: translateX(6px); transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap; background: var(--navy); color: #fff;
  padding: .2rem .5rem; border-radius: 5px; font-size: .68rem;
}
.ex-rail a:hover .rail-label { opacity: 1; transform: none; }
.ex-rail .rail-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #c7d3de;
  transition: background .25s ease, transform .25s ease; flex: none;
}
.ex-rail a.is-current .rail-dot { background: var(--sky); transform: scale(1.5); }
@media (max-width: 1100px) { .ex-rail { display: none; } }

/* table rows fade in as the calculator repaints */
table.ex tbody tr.row-in { animation: exRowIn .35s ease both; }
@keyframes exRowIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* the calm version of all of the above */
@media (prefers-reduced-motion: reduce) {
  .js-anim .ex-reveal { opacity: 1; transform: none; transition: none; }
  .ex-hero .eyebrow, .ex-hero h1, .ex-hero .lede, .ex-hero .levels { animation: none; }
  .ex-section > .container > h2::after { width: 84px; transition: none; }
  .ex-progress { display: none; }
  .ex-rail { transition: none; }
  table.ex tbody tr.row-in { animation: none; }
  html { scroll-behavior: auto; }
}
