/* ==========================================================
   HOURGLASS theme — raw, flat desert + roman numerals
   ========================================================== */
:root {
    --h-ink: #3b2a1e;
    --h-sand: #e0a95f;
    --h-sun: #ffe7ad;
    --fc9: #e8743b;
}

/* ---------- desert ---------- */
body.hourglass, .hourglass section { background-color: #f2a072; }
.hourglass section { background-color: transparent; }
body.hourglass > img, .hourglass #touch { display: none; }
#hgWorld {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}
body.hourglass #hgWorld { opacity: 1; }
#hgWorld svg { width: 100%; height: 100%; display: block; }
.hg-birds { animation: hgBirds 40s linear infinite; }
@keyframes hgBirds { from { transform: translateX(-300px); } to { transform: translateX(1700px); } }

/* ---------- fonts ---------- */
.hourglass section h2,
.hourglass .text,
.hourglass h4,
.hg-dial { font-family: 'Cinzel', 'Times New Roman', serif; }

/* ---------- first screen: a flat sun disc ---------- */
.hourglass section .box:before { display: none; }
.hourglass section .circle {
    background: var(--h-sun);
    border: 3px solid var(--h-ink);
    box-shadow: none;
    transition: transform .15s ease;
}
.hourglass section .circle:before,
.hourglass section .circle.poppuf:before {
    top: 22px; left: 22px; right: 22px; bottom: 22px;
    background: #fff1cc;
    border: 2px dashed rgba(59, 42, 30, .35);
}
.hourglass section .circle.popbig { transform: scale(.97); }
.hourglass section h2 {
    color: var(--h-ink);
    font-weight: 700;
    font-size: 3.2em;
    line-height: 1.15;
    letter-spacing: .04em;
    text-shadow: none;
}
.hourglass section .poppuf h2 { font-size: 3.3em; }

/* ---------- clock screen: the hourglass ---------- */
.hourglass #circle2 {
    background: transparent;
    border: none;
    box-shadow: none;
}
.hourglass #circle2:before { display: none; }
.hourglass #circle2 .timer-box,
.hourglass #circle2 .clock { opacity: 0; }

.hg-dial { display: none; }
.hourglass .hg-dial {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
    color: var(--h-ink);
    text-align: center;
}
.hg-flip {
    position: absolute;
    left: 50%;
    top: -14px;
    width: 230px;
    height: 345px;
    margin-left: -115px;
    transform-origin: 50% 50%;
    transition: transform 1.8s cubic-bezier(.65, 0, .35, 1);
}
.hg-flip.flipping { transform: rotate(180deg); }
.hg-flip.no-anim { transition: none; }
.hg-glass { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(10px 10px 0 rgba(59, 42, 30, .18)); }
.hg-stream { animation: hgStream .35s linear infinite; }
@keyframes hgStream { to { stroke-dashoffset: -8; } }
#circle2.popbig .hg-flip:not(.flipping) { transform: scale(.97); }

.hg-time {
    position: absolute;
    left: -40px; right: -40px;
    top: 400px;
    /* strict, upright Roman capitals */
    font-family: 'Times New Roman', Times, serif;
    font-style: normal;
    font-synthesis: none;
    font-weight: 400;
    font-size: 24px;
    letter-spacing: .04em;
    line-height: 1;
    white-space: nowrap;
}
.hg-time b { font-weight: 400; opacity: .4; margin: 0 .22em; }
.hourglass .hg-time { pointer-events: auto; cursor: help; }

