/* Paper artefacts and the device frame. Decorative: every instance is
   aria-hidden and its meaning is carried by adjacent text. */

/* ---- Device frame (real screenshots are 1080x2400, 9:20) ----
   Every metric hangs off --device-w so a 150px phone and a 300px phone keep
   the same proportions: bezel 3%, body radius 15%, screen radius 12%. The
   body is a graphite gradient with a 1px rim highlight (the metal edge), a
   punch-hole camera sits in the capture's empty status-bar centre, and the
   side buttons are the two pseudo-elements. */
.device { position: relative; width: var(--device-w, 300px); padding: calc(var(--device-w, 300px) * 0.03); border-radius: calc(var(--device-w, 300px) * 0.15); background: linear-gradient(155deg, #2b3431 0%, #0d1311 28%, #0b100f 70%, #1d2623 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 0 1px rgba(5, 10, 8, 0.75), 0 18px 30px -18px rgba(15, 26, 23, 0.4), 0 50px 90px -34px rgba(15, 26, 23, 0.5); }
.device::before, .device::after { content: ''; position: absolute; width: max(2px, calc(var(--device-w, 300px) * 0.01)); border-radius: 2px; background: linear-gradient(90deg, #2b3431, #141b19); }
.device::before { right: calc(var(--device-w, 300px) * -0.01); top: 24%; height: 11%; }
.device::after { left: calc(var(--device-w, 300px) * -0.01); top: 19%; height: 7%; box-shadow: 0 calc(var(--device-w, 300px) * 0.11) 0 0 #1c2422; }
.device-screen { position: relative; width: 100%; aspect-ratio: 9 / 20; border-radius: calc(var(--device-w, 300px) * 0.12); overflow: hidden; background: var(--bg); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); isolation: isolate; }
.device-screen picture, .device-screen img { display: block; width: 100%; height: 100%; object-fit: cover; }
.device-screen .screen-layer { position: absolute; inset: 0; }
/* Camera, then the glare: a faint diagonal sheen across the top-left of the
   glass. Both sit above every screen layer and take no pointer events. */
.device-screen::before { content: ''; position: absolute; z-index: 7; top: calc(var(--device-w, 300px) * 0.035); left: 50%; width: calc(var(--device-w, 300px) * 0.038); height: calc(var(--device-w, 300px) * 0.038); margin-left: calc(var(--device-w, 300px) * -0.019); border-radius: 50%; background: radial-gradient(circle at 40% 40%, #2a3330, #050807 65%); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
.device-screen::after { content: ''; position: absolute; z-index: 6; inset: 0; pointer-events: none; background: linear-gradient(118deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 22%, rgba(255, 255, 255, 0) 42%); }
/* On a phone-sized page the frames are small, and at 9:20 a small frame reads
   as a remote control. 9:19.5 cropped from the bottom loses only the gesture
   pill; the status bar (clock, wifi, battery) and the camera stay whole. A
   centred crop was tried first and sliced the status-bar icons in half. */
@media (max-width: 900px) {
  .device-screen { aspect-ratio: 9 / 19.5; }
  .device-screen img { object-position: top; }
}

/* ---- Browser frame (web screenshots are 1600x1000) ----
   Light desktop chrome: traffic lights, a centred address pill, a hairline
   under the bar, and the same two-layer shadow as the phone. */
.browser { border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 18px 30px -18px rgba(15, 26, 23, 0.28), 0 50px 90px -34px rgba(15, 26, 23, 0.42); }
.browser-bar { position: relative; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; background: linear-gradient(#f6f4ee, #efece4); border-bottom: 1px solid var(--line); }
.browser-bar i { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.browser-bar i:nth-child(1) { background: #ff5f57; }
.browser-bar i:nth-child(2) { background: #febc2e; }
.browser-bar i:nth-child(3) { background: #28c840; }
/* The pill is a flex item AFTER the lights, never absolutely positioned: it
   cannot overlap them at any width. Auto margins centre it in the space that
   is left; min-width: 0 lets it shrink and the ellipsis takes the rest. */
.browser-bar span { position: relative; flex: 0 1 min(46%, 300px); min-width: 0; margin: 0 auto; height: 24px; border-radius: 8px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-faint); font: 500 12px/24px var(--sans); text-align: center; padding: 0 12px 0 24px; box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser-bar span::before { content: ''; position: absolute; left: 9px; top: 7px; width: 7px; height: 6px; border: 1.5px solid var(--ink-faint); border-top-width: 0; border-radius: 0 0 2px 2px; box-sizing: border-box; }
.browser-bar span::after { content: ''; position: absolute; left: 10.5px; top: 3px; width: 4px; height: 5px; border: 1.5px solid var(--ink-faint); border-bottom: 0; border-radius: 3px 3px 0 0; box-sizing: border-box; }
.browser img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }

/* ---- Paper ---- */
.paper { background: #fbf8ef; color: #2a2f2c; font-family: var(--mono); font-size: 12px; line-height: 1.4; border-radius: 3px; box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 26px 44px -26px rgba(15, 26, 23, 0.35); }

/* Distributor invoice: the visible page of a 29-line import, dot-matrix feel.
   280px is the real default; nothing overrides it on desktop. */
.invoice { position: relative; width: 280px; padding: 14px 14px 18px; font-size: 11px; transform: rotate(-2deg); overflow: hidden; }
.inv-head { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #5a625e; border-bottom: 1px dashed #cfc7b2; padding-bottom: 8px; margin-bottom: 6px; }
.inv-head b { color: #2a2f2c; }
.inv-cols { display: grid; grid-template-columns: 1fr 40px 30px 68px; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); padding: 4px 0; }
.inv-row { position: relative; display: grid; grid-template-columns: 1fr 40px 30px 68px; gap: 8px; padding: 6px 0; border-bottom: 1px dotted #e2dbc8; }
.inv-row span:nth-child(n+2) { text-align: right; }
.inv-row::after { content: ''; position: absolute; inset: 1px -6px; border-radius: 3px; background: rgba(14, 124, 102, 0.12); opacity: 1; }
/* The paper is one page of a longer invoice; this line says so out loud so the
   phone's 29 and the chip's 29 cannot read as three different counts. */
.inv-more { color: var(--ink-faint); font-size: 11px; padding: 6px 0; }
/* Hero swaps to .more-lite on mobile, where fewer rows show. */
.inv-more .more-lite { display: none; }
.inv-total { display: flex; justify-content: space-between; padding-top: 8px; font-weight: 700; }
.scanline { position: absolute; left: 0; right: 0; top: 0; height: 100%; border-bottom: 2px solid var(--brand); box-shadow: 0 1px 0 rgba(14,124,102,0.25); transform: translateY(0); opacity: 0; pointer-events: none; }

/* ---- Sequence keyframes for the hero scan (Task 5) ---- */
@keyframes scan { from { transform: translateY(-100%); opacity: 1; } 94% { opacity: 1; } to { transform: translateY(0); opacity: 0; } }
@keyframes rowlit-1 { 0%, 12% { opacity: 0; } 16%, 100% { opacity: 1; } }
@keyframes rowlit-2 { 0%, 26% { opacity: 0; } 30%, 100% { opacity: 1; } }
@keyframes rowlit-3 { 0%, 40% { opacity: 0; } 44%, 100% { opacity: 1; } }
@keyframes rowlit-4 { 0%, 54% { opacity: 0; } 58%, 100% { opacity: 1; } }
@keyframes rowlit-5 { 0%, 68% { opacity: 0; } 72%, 100% { opacity: 1; } }
@keyframes rowlit-6 { 0%, 82% { opacity: 0; } 86%, 100% { opacity: 1; } }
/* Starts at 50%, not 0: the import screen's header and the first matched rows
   are visible before any scroll, so the phone is never a near-blank slab at rest. */
@keyframes curtain { from { transform: translateY(50%); } to { transform: translateY(100%); } }
@keyframes chip-in { 0%, 84% { opacity: 0; transform: translateY(8px); } 92%, 100% { opacity: 1; transform: none; } }
@property --n { syntax: '<integer>'; inherits: false; initial-value: 0; }
/* Animating a registered custom property is the one exception to the
   transform/opacity/clip-path rule: there is no other way to count in CSS. */
@keyframes count-up { from { --n: 0; } to { --n: 29; } }

/* The six rows are children 3-8 of .invoice: .inv-head and .inv-cols come
   first, and CSS cannot count "nth element of this class". Indices 1-2 would
   match nothing, which leaves every row lit from the first frame. */
.inv-row:nth-child(3)::after { animation-name: rowlit-1; }
.inv-row:nth-child(4)::after { animation-name: rowlit-2; }
.inv-row:nth-child(5)::after { animation-name: rowlit-3; }
.inv-row:nth-child(6)::after { animation-name: rowlit-4; }
.inv-row:nth-child(7)::after { animation-name: rowlit-5; }
.inv-row:nth-child(8)::after { animation-name: rowlit-6; }
.scanline[data-seq] { animation-name: scan; }
.device-curtain { position: absolute; inset: 0; background: var(--bg); transform: translateY(100%); }
.device-curtain[data-seq] { animation-name: curtain; animation-timing-function: steps(6, end); }
.count-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; font: 600 13px/1 var(--sans); padding: 12px 16px; border-radius: 999px; }
.count-chip[data-seq] { animation-name: chip-in; }
/* --n and its counter-reset must sit on the element that carries the
   animation; on the parent the counter is resolved once and never updates. */
.count-chip b { --n: 29; counter-reset: n var(--n); }
.count-chip b::after { content: counter(n); font-variant-numeric: tabular-nums; }
.count-chip b[data-seq] { animation-name: count-up; }

/* ---- WhatsApp message card ---- */
.wa-card { width: 260px; background: #fff; color: var(--ink); border-radius: 14px; padding: 12px 16px; box-shadow: 0 24px 40px -22px rgba(0,0,0,0.45); font-family: var(--sans); }
.wa-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.wa-head svg { width: 18px; height: 18px; fill: #1f9d55; }
.wa-head time { margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.wa-card p { margin: 0 0 8px; font-size: 13px; line-height: 1.45; }
.wa-msg-link { display: block; font-size: 12px; color: #1a6fb0; }

/* ---- Thermal receipt (58 mm proportion) ---- */
/* Every internal metric is in em so the whole receipt scales with one
   font-size: below ~1140px the column shrinks the paper, and fixed px padding
   and gaps would eat the line and wrap the item rows. */
/* The unroll clip lives on .receipt-wrap, not here: clip-path on .receipt
   would cut off .paper's own drop shadow at the border box. The extra
   bottom padding is the strip the torn edge is painted into. */
.receipt { width: 214px; padding: 1.28em 1.28em 2em; font-size: 11px; line-height: 1.5; color: #1f2523; border-radius: 0; position: relative; }
/* Torn bottom edge: teeth painted in the chapter's own colour INSIDE the
   receipt's bottom padding, so nothing is clipped and the shadow survives. */
.receipt::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: linear-gradient(-45deg, var(--brand-darker) 5.6px, transparent 0) 0 0 / 8px 8px repeat-x, linear-gradient(45deg, var(--brand-darker) 5.6px, transparent 0) 0 0 / 8px 8px repeat-x; }
.rc-shop { font-weight: 700; letter-spacing: 0.12em; text-align: center; font-size: 1.09em; }
.rc-sub { text-align: center; color: #5a625e; font-size: 1em; }
.rc-rule { border-top: 1px dashed #c9c1ad; margin: 0.73em 0; }
.rc-row { display: flex; justify-content: space-between; gap: 0.73em; }
.rc-row span:last-child { font-variant-numeric: tabular-nums; }
.rc-total { font-weight: 700; font-size: 1.182em; margin-top: 0.18em; }
.rc-paid { color: #946600; font-weight: 800; letter-spacing: 0.14em; border: 1.5px solid #946600; padding: 0 0.45em; border-radius: 3px; transform: rotate(-6deg); display: inline-block; }
.rc-foot { text-align: center; margin-top: 0.73em; color: #5a625e; }

/* ---- Counter beat keyframes ---- */
@keyframes frame-2 { 0%, 30% { opacity: 0; } 38%, 100% { opacity: 1; } }
@keyframes frame-3 { 0%, 62% { opacity: 0; } 70%, 100% { opacity: 1; } }
@keyframes beat-1 { 0%, 30% { opacity: 1; } 38%, 100% { opacity: 0.6; } }
@keyframes beat-2 { 0%, 30% { opacity: 0.6; } 38%, 62% { opacity: 1; } 70%, 100% { opacity: 0.6; } }
@keyframes beat-3 { 0%, 62% { opacity: 0.6; } 70%, 100% { opacity: 1; } }
/* The accent bar follows the same windows as the card it sits on. */
@keyframes bar-1 { 0%, 30% { opacity: 1; } 38%, 100% { opacity: 0; } }
@keyframes bar-2 { 0%, 30% { opacity: 0; } 38%, 62% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes bar-3 { 0%, 62% { opacity: 0; } 70%, 100% { opacity: 1; } }
@keyframes wa-in { 0%, 76% { opacity: 0; transform: translateY(16px); } 86%, 100% { opacity: 1; transform: none; } }
@keyframes unroll { 0%, 72% { clip-path: inset(0 0 100% 0); } 96%, 100% { clip-path: inset(0); } }
.frame-2[data-seq] { animation-name: frame-2; }
.frame-3[data-seq] { animation-name: frame-3; }
.beat:nth-child(1)[data-seq] { animation-name: beat-1; }
.beat:nth-child(2)[data-seq] { animation-name: beat-2; }
.beat:nth-child(3)[data-seq] { animation-name: beat-3; }
.beat:nth-child(1)[data-seq]::after { animation-name: bar-1; }
.beat:nth-child(2)[data-seq]::after { animation-name: bar-2; }
.beat:nth-child(3)[data-seq]::after { animation-name: bar-3; }
.wa-card[data-seq] { animation-name: wa-in; }
.receipt-wrap[data-seq] { animation-name: unroll; }

/* ---- Khaata notebook page ----
   Everything on the page hangs off two custom properties: --nb-fs (the body
   text size) and --pitch (the ruled-line spacing, 30px at the 13px default).
   Padding, the red margin rule, the row gap, the date column and the
   ruled-line gradient are all expressed in --pitch, so shrinking the notebook
   inside its size container keeps the text sitting on the rules instead of
   drifting off them. Every cell is nowrap + ellipsis so a row can never wrap
   to two lines, however narrow the paper gets. */
.notebook { --nb-fs: 13px; --pitch: calc(var(--nb-fs) * 30 / 13); width: 300px; padding: calc(var(--pitch) * 18 / 30) calc(var(--pitch) * 18 / 30) calc(var(--pitch) * 22 / 30) calc(var(--pitch) * 44 / 30); font-family: var(--sans); font-size: var(--nb-fs); background: #fbf8ef repeating-linear-gradient(transparent 0 calc(var(--pitch) - 1px), #e6dfcb calc(var(--pitch) - 1px) var(--pitch)) 0 calc(var(--pitch) * 46 / 30) / 100% var(--pitch); position: relative; }
.notebook::before { content: ''; position: absolute; left: var(--pitch); top: 0; bottom: 0; width: 1px; background: #d98a7a; }
.nb-head { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: calc(var(--nb-fs) * 11 / 13); color: #5a625e; line-height: var(--pitch); margin-bottom: calc(var(--pitch) * 16 / 30); }
.nb-row { display: grid; grid-template-columns: 1fr auto calc(var(--pitch) * 44 / 30); gap: calc(var(--pitch) / 3); line-height: var(--pitch); }
.nb-row > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-row span:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 600; overflow: visible; }
.nb-row span:nth-child(3) { color: var(--ink-faint); font-size: calc(var(--nb-fs) * 11 / 13); text-align: right; }
.nb-paid s { color: var(--ink-faint); text-decoration-color: #b6aa8c; }
.nb-paid em { font-style: normal; font-size: calc(var(--nb-fs) * 11 / 13); letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-deep); margin-left: calc(var(--pitch) * 4 / 30); }
.js-reveal .khaata:not(.is-in) .nb-row { opacity: 0; transform: translateX(-18px); }
.js-reveal .khaata.is-in .nb-row { opacity: 1; transform: none; transition: opacity 360ms var(--ease-out), transform 360ms var(--ease-out); transition-delay: calc(var(--i) * 60ms); }
.js-reveal .khaata:not(.is-in) .device { opacity: 0; transform: translateY(16px); }
.js-reveal .khaata.is-in .device { opacity: 1; transform: none; transition: opacity 400ms var(--ease-out), transform 400ms var(--ease-out); transition-delay: 240ms; }

/* ---- Bound register table ---- */
.register { width: 100%; border-collapse: collapse; margin-top: 32px; font-size: var(--fs-small); }
.register th, .register td { text-align: left; vertical-align: top; padding: 16px 12px 16px 0; border-bottom: 1px solid var(--line); }
.register thead th { font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; padding-top: 0; }
.register tbody th { font-weight: 700; font-size: 17px; color: var(--ink); width: 34%; }
.register td { color: var(--ink-soft); line-height: 1.5; }
.register td:last-child { white-space: nowrap; width: 1%; }
.register-foot { margin: 16px 0 0; font-size: var(--fs-small); color: var(--ink-soft); }
.js-reveal .registers:not(.is-in) tbody tr { opacity: 0; transform: translateY(8px); }
.js-reveal .registers.is-in tbody tr { opacity: 1; transform: none; transition: opacity 360ms var(--ease-out), transform 360ms var(--ease-out); transition-delay: calc(var(--i) * 60ms); }
@media (max-width: 720px) {
  .register thead { display: none; }
  .register tr { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line); }
  .register th, .register td { padding: 0; border: 0; width: auto; }
  .register tbody th { width: auto; }
}
