/* ===== Screensaver: after 1 minute of inactivity, the logo bounces around the screen ===== */
.saver {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  background: var(--bg); cursor: none;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .6s ease, visibility 0s linear .6s;
}
.saver.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .6s ease; }
.saver.leaving { opacity: 0; visibility: visible; pointer-events: auto; transition: opacity .2s ease; }   /* swallows the waking tap */
.saver-logo {
  position: absolute; left: 0; top: 0;
  width: clamp(100px, 22vmin, 210px); aspect-ratio: 2000 / 1731;   /* the logo's own proportions (about 20% smaller than before) */
  background: var(--accent);                                        /* signature orange #FE553A — where every loop starts and ends */
  -webkit-mask: var(--logo) center / contain no-repeat;
          mask: var(--logo) center / contain no-repeat;
  will-change: translate, rotate;
}
/* The logo fades through an "early internet" palette — the Windows "Basic colors" swatches — one loop every 2 minutes
   (its spin is driven by the bounces, in extras.js). Each loop starts and ends on the signature orange. Dark mode uses the bright row (yellow, lime, cyan, blue, magenta);
   light mode uses the deeper row (orange, green, teal, royal blue, purple) so nothing washes out on the grey. */
.saver.on .saver-logo { animation: saver-web-dark 120s linear infinite; }
:root[data-mode="light"] .saver.on .saver-logo { animation-name: saver-web-light; }
@keyframes saver-web-dark  { 0%, 100% { background: #FE553A; } 16.7% { background: #FFFF00; } 33.3% { background: #00FF00; } 50% { background: #00FFFF; } 66.7% { background: #0080FF; } 83.3% { background: #FF00FF; } }
@keyframes saver-web-light { 0%, 100% { background: #FE553A; } 16.7% { background: #FF8000; } 33.3% { background: #008000; } 50% { background: #008080; } 66.7% { background: #0D2599; } 83.3% { background: #800080; } }
@media (prefers-reduced-motion: reduce) { .saver, .saver.on, .saver.leaving { transition: none; } }
@media (prefers-reduced-motion: reduce) { .saver.on .saver-logo { animation: none; } }

/* ===== World clock frame: small live times flow clockwise around the edge of the screen ===== */
:root { --wf: 22px; }                                               /* thickness of the frame */
.wf {
  position: fixed; z-index: 4; pointer-events: none;
  top: env(safe-area-inset-top, 0px); right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px); left: env(safe-area-inset-left, 0px);
  font-family: var(--sans); font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.wf-edge { position: absolute; overflow: hidden; display: flex; align-items: center; }
.wf-top    { top: 0;    left: 0;          right: var(--wf); height: var(--wf); }
.wf-bottom { bottom: 0; left: var(--wf);  right: var(--wf); height: var(--wf); }
.wf-right  { right: 0;  top: var(--wf);   bottom: var(--wf); width: var(--wf); writing-mode: vertical-rl; }
.wf-left   { left: 0;   top: var(--wf);   bottom: var(--wf); width: var(--wf); writing-mode: vertical-rl; transform: rotate(180deg); }

.wf-track { display: flex; white-space: nowrap; will-change: transform; animation: var(--wf-anim) var(--wf-dur, 60s) linear infinite; }
.wf-top    .wf-track { --wf-anim: wf-x-fwd; }                     /* → */
.wf-bottom .wf-track { --wf-anim: wf-x-back; }                    /* ← */
.wf-right  .wf-track, .wf-left .wf-track { --wf-anim: wf-y-fwd; } /* ↓ on the right, ↑ on the left (it's turned around) */
@keyframes wf-x-fwd  { from { transform: translateX(-50%); } to { transform: none; } }
@keyframes wf-x-back { from { transform: none; } to { transform: translateX(-50%); } }
@keyframes wf-y-fwd  { from { transform: translateY(-50%); } to { transform: none; } }

.wf-item { padding-inline: 16px; }
.wf-item .wf-time { color: var(--ink); }
.wf-delta .arw { display: inline-block; width: 0; height: 0; margin-inline-end: 4px; vertical-align: 1px; border-left: 3px solid transparent; border-right: 3px solid transparent; }
.wf-delta.up .arw   { border-bottom: 4.5px solid currentColor; }   /* ahead of Montréal */
.wf-delta.down .arw { border-top: 4.5px solid currentColor; }      /* behind Montréal */
.wf-delta.even .arw { display: none; }
.wf-right .arw, .wf-left .arw { transform: rotate(90deg); }        /* keep the arrows upright to the text */

/* Montréal, pinned in the top-left corner */
.wf-home {
  position: absolute; top: 0; left: 0; z-index: 2; height: var(--wf);
  display: flex; align-items: center; gap: .5em; padding: 0 12px 0 10px;
  background: var(--bg); color: var(--accent);
  box-shadow: 14px 0 12px -4px var(--bg);                           /* the flowing tape slips softly under it */
}
.wf-home .wf-time { font-variant-numeric: tabular-nums; }
.wf-sec { opacity: .7; }
.wf-colon { animation: tk-blink 2s steps(1) infinite; }
.wf-et { opacity: .7; }
@keyframes tk-blink { 50% { opacity: .35; } }

/* make room for the frame */
.has-frame .page { padding-left: calc(24px + var(--wf)); padding-right: calc(24px + var(--wf)); padding-top: calc(max(18px, env(safe-area-inset-top)) + var(--wf)); }
.has-frame .theme-toggle { top: calc(max(10px, env(safe-area-inset-top)) + var(--wf)); left: calc(max(10px, env(safe-area-inset-left)) + var(--wf)); }
.has-frame footer { margin-bottom: var(--wf); }

@media (max-width: 520px) { :root { --wf: 20px; } .wf { font-size: 8.5px; } .has-frame .page { padding-left: calc(16px + var(--wf)); padding-right: calc(16px + var(--wf)); } }
@media (prefers-reduced-motion: reduce) { .wf-track, .wf-colon { animation: none; } }

/* full-bleed elements (the world clock) must never cause sideways scrolling */
body { overflow-x: clip; }

/* A band in the page colour behind the clock times, framing the site like a mat around a print:
   content stops cleanly at the frame instead of sliding under the times. A faint hairline marks the inner edge. */
.wf { box-shadow: inset 0 0 0 var(--wf) var(--bg); }
.wf::after { content: ""; position: absolute; inset: var(--wf); border: 1px solid var(--rule); pointer-events: none; }
