/* HOME — the desktop channel menu (console-menu-style launcher).
   Phones never show it; on desktop it is the screen behind the frame's
   Home button. Tiles open the forecast frame at the matching view.
   (768px is the one layout breakpoint; media queries cannot use tokens.) */

/* NASA globe image behind the menu */
.globe-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: var(--home-globe-opacity);
  transition: background-image var(--dur-fade) ease, opacity var(--dur-slow) ease;
  pointer-events: none;
}

.globe-hidden {
  opacity: 0 !important;
}

@media (min-width: 768px) {
  .desktop-channels {
    position: fixed;
    inset: 0;
    z-index: var(--z-frame);
    flex-direction: column;
    min-height: 0;
  }

  /* ---------- Letterbox: title + search ---------- */

  .channel-letterbox {
    position: relative;
    z-index: var(--z-status);
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--home-letterbox-height);
    padding: var(--space-4) var(--home-gutter);
    overflow: hidden;
    background: var(--home-letterbox-face);
    border-bottom: var(--hairline) solid var(--home-letterbox-edge);
    box-shadow: var(--home-letterbox-shine);
  }

  .channel-letterbox::before,
  .channel-letterbox::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
  }

  .channel-letterbox::before {
    background: var(--home-scan-dark);
    mix-blend-mode: multiply;
  }

  .channel-letterbox::after {
    background: var(--home-scan-light);
    opacity: 0.55;
  }

  .channel-letterbox-copy,
  .channel-search {
    position: relative;
    z-index: 1;
  }

  .channel-letterbox-copy h2 {
    color: var(--home-title-text);
    font-size: var(--home-title-font);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    text-shadow: var(--home-title-shadow);
  }

  .channel-letterbox-copy p {
    margin-top: var(--space-1);
    color: var(--home-sub-text);
    font-size: var(--home-sub-font);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-caps);
  }

  .channel-search {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .channel-search input {
    width: var(--home-input-width);
    min-width: 0;
    min-height: var(--touch-min);
    padding: 0 var(--space-4);
    color: var(--home-input-text);
    font-size: var(--home-input-font);
    font-weight: var(--fw-bold);
    background: var(--home-input-face);
    border: var(--cyan-rim-width) solid var(--cyan-rim);
    border-radius: var(--radius-pill);
    box-shadow: var(--home-input-shadow);
  }

  .channel-search input::placeholder {
    color: var(--home-input-placeholder);
    font-weight: var(--fw-regular);
  }

  .channel-search button {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: var(--touch-min);
    padding: 0 var(--space-6);
    color: var(--pill-silver-text);
    font-size: var(--fs-sm);
    font-weight: var(--fw-heavy);
    text-shadow: var(--pill-silver-text-shadow);
    background: var(--pill-silver-face);
    border: var(--cyan-rim-width) solid var(--cyan-rim);
    border-radius: var(--radius-pill);
    box-shadow: var(--wii-pill-rest-shadow);
  }

  /* static gloss cap over the top of the pill */
  .channel-search button::before {
    content: "";
    position: absolute;
    top: var(--rule);
    right: var(--space-1);
    left: var(--space-1);
    z-index: -1;
    height: 42%;
    pointer-events: none;
    background: var(--pill-gloss-cap);
    border-radius: var(--pill-gloss-cap-radius);
  }

  .channel-search button:disabled {
    cursor: wait;
  }

  .channel-search :is(button, input):focus-visible {
    outline-offset: var(--focus-offset);
  }

  /* ---------- Stage: prompt, status, grid ---------- */

  .channel-stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: center;
    justify-content: safe center;
    overflow: hidden;
  }

  .home-status {
    position: absolute;
    top: var(--space-3);
    left: var(--home-gutter);
    z-index: 2;
    max-width: min(var(--home-prompt-width), calc(100% - 2 * var(--home-gutter)));
    padding: var(--space-2) var(--space-5);
    background: var(--status-face);
    border: var(--hairline) solid var(--status-border);
    border-radius: var(--radius-pill);
    color: var(--panel-text);
    font-size: var(--home-status-font);
    font-weight: var(--fw-bold);
  }

  .home-status--error {
    background: var(--status-error-face);
    border-radius: var(--radius-lg);
  }

  .home-badge {
    position: absolute;
    top: var(--space-3);
    right: var(--home-gutter);
    z-index: 2;
  }

  .channel-prompt {
    max-width: min(var(--home-prompt-width), calc(100% - 2 * var(--home-gutter)));
    padding: var(--space-4) var(--space-6);
    color: var(--home-prompt-text);
    font-size: var(--home-prompt-font);
    font-weight: var(--fw-bold);
    text-align: center;
    text-shadow: var(--home-prompt-shadow);
  }

  /* "Search a city" makes no sense while a search is already running */
  body.is-loading .channel-prompt {
    visibility: hidden;
  }

  .channel-grid-wrap {
    width: 100%;
    padding: var(--space-4) 0 var(--space-3);
  }

  .channel-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--tile-gap);
    width: min(var(--home-grid-width), calc(100% - 2 * var(--home-grid-margin)));
    margin: 0 auto;
  }

  .channel-tile {
    min-width: 0;
    aspect-ratio: 380 / 205;
    padding: 0;
    overflow: visible;
    background: var(--tile-frame);
    border: 0;
    border-radius: var(--tile-radius);
    box-shadow: var(--tile-ring);
  }

  .channel-tile:focus-visible {
    outline-offset: var(--rule-thick);
  }

  .channel-screen {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--tile-radius);
  }

  .channel-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--tile-scan);
    pointer-events: none;
  }

  .channel-today-weather,
  .channel-day-weather,
  .channel-day-temps {
    display: flex;
    align-items: center;
  }

  .channel-today-icon,
  .channel-day-icon {
    width: var(--tile-icon-size);
    height: var(--tile-icon-size);
    object-fit: contain;
    filter: var(--hero-icon-shadow);
  }

  /* Today tile */
  .channel-screen--today {
    gap: var(--space-1);
    background: var(--tile-today-face);
  }

  .channel-today-title {
    max-width: calc(100% - var(--space-5));
    overflow: hidden;
    color: var(--panel-text);
    font-size: var(--tile-today-title-font);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    text-align: center;
    text-overflow: ellipsis;
    text-shadow: var(--tile-text-shadow);
    white-space: nowrap;
  }

  .channel-today-weather {
    gap: var(--space-2);
  }

  .channel-today-temp {
    color: var(--temp-high);
    font-size: var(--tile-today-temp-font);
    font-weight: var(--fw-bold);
    font-variant-numeric: tabular-nums;
    line-height: var(--lh-tight);
    text-shadow: var(--temp-high-shadow);
  }

  /* Day tiles: navy name cell like the 5-day columns, darker body for contrast */
  .channel-screen--day {
    justify-content: flex-start;
    background: var(--tile-day-face);
  }

  .channel-day-label {
    align-self: stretch;
    padding: var(--space-1) 0;
    background: var(--tile-day-head);
    color: var(--panel-text);
    font-size: var(--tile-day-label-font);
    font-weight: var(--fw-heavy);
    letter-spacing: var(--tracking-caps);
    text-align: center;
    text-shadow: var(--tile-text-shadow);
    text-transform: uppercase;
  }

  .channel-day-weather {
    flex: 1;
    gap: var(--space-3);
  }

  .channel-day-temps {
    gap: var(--space-2);
  }

  .channel-day-high,
  .channel-day-low {
    font-weight: var(--fw-heavy);
    font-variant-numeric: tabular-nums;
    text-shadow: var(--tile-text-shadow);
  }

  .channel-day-high {
    color: var(--temp-high);
    font-size: var(--tile-day-high-font);
  }

  .channel-day-low {
    color: var(--tile-day-low-text);
    font-size: var(--tile-day-low-font);
  }

  /* Empty tiles are decoration (aria-hidden), faint like an unused slot */
  .channel-screen--empty {
    gap: var(--space-1);
    background: var(--tile-empty-face);
  }

  .channel-screen--empty::after {
    background: var(--tile-empty-scan);
  }

  .channel-screen--empty b {
    color: var(--tile-empty-title);
    font-size: var(--tile-day-low-font);
    font-weight: var(--fw-heavy);
    text-shadow: var(--tile-empty-shadow);
  }

  .channel-screen--empty span {
    color: var(--tile-empty-sub);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-caps);
    text-shadow: var(--tile-empty-shadow);
    text-transform: uppercase;
  }

  .channel-grid-hint {
    margin-top: var(--space-4);
    color: var(--home-hint-text);
    font-size: var(--home-hint-font);
    text-align: center;
    text-shadow: var(--home-prompt-shadow);
  }

  /* ---------- Tray: wave, corner buttons, clock ---------- */

  .channel-tray {
    position: relative;
    z-index: var(--z-status);
    flex: 0 0 var(--tray-height);
    height: var(--tray-height);
  }

  .channel-tray-wave {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
  }

  .channel-tray-fill {
    fill: var(--tray-fill);
  }

  .channel-tray-crt {
    opacity: 0.3;
  }

  .channel-tray-crt-dark {
    fill: var(--tray-crt-dark);
  }

  .channel-tray-crt-light {
    fill: var(--tray-crt-light);
  }

  .channel-tray-shade {
    fill: none;
    stroke: var(--tray-shade);
    stroke-width: 16;
  }

  .channel-tray-rim {
    fill: none;
    stroke: var(--tray-rim);
    stroke-width: 5;
  }

  .channel-tray-controls {
    position: relative;
    z-index: 1;
    height: 100%;
  }

  .channel-tray-corner {
    position: absolute;
    top: var(--space-8);
  }

  .channel-tray-corner--left {
    left: var(--space-9);
  }

  .channel-tray-corner--right {
    right: var(--space-9);
  }

  .channel-tray-groove {
    position: absolute;
    top: 50%;
    width: calc(var(--tray-button-size) * 1.9);
    height: calc(var(--tray-button-size) * 1.23);
    background: var(--tray-groove);
    transform: translateY(-50%);
  }

  .channel-tray-corner--left .channel-tray-groove {
    left: calc(var(--tray-button-size) * -0.65);
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
    box-shadow: 0 0 0 var(--space-1) var(--tray-groove-ring), inset calc(-1 * var(--space-2)) calc(-1 * var(--space-4)) var(--space-3) var(--tray-groove-shine);
  }

  .channel-tray-corner--right .channel-tray-groove {
    right: calc(var(--tray-button-size) * -0.65);
    border-radius: var(--radius-pill) 0 0 var(--radius-pill);
    box-shadow: 0 0 0 var(--space-1) var(--tray-groove-ring), inset var(--space-2) calc(-1 * var(--space-4)) var(--space-3) var(--tray-groove-shine);
  }

  .channel-tray-button {
    position: relative;
    z-index: 1;
    display: flex;
    width: var(--tray-button-size);
    height: var(--tray-button-size);
    padding: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--tray-button-text);
    background: var(--tray-button-face);
    border: 0;
    border-radius: 50%;
    box-shadow: var(--tray-button-shadow);
  }

  .channel-tray-button:disabled {
    filter: grayscale(0.35);
  }

  .channel-tray-button.is-active {
    box-shadow: var(--tray-button-shadow-active);
  }

  .channel-tray-crescent {
    position: absolute;
    top: var(--space-1);
    left: var(--space-1);
    width: 80%;
    height: 78%;
    fill: var(--tray-crescent);
  }

  .channel-tray-button span {
    position: relative;
    font-size: var(--fs-md);
    font-weight: var(--fw-heavy);
  }

  .channel-tray-button img {
    position: relative;
    width: var(--tile-icon-size);
    height: var(--tile-icon-size);
    object-fit: contain;
  }

  .channel-clock {
    position: absolute;
    inset: 0;
    color: var(--tray-clock-text);
    text-shadow: var(--tray-clock-shadow);
    pointer-events: none;
  }

  .channel-clock-time {
    position: absolute;
    top: var(--space-6);
    left: 50%;
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    font-family: var(--font-digital);
    font-size: var(--tray-clock-font);
    line-height: var(--lh-tight);
    white-space: nowrap;
    transform: translateX(-50%);
  }

  .channel-clock-time span {
    font-family: inherit;
  }

  .channel-clock-time b {
    margin-left: var(--rule);
    font-family: var(--font-ui);
    font-size: var(--fs-base);
    font-weight: var(--fw-heavy);
  }

  .channel-clock-date {
    position: absolute;
    top: calc(var(--tray-height) * 0.64);
    left: 50%;
    font-size: var(--tray-date-font);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    white-space: nowrap;
    transform: translateX(-50%);
  }
}

/* Narrow desktops and tablets: the grid uses normal gutters, not wide margins */
@media (min-width: 768px) and (max-width: 1100px) {
  .channel-grid {
    width: calc(100% - 2 * var(--home-gutter));
  }
}
