/* ==========================================================
   Class 8 Math · Section 2 · মুনাফা
   Theme: "টাকার নোটের নকশা" — ivory security paper with faint guilloche
   waves, cheque / passbook cards with a teal frame and serial number.
   Teal = সরল, violet = চক্রবৃদ্ধি, gold = coins, green = লাভ, red = ক্ষতি.
   Band কৌতূহলী (age ~13): guided steps, sliders, a passbook that fills.
   ========================================================== */
:root {
  --bg: #fbf8ef;
  --bg-2: #f1eee2;
  --card: #fffefa;
  --line: #d9d3bf;
  --ink: #1d2326;
  --ink-2: #5b6265;
  --teal: #0e4d57;
  --teal-2: #2b7f8a;
  --violet: #6a4a9c;
  --gold: #d9a21b;
  --green: #2f8f4e;
  --red: #c4412e;
  --ok: #2f7d4a;
  --no: #b03a2e;
  --guil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='60' viewBox='0 0 240 60'%3E%3Cg fill='none' stroke='%230e4d57' stroke-opacity='.06' stroke-width='1'%3E%3Cpath d='M0 30 Q30 0 60 30 T120 30 T180 30 T240 30'/%3E%3Cpath d='M0 30 Q30 60 60 30 T120 30 T180 30 T240 30'/%3E%3Cpath d='M0 20 Q30 -6 60 20 T120 20 T180 20 T240 20'/%3E%3Cpath d='M0 40 Q30 66 60 40 T120 40 T180 40 T240 40'/%3E%3C/g%3E%3C/svg%3E");
}
body { color: var(--ink); background-color: var(--bg); background-image: var(--guil); background-size: 240px 60px; }
::selection { background: rgba(217, 162, 27, .3); }
a { color: var(--teal); }
strong { color: var(--teal); }
b.g { color: var(--green); } b.r { color: var(--red); }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 2000; }
.skip:focus { left: 8px; }
.num { font-variant-numeric: tabular-nums; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.25; font-size: .92em; margin: 0 .15em; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .2em; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: .4rem 1rem; flex-wrap: wrap; padding: .4rem var(--gutter); background: rgba(251, 248, 239, .95); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 2px solid var(--teal); font-size: var(--fs-sm); }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 3px; background: repeating-linear-gradient(90deg, var(--gold) 0 8px, transparent 8px 12px); opacity: .7; }
.crumbs { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--teal); font-weight: 700; }
.coinbar { display: flex; align-items: center; gap: .5rem; }
.coinbar svg { display: block; }
.badges { font-weight: 700; color: var(--violet); white-space: nowrap; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1.1rem; border-radius: 8px; border: 2px solid var(--ink-2); background: var(--card); color: var(--ink); font-weight: 700; transition: transform .1s, background .15s; }
.btn:hover { background: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: inset 0 0 0 2px #ffffff40; }
.btn-teal:hover { background: #0b3d45; }
.btn-violet { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: inset 0 0 0 2px #ffffff40; }
.btn-violet:hover { background: #563a82; }
.btn-sm { padding: .15rem .8rem; font-size: var(--fs-sm); }
.row-btns { display: flex; gap: .6rem; flex-wrap: wrap; margin: .75rem 0; }
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.tabs button { border: 2px solid var(--line); background: var(--bg); color: var(--ink); padding: .2rem .85rem; border-radius: 8px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
input[type="range"] { width: 100%; accent-color: var(--teal); }
input[type="number"], .tbl input { font: inherit; width: 100%; max-width: 9rem; padding: .15rem .5rem; border-radius: 6px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; }
.slider-row { display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: .8rem; align-items: center; margin: .5rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .8rem; }
.chips button { border: 2px dashed var(--teal-2); background: #fff; color: var(--teal); padding: .05rem .75rem; border-radius: 999px; font-weight: 700; font-size: var(--fs-sm); }
.chips button.on { border-style: solid; background: #e5f1f2; }

/* ---------- note (cheque-like card) ---------- */
.note { position: relative; background: var(--card); border-radius: 10px; padding: clamp(1rem, 3vw, 1.4rem); border: 1px solid var(--line); box-shadow: 0 10px 22px -18px rgba(14, 77, 87, .55), inset 0 0 0 5px var(--card), inset 0 0 0 6px #0e4d5733; background-image: linear-gradient(90deg, transparent calc(100% - 9px), var(--card) calc(100% - 9px)), var(--guil); background-size: auto, 240px 60px; }
.note::before { content: ''; position: absolute; top: 14px; bottom: 14px; right: 3px; border-right: 2px dotted var(--line); }
.note h3 { font-size: var(--fs-lg); margin-top: 0; color: var(--teal); padding-right: 4.5rem; }
.note > svg:not(.ic), .note > canvas { width: 100%; height: auto; display: block; }
.note.done-badge::after { content: 'জমা হলো'; position: absolute; top: .7rem; right: 1rem; font-size: .8rem; font-weight: 800; color: var(--violet); border: 2px solid var(--violet); border-radius: 6px; padding: 0 .5rem; transform: rotate(6deg); background: #f4effb; letter-spacing: .03em; }
.serial { position: absolute; top: .7rem; right: 1rem; font-size: .8rem; color: var(--ink-2); letter-spacing: .08em; }
.note + .note, .note + .grid2, .grid2 + .note, .grid2 + .grid2, .note + .tip, .tip + .note, .defbox + .grid2, .split + .note { margin-top: 1.1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(24rem, 100%), 1fr)); gap: 1.1rem; margin-top: 1.1rem; }
.grid2 > *, .hero-grid > *, .split > * { min-width: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.4rem; align-items: center; }
.tip { border-radius: 10px; padding: 1rem 1.2rem; margin-top: 1.1rem; background: #fff7df; border: 2px solid var(--gold); }
.tt { margin: 0 0 .3rem; font-weight: 800; color: #8a6200; }
.tip p:last-child { margin-bottom: 0; }
.msg { min-height: 1.8em; margin: .5rem 0 0; }
.msg.ok { color: var(--ok); font-weight: 700; } .msg.no { color: var(--no); font-weight: 700; }
.formula { margin: .7rem auto 0; padding: .55rem 1rem; border-radius: 8px; background: #fff; border: 2px solid var(--teal); color: var(--teal); font-weight: 800; text-align: center; }
.formula.red { border-color: var(--red); color: var(--red); }
.formula.violet { border-color: var(--violet); color: var(--violet); }
.work { background: var(--bg); border-radius: 8px; padding: .7rem 1rem; line-height: 2; border: 1px solid var(--line); margin-top: .6rem; overflow-wrap: anywhere; }
.work:empty { display: none; }
.work p { margin: .2rem 0; }
.work .big { font-size: 1.35rem; font-weight: 800; color: var(--teal); }
.work .hl { color: var(--violet); font-weight: 800; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; font-size: var(--fs-sm); text-align: center; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: .35rem .45rem; }
.tbl th { background: #e8f0ee; color: var(--teal); }
.tbl td.ok { background: #e6f4ea; } .tbl td.no { background: #fbe9e6; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.defbox { margin: 1rem 0; padding: .9rem 1.2rem; border-left: 6px solid var(--teal); background: var(--card); border-radius: 0 10px 10px 0; font-size: var(--fs-lg); box-shadow: 0 6px 16px -14px rgba(0, 0, 0, .4); }
.defs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.def { background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--gold); border-radius: 8px; padding: .8rem 1rem; }
.def b { color: var(--teal); font-size: var(--fs-lg); }
.def p { margin: .3rem 0 0; }

/* steps (guided worked examples) */
.steps { padding-left: 1.4rem; margin: .6rem 0 0; }
.steps li { margin: .25rem 0; padding: .15rem .4rem; border-radius: 6px; transition: opacity .35s, background .35s; line-height: 2; }
.steps li.hidden { opacity: 0; height: 0; margin: 0; padding: 0; overflow: hidden; }
.steps li.now { background: #fff3cf; }
.derive b { color: var(--violet); }

/* symbol flip cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 100%), 1fr)); gap: .7rem; }
.flip { perspective: 700px; border: 0; background: none; padding: 0; height: 8.4rem; color: var(--ink); }
.flip-in { display: block; position: relative; width: 100%; height: 100%; transition: transform .55s; transform-style: preserve-3d; }
.flip.on .flip-in { transform: rotateY(180deg); }
.flip-f, .flip-b { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 8px; display: grid; place-content: center; text-align: center; padding: .4rem; border: 2px solid var(--teal); background: #fff; }
.flip-f .sym { font-size: 2.2rem; font-weight: 800; color: var(--teal); font-family: Georgia, serif; line-height: 1.1; }
.flip-f .nm { font-weight: 700; font-size: var(--fs-sm); }
.flip-b { transform: rotateY(180deg); background: #f4effb; border-color: var(--violet); font-weight: 700; font-size: var(--fs-sm); }
.flip-b .v { font-size: 1.35rem; color: var(--violet); }

/* passbook */
.passbook { border-top: 6px solid var(--teal); }
.pb-head { font-weight: 800; color: var(--teal); margin: 0 0 .5rem; letter-spacing: .02em; }
.tbl.pb td { font-variant-numeric: tabular-nums; }
.tbl.pb tr.pb-profit td, .tbl.pb tr.new td { background: #f4effb; }
.tbl.pb tr.new { animation: pbin .6s ease; }
@keyframes pbin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* solver */
.solve-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr)); gap: .7rem; }
.fld { display: grid; gap: .25rem; font-weight: 700; font-size: var(--fs-sm); background: #fff; border: 2px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.fld input { max-width: none; }
.fld.unknown { border-color: var(--violet); background: #f4effb; }
.fld.unknown input { background: transparent; border-style: dashed; color: var(--violet); }
.race-ctrl { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: 0 1.2rem; }
#pop-canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: #f1f5f4; }
.why { margin-top: .7rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.why summary { cursor: pointer; padding: .5rem .9rem; font-weight: 700; color: var(--teal); }
.why .work { margin: 0 .6rem .6rem; }

/* ---------- hero ---------- */
.hero { padding: clamp(1.5rem, 4vw, 2.8rem) 0 1rem; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 2rem; align-items: center; }
.eyebrow { color: var(--violet); font-weight: 700; margin-bottom: .2rem; }
.hero h1 { font-size: var(--fs-3xl); margin: .2rem 0 .6rem; line-height: 1.2; color: var(--teal); letter-spacing: .02em; }
.lede { font-size: var(--fs-lg); }
.hint { color: var(--ink-2); font-size: var(--fs-sm); }
.hero-fig { margin: 0; background: var(--card); border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 16px 30px -24px rgba(14, 77, 87, .7), inset 0 0 0 6px var(--card), inset 0 0 0 8px #d9a21b66; padding: .5rem; }
.hero-fig > svg { width: 100%; height: auto; display: block; }

/* ---------- sections ---------- */
.block { padding: clamp(2rem, 5vw, 3.2rem) 0; }
.lesson-part { border-top: 1px solid var(--line); }
.lesson-part.alt { background-color: var(--bg-2); }
.part-tag { display: inline-block; margin: 0 0 .3rem; padding: .05rem .8rem; border-radius: 6px; background: var(--teal); color: #fff; font-weight: 700; font-size: var(--fs-sm); box-shadow: inset 0 0 0 2px #ffffff40; }
h2 { color: var(--ink); }
.sec-title { display: flex; gap: .6rem; align-items: center; }
.sub-title { font-size: var(--fs-lg); margin-top: 2.2rem; color: var(--violet); }
.goals { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); gap: .4rem 1.5rem; }
.goals li { position: relative; padding-left: 1.8rem; }
.goals li::before { content: ''; position: absolute; left: .1rem; top: .45em; width: 1rem; height: 1rem; border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 2px #a87b0c, inset 0 0 0 4px #f3cf6a; }
.story { border-top: 6px solid var(--gold); }
[data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity .5s, transform .5s; }
[data-reveal].is-in { opacity: 1; transform: none; }
.cmp th[scope], .cmp tbody th { background: #f6f3e8; color: var(--ink); text-align: left; }
.cmp td { text-align: left; }

/* ---------- player ---------- */
.player { border-radius: 12px; background: #13262b; padding: clamp(.5rem, 2vw, 1rem); color: #fff; box-shadow: inset 0 0 0 3px #d9a21b55; }
.stage { position: relative; border-radius: 8px; overflow: hidden; }
.stage svg:not(.ic) { width: 100%; height: auto; display: block; }
.big-play { position: absolute; inset: 0; margin: auto; width: 5.5rem; height: 5.5rem; border-radius: 50%; border: 4px solid #fff; background: var(--teal); color: #fff; display: grid; place-items: center; }
.big-play .ic { width: 2.4rem; height: 2.4rem; }
.big-play.hide { display: none; }
.caption { min-height: 3.6em; margin: .75rem .25rem; font-size: var(--fs-lg); line-height: 1.6; }
.controls { display: flex; align-items: center; gap: .6rem; }
.ctrl { width: 2.6rem; height: 2.6rem; flex: none; border-radius: 50%; border: 2px solid #fff; background: transparent; color: #fff; display: grid; place-items: center; }
.controls input { flex: 1; min-width: 0; accent-color: var(--gold); }
.time { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: var(--fs-sm); }
.chapters { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: .75rem 0 0; list-style: none; }
.chapters button { border: 1px solid rgba(255, 255, 255, .45); background: transparent; color: #eef3f2; border-radius: 6px; padding: .1rem .7rem; font-size: var(--fs-sm); }
.chapters button.on { background: var(--gold); border-color: var(--gold); color: #13262b; }

/* ---------- quiz ---------- */
.score-pill { position: sticky; top: 4.2rem; z-index: 5; display: inline-block; padding: .2rem .9rem; border-radius: 999px; background: var(--violet); color: #fff; font-weight: 700; }
.score-pill .ic { vertical-align: -.2em; }
.mcq { display: grid; gap: 1rem; }
.lk-q { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--teal); border-radius: 10px; padding: 1rem 1.2rem; }
.lk-q-stem { font-weight: 700; margin-bottom: .6rem; }
.lk-q-num { color: var(--teal); }
.mcq-stem-list { display: block; margin: .3rem 0; font-weight: 500; }
.lk-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); gap: .5rem; }
.lk-opt { display: flex; gap: .6rem; align-items: center; text-align: left; padding: .45rem .8rem; border-radius: 8px; border: 2px solid var(--line); background: #fff; color: var(--ink); }
.lk-opt:hover { border-color: var(--teal); }
.lk-opt-key { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--gold); border: 2px solid #a87b0c; color: #3b2a00; display: grid; place-items: center; font-weight: 700; }
.lk-opt.is-right { border-color: var(--ok); background: #e6f4ea; }
.lk-opt.is-wrong { border-color: var(--no); background: #fbe9e6; }
.lk-opt[aria-disabled="true"] { cursor: default; }
.lk-explain { margin: .6rem 0 0; padding: .5rem .8rem; border-radius: 8px; }
.lk-explain.ok { background: #e6f4ea; } .lk-explain.no { background: #fbe9e6; }
.qa details, .cq-parts details { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; margin-bottom: .55rem; }
.qa summary, .cq-parts summary { cursor: pointer; padding: .6rem 1rem; font-weight: 700; }
.qa details > div, .qa details > p, .cq-parts p { padding: 0 1rem .8rem; margin: 0; line-height: 2; }
.cq { margin-top: 1rem; }
.cq-stem { font-size: var(--fs-lg); margin: 0 0 .4rem; padding-right: 3rem; }
.cq-parts { padding-left: 0; list-style: none; display: grid; gap: .1rem; margin-top: .75rem; }
.summary { border-top: 6px solid var(--violet); }
.summary li { margin-bottom: .4rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 2rem 0 1rem; }
.pager-btn { padding: .55rem 1.1rem; border-radius: 8px; border: 2px solid var(--teal); background: var(--card); color: var(--teal); text-decoration: none; font-weight: 700; }
.pager-btn.disabled { opacity: .55; border-color: var(--ink-2); color: var(--ink-2); }
.credit { color: var(--ink-2); font-size: var(--fs-sm); padding-bottom: 2rem; }

@media (max-width: 900px) {
  .hero-grid, .split { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .crumbs { font-size: .9rem; }
  .coinbar svg { width: 120px; }
  .score-pill { top: 5.6rem; }
  .slider-row { grid-template-columns: 1fr; gap: .2rem; }
  .note h3 { padding-right: 0; }
  .note.done-badge h3 { padding-right: 4.5rem; }
  .flip { height: 7.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; }
  .flip-in, .steps li { transition: none; }
  .tbl.pb tr.new { animation: none; }
}
