/* Channels & Settings, pp. 2–3: three rows, a single blue page pointer,
   pearl shoulders above a lower central clock. The GX toolbar stays functional
   in the otherwise empty top overscan. Never change the carousel coordinate system. */
html #channel[data-system-view="channels"] {
  --shell-target: max(44px, calc(44px / var(--scale, 1)));
  --shell-gutter: max(6%, var(--shell-target));
  --shell-top: max(12%, calc(var(--shell-target) + 10px));
  --shell-foot: 23%;
  background: url('assets/channel-shell-hd.svg') center bottom / 100% var(--shell-foot) no-repeat,
    repeating-linear-gradient(0deg, transparent 0 2px, #53616a09 2px 3px), linear-gradient(#f6f6f5,#e7e8e8) !important;
}
#channel[data-system-view="channels"] .toolbar {
  top: max(2px, env(safe-area-inset-top)); bottom:auto; left:50%; right:auto;
  transform:translateX(-50%); height:var(--shell-target); gap:0;
}
#channel[data-system-view="channels"] .toolbar .tool {
  width:var(--shell-target); height:var(--shell-target); min-width:var(--shell-target); min-height:var(--shell-target);
}
#channel[data-system-view="channels"] #library[data-view="channels"] {
  inset:var(--shell-top) max(var(--shell-gutter), env(safe-area-inset-right)) calc(var(--shell-foot) + 1%) max(var(--shell-gutter), env(safe-area-inset-left)) !important;
}
#library[data-view="channels"] .wii-channels-page {
  grid-template-rows:repeat(3,minmax(0,1fr)) !important; gap:5px !important; padding:5px !important;
}
#channel #library[data-view="channels"] :is(.cover,.wii-channel-slot) {
  min-height:0; border-radius:10% / 15% !important;
}
#library[data-view="channels"] :is(.cover,.wii-channel-slot):not(.selected,:hover,:active,:focus-visible,.wii-grid-drop-target,.wii-grid-drag-source) {
  border:2px solid #b3b8bb !important; box-shadow:inset 0 0 0 1px #fff, 0 1px 1px #fff !important;
}
#library[data-view="channels"] .cover img {border-radius:inherit !important;}
#channel #library[data-view="channels"] .wii-static-slot {
  opacity:1; background:repeating-linear-gradient(0deg,#e4e5e6 0 2px,#e9eaeb 2px 4px) !important;
}
#channel[data-system-view="channels"] .wii-page-indicator { display:none !important; }
/* The existing buttons call changeChannelsPage; their inline pointer state
   also identifies the unavailable edge. Keep the graphic smaller than its hit area. */
#channel #library[data-view="channels"] ~ :is(#previous,#next) {
  /* The empty pseudo-element needs a definite column for its percentage width. */
  display:grid !important;grid-template-columns:minmax(0,1fr);place-items:center; width:var(--shell-target); height:var(--shell-target);
  top:calc((100% + var(--shell-top) - var(--shell-foot)) / 2); padding:0; transform:translateY(-50%);
  border:0; border-radius:8px; background:none; box-shadow:none;
}
#channel #library[data-view="channels"] ~ #previous {left:max(0px,env(safe-area-inset-left));}
#channel #library[data-view="channels"] ~ #next {right:max(0px,env(safe-area-inset-right));}
#channel #library[data-view="channels"] ~ .arrow[style*="pointer-events: none"] {visibility:hidden;}
#channel #library[data-view="channels"] ~ .arrow img {display:none;}
#channel #library[data-view="channels"] ~ .arrow::before {
  content:''; width:36%; height:58%; background:linear-gradient(90deg,#219ec4,#76d9ee 65%,#21a7cb); clip-path:polygon(0 0,100% 50%,0 100%);
}
#channel #library[data-view="channels"] ~ #previous::before {transform:scaleX(-1);}
#channel[data-system-view="channels"] :is(.arrow,.tool,.wii-clock):focus-visible,
.wii-channel-screen :is(.wii-channel-pill-btn,.wii-channel-step):focus-visible {outline:3px solid #057da2;outline-offset:1px;}
#channel[data-system-view="channels"] #wii-clock {
  /* Use the painted shell as the clock's coordinate system: at its centre
     the SVG stroke is 36/130 from the top. Keep time above it, date below. */
  bottom:0;height:var(--shell-foot);min-height:var(--shell-target);padding:0;gap:0;
  color:#555e65;text-shadow:0 1px #fff;font-variant-numeric:tabular-nums;
}
#channel[data-system-view="channels"] .wii-clock-time {position:absolute;bottom:73%;font-size:30px;line-height:1.03;letter-spacing:.045em;}
#channel[data-system-view="channels"] .wii-clock-date {position:absolute;top:34%;font-size:13px;letter-spacing:.035em;}
#channel[data-system-view="channels"] .wii-pure-control {
  width:max(var(--shell-target),min(9%,78px));height:auto;aspect-ratio:1;bottom:max(2%, env(safe-area-inset-bottom));
}
@media (orientation:portrait) {
  html #channel[data-system-view="channels"] {--shell-target:44px;--shell-foot:calc(clamp(96px,17%,156px) + env(safe-area-inset-bottom));--shell-top:calc(52px + env(safe-area-inset-top));}
  /* This portrait variant owns the frame gradients. Paint only its missing
     shell, behind the controls and on the same height token as the clock. */
  html[data-safari-polish="curve"] #channel.mobile-portrait[data-system-view="channels"]::before {
    content:''; position:absolute; inset:auto 0 0; height:var(--shell-foot); pointer-events:none;
    background:url('assets/channel-shell-hd.svg') center bottom / 100% 100% no-repeat;
    mask-image:linear-gradient(to bottom, #000 calc(100% - clamp(32px,8vh,64px)), transparent);
  }
  #channel.mobile-portrait #library[data-view="channels"] .wii-channels-page {grid-template-rows:repeat(4,minmax(0,1fr)) !important;padding:5px !important;gap:6px !important;}
  #channel[data-system-view="channels"] .wii-pure-control {width:clamp(58px,14vw,84px);}
}
/* Console footage (20–26s): a small upright card just inside the Wii button.
   Share the option button's geometry, not its artwork or its circular hit box. */
