Files
rotatyvote/static/css/screen.css
T

185 lines
14 KiB
CSS

body.screen {
height: 100vh; height: 100dvh; overflow: hidden;
display: grid; grid-template-rows: auto 1fr auto;
background: var(--bg);
}
.s-head, .s-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2vh 3vw; }
.s-title { font: 700 clamp(1rem, 2vw, 2rem) var(--round); text-align: center; flex: 1; color: var(--ink-2); }
.s-tools { display: flex; gap: 10px; align-items: center; }
:fullscreen .s-tools button { display: none; }
/* definite tracks: percentage heights below resolve the same in every engine */
.s-main { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); padding: 1vh 4vw; }
.s-enroll { display: grid; grid-template-columns: auto 1fr; grid-template-rows: minmax(0, 1fr); gap: 5vw; align-items: center; min-height: 0; height: 100%; }
.qr-wrap {
height: 100%; max-height: 74vh; aspect-ratio: 1; display: grid; grid-template-rows: 1fr auto;
background: #fff; border-radius: 28px; padding: 2vh; gap: 1.4vh;
}
.qr-wrap.ring { background: transparent; padding: 0; }
/* the entry qr docks in the bottom right corner, outside the layout: the ring never shrinks for it.
the column under it keeps that much room free (body.has-entry) */
body.screen { --dock-qr: clamp(150px, min(34vh, 24vw), 480px); --dock-h: calc(var(--dock-qr) + 2.4vh + 2.9rem); }
/* with a question on screen the qr leaves the question some height */
body.split-on { --dock-qr: clamp(130px, min(26vh, 19vw), 380px); }
.entry {
position: fixed; right: 1.2vw; bottom: 1.5vh; z-index: 5; display: grid; justify-items: center; gap: .8vh;
background: var(--surface); border-radius: 18px; padding: 1.2vh; text-align: center; max-width: 40vw;
}
.entry canvas { width: var(--dock-qr); height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.entry div { display: grid; gap: .2vh; font-size: clamp(.7rem, .95vw, 1rem); color: var(--ink-2); overflow-wrap: break-word; }
.entry b { color: var(--ink); font-weight: 700; }
body.has-entry .s-main:not(.split) .s-steps, body.has-entry .s-main.split #focus { padding-bottom: var(--dock-h); }
/* big mode: the entry qr takes the right column beside the ring, the steps give it the room.
translate, not transform: the entrance animation owns transform */
body.entry-big { --dock-qr: clamp(180px, min(58vh, 34vw), 640px); }
body.entry-big .entry { top: 50%; bottom: auto; right: max(4vw, calc((50vw - var(--dock-qr)) / 2 - 2vw)); translate: 0 -46%; padding: 2vh; gap: 1.2vh; }
body.entry-big .entry div { font-size: clamp(.9rem, 1.4vw, 1.6rem); }
body.entry-big .s-main:not(.split) .s-steps { visibility: hidden; }
body.entry-q-on { --dock-qr: clamp(160px, min(52vh, 32vw), 580px); }
/* width 0 + min-width 100%: a long question wraps to the qr's width instead of widening the block */
.entry-q { display: grid; gap: .6vh; padding-bottom: 1vh; margin-bottom: .4vh; border-bottom: 2px solid var(--bg); width: 0; min-width: 100%; }
.entry-q > b { font: 700 clamp(1rem, 1.7vw, 2rem) var(--round); color: var(--ink); line-height: 1.15; }
.entry-q > span { font: 600 clamp(.85rem, 1.2vw, 1.4rem) var(--round); color: var(--ink-2); }
/* open vote above the big qr: its options and the turnout bar, smaller than in the question block */
body.entry-q-on.entry-opts-on { --dock-qr: clamp(150px, min(48vh, 30vw), 540px); }
.entry-opts { list-style: none; padding: 0; margin: .2vh 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .6vh .5vw; }
.entry-opts li { font: 600 clamp(.8rem, 1.15vw, 1.35rem) var(--round); background: var(--bg); border-radius: 12px; padding: .6vh .8vw; }
/* .entry div is a grid: the count reads on one line, the bar stays a flex row */
.entry-q .turnout { display: block; font: 600 clamp(.8rem, 1.1vw, 1.3rem) var(--round); color: var(--ink-2); }
.entry-q .turnout .progress { display: flex; }
.entry-q .turnout b { color: var(--ink); font-size: 1.35em; }
.entry-q .turnout .progress { height: 10px; margin-top: .8vh; }
/* the ring loop resizes the canvas bitmap every frame: its intrinsic size must not feed the layout,
or safari widens the column, which grows the bitmap, which widens the column... */
#qr { width: 100%; height: 100%; min-width: 0; min-height: 0; contain: size; image-rendering: pixelated; image-rendering: crisp-edges; object-fit: contain; }
.tick { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 0 1vh; }
#tick-bar { height: 100%; width: 0; background: var(--mark); border-radius: 99px; }
.s-steps h2 { font-size: clamp(2rem, 4.6vw, 5rem); letter-spacing: -.03em; margin-bottom: .5em; }
.s-steps ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 2vh; counter-reset: s; }
.s-steps li {
counter-increment: s; display: flex; align-items: center; gap: 1.2vw;
font: 600 clamp(1.1rem, 2.3vw, 2.5rem) var(--round); color: var(--ink-2);
}
.s-steps li::before {
content: counter(s); flex: none; display: grid; place-items: center;
width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--surface); color: var(--ink);
font-weight: 700; font-size: .8em;
}
/* a question on screen while the ring is up (vote with presence scans, late enrollment). the back rows read
the ring, so it keeps the wider column and as much height as possible */
.s-main.split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4vw; }
.s-main.split .s-enroll { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 3vh; }
.s-main.split .s-enroll { grid-template-rows: minmax(0, 1fr) auto; gap: 1.5vh; height: 100%; }
.s-main.split .qr-wrap { height: 100%; width: auto; max-width: 100%; max-height: none; }
.s-main.split #qr-steps { display: none; }
.s-main.split .s-steps { text-align: center; }
.s-main.split .s-steps h2 { font-size: clamp(1.2rem, 2.1vw, 2.4rem); margin: 0; }
/* the question side scales with height too, so it still fits above the docked qr on short screens */
.s-main.split .s-focus .q-text { font-size: clamp(1.3rem, min(3.2vw, 6.5vh), 3.6rem); margin-bottom: 2.5vh; }
.s-main.split .s-focus .opts { gap: 1vh; margin-bottom: 2.5vh; }
.s-main.split .s-focus .opts li { font-size: clamp(.95rem, min(1.8vw, 3.6vh), 2rem); padding: 1.1vh 1.5vw; }
.s-main.split .s-focus .turnout { font-size: clamp(.9rem, min(1.5vw, 3vh), 1.7rem); }
.s-main.split .s-focus .results .bar-row { font-size: clamp(.95rem, min(1.8vw, 3.6vh), 2rem); margin: 1.2vh 0; }
.s-main.split .s-steps li { font-size: clamp(1rem, 1.5vw, 1.6rem); }
.s-focus { align-self: center; align-self: safe center; max-width: 1400px; width: 100%; margin: 0 auto; }
.s-focus .q-text { font-size: clamp(1.8rem, 3.8vw, 4rem); letter-spacing: -.025em; line-height: 1.1; margin-bottom: 4vh; }
.s-focus .opts { list-style: none; padding: 0; margin: 0 0 4vh; display: grid; gap: 1.4vh; }
.s-focus .opts li { font: 600 clamp(1.1rem, 2.2vw, 2.3rem) var(--round); background: var(--surface); border-radius: 20px; padding: 1.6vh 2vw; }
.s-focus .turnout { font: 600 clamp(1rem, 1.8vw, 1.9rem) var(--round); color: var(--ink-2); }
.s-focus .turnout b { color: var(--ink); font-size: 1.5em; }
.s-focus .turnout .progress { height: 14px; margin-top: 1.2vh; background: var(--surface); }
.s-focus .results .bar-row { font-size: clamp(1rem, 2.1vw, 2.2rem); grid-template-columns: minmax(120px, 32%) 1fr auto; gap: 2vw; margin: 2vh 0; }
.s-focus .results .bar-track { height: clamp(16px, 3vh, 40px); background: var(--surface); }
.s-focus .results .bar-num { min-width: 7ch; font-size: 1em; }
.s-focus .results-foot { font-size: clamp(.9rem, 1.3vw, 1.3rem); }
.s-focus .status { font: 600 clamp(1rem, 1.8vw, 1.9rem) var(--round); color: var(--ink-2); }
.s-idle { place-self: center; text-align: center; }
.s-idle h1 { font-size: clamp(2.4rem, 5.5vw, 6rem); letter-spacing: -.03em; }
.s-idle img { width: clamp(64px, 9vw, 140px); margin-bottom: 3vh; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .s-idle img { animation: none; } }
.s-count { font: 600 clamp(.95rem, 1.5vw, 1.5rem) var(--round); color: var(--ink-2); display: flex; align-items: baseline; gap: .4em; }
.s-count b { font-size: 2.2em; line-height: 1; color: var(--ink); letter-spacing: -.03em; }
.screen-center { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 10; padding: 16px; }
@media (max-aspect-ratio: 1/1) {
.s-enroll, .s-main.split { grid-template-columns: 1fr; }
.qr-wrap { max-height: 50vh; justify-self: center; }
/* upright screen: the ring takes what the text leaves, the docked entry qr sits right of the steps */
body.screen { --dock-qr: clamp(120px, min(21vh, 34vw), 340px); }
.s-main:not(.split) .s-enroll { grid-template-rows: minmax(0, 1fr) auto; gap: 3vh; height: 100%; }
.s-main:not(.split) .qr-wrap { height: 100%; width: auto; max-width: 100%; max-height: none; }
body.has-entry .s-main:not(.split) .s-steps { padding-bottom: 0; padding-right: calc(var(--dock-qr) + 6vw); }
/* no room beside the ring on an upright screen: the big qr stays a (bigger) corner one */
body.entry-big { --dock-qr: clamp(140px, min(26vh, 40vw), 400px); }
body.entry-big .entry { top: auto; bottom: 1.5vh; right: 1.2vw; translate: none; }
body.entry-big .s-main:not(.split) .s-steps { visibility: visible; }
.entry-q { display: none; }
/* upright + question: ring and title share one row above the question */
.s-main.split .s-enroll { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: none; height: auto; align-items: center; justify-items: stretch; }
.s-main.split .qr-wrap { height: auto; width: 100%; max-height: 38vh; justify-self: center; }
.s-main.split .s-steps { display: grid; grid-template-columns: auto; justify-items: center; row-gap: 1vh; text-align: center; max-width: 42vw; }
}
.qr-wrap.ring .tick { display: none; }
/* light motion: blocks rise in, fade out, the question lands piece by piece, result bars grow */
@keyframes s-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes s-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes s-grow { from { transform: scaleX(0); } }
@keyframes s-bump { 40% { transform: scale(1.18); } }
.s-main:not(.split) > section { grid-area: 1 / 1; }
.s-main > section:not([hidden]), .entry:not([hidden]) { animation: s-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.s-main > section.leaving, .entry.leaving { animation: s-out .22s ease both; }
#focus.enter .q-text { animation: s-in .5s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter .opts li, #focus.enter .bar-row { animation: s-in .45s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter :is(.opts li, .bar-row):nth-child(1) { animation-delay: .08s; }
#focus.enter :is(.opts li, .bar-row):nth-child(2) { animation-delay: .14s; }
#focus.enter :is(.opts li, .bar-row):nth-child(3) { animation-delay: .2s; }
#focus.enter :is(.opts li, .bar-row):nth-child(4) { animation-delay: .26s; }
#focus.enter :is(.opts li, .bar-row):nth-child(n+5) { animation-delay: .32s; }
#focus.enter .turnout, #focus.enter .results-foot, #focus.enter .status { animation: s-in .45s .3s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter .bar-stack { transform-origin: left; animation: s-grow .9s .25s cubic-bezier(.2, .7, .2, 1) both; }
.turnout .progress > div { transition: width .5s cubic-bezier(.2, .7, .2, 1); }
#voters { display: inline-block; }
#voters.bump { animation: s-bump .35s ease; }
@media (prefers-reduced-motion: reduce) {
.s-main > section, .entry, #focus.enter *, #voters.bump { animation: none !important; }
.turnout .progress > div { transition: none; }
}
/* duplicated screen: the admin slides in over the projection, the room sees it while it's open */
.ctl {
position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(480px, 94vw); display: grid; grid-template-rows: auto 1fr;
background: var(--bg); box-shadow: -12px 0 40px rgba(28, 32, 54, .18); translate: 105% 0; transition: translate .35s cubic-bezier(.2, .7, .2, 1);
}
.ctl.open { translate: 0 0; }
.ctl-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font: 700 1rem var(--round); }
.ctl iframe { width: 100%; height: 100%; border: 0; background: var(--bg); }
/* the manage button stays reachable in full screen, faint until hovered */
:fullscreen .s-tools .ctl-btn { display: inline-flex; opacity: .3; }
:fullscreen .s-tools .ctl-btn:hover, :fullscreen .s-tools .ctl-btn:focus-visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .ctl { transition: none; } }
/* drawer open: the projection keeps the space on its left. --room is that width */
body.screen { --ctl-w: min(480px, 94vw); }
body.ctl-open { --room: calc(100vw - var(--ctl-w)); }
body.ctl-open :is(.s-head, .s-main, .s-foot) { margin-right: var(--ctl-w); }
body.ctl-open .entry { right: calc(var(--ctl-w) + 1.2vw); }
/* big qr: ring and qr share the room, the qr right against the ring */
body.ctl-open.entry-big { --dock-qr: clamp(140px, min(46vh, calc(var(--room) * .34)), 520px); }
body.ctl-open.entry-big .s-main:not(.split) .qr-wrap { max-height: min(74vh, calc(var(--room) * .48)); }
body.ctl-open.entry-big .s-main:not(.split) .s-enroll { gap: 2vw; }
body.ctl-open.entry-big .entry { right: auto; left: calc(4vw + min(74vh, var(--room) * .48) + 2vw); }
body.ctl-open.split-on { --dock-qr: clamp(100px, min(22vh, calc(var(--room) * .2)), 260px); }
body.ctl-open .s-main.split .s-focus .q-text { font-size: clamp(1.1rem, min(calc(var(--room) * .04), 6vh), 3rem); }
body.ctl-open .s-main.split .s-focus .opts li { font-size: clamp(.9rem, min(calc(var(--room) * .024), 3.4vh), 1.8rem); }
/* narrow room: the ring follows its column's width, not the row's height */
body.ctl-open .s-main.split .qr-wrap { width: 100%; height: auto; max-height: 100%; align-self: center; }
/* grid items won't shrink below their content by default: let the ring's column be as narrow as the room */
.s-main > section { min-width: 0; }