/* ==========================================================
   Class 7 Math · Section 2 · সমানুপাত ও লাভ-ক্ষতি
   Theme: "নদীবন্দরের গদিঘর" — a river-port wholesaler's office at
   dusk. Jute-cream page with a faint woven crosshatch, river-navy
   ink, river blue (speed / current), marigold (ratio parts),
   leaf green (লাভ), brick maroon (ক্ষতি), dusk violet (definitions).
   Cards are consignment slips (চালান) with a perforated left edge
   and a round maroon rubber stamp. Band কৌতূহলী (age 12–13).
   ========================================================== */
:root {
  --bg: #f5ecdc;
  --card: #fffdf8;
  --ink: #1c2a4a;
  --ink-2: #55607a;
  --river: #2b6c9e;
  --river-deep: #1d4f78;
  --river-soft: #dcebf5;
  --gold: #ef9a2b;
  --gold-deep: #b8690f;
  --gold-soft: #fdebcf;
  --gain: #2f8a4f;
  --gain-soft: #dff1e4;
  --loss: #a3343f;
  --loss-soft: #f6dfe1;
  --dusk: #5b3f7a;
  --dusk-soft: #ece4f4;
  --jute: #c9a46a;
  --line: #e4d7bf;
  --ok: #2f8a4f;
  --no: #a3343f;
}
* { box-sizing: border-box; }
body {
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, rgba(201, 164, 106, .10) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(201, 164, 106, .08) 0 2px, transparent 2px 9px);
}
::selection { background: rgba(239, 154, 43, .4); }
a { color: var(--river-deep); }
strong { color: var(--dusk); }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 2000; }
.skip:focus { left: 8px; }
main, .wrap, .lesson-part > *, .grid2 > *, .row-ctrl > *, .tank-grid > *, .vat-grid > * { min-width: 0; }

/* top bar with a boat sailing along the river line */
.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(245, 236, 220, .95); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-bottom: 3px solid var(--river); font-size: var(--fs-sm); }
.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(--loss); font-weight: 700; }
.river-track { position: relative; flex: 1 1 6rem; max-width: 14rem; height: 26px; color: var(--river); }
.river-track > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mini-boat { position: absolute; top: 1px; left: 0; width: 26px; height: 16px; transform: translateX(var(--x, 0)); transition: transform .2s linear; }
.mini-boat::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: var(--loss); border-radius: 0 0 12px 12px; }
.mini-boat::after { content: ""; position: absolute; left: 10px; bottom: 7px; border-left: 9px solid var(--gold); border-top: 9px solid transparent; }
.level { display: flex; align-items: center; gap: .4rem; font-weight: 800; color: var(--loss); background: var(--card); border: 2px dashed var(--loss); border-radius: 6px; padding: 0 .7rem; }
.level.pop { animation: stampin .6s; }
@keyframes stampin { 0% { transform: scale(1.5) rotate(-12deg); opacity: .3; } 60% { transform: scale(.95) rotate(3deg); opacity: 1; } }