/* ---------- wind-blown sand (the floating dots) ---------- */
.hourglass section i {
    max-width: 4px;
    max-height: 4px;
    background: #fff1cc;
    border: none;
    box-shadow: none;
    opacity: .8;
    animation: hgWind linear infinite;
}
.hourglass section i:nth-child(3n+1) { background: #b96b33; border: none; }
.hourglass section i:nth-child(n+80) { display: none; }
@keyframes hgWind {
    0%   { transform: translate(0, 0); opacity: 0; }
    10%  { opacity: .8; }
    90%  { opacity: .8; }
    100% { transform: translate(-2400%, -300%); opacity: 0; }
}

/* ---------- buttons: flat ---------- */
.hourglass .label { color: var(--h-ink); }
.hourglass .text { font-weight: 700; }
.hourglass .indicator {
    background: #fbe3b0;
    border: 2px solid var(--h-ink);
    box-shadow: none;
}
.hourglass .indicator::before { box-shadow: none; }
.hourglass .indicator::after { background: #fbe3b0; box-shadow: none; }
.hourglass .state:checked ~ .label .indicator { background: var(--h-sand); }
.wrapper:nth-child(6) .indicator {
    animation: lefting .4s ease;
    animation-iteration-count: 1;
    animation-delay: 3.8s;
    animation-fill-mode: forwards;
    transform: scale(1.2);
}

.hourglass h4 {
    color: var(--h-ink);
    font-weight: 700;
    letter-spacing: .2em;
    font-size: .8em;
    text-transform: uppercase;
}

/* ---------- fireworks ---------- */
body.hourglass #fireworks:before, body.hourglass #fireworks:after {
    animation: 1s bang ease-out infinite backwards,
               1s gravity ease-in infinite backwards,
               5s position linear infinite backwards;
    box-shadow: -120px 0 var(--fc9), 120px 0 var(--fc9), 0 120px var(--fc9), 0 -120px var(--fc9),
                45px 45px var(--fc9), -45px 45px var(--fc9), 85px 85px var(--fc9), -85px 85px var(--fc9),
                45px -45px var(--fc9), -45px -45px var(--fc9), 85px -85px var(--fc9), -85px -85px var(--fc9),
                65px 0 var(--fc9), -65px 0 var(--fc9), 0 65px var(--fc9), 0 -65px var(--fc9),
                100px 45px var(--fc9), -100px 45px var(--fc9), -50px 100px var(--fc9), 50px 100px var(--fc9),
                100px -45px var(--fc9), -100px -45px var(--fc9), -50px -100px var(--fc9), 50px -100px var(--fc9),
                5px 10px var(--fc9);
}
body.hourglass #fireworks:after {
    animation-delay: 1.25s, 1.25s, 1.25s;
    animation-duration: 1.25s, 1.25s, 6.25s;
}

@media only screen and (max-width: 600px) {
    .hourglass section h2 { font-size: 2.7em; }
    .hourglass .label::after { font-family: 'Cinzel', serif; font-size: .62rem; font-weight: 700; }
}

/* desktop: room for the longer "hourglass" label */
@media only screen and (min-width: 601px) {
    #space ~ .label .text.start,
    #space:hover ~ .label .text { width: 70px !important; }
}

/* roman time as a centred column: hours / minutes / seconds */
.hg-time { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hg-time span { display: block; white-space: nowrap; line-height: 1; }
.hg-time .hg-h { font-size: 1em; }
.hg-time .hg-m { font-size: .86em; opacity: .9; }
.hg-time .hg-s { font-size: .72em; opacity: .75; }
.hg-measure { position: absolute; visibility: hidden; white-space: nowrap; left: -9999px; }

/* grains of sand left (= seconds until New Year): a centred column right under the hourglass */
.hg-grains {
    position: absolute;
    left: -80px; right: -80px;
    top: 342px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    letter-spacing: .22em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: .8;
}
.hg-gn {
    display: block;
    font-size: 21px;
    letter-spacing: .14em;
    margin-right: -.14em;          /* keep the digits optically centred */
    font-variant-numeric: tabular-nums;
    opacity: 1;
}

/* sand worm (body colours are set per worm in JS) */
.hg-worm .ws { stroke: #3b2a1e; stroke-width: 3; }
.hg-worm .ws.a { fill: #a5713f; }
.hg-worm .ws.b { fill: #8d5c33; }
.hg-worm .wm { fill: #2a1a10; stroke: #3b2a1e; stroke-width: 3; }
.hg-worm .wt { fill: #f3e2c0; stroke: #3b2a1e; stroke-width: 1.2; stroke-linejoin: round; }
.hg-worm .wd { fill: #120a05; }
.hg-worm.far { opacity: .7; }
.hg-wslot .wsp {
    fill: #e2a764;
    stroke: #3b2a1e;
    stroke-width: 1.5;
    transform-box: fill-box;
    transform-origin: center;
    animation: hgSpray 1.5s ease-out both;
}
.hg-wslot .wsp:nth-child(3n) { fill: #c98d45; }
.hg-wslot.far .wsp { opacity: .7; }
@keyframes hgSpray {
    0%   { transform: translate(0, 0) scale(.4); opacity: 0; }
    15%  { opacity: 1; }
    55%  { transform: translate(calc(var(--dx) * .6), var(--dy)) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), calc(var(--dy) * .2 + 50px)) scale(.8); opacity: 0; }
}
