/* The rooftop switch: a pill-shaped track in a moulded bezel, holding a code-drawn
   pixel scene. rooftop.js sets the --rim-* colours (graphite at night, white by day). */
.roof {
  --rim-top: #6c7a91; --rim-mid: #343d4f; --rim-low: #181d29; --rim-bottom: #525e75;
  position: relative;
  /* Confetti extends beyond the bezel, but must not widen the page. */
  overflow-x: clip;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 18px var(--gutter) 26px;
}
.rooftop-switch {
  position: relative;
  width: 100%;
  padding: 14px;
  border-radius: 999px;
  background: linear-gradient(155deg, var(--rim-top), var(--rim-mid) 36%, var(--rim-low) 72%, var(--rim-bottom));
  box-shadow: 0 24px 48px #080c242d, 0 4px 6px #080c2440, inset 0 2px 3px #ffffff99, inset 0 -4px 7px #1e15354a;
  cursor: grab;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  outline: none;
  transform-origin: center;
}
.rooftop-switch:focus-visible { outline: 3px solid var(--blue); outline-offset: 8px; }
.rooftop-switch.is-dragging { cursor: grabbing; }
/* 3:1, the same shape as the 420x140 scene, so every pixel stays square. */
.rooftop-viewport { position: relative; width: 100%; aspect-ratio: 3 / 1; border-radius: 999px; overflow: hidden; background: #111732; }
.rooftop-viewport::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 5px 12px #030c2670, inset 0 -3px 5px #ffffff22; pointer-events: none; }
.rooftop-art { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

/* The knob: a drop of clear jelly glass. Its refraction is drawn into .rooftop-lens. */
.rooftop-glass {
  position: absolute; z-index: 2; top: 3%; left: 2%; height: 94%; aspect-ratio: 1;
  border-radius: 50%; overflow: hidden;
  border: 1px solid #eafbffb3;
  box-shadow: inset 2px 2px 3px #ffffffcc, inset -3px -2px 6px #beeaff77, inset 0 0 13px #b9dfff24, 4px 9px 18px #0b18335c;
  pointer-events: none;
  will-change: left, transform;
}
.rooftop-lens { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; image-rendering: pixelated; }
.rooftop-glass::before {
  content: ""; position: absolute; z-index: 2; inset: 0; border-radius: inherit;
  background:
    radial-gradient(circle at 30% 22%, #ffffffd9 0, #ffffff4d 7%, transparent 17%),
    radial-gradient(ellipse 30% 9% at 62% 88%, #ffffff66, transparent 70%),
    linear-gradient(115deg, #ffffff38, #d5edff06 30%, transparent 62%, #a9e6ff30);
}
.rooftop-glass::after {
  content: ""; position: absolute; z-index: 3; inset: 0; border-radius: inherit;
  background: conic-gradient(from 180deg at 45% 50%, #fff0 25%, #ffffbb66 33%, #aaf9ff88 35%, #fff0 39%, #fff0 63%, #ffcbcc88 67%, #b6c6ff66 70%, #fff0 74%, #fff0);
  opacity: .6;
  mask-image: radial-gradient(circle, transparent 60%, #000 70%); -webkit-mask-image: radial-gradient(circle, transparent 60%, #000 70%);
}
.rooftop-switch.is-dragging .rooftop-glass { box-shadow: inset 2px 2px 4px #ffffffee, inset -3px -2px 9px #b5e7ff99, 0 0 28px #a3d7ff44, 5px 10px 20px #0b183340; }
.rooftop-effects { position: absolute; left: -10%; top: -24%; width: 120%; height: 148%; pointer-events: none; z-index: 5; }
.rooftop-switch.roof-pop { animation: roof-settle .52s ease-out; }
@keyframes roof-settle { 0% { transform: none; } 18% { transform: translateY(2px) scale(1.007, .982); } 38% { transform: translateY(-2px) scale(.994, 1.014); } 62% { transform: translateY(1px) scale(1.003, .995); } 100% { transform: none; } }

/* Readouts under the switch. */
.roof-panel { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 28px; flex-wrap: wrap; margin-top: 22px; padding: 0 6px; }
.roof-readouts { display: flex; flex-wrap: wrap; gap: 10px 44px; font-size: 20px; line-height: 1.2; }
.roof-readouts dt { font-family: var(--serif); -webkit-font-smoothing: antialiased; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.roof-readouts dd { min-width: 3.2em; white-space: nowrap; }
#roof-light { min-width: 6.8em; }
.roof-hint { margin-top: 14px; padding: 0 6px; font-size: 15px; color: var(--muted); }

@media (max-width: 640px) {
  .roof { padding-top: 10px; }
  .rooftop-switch { padding: 7px; }
  .roof-readouts { gap: 8px 22px; font-size: 20px; }
  #roof-light { min-width: 0; }
  .roof-readouts dd { min-width: 0; }
}
.roof-static .rooftop-switch { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .rooftop-effects { display: none; } }


/* The first-drag cue is a sibling of the clipped viewport, not part of its canvas. */
.rooftop-drag-hand {
  --hand-size: clamp(40px, 6vw, 72px);
  position: absolute; z-index: 6;
  top: calc(100% - var(--hand-size) * .78);
  width: var(--hand-size); height: var(--hand-size);
  pointer-events: none; user-select: none;
  filter: drop-shadow(2px 3px 0 #13203966);
  transform: translateX(-50%);
}
.rooftop-drag-hand svg { display: block; overflow: visible; }
.rooftop-drag-glove {
  width: 100%; height: 100%;
  --swipe-distance: clamp(18px, 3.2vw, 38px);
  animation: rooftop-hand-swipe 2s steps(12, end) infinite;
}
.rooftop-drag-arrows {
  position: absolute; left: 50%; top: 28%;
  width: clamp(112px, 19vw, 224px); height: auto;
  transform: translateX(-50%);
  animation: rooftop-arrows-hop 1.1s steps(5, end) infinite;
}
@keyframes rooftop-hand-swipe {
  0%, 10%, 100% { transform: translate(0, 0); }
  30%, 40% { transform: translate(var(--swipe-distance), -6px); }
  65%, 75% { transform: translate(calc(-1 * var(--swipe-distance)), -3px); }
}
@keyframes rooftop-arrows-hop {
  0%, 20%, 100% { transform: translate(-50%, 0) scale(1); }
  45%, 55% { transform: translate(-50%, -9px) scale(1.08); }
  75% { transform: translate(-50%, -3px) scale(1.03); }
}
.roof-static .rooftop-drag-glove, .roof-static .rooftop-drag-arrows { animation: none; }
@media (prefers-reduced-motion: reduce) { .rooftop-drag-glove, .rooftop-drag-arrows { animation: none; } }
