/* Hofkasse. The brand theme of Hoftor (brown, gold) around cards that look like the
   printed Wertkarte: same green paper, the badge as a watermark, boxes that get struck. */
:root {
    --brown: #2a2119;
    --brown-2: #3b2f24;
    --brown-3: #4a3c2f;
    --gold: #d9a441;
    --muted: #cdbfad;
    --green: #15803d;
    --red: #b91c1c;
    --amber: #b45309;
    --ink: #1d1d1b;
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #fff;
    background-color: var(--brown);
    background-image: radial-gradient(130% 60% at 50% -10%, rgba(217, 164, 65, .28), transparent 70%);
    background-repeat: no-repeat;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
svg { flex: none; }

.app {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

/* ---------- header and balance ---------- */

.top { display: flex; align-items: center; justify-content: space-between; min-height: 50px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 800; letter-spacing: .01em; }
.brand-mark {
    width: 40px; height: 40px;
    background: #fff;
    -webkit-mask: url(logo.svg) center / contain no-repeat;
    mask: url(logo.svg) center / contain no-repeat;
}
.icon-btn {
    display: grid; place-items: center;
    width: 46px; height: 46px; padding: 0;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer;
}
.icon-btn svg { width: 26px; height: 26px; }

.summary { margin: 10px 0 4px; }
.sum-label { margin: 0; color: var(--muted); font-size: 1rem; }
.sum-total { margin: 0; font-size: clamp(2.4rem, 12vw, 3.2rem); font-weight: 900; line-height: 1.05; letter-spacing: -.01em; }
.sum-meta { margin: 4px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.35; }

/* ---------- card carousel ---------- */

/* Full bleed, so the next card peeks in from the edge: you can see there are more. */
.wallet { margin: 8px -16px 0; }
.cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    padding: 8px 16px 16px;
    scrollbar-width: none;
}
.cards::-webkit-scrollbar { display: none; }
.slot { flex: 0 0 100%; scroll-snap-align: center; }
.cards.many .slot { flex-basis: calc(100% - 30px); }
.dots { display: flex; justify-content: center; gap: 6px; min-height: 6px; margin-top: -4px; }
.dot {
    width: 26px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer;
    display: grid; place-items: center;
}
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .32); transition: width .2s ease; }
.dot.on::before { width: 22px; background: var(--gold); }

/* ---------- the Wertkarte ----------
   Proportions of the printed card (1954 × 1208). Everything inside is sized in cqw of
   the card, so it scales like a picture but stays sharp text. */
