/* DV81 RECEIPT CHECKOUT · Kōbō (fictional coffee roasters) · stage 1 of 3: the checkout and the CSS receipt and printer. The theme is the page's own (light); the OS scheme is never read. */
:root {
  --bg: #efe9e1; --ink: #2a2420; --mute: #7d7268; --mute2: #93887d; --line: rgba(42, 36, 32, .14);
  --field: #f8f5f1; --err: #b3361d; --ok: #2f7a4f; --net: #1a1f71; --thermal: #34302d;
  --s: min(calc(100vw / 1600), calc(100vh / 1000));
  --u: 1;
  --serif: 'Instrument Serif', 'Times New Roman', serif; --sans: Manrope, system-ui, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: #f6f1ea; padding: 13px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; text-decoration: none; min-height: 44px; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: calc(110 * var(--s)); min-height: 64px; padding: 0 calc(80 * var(--s)); position: relative; z-index: 3; }
.logo { font-family: var(--serif); font-size: max(24px, calc(30 * var(--s))); letter-spacing: .01em; text-decoration: none; line-height: 1; display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; border-radius: 8px; }
.top nav { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.steps { list-style: none; display: flex; gap: calc(26 * var(--s)); font-size: max(11.5px, calc(12.5 * var(--s))); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--mute); }
.steps a, .steps span { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 4px; text-decoration: none; border-radius: 8px; transition: color .2s; }
.steps a:hover { color: var(--ink); }
.steps [aria-current] { color: var(--ink); }
.secure-top { font-size: max(13px, calc(13.5 * var(--s))); color: var(--mute); }

/* ---------- desktop grid: form column left, stage right, caption under both */
.main {
  display: grid; position: relative;
  grid-template-columns: max(380px, calc(520 * var(--s))) minmax(0, 1fr);
  column-gap: calc(130 * var(--s));
  grid-template-rows: auto auto auto auto 1fr calc(122 * var(--s));
  grid-template-areas: "title stage" "fields stage" "pay stage" "secure stage" ". stage" "cap cap";
  padding: 0 calc(80 * var(--s)) 0 calc(110 * var(--s));
  min-height: calc(100vh - max(64px, calc(110 * var(--s))));
}
.title { grid-area: title; padding-top: calc(98 * var(--s)); }
h1 { font-family: var(--serif); font-weight: 400; font-size: max(40px, calc(60 * var(--s))); line-height: 1; letter-spacing: -.012em; outline: none; }
.sub { color: var(--mute); font-size: max(14px, calc(15 * var(--s))); line-height: 1.45; margin-top: calc(14 * var(--s)); max-width: 34em; }

.fields { grid-area: fields; display: grid; grid-template-columns: 1fr 1fr; gap: max(12px, calc(14 * var(--s))); margin-top: max(22px, calc(36 * var(--s))); align-content: start; }
.f { position: relative; }
.f.w { grid-column: span 2; }
.f label { position: absolute; left: 16px; top: max(9px, calc(11 * var(--s))); font-size: max(10.5px, calc(11 * var(--s))); font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); pointer-events: none; transition: color .2s; }
.f input {
  width: 100%; height: max(54px, calc(58 * var(--s))); border-radius: 14px; border: 1px solid var(--line); background: var(--field);
  padding: max(22px, calc(24 * var(--s))) 16px 6px; font: 500 max(15px, calc(16 * var(--s))) var(--sans); color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s; box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 1px 2px rgba(42, 36, 32, .04);
}
.f input::placeholder { color: #b3a99f; }
.f input:hover { background: #fcfaf7; border-color: rgba(42, 36, 32, .24); }
.f input:focus { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 4px rgba(42, 36, 32, .08); }
.f input:focus + .net, .f input:focus ~ label { color: var(--ink); }
.f:focus-within label { color: var(--ink); }
.f input[readonly] { background: #f3efe9; color: #6c625a; cursor: default; }
#f-cvc { -webkit-text-security: disc; letter-spacing: .14em; }
.f .net { position: absolute; right: 16px; top: max(19px, calc(21 * var(--s))); font: 700 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--net); pointer-events: none; transition: opacity .2s; }
.f .net:empty { opacity: 0; }
.err { color: var(--err); font-size: 12.5px; font-weight: 500; line-height: 1.35; padding: 6px 4px 0 4px; display: none; }
.f.bad .err { display: block; }
.f.bad input { border-color: var(--err); background: #fdf6f3; }
.f.bad input:focus { box-shadow: 0 0 0 4px rgba(179, 54, 29, .12); }
.f.bad label { color: var(--err); }

.paybox { grid-area: pay; margin-top: max(18px, calc(22 * var(--s))); display: grid; gap: 10px; }
.pay {
  position: relative; width: 100%; height: max(56px, calc(62 * var(--s))); border: 0; border-radius: 16px; background: var(--ink); color: #f6f1ea; cursor: pointer;
  font: 600 max(15.5px, calc(16.5 * var(--s))) var(--sans); display: flex; align-items: center; justify-content: center; gap: .55em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 6px 16px rgba(42, 36, 32, .14);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .22s, background-color .22s, opacity .22s;
}
.pay .amt { font-family: var(--mono); font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.pay:hover { transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 16px 32px rgba(42, 36, 32, .24); background: #1f1a17; }
.pay:active { transform: translateY(0) scale(.985); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 4px 10px rgba(42, 36, 32, .18); }
.pay:focus-visible { outline: 3px solid rgba(194, 85, 46, .55); outline-offset: 3px; }
.pay[aria-disabled="true"] { background: #8d847c; box-shadow: none; transform: none; cursor: not-allowed; }
.pay .spin, .pay .tick { display: none; width: 18px; height: 18px; }
.pay .spin { border: 2px solid rgba(246, 241, 234, .3); border-top-color: #f6f1ea; border-radius: 50%; animation: spin .8s linear infinite; }
.pay[aria-busy="true"] { cursor: progress; background: #3a332e; transform: none; }
.pay[aria-busy="true"] .spin { display: block; }
.pay.is-paid { background: var(--ok); cursor: default; transform: none; box-shadow: 0 10px 24px rgba(47, 122, 79, .22); }
.pay.is-paid .tick { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.again { height: 48px; border-radius: 14px; border: 1px solid rgba(42, 36, 32, .2); background: transparent; font-weight: 600; font-size: 15px; cursor: pointer; transition: background-color .2s, border-color .2s; }
.again:hover { background: rgba(255, 255, 255, .6); border-color: rgba(42, 36, 32, .35); }
.again:active { background: rgba(255, 255, 255, .9); }
.payline { display: none; }
.secure { grid-area: secure; display: flex; align-items: center; gap: 7px; margin-top: 14px; font-size: max(12px, calc(12.5 * var(--s))); color: var(--mute); }
.secure svg { width: 13px; height: 13px; flex: none; color: #9a8b6e; }

/* ---------- stage */
.stage {
  grid-area: stage; position: relative; border-radius: calc(34 * var(--s)); min-height: 520px; isolation: isolate;
  background:
    radial-gradient(70% 46% at 50% 96%, rgba(120, 104, 88, .20), transparent 70%),
    radial-gradient(90% 70% at 34% 14%, #faf6f0 0%, rgba(250, 246, 240, 0) 60%),
    linear-gradient(176deg, #f5efe7 0%, #ece4d9 56%, #e3d9cc 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .65), inset 0 -40px 80px rgba(120, 100, 80, .06), 0 30px 60px -30px rgba(80, 60, 40, .25);
}
.stage::after { /* soft window light across the backdrop */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: linear-gradient(116deg, transparent 18%, rgba(255, 252, 246, .55) 30%, transparent 46%, transparent 58%, rgba(255, 252, 246, .35) 66%, transparent 80%);
  opacity: .55;
}
.tag { position: absolute; left: calc(30 * var(--s)); top: calc(26 * var(--s)); z-index: 4; font-size: max(10.5px, calc(11 * var(--s))); letter-spacing: .22em; font-weight: 700; color: var(--mute); text-transform: uppercase; }
.tag { transition: opacity .3s; }
.tag.under { opacity: 0; }
.fx { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.fx canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.slotclip { position: absolute; left: 0; top: 0; right: 0; height: 0; overflow: hidden; pointer-events: none; }

/* ---------- the receipt: real DOM text, laid out in paper units (400 wide), shaded by the GL paper through multiply */
.paper {
  position: absolute; left: 0; top: 0; width: calc(var(--u) * 400px); transform-origin: 0 0; pointer-events: none;
  font-family: var(--mono); color: var(--thermal); visibility: hidden;
}
.ready .paper { visibility: visible; }
.paper .ink { position: relative; mix-blend-mode: multiply; padding: 0 calc(var(--u) * 26px); -webkit-mask-image: var(--speckle); mask-image: var(--speckle); -webkit-mask-size: calc(var(--u) * 180px); mask-size: calc(var(--u) * 180px); }
.paper .ln { transition: none; }  /* lines develop at the head; a colour transition re-rasterised the masked ink every frame (24 missed frames @3×) */
.paper .ln.wet { color: #a59f98; }
.paper .bean.wet { opacity: .45; }
.lead { height: calc(var(--u) * 140px); }
.bean { display: block; margin: 0 auto; width: calc(var(--u) * 38px); height: calc(var(--u) * 44px); color: var(--thermal); }
.r-brand { height: calc(var(--u) * 34px); margin-top: calc(var(--u) * 4px); font-weight: 700; font-size: calc(var(--u) * 23px); line-height: calc(var(--u) * 34px); text-align: center; letter-spacing: .42em; padding-left: .42em; white-space: nowrap; }
.r-meta, .r-meta2 { height: calc(var(--u) * 15px); font-size: calc(var(--u) * 9.6px); line-height: calc(var(--u) * 15px); text-align: center; white-space: pre; }
.r-meta { margin-top: calc(var(--u) * 20px); font-weight: 500; letter-spacing: .32em; padding-left: .32em; text-transform: uppercase; }
.r-meta2 { letter-spacing: .06em; }
.r-rule { height: calc(var(--u) * 18px); font-size: calc(var(--u) * 10.4px); line-height: calc(var(--u) * 18px); text-align: center; overflow: hidden; white-space: nowrap; letter-spacing: .02em; margin: 0 calc(var(--u) * 10px); }
.r-items { width: 100%; border-collapse: collapse; font-size: calc(var(--u) * 14px); font-weight: 500; }
.r-items tr { height: calc(var(--u) * 21px); }
.r-items td { padding: 0; line-height: calc(var(--u) * 21px); white-space: nowrap; }
.r-items td:first-child { width: calc(var(--u) * 26px); }
.r-items td:last-child { text-align: right; }
.r-tot { font-size: calc(var(--u) * 13.2px); font-weight: 500; }
.r-tot > div, .r-total { display: flex; justify-content: space-between; }
.r-tot > div { height: calc(var(--u) * 21px); line-height: calc(var(--u) * 21px); }
.r-total { height: calc(var(--u) * 32px); line-height: calc(var(--u) * 32px); font-size: calc(var(--u) * 22px); font-weight: 700; letter-spacing: .01em; }
.r-card { margin-top: calc(var(--u) * 12px); height: calc(var(--u) * 16px); line-height: calc(var(--u) * 16px); font-size: calc(var(--u) * 9.6px); font-weight: 500; letter-spacing: .14em; text-align: center; white-space: pre; }
.r-tail { height: calc(var(--u) * 30px); }
/* printed later: decline band and approval block */
.r-gap { height: calc(var(--u) * 8px); }
.r-band { height: calc(var(--u) * 26px); line-height: calc(var(--u) * 26px); background: var(--thermal); color: #f7f4ef; font-weight: 700; font-size: calc(var(--u) * 11.5px); letter-spacing: .26em; text-align: center; margin: 0 calc(var(--u) * 6px); white-space: pre; }
.r-ok { display: flex; justify-content: space-between; height: calc(var(--u) * 24px); line-height: calc(var(--u) * 24px); font-weight: 700; font-size: calc(var(--u) * 13px); letter-spacing: .04em; }
.r-ok span:last-child { font-weight: 500; letter-spacing: .1em; font-size: calc(var(--u) * 10.4px); }
.r-bar { display: block; margin: calc(var(--u) * 6px) auto 0; width: calc(var(--u) * 232px); height: calc(var(--u) * 30px); color: var(--thermal); }
.r-thanks { height: calc(var(--u) * 20px); line-height: calc(var(--u) * 20px); margin-top: calc(var(--u) * 4px); font-size: calc(var(--u) * 9.6px); font-weight: 600; letter-spacing: .3em; padding-left: .3em; text-align: center; white-space: pre; }

/* ---------- CSS paper + printer when there is no WebGL (same layout) */
.pbg { display: none; }
.cssprinter { display: none; }
.no-gl .paper .ink { mix-blend-mode: normal; }
.no-gl .pbg {
  display: block; position: absolute; left: 0; right: 0; top: calc(var(--u) * 90px); bottom: 0;
  background: linear-gradient(180deg, #f7f5f0 0%, #f4f1eb 70%, #d6d3cd 100%);
  box-shadow: 14px 12px 24px -8px rgba(70, 50, 30, .22), 3px 3px 6px rgba(70, 50, 30, .10);
}
.plip { display: none; }
.no-gl .plip {
  display: block; position: absolute; left: -3px; right: -3px; top: calc(var(--u) * 60px); height: calc(var(--u) * 37px); border-radius: calc(var(--u) * 15px) calc(var(--u) * 15px) 0 0;
  background: linear-gradient(180deg, #fffdf9 0%, #f3f0ea 55%, #e7e3dc 100%); box-shadow: 18px 16px 20px -10px rgba(70, 50, 30, .25);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at 50% 0, #000 90deg, #0000 0) bottom / calc(var(--u) * 18.18px) 8px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from -45deg at 50% 0, #000 90deg, #0000 0) bottom / calc(var(--u) * 18.18px) 8px repeat-x;
}
.no-gl .torn .pbg { -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from 135deg at 50% 100%, #000 90deg, #0000 0) bottom / calc(var(--u) * 18.18px) 8px repeat-x; mask: linear-gradient(#000 0 0) top / 100% calc(100% - 6px) no-repeat, conic-gradient(from 135deg at 50% 100%, #000 90deg, #0000 0) bottom / calc(var(--u) * 18.18px) 8px repeat-x; }
.no-gl .cssprinter {
  display: block; position: absolute; border-radius: calc(var(--u) * 30px);
  background: linear-gradient(180deg, #3a3532 0%, #2a2624 9%, #1d1b19 40%, #121110 100%);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .22), inset 0 -10px 18px rgba(0, 0, 0, .35), 0 28px 40px -14px rgba(60, 40, 25, .45), 0 6px 10px rgba(60, 40, 25, .25);
}
.cp-slot { position: absolute; height: 7px; border-radius: 4px; background: linear-gradient(#070606, #151312); box-shadow: 0 1.5px 0 rgba(255, 255, 255, .2); }
.cp-led { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: #5cf59a; box-shadow: 0 0 10px 2px rgba(92, 245, 154, .55); }
.cp-led[data-s="busy"] { background: #ffb547; box-shadow: 0 0 10px 2px rgba(255, 181, 71, .55); }
.cp-led[data-s="error"] { background: #ff5a4a; box-shadow: 0 0 10px 2px rgba(255, 90, 74, .55); }

/* ---------- caption */
.cap { grid-area: cap; align-self: center; text-align: center; font-size: max(12px, calc(13 * var(--s))); color: #94897e; }
.cap b { color: #3d342e; font-weight: 600; letter-spacing: .14em; margin-right: 12px; text-transform: uppercase; }

/* ---------- success copy */
.paid .sub b { color: var(--ink); font-weight: 600; }

/* ---------- stacked layout: tablets portrait, phones, short landscapes */
@media (max-width: 999.98px), (max-aspect-ratio: 6/5) {
  :root { --s: 1px; }
  .top { height: 64px; padding: 0 22px; max-width: 640px; margin: 0 auto; }
  .top nav { display: none; }
  .logo { font-size: 26px; }
  .secure-top { font-size: 14px; }
  .main {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: none; column-gap: 0; min-height: 0;
    grid-template-areas: "title" "pay" "payline" "stage" "cap" "fields" "secure";
    padding: 0 22px 40px; max-width: 640px; margin: 0 auto;
  }
  .title { padding-top: 2px; }
  h1 { font-size: 36px; }
  .sub { font-size: 15px; margin-top: 8px; }
  .paybox { margin-top: 16px; }
  .pay { height: 56px; border-radius: 14px; }
  .payline { display: block; grid-area: payline; margin-top: 10px; font-size: 13px; color: var(--mute); text-align: center; }
  .payline b { color: var(--ink); font-weight: 600; }
  .payline a { display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; padding: 0 4px; font-weight: 600; color: var(--ink); text-underline-offset: 3px; }
  .stage { margin: 2px -7px 0; aspect-ratio: 360 / 488; min-height: 0; border-radius: 30px; }
  .tag { left: 29px; top: 30px; font-size: 11px; }
  .cap { margin: 14px 0 6px; font-size: 11.5px; line-height: 1.5; padding: 0 8px; }
  .cap b { display: inline; margin-right: 8px; }
  .fields { margin-top: 26px; scroll-margin-top: 20px; }
  .fields .dh { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; white-space: normal; grid-column: span 2; font-family: var(--serif); font-weight: 400; font-size: 26px; margin-bottom: 2px; }
  .f input { scroll-margin-top: 90px; scroll-margin-bottom: 120px; }
  .secure { justify-content: center; margin-top: 16px; }
}
@media (max-width: 380px) { h1 { font-size: 34px; } .main { padding: 0 16px 36px; } .top { padding: 0 16px; } .stage { margin: 4px -4px 0; } }
@media (min-width: 700px) and (max-width: 999.98px), (min-width: 700px) and (max-aspect-ratio: 6/5) {
  .stage { aspect-ratio: 4 / 4.6; }
}
@media (min-width: 2200px) and (min-aspect-ratio: 6/5) { .f label { font-size: calc(11 * var(--s)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .pay .spin { animation: spin 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
