/* Finance with Baba: ink + amber napkin style, mobile first */
:root {
  --ink: #25231f; --amber: #dda13c; --amber-soft: #f3d79b; --paper: #f7f1e3; --napkin: #fffaf0;
  --pencil: #6f685e; --rule: #e3d8c2;
  --gA: #25231f; --gB: #5b5347; --gC: #a39478; --gD: #ecc779; --gF: #dda13c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, .hand { font-family: "Patrick Hand", "Comic Sans MS", cursive; font-weight: 400; line-height: 1.15; }
h1 { font-size: clamp(2rem, 7vw, 3rem); margin: 0.2em 0 0.15em; }
h2 { font-size: clamp(1.6rem, 5vw, 2.1rem); margin: 1.6em 0 0.4em; }
h3 { font-size: 1.35rem; margin: 0 0 0.3em; }
a { color: var(--ink); text-decoration-color: var(--amber); text-decoration-thickness: 3px; text-underline-offset: 3px; }
main { max-width: 960px; margin: 0 auto; padding: 8px 16px 48px; }
.nav { max-width: 960px; margin: 0 auto; padding: 12px 16px 0; display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.nav .brand { font-family: "Patrick Hand", cursive; font-size: 1.4rem; text-decoration: none; margin-right: auto; }
.nav a { font-size: 1rem; }
.lead { font-size: 1.15rem; color: var(--pencil); margin: 0 0 1em; }
.muted { color: var(--pencil); }
.small { font-size: 0.9rem; }
.card { background: var(--napkin); border: 2.5px solid var(--ink); border-radius: 14px 10px 16px 9px; padding: 16px; box-shadow: 4px 5px 0 rgba(37,35,31,0.08); }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.card { min-width: 0; }
@media (min-width: 680px) { .grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.btn { display: inline-block; font-family: "Patrick Hand", cursive; font-size: 1.25rem; color: var(--ink); text-decoration: none; border: 2.5px solid var(--ink); border-radius: 12px; padding: 6px 16px; background: var(--napkin); box-shadow: 3px 3px 0 var(--amber); cursor: pointer; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--napkin); }
.footer { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; border-top: 2px dashed var(--rule); color: var(--pencil); font-size: 0.92rem; }

/* grade letters */
.grade { display: inline-flex; align-items: center; justify-content: center; font-family: "Patrick Hand", cursive; border-radius: 10px; border: 2.5px solid var(--ink); }
.g-A { background: var(--gA); color: var(--napkin); }
.g-B { background: var(--gB); color: var(--napkin); }
.g-C { background: var(--gC); color: var(--ink); }
.g-D { background: var(--gD); color: var(--ink); }
.g-F { background: var(--gF); color: var(--ink); }

/* tile map */
.tiles { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; margin: 8px auto; max-width: 660px; }
.tile { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; border: 2px solid var(--ink); border-radius: 7px; font-family: "Patrick Hand", cursive; line-height: 1; transition: transform .15s; }
.tile:hover, .tile:focus { transform: scale(1.12); z-index: 1; position: relative; }
.tile .ab { font-size: clamp(0.55rem, 1.9vw, 0.95rem); opacity: 0.9; }
.tile .lt { font-size: clamp(0.9rem, 3.6vw, 1.7rem); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 0.95rem; }
.legend .grade { width: 28px; height: 28px; font-size: 1.1rem; margin-right: 4px; }
.toggle { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; }

/* table */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--napkin); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; min-width: 640px; }
th, td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-family: "Patrick Hand", cursive; font-weight: 400; font-size: 1.1rem; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--napkin); }
th[aria-sort="ascending"]::after { content: " \2191"; color: var(--amber); }
th[aria-sort="descending"]::after { content: " \2193"; color: var(--amber); }
td .grade { width: 30px; height: 30px; font-size: 1.15rem; }
tr:hover td { background: #fbf2dc; }

/* state report card */
.hero-grade { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero-grade .grade.big { width: 110px; height: 110px; font-size: 4.6rem; border-width: 4px; border-radius: 18px; }
.hero-grade .was { font-family: "Patrick Hand", cursive; font-size: 1.35rem; }
.hero-grade .was .grade { width: 40px; height: 40px; font-size: 1.6rem; vertical-align: middle; }
.num { font-family: "Patrick Hand", cursive; font-size: 2.2rem; line-height: 1.1; }
.num .arrow { color: var(--amber); padding: 0 6px; }
.bars svg { width: 100%; height: auto; display: block; }
.note { font-size: 0.92rem; color: var(--pencil); margin: 6px 0 0; }
.signals { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.signals li { counter-increment: s; padding-left: 46px; position: relative; }
.signals li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border: 2.5px solid var(--ink); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: "Patrick Hand", cursive; font-size: 1.3rem; background: var(--amber-soft); }
.share { display: flex; gap: 10px; flex-wrap: wrap; }
.video { aspect-ratio: 16/9; width: 100%; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--napkin); display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }
.video iframe { width: 100%; height: 100%; border: 0; border-radius: 10px; }
.chart svg { width: 100%; height: auto; display: block; }
select { font: inherit; font-size: 1.05rem; padding: 6px 10px; border: 2.5px solid var(--ink); border-radius: 10px; background: var(--napkin); color: var(--ink); max-width: 100%; }

/* US grade map */
.mapwrap { margin: 4px 0 8px; }
.usmap { width: 100%; height: auto; display: block; }
.usmap .st { stroke: var(--napkin); stroke-width: 1.2; transition: opacity .15s; }
.usmap rect.st { stroke: var(--ink); stroke-width: 1.5; }
.usmap a:hover .st, .usmap a:focus .st { opacity: 0.75; }
.usmap .st.g-A { fill: var(--gA); } .usmap .st.g-B { fill: var(--gB); } .usmap .st.g-C { fill: var(--gC); }
.usmap .st.g-D { fill: var(--gD); } .usmap .st.g-F { fill: var(--gF); }
.usmap .lb { font-family: "Patrick Hand", cursive; font-size: 26px; pointer-events: none; fill: var(--ink); }
.usmap .lb.g-A, .usmap .lb.g-B { fill: var(--napkin); }


/* topics and videos */
.tgrid, .vgrid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 620px) { .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .vgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .vgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tcard, .vcard { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); transition: transform .15s; }
.tcard:hover, .vcard:hover { transform: translateY(-2px); }
.tcard .tt { font-size: 1.9rem; }
.vcard img, .vcard .soon { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; border: 2px solid var(--ink); background: var(--amber-soft); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.vcard .vt { font-size: 1.3rem; line-height: 1.2; }
.napkin { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }

/* ---------- phones ---------- */
.print-only { display: none; }
.swipe { display: none; }

@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .nav { gap: 4px 16px; padding-top: 10px; }
  .nav .brand { width: 100%; margin: 0 0 2px; font-size: 1.5rem; }
  .nav a:not(.brand) { font-size: 1.02rem; padding: 4px 0; }
  .usmap .lb { font-size: 46px; }
  .usmap .lb.co { font-size: 36px; }
  .usmap .code { font-size: 28px; }
  .video { padding: 6px; border-radius: 10px; }
  .card:has(.mapwrap) { margin: 0 -14px; padding: 10px 6px; border-radius: 12px; }
  .card:has(.mapwrap) .toggle, .card:has(.mapwrap) .legend, .card:has(.mapwrap) p { padding: 0 8px; }
  .card { padding: 14px; }
  .swipe { display: inline; }
  .hero-grade .grade.big { width: 92px; height: 92px; font-size: 3.9rem; }
  .num { font-size: 1.95rem; }
}
/* the state column stays put while the table scrolls sideways */
.tablewrap th:first-child, .tablewrap td:first-child { position: sticky; left: 0; background: var(--napkin); z-index: 1; box-shadow: 1px 0 0 var(--rule); }
.tablewrap th:first-child { z-index: 2; }
ul.small a, .note a { text-decoration-thickness: 2px; }

