/* theme/caffe.css: il primo caffè. Tasti, QR e spunta vengono da register.css, la cassa vera: qui c'è il palco intorno. */
.page-caffe .rubrics a[href$="/impara/"] { color: var(--red); }
.page-caffe .page-head { margin-bottom: 0; padding-bottom: 48px; }
.page-caffe .page-head p.deck { margin-bottom: 8px; }
p.caffe-avviso { max-width: 760px; margin: 0; padding: 8px 12px; border-left: 4px solid var(--spot); background: var(--paper-2); color: var(--ink); font-family: var(--cond); font-size: 17px; font-weight: 500; line-height: 1.35; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.caffe { --alto: 568px; --m: 0; margin-top: 20px; scroll-margin-top: 6px; }
.caffe:empty { display: none; }
/* La cassa la costruisce caffe.js, spesso a pagina già disegnata: quando compariva, il testo sotto saltava giù (CLS fino
   a 0,37). Se il browser ha JavaScript il suo posto si tiene da subito, alto quanto la cassa costruita; senza JavaScript
   (scripting: none) resta nascosta e non lascia buchi. Le altezze sono misurate: se la cassa cambia, vanno rifatte. */
@media screen and (scripting: enabled) {
  .caffe:empty { display: block; min-height: 706px; }
}
.caffe p { margin: 0; }
.caffe-banda { display: flex; justify-content: space-between; gap: 12px; padding: 3px 12px; background: var(--spot); color: var(--on-spot); font-family: var(--cond); font-size: 15px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.caffe-tempo { font-family: var(--mono); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.caffe-atti { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-inline: 1px solid var(--ink); }
.caffe-atti button, .caffe-libro button { min-height: 44px; padding: 4px 8px; border: 0; border-bottom: 1px solid var(--ink); background: var(--paper); color: var(--ink); font-family: var(--cond); font-size: 17px; font-weight: 700; letter-spacing: .02em; line-height: 1.1; cursor: pointer; touch-action: manipulation; }
.caffe-atti button + button { border-left: 1px solid var(--ink); }
.caffe-atti button b { font-family: var(--mono); font-weight: 600; color: var(--muted); }
.caffe-atti button[aria-current] { background: var(--ink); color: var(--paper); }
.caffe-atti button[aria-current] b { color: inherit; }
.caffe-libro { display: none; grid-template-columns: 1fr 1fr; border-inline: 1px solid var(--ink); }
.caffe-libro button[aria-pressed="true"] { background: var(--paper-2); border-bottom-color: var(--paper-2); text-decoration: underline 2px; text-underline-offset: 3px; }
.caffe-libro button[aria-pressed="false"] { color: var(--muted); }
.caffe-libro button + button { border-left: 1px solid var(--ink); }

.caffe-palco { display: grid; grid-template-columns: minmax(280px, 360px) minmax(220px, 1fr) minmax(280px, 360px); grid-template-rows: auto minmax(0, 1fr); gap: 14px 30px; padding: 16px 24px 22px; border: 1px solid var(--ink); border-top: 0; background: var(--paper-2); transition: background .5s; }
.caffe-barista { grid-column: 1; grid-row: 1 / 3; }
.caffe-riga { grid-column: 2; grid-row: 1; padding-top: 26px; font-family: var(--font-display); font-size: clamp(21px, 1.75vw, 26px); font-weight: 600; line-height: 1.24; }
.caffe-extra { grid-column: 2; grid-row: 2; min-width: 0; font-size: 18px; }
.caffe-extra > * + * { margin-top: 10px; }
.caffe-cliente { grid-column: 3; grid-row: 1 / 3; }
.caffe-app { min-width: 0; }
.caffe-app h2 { margin: 0 0 6px; font-family: var(--cond); font-size: 15px; font-weight: 700; letter-spacing: .09em; line-height: 1.3; text-transform: uppercase; color: var(--muted); }
.caffe-guscio { height: var(--alto); overflow: hidden; border: 3px solid var(--ink); border-radius: 26px; background: var(--paper); }

/* la cassa vera, tolta dalla pagina intera */
.caffe .register { min-height: 0; height: 100%; max-width: none; padding: 12px 14px; color: var(--text); }
/* la cassa ha il fondo carta anche sul palco notte: lì il giallo del fuoco non si vedeva (1,3:1) */
.caffe .register :focus-visible { outline-color: var(--red); }
.caffe .register-top { font-family: var(--cond); font-size: 17px; }
.caffe-cassa { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.caffe .register-screen { gap: 12px; min-height: 0; }
.caffe .register output { min-height: 76px; font-size: 40px; }
.caffe .keys { gap: 8px; }
.caffe .keys button { height: 66px; }
.caffe .hint { margin: 0; font-size: 16px; }
.caffe .qr-box { padding: 10px; box-shadow: none; border: 1px solid var(--line); }
.caffe .qr { width: 240px; height: auto; aspect-ratio: 1; }
.caffe .waiting { flex-wrap: wrap; font-size: 16px; line-height: 1.3; }
.caffe .waiting span { flex: none; animation-iteration-count: 3; animation-fill-mode: both; }  /* nella dimostrazione tre giri e basta (WCAG 2.2.2) */
.caffe .muted { color: var(--muted); font-size: 16px; line-height: 1.3; }
.caffe-esito { font-family: var(--font-display); font-size: 27px; font-weight: 800; line-height: 1.1; }
.caffe-errore { color: var(--error, #b00020); font-weight: 600; font-size: 16px; line-height: 1.25; }
.caffe-qr:has(.caffe-errore) .qr { width: 150px; opacity: .55; }

/* i bottoni dei gesti: stesso arancio del tasto OK */
/* il tasto da battere pulsa tre volte e poi resta segnato: niente che si muova da solo per più di 5 secondi */
.caffe .keys button.prossimo { box-shadow: 0 0 0 3px var(--ink); position: relative; z-index: 1; animation: caffe-invito 1.5s 3 ease-in-out; }
.caffe .button { min-height: 48px; padding: 10px 14px; border-radius: 0; font-family: var(--cond); font-size: 18px; font-weight: 700; line-height: 1.15; touch-action: manipulation; }
.caffe .caffe-via { background: var(--pos-primary); color: var(--pos-on); }
.caffe .button.caffe-via:hover { background: var(--pos-primary); color: var(--pos-on); text-decoration: underline; }
.caffe .button-quiet { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.solo-libro { display: none !important; }
@keyframes caffe-invito { 50% { box-shadow: 0 0 0 6px var(--ink); } }

/* il telefono: un wallet senza marca, sempre di sera */
.caffe-wallet { height: 100%; background: #17163a; color: #f5efe0; font-family: var(--cond); text-align: center; --pos-on: #17163a; }
.w-schermo { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 12px; height: 100%; padding: 20px 18px; }
.w-titolo { font-size: 18px; font-weight: 700; letter-spacing: .03em; }
.w-saldo { font-family: var(--mono); font-size: 32px; font-weight: 600; line-height: 1.1; }
.w-euro { font-family: var(--font-display); font-size: 44px; font-weight: 800; line-height: 1.05; }
.w-sat { font-family: var(--mono); font-size: 21px; color: #ffcc07; }
.w-nota { color: #c9c5d8; font-size: 16px; line-height: 1.3; }
.w-piede { margin-top: 18px !important; color: #c9c5d8; font-size: 17px; }
.w-righe { margin: 4px 0; font-size: 17px; line-height: 1.25; }
.w-righe div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid #413f6c; text-align: left; }
.w-righe dd { margin: 0; text-align: right; font-weight: 700; }
.w-azioni { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.w-attesa { color: #c9c5d8; }
.w-mirino { position: relative; align-self: center; width: 220px; height: 220px; padding: 10px; background: #0e0d26; }
.w-mirino::before, .w-mirino::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.w-mirino::before { background: linear-gradient(#ffcc07, #ffcc07) 0 0 / 34px 4px no-repeat, linear-gradient(#ffcc07, #ffcc07) 0 0 / 4px 34px no-repeat, linear-gradient(#ffcc07, #ffcc07) 100% 0 / 34px 4px no-repeat, linear-gradient(#ffcc07, #ffcc07) 100% 0 / 4px 34px no-repeat; }
.w-mirino::after { background: linear-gradient(#ffcc07, #ffcc07) 0 100% / 34px 4px no-repeat, linear-gradient(#ffcc07, #ffcc07) 0 100% / 4px 34px no-repeat, linear-gradient(#ffcc07, #ffcc07) 100% 100% / 34px 4px no-repeat, linear-gradient(#ffcc07, #ffcc07) 100% 100% / 4px 34px no-repeat; }
.w-mirino img { display: block; width: 200px; height: 200px; padding: 8px; background: #fff; }
.w-mirino i { position: absolute; left: 6px; right: 6px; top: 8px; height: 3px; background: #ffcc07; animation: caffe-leggi 1s ease-in-out infinite alternate; }
@keyframes caffe-leggi { to { top: 208px; } }
.caffe-wallet .tick { flex: none; align-self: center; }
.caffe-wallet .waiting span { background: #ffcc07; }
.w-nero { background: #000; color: #8a8a8a; font-size: 20px; }
.w-parole, .w-foglio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 6px; margin: 0; padding: 0; list-style: none; counter-reset: p; font-size: 15px; }
.w-parole li, .w-foglio li { display: flex; gap: 3px; align-items: baseline; min-height: 30px; padding: 3px 4px; border-bottom: 1px solid currentColor; text-align: left; overflow-wrap: anywhere; line-height: 1.15; counter-increment: p; }
.w-parole li::before, .w-foglio li::before { content: counter(p); font-family: var(--mono); font-size: 11px; opacity: .7; }
.w-foglio { padding: 10px; background: var(--field); color: var(--ink); font-family: var(--font-display); font-style: italic; font-size: 16px; box-shadow: 1px 2px 0 var(--line); }
.caduto { animation: caffe-cade 1s ease-in forwards; }
@keyframes caffe-cade { 30% { transform: rotate(-4deg); } 100% { transform: translateY(120%) rotate(22deg); opacity: 0; } }

/* la ricevuta che esce dalla cassa */
.caffe-feritoia { overflow: hidden; border-top: 3px solid var(--ink); }
.caffe-scontrino { display: flex; flex-direction: column; gap: 3px; padding: 10px; background: var(--field); font-family: var(--mono); font-size: 13px; line-height: 1.35; text-align: left; overflow-wrap: anywhere; animation: caffe-esce .9s ease-out; }
.caffe-scontrino b { font-size: 15px; }
.caffe-scontrino small { padding-top: 4px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
@keyframes caffe-esce { from { transform: translateY(-101%); } }

/* il pagamento che attraversa il banco */
.caffe-scia { position: relative; height: 4px; margin-top: 60px; background: var(--line); }
.caffe-scia i { position: absolute; top: -6px; right: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--pos-primary); box-shadow: 0 0 0 3px var(--ink); animation: caffe-corre 1.2s ease-in-out forwards; }
@keyframes caffe-corre { to { right: calc(100% - 16px); } }

/* fine della prima scena e parole vere */
.caffe-tuttoqui { font-family: var(--font-display); font-size: clamp(34px, 3.4vw, 46px); font-weight: 800; line-height: 1; }
.caffe-tuttoqui-s { font-size: 18px; line-height: 1.3; }
.caffe-extra .caffe-negozio { font-family: var(--cond); font-size: 18px; font-weight: 700; }
.caffe-detto { margin: 12px 0; padding: 0 0 0 12px; border-left: 4px solid var(--pos-primary); font-family: var(--font-display); font-size: 21px; font-style: italic; line-height: 1.25; color: inherit; }
.caffe-detto p { margin: 0; }
.caffe-detto cite { display: block; margin-top: 6px; font-family: var(--cond); font-size: 15px; font-style: normal; font-weight: 500; line-height: 1.3; }
.caffe-fonte { font-family: var(--cond); font-size: 15px; font-weight: 500; line-height: 1.3; }

/* la catena: cambia la luce */
.caffe.catena .caffe-palco { background: var(--night); color: var(--night-text); }
.caffe.catena .caffe-app h2 { color: var(--night-text); }
.caffe.catena .caffe-guscio { border-color: var(--night-text); }
.caffe-barre { font-family: var(--cond); font-size: 17px; --q: 55.3%; }
.caffe-barre p { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.caffe-barre p + p { margin-top: 8px; }
.caffe-barre b { font-family: var(--mono); }
.caffe-barre i { grid-column: 1 / -1; display: block; height: 16px; background: var(--pos-primary); }
.b-caffe { width: var(--q); }
.b-fee { width: 100%; background: #e2583e !important; animation: caffe-sale 1.8s ease-out; }
@keyframes caffe-sale { from { width: 0; } }
.caffe-barre .b-segno { display: block; margin-left: var(--q); padding: 3px 0 0 6px; border-left: 2px solid currentColor; font-size: 15px; line-height: 1.2; animation: caffe-appare .4s 1s both; }
@keyframes caffe-appare { from { opacity: 0; } }
.caffe-attesa { display: grid; grid-template-columns: 84px 56px minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.caffe-orologio { position: relative; width: 84px; height: 84px; border: 3px solid currentColor; border-radius: 50%; background: repeating-conic-gradient(currentColor 0 1.5deg, transparent 0 30deg) center / 100% 100% no-repeat; }
.caffe-orologio::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--night); }
.caffe-orologio i { position: absolute; z-index: 1; left: calc(50% - 1.5px); bottom: 50%; width: 3px; height: 32px; background: currentColor; transform-origin: bottom; transform: rotate(calc(var(--m) * 6deg)); transition: transform .9s linear; }
.caffe-orologio i + i { width: 1px; left: calc(50% - .5px); background: var(--pos-primary); animation: caffe-lancetta 1s linear infinite; }
@keyframes caffe-lancetta { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.caffe-tazza { width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.caffe-tazza .fumo { opacity: calc(1 - var(--m) / 5); transition: opacity .9s; }
.caffe-progresso { height: 12px; border: 1px solid currentColor; }
.caffe-progresso i { display: block; height: 100%; width: calc(var(--m) * 10%); background: var(--pos-primary); transition: width .9s linear; }
.caffe-minuto { margin-top: 4px !important; font-family: var(--mono); font-size: 16px; }
.caffe-conti { font-size: 16px; color: inherit; }
.caffe-conti th, .caffe-conti td { padding: 6px 8px 6px 0; border-bottom: 1px solid currentColor; text-align: left; }
.caffe-consegna:empty { display: none; }

/* il bivio */
.caffe-bivio { display: flex; flex-direction: column; gap: 8px; }
.caffe-bivio .button { text-align: left; }
.caffe-bivio a.caffe-via { margin-top: 6px; text-align: center; text-decoration: none; }
.caffe-fatto { font-family: var(--mono); color: var(--red); }

/* la storia come testo e l'invito */
.caffe-comincia { display: none; }
.caffe-storia { margin-top: 18px; }
.caffe-storia summary { font-family: var(--cond); font-size: 18px; font-weight: 700; }
.caffe-storia h2 { font-size: 26px; }
.caffe-storia li { margin-bottom: 6px; }
.caffe-adesso { scroll-margin-top: 10px; }
.caffe-adesso .formula a { font-weight: 800; }
.caffe-adesso .caffe-detto { max-width: 700px; margin-block: 18px; }

/* a libro: una pagina alla volta */
@media (max-width: 899px) {
  .caffe { --alto: auto; margin-top: 14px; }
  .page-caffe .page-head { padding-bottom: 38px; }
  .caffe-comincia { display: block; margin-top: 12px; padding: 12px 14px; background: var(--pos-primary); color: var(--pos-on); font-family: var(--cond); font-size: 19px; font-weight: 700; letter-spacing: .03em; text-align: center; text-transform: uppercase; text-decoration: none; }
  a.caffe-comincia:hover, a.caffe-comincia:visited { color: var(--pos-on); }
  .caffe-libro { display: grid; }
  .solo-libro { display: block !important; width: 100%; }
  .caffe-palco { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 8px; padding: 10px 10px 14px; perspective: 1400px; }
  .caffe-riga { grid-column: 1; grid-row: auto; order: 0; min-height: 3.75em; padding-top: 0; font-size: 19px; }
  .caffe-barista, .caffe-cliente { grid-column: 1; grid-row: auto; order: 1; }
  .caffe-extra { grid-column: 1; grid-row: auto; order: 2; }
  .caffe-extra:empty { display: none; }
  .caffe-palco.sopra .caffe-extra { order: 0; }
  .caffe-palco[data-pagina="cassa"] .caffe-cliente, .caffe-palco[data-pagina="telefono"] .caffe-barista, .caffe-palco.solo-mezzo .caffe-app { display: none; }
  .caffe-app { transform-origin: left center; animation: caffe-volta .34s ease-out; }
  .caffe-app h2 { display: none; }
  .caffe-guscio { min-height: 400px; border-radius: 20px; }
  .caffe .register { min-height: 400px; }
  .caffe-wallet { min-height: 400px; }
  .caffe .keys button { height: 52px; }
  .caffe .register output { min-height: 58px; font-size: 32px; }
  .caffe .register-screen { gap: 8px; }
  .caffe .qr { width: 200px; }
  .caffe-banda { padding-inline: 8px; font-size: 13px; letter-spacing: 0; }
  .caffe-palco.sopra .caffe-guscio, .caffe-palco.sopra .register, .caffe-palco.sopra .caffe-wallet { min-height: 0; }
  .caffe-atti button, .caffe-libro button { font-size: 16px; }
  .caffe-scia { display: none; }
}
/* Sul telefono caffe.js mette anche «Comincia dalla cassa» in fondo alla testata: si tiene anche il suo posto (65 px) */
@media screen and (scripting: enabled) and (max-width: 899px) {
  .caffe:empty { min-height: 624px; }
  .page-caffe .page-head:has(+ .caffe:empty) { padding-bottom: calc(38px + 65px); }
}
@media (max-width: 899px) and (max-height: 640px) {
  .caffe .keys button { height: 44px; }
  .caffe .qr { width: 160px; }
  .caffe .register output { min-height: 48px; font-size: 28px; }
  .caffe .hint { font-size: 15px; }
}
@keyframes caffe-volta { from { transform: rotateY(62deg); opacity: .25; } }

@media (prefers-reduced-motion: reduce) {
  .caffe *, .caffe-palco { animation: none !important; transition: none !important; }
}
@media screen and (prefers-color-scheme: dark) {
  .caffe .keys button { color: var(--text); }
  .caffe .keys .ok { color: var(--pos-on); }
  .caffe .keys button:active { color: var(--pos-on); }
  .caffe-wallet { background: #0f0e26; }
  .caffe-guscio { border-color: #6b6999; }
  .caffe.catena .caffe-palco { background: #0f0e26; }
  .caffe-orologio::after { background: #0f0e26; }
}
@media print {
  .caffe { display: none; }
}

/* Chi batte un importo diverso da 1,20: la riga che lo suggeriva lampeggia due volte, e si va avanti lo stesso */
.caffe-riga.caffe-lampo { animation: caffe-lampo .45s ease-in-out 3; }
@keyframes caffe-lampo { 50% { color: var(--red, #b3261e); } }
@media (prefers-reduced-motion: reduce) { .caffe-riga.caffe-lampo { animation: none; text-decoration: underline wavy var(--red, #b3261e); } }
/* «Genera QR» al posto di «OK»: due parole nel tasto, più piccole */
.caffe .caffe-cassa .keys button.ok { font-size: 17px; line-height: 1.15; padding: 0 4px; white-space: normal; }