/* hero */
.hero { padding: clamp(2rem, 5vw, 4rem) 0 2rem; }
.hero-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1fr 1.05fr; } }
.eyebrow { display: inline-block; color: #fff; background: var(--river-deep); font-weight: 700; padding: .1rem .9rem; border-radius: 4px; font-size: var(--fs-sm); }
h1 { font-size: var(--fs-3xl); line-height: 1.25; margin: .5rem 0 1rem; }
h1::after { content: ""; display: block; width: 7rem; height: 10px; margin-top: .4rem; background: radial-gradient(circle at 5px 5px, var(--river) 3px, transparent 3.5px) 0 0 / 14px 10px; }
.lede { font-size: var(--fs-lg); line-height: 1.75; }
.hint { color: var(--ink-2); border-left: 4px solid var(--gold); padding-left: .8rem; }
.hero-fig { margin: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 16px 34px rgba(28, 42, 74, .25); border: 4px solid var(--card); }
.hero-fig > svg { display: block; width: 100%; height: auto; }

.block { padding-block: clamp(1.6rem, 4vw, 3rem); }
.sec-title, .lesson-part h2, #compare h2, #activity h2, #quiz h2 { font-size: var(--fs-2xl); line-height: 1.35; margin: .2rem 0 1rem; }
.sub-title { font-size: var(--fs-xl); margin: 2.2rem 0 .8rem; color: var(--river-deep); }
.part-tag { display: inline-block; margin: 0; font-weight: 800; color: #fff; background: var(--loss); padding: .05rem .8rem; border-radius: 999px; font-size: var(--fs-sm); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--loss); }
.goals { display: grid; gap: .6rem; padding: 0; list-style: none; grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); }
.goals li { background: var(--card); border-radius: 6px; padding: .7rem 1rem .7rem 2.3rem; border: 1px solid var(--line); position: relative; }
.goals li::before { content: ""; position: absolute; left: .85rem; top: 1.05rem; width: .8rem; height: .55rem; border-radius: 0 0 .5rem .5rem; background: var(--river); }

/* consignment-slip card */
.card { position: relative; background: var(--card); border-radius: 8px; padding: clamp(1rem, 3vw, 1.6rem); padding-left: calc(clamp(1rem, 3vw, 1.6rem) + 12px); border: 1px solid var(--line); box-shadow: 0 10px 22px rgba(28, 42, 74, .08); }
.card::before { content: ""; position: absolute; top: 10px; bottom: 10px; left: 6px; width: 8px; background: radial-gradient(circle, var(--bg) 3px, transparent 3.5px) 0 0 / 8px 14px; }
.card::after { content: ""; position: absolute; right: 14px; top: 12px; width: 34px; height: 34px; border-radius: 50%; border: 3px double rgba(163, 52, 63, .45); transform: rotate(-14deg); pointer-events: none; }
.card h3, .card h2 { margin: 0 2.6rem .5rem 0; font-size: var(--fs-lg); display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.story h2 { font-size: var(--fs-xl); }
.widget { margin: 1.6rem 0; }
.worked { margin: 1.2rem 0; background: var(--river-soft); }
.def { margin: 1rem 0; background: var(--dusk-soft); border-left: 6px solid var(--dusk); border-radius: 6px; padding: .8rem 1rem; }
.def b:first-child { color: var(--dusk); }
.def.rule { background: var(--gold-soft); border-left-color: var(--gold-deep); }
.def.rule b:first-child { color: var(--gold-deep); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .3rem; font-size: .92em; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 .3rem; }
.frac > span:last-child { padding: 0 .3rem; }
.formula { display: block; margin: .6rem 0 1rem; font-weight: 800; background: var(--card); border: 2px solid var(--river); border-radius: 8px; padding: .6rem 1rem; max-width: 100%; overflow-wrap: anywhere; }
.remember { margin: 1.4rem 0 .4rem; background: var(--gold-soft); border-radius: 6px; padding: .9rem 1rem; border: 2px dashed var(--gold); }
.remember > b:first-child { display: inline-block; background: var(--river-deep); color: #fff; padding: 0 .6rem; border-radius: 4px; margin-right: .4rem; }

.grid2 { display: grid; gap: 1.2rem; grid-template-columns: 1fr; margin: 1rem 0; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.align-c { align-items: center; }
.steps { padding-left: 1.6rem; margin: .6rem 0; list-style-type: bengali; }
.steps li { margin: .4rem 0; animation: rise .4s both; }
.steps.static li { animation: none; }
.steps li.final { font-weight: 800; color: var(--river-deep); }
.steps li.gain { font-weight: 800; color: var(--gain); }
.steps li.loss { font-weight: 800; color: var(--loss); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.fig { display: block; width: 100%; height: auto; }

.row-ctrl { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin: .7rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .6rem; }
.chips button, .seg button { border: 2px solid var(--river); background: var(--card); color: var(--river-deep); border-radius: 999px; padding: .05rem .8rem; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.chips button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--river); color: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 .5rem; }
.inp { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; flex-wrap: wrap; max-width: 100%; }
.inp input, .ratio-in input, .slot input, .task input, .vat-row input { font: inherit; padding: .15rem .5rem; border: 2px solid var(--ink-2); border-radius: 6px; background: #fff; color: var(--ink); max-width: 100%; }
.w5 { width: 5rem; } .w6 { width: 6.5rem; } .w7 { width: 8rem; } .w8 { width: 9rem; }
.btn { font: inherit; font-weight: 800; border: 0; background: var(--river); color: #fff; padding: .35rem 1.1rem; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 0 var(--river-deep); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--river-deep); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--ink-2); box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: default; }
.msg { min-height: 1.8em; font-weight: 700; margin: .5rem 0; }
.msg.ok { color: var(--ok); } .msg.no { color: var(--no); }
.sliders { display: grid; gap: .3rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); margin: .5rem 0; }
.sliders label, .range-l { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: var(--fs-sm); flex-wrap: wrap; }
.sliders input, .range-l input { accent-color: var(--river); flex: 1 1 8rem; min-width: 0; }
.sliders b, .range-l b { color: var(--river-deep); white-space: nowrap; }
.big-ratio { font-size: var(--fs-xl); font-weight: 800; color: var(--gold-deep); margin: .6rem 0; }
.big-ratio small { display: block; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 400; }

/* ratio inputs */
.ratio-in { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .4rem; margin: .5rem 0; font-size: var(--fs-lg); }
.ratio-in input { width: 4.2rem; text-align: center; font-weight: 800; }
.ratio-in .and { font-size: var(--fs-sm); color: var(--ink-2); margin: 0 .4rem; }
.four-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .4rem; font-size: var(--fs-lg); }
.slot { display: flex; flex-direction: column; align-items: center; font-size: var(--fs-sm); font-weight: 700; }
.slot input { width: min(5.2rem, 16vw); text-align: center; font-weight: 800; font-size: var(--fs-base); }
.slot.ext input { border-color: var(--gold-deep); background: var(--gold-soft); }
.slot.mid input { border-color: var(--river); background: var(--river-soft); }
.slot input.found { animation: glow 1s; border-color: var(--gain); background: var(--gain-soft); }
@keyframes glow { 30% { transform: scale(1.12); } }
.four-arcs { max-width: 640px; }
.four-row > b { padding-bottom: .4rem; }

/* profit/loss formula cards */
.formulas { margin: 1rem 0; }
.f-card { display: flex; flex-direction: column; gap: .25rem; padding: .8rem 1rem; border-radius: 8px; border: 2px solid; background: var(--card); }
.f-card b { font-size: var(--fs-lg); }
.f-card.gain { border-color: var(--gain); } .f-card.gain b { color: var(--gain); }
.f-card.loss { border-color: var(--loss); } .f-card.loss b { color: var(--loss); }
.rev-q { font-weight: 700; background: var(--gold-soft); border-radius: 6px; padding: .6rem .8rem; }

/* VAT receipt */
.vat-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .vat-grid { grid-template-columns: 1.2fr 1fr; } }
.vat-rows { display: grid; gap: .5rem; align-content: start; }
.vat-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; background: var(--bg); border-radius: 6px; padding: .4rem .6rem; }
.vat-row .nm { font-weight: 800; flex: 1 1 8rem; }
.vat-row input { width: 6rem; }
.vat-row label { font-size: var(--fs-sm); display: inline-flex; gap: .3rem; align-items: center; }
.receipt { background: #fff; border: 1px dashed var(--ink-2); border-radius: 4px; padding: 1rem; font-size: var(--fs-sm); box-shadow: 0 6px 14px rgba(28, 42, 74, .1); background-image: linear-gradient(transparent 95%, var(--line) 95%); background-size: 100% 1.8em; }
.receipt h4 { margin: 0 0 .4rem; text-align: center; letter-spacing: .05em; }
.receipt .ln { display: flex; justify-content: space-between; gap: .6rem; }
.receipt .ln.tot { border-top: 2px solid var(--ink); margin-top: .3rem; padding-top: .3rem; font-weight: 800; font-size: var(--fs-base); }
.receipt .ln.vat { color: var(--loss); }
.receipt .ln.chg { color: var(--gain); font-weight: 800; }
.receipt .stamp { display: block; width: fit-content; margin: .6rem auto 0; color: var(--loss); border: 3px double var(--loss); border-radius: 6px; padding: 0 .6rem; transform: rotate(-6deg); font-weight: 800; }

/* tank */
.tank-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 760px) { .tank-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
#tank-svg { max-width: 380px; margin-inline: auto; }
.pipes { display: grid; gap: .4rem; }
.pipes button { font: inherit; text-align: left; border: 2px solid var(--ink-2); background: var(--card); color: var(--ink); border-radius: 8px; padding: .3rem .7rem; cursor: pointer; }
.pipes button[aria-pressed="true"].fill { border-color: var(--river); background: var(--river-soft); }
.pipes button[aria-pressed="true"].drain { border-color: var(--loss); background: var(--loss-soft); }
.pipes button[aria-pressed="false"] { opacity: .6; text-decoration: line-through; }

/* tasks */
.tasks { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr)); }
.task { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; display: flex; flex-direction: column; gap: .4rem; }
.task p { margin: 0; font-weight: 700; }
.task .tag { font-size: var(--fs-sm); color: var(--loss); font-weight: 800; }
.task .tr { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.task input { width: 11rem; }
.task .fb { font-size: var(--fs-sm); min-height: 1.5em; }
.task.right { border-color: var(--ok); background: var(--gain-soft); }
.task.wrong { border-color: var(--no); }
.task .fb.no { color: var(--no); } .task .fb.ok { color: var(--ok); font-weight: 700; }

.chart-box { position: relative; height: 290px; margin: .6rem 0; }

/* player */
.player { border-radius: 12px; background: var(--ink); padding: clamp(.5rem, 2vw, 1rem); color: #fff; }
.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(--loss); color: #fff; display: grid; place-items: center; cursor: pointer; }
.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; border-radius: 50%; border: 0; background: var(--gold); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.controls input { flex: 1; min-width: 0; accent-color: var(--gold); }
.time { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); white-space: nowrap; }
.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, .5); background: transparent; color: #e8ecf6; border-radius: 999px; padding: .1rem .7rem; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.chapters button.on { background: var(--gold); border-color: var(--gold); color: var(--ink); }

.table-wrap { overflow-x: auto; margin: .6rem 0; }
.cmp { width: 100%; border-collapse: collapse; background: var(--card); min-width: 34rem; }
.cmp th, .cmp td { border: 1px solid var(--line); padding: .5rem .7rem; text-align: left; }
.cmp thead th { background: var(--river-deep); color: #fff; }
.cmp tbody th { background: var(--gold-soft); }
.cmp td:last-child { font-weight: 800; color: var(--loss); }

.score-pill { display: inline-block; background: var(--river-deep); color: #fff; padding: .1rem .9rem; border-radius: 999px; font-weight: 700; }
.lk-q { background: var(--card); border-radius: 8px; padding: 1rem; margin: .8rem 0; border-left: 5px solid var(--gold); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lk-q-stem { font-weight: 700; margin-bottom: .6rem; }
.lk-opts { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); }
.lk-opt { display: flex; gap: .6rem; align-items: center; text-align: left; font: inherit; padding: .45rem .7rem; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.lk-opt-key { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--river-deep); color: #fff; flex: none; font-size: .95rem; }
.lk-opt.is-right { border-color: var(--ok); background: var(--gain-soft); }
.lk-opt.is-wrong { border-color: var(--no); background: var(--loss-soft); }
.lk-explain { margin: .6rem 0 0; }
.lk-explain.ok { color: var(--ok); } .lk-explain.no { color: var(--no); }
.qa details, .cq-parts details { background: var(--card); border-radius: 6px; padding: .6rem .9rem; margin: .5rem 0; border-left: 5px solid var(--river); }
.cq .cq-parts details { background: var(--bg); }
.qa summary, .cq-parts summary { cursor: pointer; font-weight: 700; }
.qa details p, .cq-parts details p { margin: .6rem 0 .2rem; }
.cq { margin: 1rem 0; }
.cq-stem { font-weight: 800; font-size: var(--fs-lg); margin-right: 2.6rem; }
.cq-parts { list-style: none; padding: 0; }
.summary ul { padding-left: 1.3rem; }
.summary li { margin: .4rem 0; }

.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: 2rem 1rem; }
.pager-btn { display: inline-block; padding: .5rem 1.1rem; border-radius: 999px; background: var(--river-deep); color: #fff; text-decoration: none; font-weight: 700; }
.pager-btn.disabled { background: #e6dfd2; color: #5b5648; }
.credit { color: var(--ink-2); font-size: var(--fs-sm); padding-bottom: 2rem; }

[data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity .6s, transform .6s; }
[data-reveal].is-in { opacity: 1; transform: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
.cut { animation: rise .45s both; }
[hidden] { display: none !important; }
