/* Guest board – runs on bar TVs and must stay readable from across the room.
   Four designs share one frame (header, stage, footer). Sizes inside the stage derive from
   --u (row/tile height in px) and --w (column/tile width in px), measured by board.js, so every
   design uses the largest type that fits, for any number of drinks.
   Bars override the variables below (and any class) via their custom CSS. */
:root {
    --ds-bg: #07090d;
    --ds-surface: #11151c;
    --ds-surface-2: #181d26;
    --ds-border: #262e3b;
    --ds-text: #f4f6fa;
    --ds-muted: #97a1b3;
    --ds-up: #22e083;
    --ds-down: #ff5566;
    --ds-flat: #97a1b3;
    --ds-accent: #ffb000;
    --ds-crash: #ff2e4d;
    --ds-flap-bg: #16191f;
    --ds-flap-text: #ffcf5a;
    --ds-font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --ds-mono: Consolas, "SFMono-Regular", Menlo, monospace;
    --ds-logo: none;
    --ds-logo-width: 0px;
    --ds-radius: 14px;
    --u: 100px;
    --w: 600px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--ds-bg);
    color: var(--ds-text);
    font-family: var(--ds-font);
    overflow: hidden;
}

.board { height: 100%; display: flex; flex-direction: column; }

/* ============================ header ============================ */
.board-header {
    flex: none;
    display: flex;
    align-items: center;
    gap: 2vw;
    padding: 1.3vh 1.6vw;
    border-bottom: 2px solid var(--ds-border);
    min-width: 0;
}
/* Hidden until a bar sets --ds-logo and --ds-logo-width (e.g. 12vh). */
.board-logo { width: var(--ds-logo-width); height: 6vh; background: var(--ds-logo) left center / contain no-repeat; flex: none; }
.board-title {
    margin: 0;
    font-size: clamp(1.4rem, 4.4vh, 4rem);
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.board-demo {
    flex: none;
    font-family: var(--ds-mono);
    font-size: clamp(.8rem, 2.2vh, 1.8rem);
    font-weight: 800;
    letter-spacing: .2em;
    padding: .3vh .8vw;
    border: 2px solid var(--ds-accent);
    border-radius: 6px;
    color: var(--ds-accent);
}
.board-demo[hidden] { display: none; }
.board-status { flex: none; font-family: var(--ds-mono); font-size: clamp(.9rem, 2.4vh, 2rem); font-weight: 800; letter-spacing: .12em; }
.board-status--open { color: var(--ds-up); }
.board-status--closed { color: var(--ds-muted); }

.board-movers { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 2.5vw; font-family: var(--ds-mono); font-size: clamp(.9rem, 2.4vh, 2rem); white-space: nowrap; overflow: hidden; }
.board-movers__item { overflow: hidden; text-overflow: ellipsis; }
.board-movers__item--up { color: var(--ds-up); }
.board-movers__item--down { color: var(--ds-down); }
.board-movers b { color: var(--ds-text); }

.board-refresh { flex: none; display: flex; align-items: center; gap: .7vw; color: var(--ds-muted); font-size: clamp(.8rem, 2vh, 1.6rem); }
.board-refresh__ring { width: 4.4vh; height: 4.4vh; transform: rotate(-90deg); }
.board-refresh__ring circle { fill: none; stroke-width: 4; }
.board-refresh__track { stroke: var(--ds-border); }
.board-refresh__bar { stroke: var(--ds-accent); stroke-linecap: round; stroke-dasharray: 100; }
.board-refresh__text b { font-family: var(--ds-mono); font-size: 1.35em; color: var(--ds-text); font-variant-numeric: tabular-nums; }
.board--closed .board-refresh__ring { visibility: hidden; }

.board-clock { flex: none; font-family: var(--ds-mono); font-size: clamp(1.2rem, 4.2vh, 3.6rem); font-weight: 700; color: var(--ds-accent); }

/* ============================ stage ============================ */
.board-stage {
    flex: 1;
    min-height: 0;
    padding: 1.4vh 1.6vw;
    display: grid;
    gap: 1.1vh 1.6vw;
    grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
    grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
    grid-auto-flow: column;
    overflow: hidden;
}

/* shared value styling – price changes fade the colour, never flash a background */
[data-f="price"] { font-family: var(--ds-mono); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; transition: color 1.4s ease; }
[data-f="price"].tick-up { color: var(--ds-up); transition: none; }
[data-f="price"].tick-down { color: var(--ds-down); transition: none; }
[data-f="change"] { font-family: var(--ds-mono); font-weight: 700; white-space: nowrap; }
[data-trend="up"] [data-f="change"] { color: var(--ds-up); }
[data-trend="down"] [data-f="change"] { color: var(--ds-down); }
[data-trend="flat"] [data-f="change"] { color: var(--ds-flat); }
[data-f="name"] { overflow-wrap: break-word; hyphens: auto; }
.drink-img { display: block; aspect-ratio: 1; object-fit: cover; border-radius: 18%; flex: none; }
.drink-img[hidden] { display: none; }

.sparkline { display: block; width: 100%; overflow: visible; }
.sparkline__area { fill: var(--ds-flat); opacity: .14; }
.sparkline__line { fill: none; stroke: var(--ds-flat); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
[data-trend="up"] .sparkline__line { stroke: var(--ds-up); }
[data-trend="up"] .sparkline__area { fill: var(--ds-up); }
[data-trend="down"] .sparkline__line { stroke: var(--ds-down); }
[data-trend="down"] .sparkline__area { fill: var(--ds-down); }

.drink.is-crashed { box-shadow: inset 0 0 0 4px var(--ds-crash); }
.drink.is-crashed [data-f="price"] { color: var(--ds-crash); }

/* ============================ design: Anzeigetafel ============================ */
.board--anzeigetafel .board-stage { gap: .8vh 1.6vw; }
/* --k: one size unit per row, bounded by row height AND column width, so flaps never squeeze the name
   (two columns on a wide screen, or narrow portrait screens). */
.dt {
    --k: min(var(--u), calc(var(--w) / 13));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto calc(var(--k) * 1.55);
    align-items: center;
    gap: calc(var(--k) * .18);
    padding: 0 calc(var(--k) * .2) 0 calc(var(--k) * .12);
    min-height: 0;
    background: #0c0e12;
    border: 1px solid #1d212a;
    border-radius: 8px;
    color: var(--ds-flap-text);
    font-family: var(--ds-mono);
}
.dt .drink-img { height: min(calc(var(--u) * .74), calc(var(--k) * .9)); }
.dt [data-f="name"] { font-size: min(calc(var(--u) * .4), calc(var(--w) * .04)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.08; }
.dt .flaps { display: flex; gap: calc(var(--k) * .05); }
.flap {
    position: relative;
    width: calc(var(--k) * .48);
    height: calc(var(--k) * .76);
    display: grid;
    place-items: center;
    background: var(--ds-flap-bg);
    border-radius: 5px;
    font-size: calc(var(--k) * .58);
    font-weight: 800;
    color: var(--ds-flap-text);
    box-shadow: inset 0 -2px 0 #0009;
    transition: color 1.4s ease;
}.flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #000c; }
.flap.flip { animation: flip .45s ease-in-out; }
.flaps.tick-up .flap { color: var(--ds-up); transition: none; }
.flaps.tick-down .flap { color: var(--ds-down); transition: none; }
.dt.is-crashed .flap { color: var(--ds-crash); }
@keyframes flip { 50% { transform: rotateX(90deg); } }
.dt [data-f="change"] { font-size: calc(var(--k) * .3); text-align: right; }

/* ============================ design: Kurstafel ============================ */
.kt {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "name name" "img price" "img meta";
    grid-template-rows: auto 1fr auto;
    column-gap: calc(var(--u) * .1);
    align-items: center;
    padding: calc(var(--u) * .06) calc(var(--u) * .1);
    min-height: 0;
    border-bottom: 2px solid var(--ds-border);
}
.kt [data-f="name"] { grid-area: name; font-size: min(calc(var(--u) * .17), calc(var(--w) * .05)); font-weight: 800; line-height: 1.12; }
.kt .drink-img { grid-area: img; height: calc(var(--u) * .5); }
.kt [data-f="price"] { grid-area: price; font-size: min(calc(var(--u) * .4), calc(var(--w) * .11)); line-height: 1; }
.kt__meta { grid-area: meta; display: flex; align-items: center; gap: calc(var(--u) * .08); min-width: 0; }
.kt .sparkline { height: calc(var(--u) * .12); flex: 1; min-width: 0; }
.kt [data-f="change"] { font-size: min(calc(var(--u) * .13), calc(var(--w) * .045)); }

/* ============================ design: Kacheln ============================ */
.board--kacheln .board-stage { grid-auto-flow: row; gap: 1.4vh 1.2vw; }
.kc {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: calc(var(--u) * .03);
    padding: calc(var(--u) * .06) calc(var(--u) * .065);
    min-height: 0;
    background: linear-gradient(180deg, var(--ds-surface-2), var(--ds-surface));
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius);
    overflow: hidden;
}
.kc__head { display: flex; align-items: center; gap: calc(var(--u) * .05); min-width: 0; }
.kc .drink-img { height: calc(var(--u) * .2); }
.kc [data-f="name"] { font-size: min(calc(var(--u) * .095), calc(var(--w) * .09)); font-weight: 800; line-height: 1.12; min-width: 0; }
.kc [data-f="price"] { align-self: center; font-size: min(calc(var(--u) * .2), calc(var(--w) * .185)); line-height: 1; }
.kc__meta { display: flex; align-items: center; gap: calc(var(--u) * .04); min-width: 0; }
.kc .sparkline { height: calc(var(--u) * .13); flex: 1; min-width: 0; opacity: .5; }
.kc [data-f="change"] { font-size: calc(var(--u) * .07); padding: .2em .6em; border-radius: 999px; background: #0006; }

/* ============================ design: Spotlight ============================ */
.board--spotlight .board-stage { grid-template-columns: 42fr 58fr; grid-template-rows: 1fr; grid-auto-flow: row; }
.sp-spot { position: relative; min-height: 0; border-radius: 20px; background: radial-gradient(circle at 30% 20%, #1f2838, var(--ds-surface)); border: 1px solid var(--ds-border); overflow: hidden; }
.sp-slide {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto 1fr auto auto;
    gap: calc(var(--sh) * .015);
    padding: calc(var(--sh) * .05) calc(var(--sw) * .07);
    opacity: 0;
    transition: opacity 1.2s ease;
}
.sp-slide.is-active { opacity: 1; }
.sp-slide__label { font-size: calc(var(--sh) * .035); letter-spacing: .2em; text-transform: uppercase; color: var(--ds-accent); font-weight: 700; }
.sp-slide__top { display: flex; align-items: center; gap: calc(var(--sw) * .05); min-width: 0; }
.sp-slide .drink-img { height: min(calc(var(--sh) * .22), calc(var(--sw) * .3)); }
.sp-slide [data-f="name"] { font-size: min(calc(var(--sh) * .075), calc(var(--sw) * .085)); font-weight: 900; line-height: 1.05; min-width: 0; }
.sp-slide__bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 1vw; flex-wrap: wrap; }
.sp-slide .sparkline { align-self: end; height: calc(var(--sh) * .13); opacity: .5; }
.sp-slide [data-f="price"] { font-size: min(calc(var(--sh) * .17), calc(var(--sw) * .17)); line-height: 1; }
.sp-slide [data-f="change"] { font-size: calc(var(--sh) * .05); }
.sp-list { display: grid; grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr)); min-height: 0; }
.sp-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto calc(var(--u) * 1.7);
    align-items: center;
    gap: calc(var(--u) * .16);
    padding: 0 calc(var(--u) * .12);
    min-height: 0;
    border-bottom: 1px solid var(--ds-border);
}
.sp-item .drink-img { height: calc(var(--u) * .74); }
.sp-item [data-f="name"] { font-size: min(calc(var(--u) * .4), calc(var(--w) * .042)); font-weight: 700; line-height: 1.08; }
.sp-item [data-f="price"] { font-size: min(calc(var(--u) * .58), calc(var(--w) * .06)); }
.sp-item [data-f="change"] { font-size: calc(var(--u) * .3); text-align: right; }

/* ============================ footer: ticker / crash ============================ */
.board-footer { flex: none; position: relative; height: 8vh; overflow: hidden; background: var(--ds-surface); border-top: 3px solid var(--ds-accent); }
/* Crossfade; visibility as well, because the animated ticker sits on its own compositing layer. */
.ticker, .crash-banner { position: absolute; inset: 0; display: flex; align-items: center; transition: opacity .6s, visibility .6s; }
.ticker { white-space: nowrap; font-family: var(--ds-mono); font-size: clamp(1rem, 3.4vh, 3rem); }
.ticker__track { display: inline-flex; gap: 3.5vw; padding-left: 3.5vw; animation: ticker-scroll var(--ticker-duration, 60s) linear infinite; }
.ticker__item { display: inline-flex; gap: .9vw; }
.ticker__item [data-f="name"] { font-weight: 700; }
.ticker__item [data-f="price"] { color: var(--ds-accent); }
@keyframes ticker-scroll { to { transform: translateX(-50%); } }

.crash-banner { opacity: 0; visibility: hidden; justify-content: center; gap: 2vw; background: var(--ds-crash); color: #fff; font-weight: 900; font-size: clamp(1.2rem, 4.4vh, 4rem); text-transform: uppercase; letter-spacing: .03em; }
.crash-banner__countdown { font-family: var(--ds-mono); background: #0004; padding: .2vh 1vw; border-radius: 8px; }
.board--crash .crash-banner { opacity: 1; visibility: visible; }
.board--crash .ticker { opacity: 0; visibility: hidden; }

/* ============================ closed / offline ============================ */
.board-closed {
    position: fixed; left: 50%; bottom: 11vh; transform: translateX(-50%);
    padding: 1vh 3vw; background: var(--ds-surface-2); border: 1px solid var(--ds-border); border-radius: var(--ds-radius);
    color: var(--ds-text); font-size: clamp(1rem, 3vh, 2.6rem); white-space: nowrap;
}
.board-closed[hidden] { display: none; }
.board--closed [data-f="change"], .board--closed .sparkline { opacity: .3; }

.board-offline { position: fixed; top: 1vh; right: 1vw; padding: .6vh 1vw; background: var(--ds-down); color: #fff; border-radius: 8px; font-size: clamp(.8rem, 2vh, 1.4rem); }
.board-offline[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    .ticker__track { animation: none; }
    .flap.flip { animation: none; }
}

/* Portrait screens (and phones): header wraps, movers drop out. Sizes still follow --u/--w. */
@media (orientation: portrait) {
    .board-header { flex-wrap: wrap; gap: 1vh 3vw; }
    .board-movers { display: none; }
    .board-title { font-size: clamp(1.1rem, 3vh, 3rem); flex: 1; }
    .board--spotlight .board-stage { grid-template-columns: 1fr; grid-template-rows: 38fr 62fr; }
}