#channel[data-system-view="channels"] {
  --options-left:max(45px, env(safe-area-inset-left));
  --options-size:max(var(--shell-target),min(calc(var(--frame-width, 854px) * .09),78px));
  --sd-target:calc(44px / var(--scale, 1));
}
#channel[data-system-view="channels"] #wii-options-launch {left:var(--options-left);width:var(--options-size);}
#channel #wii-sd-launch {display:none;}
html[data-wii-presentation="wii"]:not([data-channel-presentation="active"]) body:not(:has(dialog[open])) #channel[data-system-view="channels"]:not(.case-open,.case-closing,[inert]) #wii-sd-launch:not([hidden]) {
  display:grid;place-items:center;position:absolute;box-sizing:border-box;
  left:calc(var(--options-left) + var(--options-size) + 3px);
  bottom:calc(max(2%, env(safe-area-inset-bottom)) + (var(--options-size) - var(--sd-target)) / 2);
  width:var(--sd-target);height:var(--sd-target);padding:0;border:0;border-radius:6px;background:none;box-shadow:none;
}
#channel #wii-sd-launch svg {display:block;width:50%;height:64%;pointer-events:none;}
#channel #wii-sd-launch:focus-visible {outline:2px solid #057da2;outline-offset:1px;}
@media (hover:hover) {#channel #wii-sd-launch:hover svg {filter:drop-shadow(0 0 2px #47c5e9);}}
#channel #wii-sd-launch:active svg {transform:translateY(1px);}
@media (orientation:portrait) {
  #channel[data-system-view="channels"] {--options-left:max(10px,env(safe-area-inset-left));--options-size:clamp(48px,14vw,84px);--sd-target:44px;}
}
@media (orientation:portrait) and (max-width:400px) {
  html[data-wii-presentation="wii"] #channel[data-system-view="channels"] #wii-clock {width:clamp(88px,30vw,116px);}
}
/* The available artwork fills the real TV aperture; leave its camera, clip,
   flight geometry and special channel layers alone. Surface only, including the clone. */
.wii-channel-tv-frame {box-shadow:inset 0 0 0 1px #858c91;}
.wii-channel-scanlines {background:repeating-linear-gradient(0deg,transparent 0 2px,#24313b0a 2px 3px);}
.wii-channel-nav {border-top:2px solid #a8aeb3;background:repeating-linear-gradient(0deg,transparent 0 2px,#636e7708 2px 3px),linear-gradient(#fff,#e6e7e8);}
.wii-channel-nav .wii-channel-pill-btn {min-height:44px;border:2px solid #aeb3b7;background:linear-gradient(#fff 4%,#fafafa 47%,#f1f2f2 52%,#e1e3e4);box-shadow:inset 0 0 0 2px #fff,0 2px 1px #a0a5aa;}
.wii-channel-nav .wii-channel-pill-btn:is(:focus-visible,:hover) {border-color:#3db7de;}
.wii-channel-nav .wii-channel-pill-btn:active {background:linear-gradient(#d7e6eb,#fff);}