/* ---------- printing ---------- */
@media print {
  @page { margin: 12mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; }
  html, body { background: #fff; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .noprint, .nav, .btn, .share, .toggle, .video, iframe, #baba-hero, #pick, label[for="pick"], .swipe, .sorthint, .footer a[href*="youtube"], .vgrid, .tgrid { display: none !important; }
  .print-only { display: block; color: var(--pencil); margin: 0 0 6pt; }
  h1 { font-size: 22pt; margin-top: 0; }
  h2 { font-size: 15pt; margin: 14pt 0 6pt; break-after: avoid; }
  .card, .chart, .hero-grade, .grid > *, li, tr, .legend { break-inside: avoid; }
  .card { border-width: 1.5pt; padding: 8pt 10pt; }
  .grid { gap: 8pt; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .tablewrap { overflow: visible; border-width: 1pt; }
  table { min-width: 0; font-size: 8.5pt; }
  th, td { padding: 1.2pt 4pt; position: static !important; }
  td .grade { width: 13pt; height: 13pt; font-size: 9pt; border-width: 1pt; border-radius: 4pt; }
  th { font-size: 9.5pt; }
  a { text-decoration: none; color: var(--ink); }
  ul.small a::after { content: " \2014  " attr(href); color: var(--pencil); font-size: 8pt; word-break: break-all; }
  .footer { border-top: 1pt solid var(--rule); padding: 8pt 0 0; font-size: 8.5pt; }
  .usmap .st { stroke-width: 0.8; }
  .chart svg { max-width: 78%; margin: 0 auto; }
  .hero-grade .grade.big { width: 64pt; height: 64pt; font-size: 40pt; }
  .num { font-size: 18pt; }
  .bars svg { max-height: 60pt; }
  .footer p { margin: 2pt 0; }
}

.updated { font-size: 0.93rem; color: var(--pencil); margin: 6px 0 10px; padding: 6px 10px; border-left: 4px solid var(--amber); background: var(--napkin); border-radius: 4px; }
.updated b { color: var(--ink); font-weight: 600; }
@media print { .updated { border-left-width: 2pt; } }

/* questions a video answers */
.qtoc { padding-left: 1.3em; display: grid; gap: 6px; margin: 0 0 18px; }
.qa { margin: 0 0 16px; scroll-margin-top: 12px; }
.qa h3 { font-size: 1.45rem; }
.qa .also { font-size: 0.9rem; color: var(--pencil); margin: -2px 0 8px; font-style: italic; }
.qa .caveat, .caveat { border-left: 4px solid var(--amber); padding: 4px 10px; background: #fbf2dc; border-radius: 4px; font-size: 0.95rem; }
.qa .watch { margin: 12px 0 6px; }
.qsrc summary { cursor: pointer; color: var(--pencil); font-size: 0.92rem; }
@media print { .qa { break-inside: auto; } .qsrc { display: block; } .qsrc summary { display: none; } .qsrc ul.small a::after { content: " \2014  " attr(href); } }

/* ---------- Keep or Sell? calculator ---------- */
.presets { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.tag { font-family: "Patrick Hand", cursive; font-size: 1.2rem; margin: 6px 0 0; }
.klayout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .klayout { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); } }
.kform { display: grid; gap: 14px; }
.kform fieldset { margin: 0; min-width: 0; }
.kform legend, .kmore summary { font-size: 1.5rem; padding: 0 6px; }
.kmore summary { cursor: pointer; }
.kgrid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
.kf label, .kf .lab { display: block; font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.kin { display: flex; align-items: center; gap: 6px; }
.kin input[type=text], .kin select { font: inherit; font-size: 20px; padding: 8px 10px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.kin .u { font-size: 1.15rem; color: var(--pencil); white-space: nowrap; }
.kmon select { width: auto; flex: 1; }
.kchk label { font-weight: 500; display: flex; gap: 10px; align-items: center; font-size: 1.05rem; }
.kchk input { width: 24px; height: 24px; accent-color: var(--ink); }
.step input { text-align: center; max-width: 90px; }
.btn.sm { padding: 2px 14px; font-size: 1.4rem; }
.hint { font-size: 0.88rem; color: var(--pencil); margin: 4px 0 0; }
.err { color: #9b2c1c; font-weight: 600; font-size: 0.95rem; margin: 4px 0 0; }
.err:empty { display: none; }
#result { display: grid; gap: 14px; transition: opacity .2s; }
#result.stale { opacity: 0.4; }
#result h3 { font-size: 1.5rem; }
.khead { font-family: "Patrick Hand", cursive; font-size: clamp(1.7rem, 5.5vw, 2.3rem); line-height: 1.15; margin: 0 0 8px; }
.khead b { background: var(--amber-soft); padding: 0 4px; border-radius: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 2px solid var(--ink); border-radius: 999px; padding: 3px 12px; font-size: 0.92rem; background: var(--paper); }
.chip .grade { width: 24px; height: 24px; font-size: 1rem; border-width: 2px; border-radius: 6px; }
.kflags { border-color: #9b2c1c; background: #fff4ea; }
.kflags ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.kred { color: #7c2114; background: #fff0e6; border: 2px solid #9b2c1c; border-radius: 10px; padding: 10px 12px; }
.kbar { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; align-items: center; margin: 6px 0; }
.kbl { font-family: "Patrick Hand", cursive; font-size: 1.2rem; }
.kbt { background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; height: 26px; overflow: hidden; }
.kbf { display: block; height: 100%; background: var(--gB); }
.kbf.am { background: var(--amber); }
.kbv { font-family: "Patrick Hand", cursive; font-size: 1.25rem; }
.ktable table { min-width: 760px; font-size: 0.92rem; }
.ktable th, .ktable td { cursor: default; }
.ktable tbody th { text-align: left; font-family: system-ui, sans-serif; font-size: 0.92rem; position: sticky; left: 0; background: var(--napkin); }
.wtag { display: inline-block; font-size: 0.72rem; background: var(--amber-soft); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.wtag.off { background: #f1d3c8; }
table.kbreak { min-width: 0; width: 100%; font-size: 0.98rem; }
table.kbreak td { white-space: normal; padding: 6px 4px; }
table.kbreak td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.kbreak tr.sub td { border-top: 2px solid var(--ink); font-weight: 600; }
table.kbreak details summary { cursor: pointer; }
.kwarn { margin: 10px 0 0; }
@media print {
  .klayout { display: block; } .kright { position: static; max-height: none; overflow: visible; }
  .kmore:not([open]) > *:not(summary) { display: block !important; }
  .kform .hint, .presets, #kprint, #kshare, .kmore summary::marker { display: none !important; }
  .kin input[type=text], .kin select { font-size: 10pt; padding: 1pt 4pt; border-width: 1pt; }
  .kgrid { grid-template-columns: 1fr 1fr 1fr; gap: 4pt; }
  #result { display: block; } #result .card { margin-bottom: 8pt; }
}
@media (min-width: 760px) { .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.legend .sw { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.kjump { display: none; }
@media (max-width: 899px) { .kjump { display: block; position: sticky; top: 0; z-index: 5; background: var(--ink); color: var(--napkin); border-radius: 0 0 12px 12px; padding: 8px 12px; margin: 0 -16px 8px; font-family: "Patrick Hand", cursive; font-size: 1.2rem; text-decoration: none; } .kjump:empty { display: none; } }
@media print { .kjump { display: none !important; } }

/* Keep or Sell? simple first view */
.kbig2 { font-size: 1.25rem; margin: 0 0 8px; }
.kone { background: var(--amber-soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.kdet { margin-top: 2px; }
.kdet > summary { list-style: none; display: inline-block; }
.kdet > summary::-webkit-details-marker { display: none; }
.kdet[open] > summary { margin-bottom: 14px; }
.kdetin { display: grid; gap: 14px; }
details.kall { padding: 12px 16px; }
details.kall[open] { display: grid; gap: 14px; }
details.kall > fieldset { box-shadow: none; }
@media print { .kdet > .kdetin { display: grid !important; } details.kall > *:not(summary) { display: block !important; } }
.kplans { background: var(--napkin); border: 2px dashed var(--rule); border-radius: 10px; padding: 8px 12px; }
.krow2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.kecho { margin: 0; font-size: 0.98rem; color: var(--pencil); }
.kecho:empty { display: none; }
.kl { font-size: 1.12rem; margin: 6px 0; }
.kyears { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.kwarnbox { background: #fff4d6; border-color: var(--amber); }
.khint { font-size: 1.15rem; color: var(--pencil); margin: 0; }
.ksub { margin: 10px 0 0; }
tr.kbest td { background: #fbf2dc; }
