/* =====================================================================
   Orlando — Maths components
   Shared by every maths module. Teaching rules behind them:
   - Calculations as in the notebook: p × valor / 100 as a fraction, then "R: …".
   - Regra de três shown as "gavetas": % in one column, € in the other.
   - One guided question at a time; colours keep their meaning
     (neutral = 100 %, paid = what's left, disc = what comes off / x, extra = what's added).
   ===================================================================== */

/* ---------- Enunciado ---------- */
.enun { background: var(--soft); border-left: 5px solid var(--ink); border-radius: 0 var(--r-md) var(--r-md) 0; padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 6px; transition: box-shadow .4s; }
.enun.reading { box-shadow: 0 0 0 3px var(--brand); }
.enun p { font-size: 19px; line-height: 1.55; max-width: 65ch; }
.enun mark { background: transparent; color: inherit; border-bottom: 2px dotted var(--muted); padding: 0 2px; border-radius: 4px; transition: background .5s, color .5s; }
.enun mark.on { background: var(--brand); color: var(--brand-ink); border-bottom-color: transparent; }
.enun mark.q.on { background: transparent; color: inherit; border-bottom: 3px solid var(--m-disc); }

/* ---------- Notebook of collected data ---------- */
.notes {
  background: var(--soft); border-radius: var(--r-md); padding: var(--s3) 14px; min-height: 150px;
  background-image: repeating-linear-gradient(transparent 0 31px, var(--line) 31px 32px); background-position: 0 40px;
}
.notes h3 { margin: 0 0 6px; font-family: var(--font-body); font-size: var(--t-label); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.notes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.notes li { display: flex; gap: var(--s2); align-items: baseline; height: 32px; line-height: 32px; animation: write .6s ease-out; }
.notes li .k { color: var(--muted); font-size: var(--t-small); }
.notes li .v { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.notes .empty { display: block; padding: 0; text-align: left; color: var(--muted); font-size: var(--t-small); font-style: italic; line-height: 32px; }
.notes li.ans .v { background: var(--brand); color: var(--brand-ink); padding: 0 8px; border-radius: 6px; line-height: 28px; }
@keyframes write { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

/* ---------- Price tag ---------- */
.ptag {
  position: relative; width: 190px; background: var(--brand); color: var(--brand-ink);
  padding: 16px 14px 16px 38px; clip-path: polygon(22px 0, 100% 0, 100% 100%, 22px 100%, 0 50%);
  border-radius: 0 var(--r-md) var(--r-md) 0; transform: rotate(-3deg);
  display: flex; flex-direction: column; gap: 2px; min-height: 120px; justify-content: center;
}
.ptag .hole { position: absolute; left: 14px; top: 50%; width: 11px; height: 11px; margin-top: -5px; border-radius: 50%; background: var(--surface); }
.ptag .item { font-size: var(--t-label); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.ptag .old { font-family: var(--font-display); font-weight: 700; font-size: 18px; position: relative; width: fit-content; opacity: .65; font-variant-numeric: tabular-nums; }
.ptag .old::after { content: ""; position: absolute; left: -3px; right: -3px; top: 52%; height: 3px; background: var(--m-sale); transform: scaleX(0); transform-origin: left; transition: transform .5s .2s; }
.ptag .old.struck::after { transform: scaleX(1); }
.ptag .now { font-family: var(--font-display); font-weight: 800; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.sticker {
  position: absolute; right: -8px; top: -16px; width: 62px; height: 62px; border-radius: 50%;
  background: var(--m-sale); color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 17px; transform: rotate(12deg) scale(0); transition: transform .55s var(--ease-spring);
}
.sticker.on { transform: rotate(12deg) scale(1); }

/* ---------- 100 % bar ---------- */
.pbar { --pw: 75; position: relative; padding-inline: 2px; }
.pbar .bracket { position: relative; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); margin-bottom: 8px; min-height: 35px; }
.pbar .bracket::before, .pbar .bracket::after { content: ""; position: absolute; bottom: -2px; width: 2px; height: 10px; background: var(--ink); }
.pbar .bracket::before { left: 0; } .pbar .bracket::after { right: 0; }
.pbar .lrow { position: relative; height: 30px; font-variant-numeric: tabular-nums; }
.pbar .lbl { position: absolute; top: 0; height: 100%; display: flex; justify-content: center; align-items: center; white-space: nowrap; font-weight: 700; transition: left .8s var(--ease-move), width .8s var(--ease-move); }
.pbar .ltop .lbl { font-family: var(--font-display); font-size: 20px; }
.pbar .lbl.a { left: 0; width: calc(var(--pw) * 1%); color: var(--m-paid); }
.pbar .lbl.b { left: calc(var(--pw) * 1%); width: calc(100% - var(--pw) * 1%); color: var(--m-disc); }
.pbar .bar { position: relative; height: 68px; }
.pbar .seg { position: absolute; top: 0; height: 100%; border: 3px solid transparent; transition: left .8s var(--ease-move), width .8s var(--ease-move), background-color .6s, transform .8s var(--ease-move), opacity .6s; }
.pbar .seg.a { left: 0; width: calc(var(--pw) * 1%); border-radius: var(--r-md) 0 0 var(--r-md); }
.pbar .seg.b { left: calc(var(--pw) * 1%); width: calc(100% - var(--pw) * 1%); border-radius: 0 var(--r-md) var(--r-md) 0; }
.seg.neutral { background: var(--m-neutral); }
.seg.paid { background: var(--m-paid); }
.seg.disc { background: var(--m-disc); }
.seg.extra { background: var(--m-extra); }
.seg.unknown { background: transparent; border: 3px dashed var(--muted) !important; }

/* ---------- Fraction ---------- */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.15; margin: 0 2px; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 4px 2px; }
.frac > span:last-child { padding: 2px 4px 0; }

/* ---------- Calculation box ---------- */
.calc {
  border-radius: var(--r-md); background: var(--soft); padding: 14px 18px; font-family: var(--font-mono);
  font-size: clamp(18px, 2.8vw, 24px); font-weight: 700; font-variant-numeric: tabular-nums; overflow-x: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.calc .small { font-size: .7em; font-weight: 400; color: var(--muted); font-family: var(--font-body); white-space: normal; }
.calc .hr { color: var(--m-disc); } .calc .hg { color: var(--m-paid); } .calc .hn { color: var(--m-neutral); } .calc .hx { color: var(--m-extra); }
.calc > div:not(.resp):not(.gavetas):not(.glegend):not(.small) { white-space: nowrap; }
.resp { font-family: var(--font-body); font-size: .75em; font-weight: 700; color: var(--ink); border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }

/* ---------- Gavetas (regra de três) ---------- */
.gavetas { display: grid; grid-template-columns: repeat(2, minmax(0, 150px)); gap: 6px 14px; padding: 4px 0; }
.gcol { display: flex; flex-direction: column; gap: 8px; }
.ghead { font-family: var(--font-body); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.gav { position: relative; text-align: center; padding: 10px 8px 16px; border-radius: var(--r-sm); background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-key); }
.gav::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 28px; height: 4px; margin-left: -14px; border-radius: 2px; background: var(--line); }
.gav.isx { color: var(--m-disc); }
.gav.is-mul { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.gav.is-div { border-color: var(--m-disc); border-style: dashed; }
/* Animated version: cells drop in one by one (--d = order), then the two
   multiplied cells turn yellow and the divisor gets a dashed red border. */
.gavetas .gav { animation: drawer .5s var(--ease-out) both; animation-delay: calc(var(--d, 0) * .55s); }
.gavetas .gav.mul { animation: drawer .5s var(--ease-out) both calc(var(--d, 0) * .55s), mulOn .4s ease forwards 2.6s; }
.gavetas .gav.div { animation: drawer .5s var(--ease-out) both calc(var(--d, 0) * .55s), divOn .4s ease forwards 3.2s; }
@keyframes drawer { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes mulOn { to { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); } }
@keyframes divOn { to { border-color: var(--m-disc); border-style: dashed; } }
.glegend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--muted); animation: pop .5s both 3.4s; }
.glegend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.glegend .lm::before { background: var(--brand); }
.glegend .ld::before { border: 2px dashed var(--m-disc); }
.gform { animation: pop .5s both 3.8s; }
.gform ~ .resp, .gform ~ .small { animation: pop .5s both 4.3s; }

/* ---------- Guided question card ---------- */
.qcard { border-top: 2px dashed var(--line); padding-top: 18px; display: flex; flex-direction: column; gap: var(--s3); }
.qcard .question { font-family: var(--font-display); font-weight: 700; font-size: clamp(22px, 3.4vw, 28px); line-height: 1.2; text-wrap: balance; }
.qcard .story { color: var(--muted); }

/* ---------- Revealed answer ---------- */
.answer { display: flex; flex-direction: column; gap: 10px; animation: pop .55s var(--ease-out); }
.answer p { max-width: 62ch; }
.answer .r { color: var(--m-disc); font-weight: 700; }
.answer .g { color: var(--m-paid); font-weight: 700; }
.answer .x { color: var(--m-extra); font-weight: 700; }
.note { border-left: 4px solid var(--m-disc); padding: 6px 12px; font-size: var(--t-small); background: var(--soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.note b { color: var(--m-disc); }
.r3 { display: grid; grid-template-columns: auto auto auto; gap: 2px 14px; justify-content: start; }
.r3 .arrow { color: var(--muted); font-weight: 400; } .r3 .x { color: var(--m-disc); }