.wk {
    container-type: inline-size;
    position: relative;
    width: 100%;
    aspect-ratio: 1954 / 1208;
    border-radius: 14px;
    background: var(--paper);
    color: var(--ink);
    text-align: left;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .38), 0 1px 0 rgba(255, 255, 255, .25) inset;
    --paper: #a5cda1;
    --mark: #88b884;
    --line: .26cqw;
}
.wk-50 { --paper: #a5cda1; --mark: #88b884; }
.wk-20 { --paper: #f1d78e; --mark: #dfbd62; }
.wk-x { --paper: #aecbe6; --mark: #8db0d2; }
.wk-in {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 5cqw 2.2cqw 3.6cqw 6cqw;
    font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}
.wk-mark {
    position: absolute;
    left: 37cqw;
    top: -8cqw;
    width: 65cqw;
    aspect-ratio: 2160 / 2144;
    background: var(--mark);
    -webkit-mask: url(logo.svg) center / contain no-repeat;
    mask: url(logo.svg) center / contain no-repeat;
    pointer-events: none;
}
.wk-in > :not(.wk-mark) { position: relative; }
.wk-no { position: absolute !important; right: 8.6cqw; top: 4.4cqw; margin: 0; font-size: 2.6cqw; letter-spacing: .02em; }
.wk-title { margin: 2.4cqw 0 0; font-size: 4.9cqw; font-weight: 800; line-height: 1.05; letter-spacing: -.01em; }
.wk-subtitle { margin: .5cqw 0 0; font-size: 3.5cqw; font-weight: 700; line-height: 1.15; }
.wk-value { position: absolute !important; right: 8.6cqw; top: 10.4cqw; margin: 0; font-size: 5.6cqw; font-weight: 800; letter-spacing: -.01em; }
.wk-value b { font-size: 7.8cqw; }
.wk-rows { display: grid; gap: 1.6cqw; margin-top: 5.6cqw; }
.wk-row { display: flex; align-items: center; gap: 1.4cqw; }
.wk-group {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 8.2cqw;
    border: var(--line) solid var(--ink);
    border-right: 0;
    width: max-content;
}
.wk-box {
    position: relative;
    height: 6.1cqw;
    display: grid;
    place-items: center;
    border-right: var(--line) solid var(--ink);
}
.wk-box b { font-size: 3.2cqw; font-weight: 800; letter-spacing: -.02em; }
.wk-sum { margin-left: auto; padding-right: .4cqw; font-size: 2.2cqw; }
.wk-strike { position: absolute; inset: -.4cqw; width: calc(100% + .8cqw); height: calc(100% + .8cqw); overflow: visible; }
.wk-strike path { fill: none; stroke: #1e2a5a; stroke-width: 5.5; stroke-linecap: round; opacity: .9; }
.wk-box.is-new path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .24s ease-out forwards; animation-delay: calc(var(--t, 0s) + .45s); }
.wk-box.is-new path + path { animation-delay: calc(var(--t, 0s) + .57s); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.wk-box i {
    position: absolute;
    right: -.8cqw;
    bottom: -1.9cqw;
    padding: 0 .6cqw;
    border-radius: .8cqw;
    background: var(--ink);
    color: var(--paper);
    font-size: 1.7cqw;
    font-style: normal;
    font-weight: 700;
    white-space: nowrap;
    z-index: 1;
}
.wk-note { margin: auto 0 0; padding-right: 4cqw; font-size: 2.05cqw; line-height: 1.25; }
.wk-rest { margin: 1.2cqw 0 0; font-size: 3.6cqw; font-weight: 800; letter-spacing: -.01em; }
.wk.is-empty { filter: saturate(.45) brightness(.92); }
.wk.is-given { filter: grayscale(.85) brightness(.9); }
.wk.is-sharing .wk-rows { opacity: .55; }
/* Small label next to the card number: "Erhalten" / "Wird weitergegeben". */
.wk-tag {
    position: absolute !important;
    right: 22cqw;
    top: 4.1cqw;
    padding: .3cqw 1.6cqw;
    border-radius: 3cqw;
    background: var(--ink);
    color: var(--paper);
    font-size: 2.2cqw;
    font-weight: 800;
    letter-spacing: .02em;
}
.wk-tag.is-sharing { background: #b45309; color: #fff; }
.wk-stamp.is-given { border-color: #1e3a8a; color: #1e3a8a; font-size: 6cqw; }
/* Share button, bottom right where the printed card has no text. */
.wk-share {
    position: absolute !important;
    right: 2.6cqw;
    bottom: 2.6cqw;
    display: grid;
    place-items: center;
    width: max(40px, 10cqw);
    height: max(40px, 10cqw);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(29, 29, 27, .86);
    color: var(--paper);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.wk-share svg { width: 56%; height: 56%; }
.wk.is-sharing .wk-share { background: #b45309; color: #fff; }
.wk-stamp {
    position: absolute !important;
    left: 50%;
    top: 47%;
    transform: translate(-50%, -50%) rotate(-12deg);
    padding: .6cqw 2.6cqw;
    border: .7cqw solid #8f1d1d;
    border-radius: 1.6cqw;
    color: #8f1d1d;
    font-size: 7cqw;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: .82;
}
/* The placeholder before the first card: the card's shape, nothing to strike. */
.wk-ghost {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    box-shadow: none;
    outline: 2px dashed rgba(255, 255, 255, .28);
    outline-offset: -2px;
    --mark: rgba(255, 255, 255, .1);
}
.wk-ghost .wk-in { justify-content: center; padding-right: 30cqw; }
.wk-ghost .wk-title { margin: 0 0 1.6cqw; font-size: 6cqw; }
.wk-ghost .wk-subtitle { font-size: 3.9cqw; font-weight: 500; color: var(--muted); line-height: 1.35; }

/* ---------- actions, hints, history ---------- */

.actions { display: grid; gap: 10px; margin-top: 14px; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 60px;
    padding: 10px 20px;
    border-radius: 18px;
    border: 2px solid transparent;
    font-size: 1.2rem;
    font-weight: 800;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.btn svg { width: 26px; height: 26px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-gold { background: var(--gold); color: var(--brown); }
.btn-line { background: transparent; border-color: rgba(255, 255, 255, .3); color: #fff; font-size: 1.08rem; min-height: 54px; }
.btn-white { background: #fff; color: var(--brown); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .75); color: #fff; }
.btn-small { min-height: 42px; padding: 6px 14px; font-size: 1rem; border-radius: 12px; }
.btn-wide { width: 100%; margin-top: 10px; }

.notice {
    display: flex; gap: 12px;
    margin-top: 16px; padding: 14px;
    border: 2px solid rgba(217, 164, 65, .55);
    border-radius: 18px;
    background: rgba(217, 164, 65, .1);
}
.notice-icon { color: var(--gold); }
.notice-icon svg { width: 28px; height: 28px; }
.notice-title { margin: 0 0 2px; font-weight: 800; font-size: 1.1rem; color: var(--gold); }
.notice-text { margin: 0 0 10px; color: var(--muted); line-height: 1.4; }
.notice-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.restore { margin-top: 18px; text-align: center; color: var(--muted); }
.restore p { margin: 0 0 8px; }
.restore .btn { width: 100%; }

.history { margin-top: 22px; }
.history h2 { margin: 0; font-size: 1.15rem; }
.hist-sum { margin: 2px 0 10px; color: var(--muted); font-size: .95rem; }
.moves { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mv {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--brown-2);
}
.mv-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .08); color: var(--muted); }
.mv-ico svg { width: 20px; height: 20px; }
.mv-in .mv-ico { background: rgba(217, 164, 65, .2); color: var(--gold); }
.mv-main { display: grid; min-width: 0; }
.mv-main b { font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.mv-main small { color: var(--muted); font-size: .88rem; line-height: 1.35; }
.mv-amt { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.mv-in .mv-amt { color: var(--gold); }

.foot { margin-top: auto; padding-top: 26px; display: grid; justify-items: center; gap: 12px; }
.foot-note { margin: 0; color: var(--muted); font-size: .85rem; text-align: center; opacity: .8; line-height: 1.4; }
.pill {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 16px;
    border-radius: 22px; border: 2px solid rgba(255, 255, 255, .35);
    background: transparent; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.pill svg { width: 20px; height: 20px; }

/* ---------- camera ---------- */

.scanner { position: fixed; inset: 0; z-index: 20; background: #000; display: grid; place-items: center; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame {
    position: absolute;
    width: min(70vw, 50vh, 340px);
    aspect-ratio: 1;
    border: 4px solid rgba(255, 255, 255, .95);
    border-radius: 24px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
}
.scan-hint {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 24px);
    left: 20px; right: 20px;
    margin: 0;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
}
.scanner .btn { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 24px); left: 20px; right: 20px; background: rgba(0, 0, 0, .35); }

/* ---------- full-screen result ---------- */

.result {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: calc(env(safe-area-inset-top) + 24px) 18px calc(env(safe-area-inset-bottom) + 14px);
    background: var(--res-bg, var(--brown-2));
    text-align: center;
    cursor: pointer;
}
.result[data-kind="ok"] { --res-bg: var(--green); }
.result[data-kind="bad"] { --res-bg: var(--red); }
.result[data-kind="error"] { --res-bg: var(--amber); }
.result[data-kind="info"] { --res-bg: var(--brown-3); }
.res-body { width: 100%; max-width: 30rem; margin: auto 0; }
.result h1 { margin: 0 0 .15em; font-size: clamp(2.4rem, 12vw, 4.2rem); line-height: 1.02; font-weight: 900; text-transform: uppercase; }
.res-amount { margin: 0; font-size: clamp(1.8rem, 9vw, 2.8rem); font-weight: 800; }
.res-text { margin: .3em 0 0; font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.res-cards { display: grid; gap: 14px; margin: 20px auto 0; max-width: 440px; cursor: default; }
.res-sub { margin: 16px 0 0; font-size: 1.12rem; line-height: 1.35; opacity: .95; }
.res-amount:empty, .res-text:empty, .res-sub:empty, .res-cards:empty, .res-actions:empty { display: none; }
.res-actions { display: grid; gap: 10px; margin-top: 20px; }
.res-tap { margin: 18px 0 0; font-size: .9rem; opacity: .7; }

.busy {
    position: fixed; inset: 0; z-index: 40;
    display: grid; place-content: center; justify-items: center; gap: 14px;
    background: rgba(26, 20, 15, .72);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.busy p { margin: 0; font-size: 1.15rem; font-weight: 700; }
.busy-mark {
    width: 96px; height: 96px;
    background: #fff;
    -webkit-mask: url(logo.svg) center / contain no-repeat;
    mask: url(logo.svg) center / contain no-repeat;
    animation: pulse .9s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

.toast {
    position: fixed; z-index: 50;
    left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px);
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    margin: 0; padding: 12px 18px;
    border-radius: 14px;
    background: #fff; color: var(--brown);
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    overflow-wrap: anywhere;
}

/* ---------- sheets ---------- */

/* Anchored below the iPhone status bar: the app draws under it (black-translucent). */
.sheet {
    width: min(100vw - 24px, 460px);
    margin: calc(env(safe-area-inset-top) + 12px) auto auto;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    padding: 0 20px calc(env(safe-area-inset-bottom) + 20px);
    border: 0;
    border-radius: 22px;
    background: var(--brown-2);
    color: #fff;
    overflow-y: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-head {
    position: sticky; top: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0 10px;
    background: var(--brown-2);
}
.sheet h2 { margin: 0; font-size: 1.5rem; }
.sheet h3 { margin: 0 0 8px; font-size: 1.15rem; color: var(--gold); }
.block { padding: 12px 0 18px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.muted { color: var(--muted); font-size: 1rem; line-height: 1.45; }
.muted svg { width: 18px; height: 18px; vertical-align: -3px; }
.small { font-size: .92rem; }
.center { text-align: center; }
.state-line { margin: 0 0 4px; font-weight: 700; color: var(--muted); }
.state-line.ok { color: #86efac; }
.meta { margin: 14px 0 0; color: var(--muted); font-size: .85rem; text-align: center; opacity: .75; }
.qr { width: min(100%, 260px); margin: 8px auto 4px; border-radius: 14px; overflow: hidden; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }

.pay-items { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.pay-items li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, .2); font-size: 1.1rem; }
.pi-ico { display: grid; place-items: center; }
.pi-ico svg { width: 30px; height: 30px; }
.pi-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 2px; font-size: 1.2rem; }
.pay-total b { font-size: 2rem; font-weight: 900; }
.pay-from { margin: 0 0 6px; color: var(--muted); }

.steppers { display: grid; gap: 10px; margin-top: 4px; }
.preview-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; background: rgba(217, 164, 65, .16); color: var(--gold); font-weight: 700; }
.stepper { display: grid; grid-template-columns: auto 1fr 44px 32px 44px; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, .2); }
.stepper-label { font-weight: 700; }
.stepper-count { text-align: center; font-size: 1.35rem; }
.mini { display: grid; place-items: center; width: 64px; height: 40px; border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 1.05rem; }
.round { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: none; cursor: pointer; }
.round svg { width: 22px; height: 22px; }
.round:disabled { opacity: .3; cursor: default; }

@media (prefers-reduced-motion: reduce) {
    .wk-box.is-new path { animation: none; stroke-dashoffset: 0; }
    .busy-mark { animation: none; }
}
