/* Home layout: keep the wide desktop composition fluid, then collapse it
   into readable two-column and single-column arrangements as space narrows. */

html body:not(.ai-chat-mode) main,
html body:not(.ai-chat-mode) .site-footer {
  width: min(2480px, calc(100% - clamp(24px, 2.4vw, 60px))) !important;
}

html body:not(.ai-chat-mode) .command-hero {
  width: min(1520px, 100%);
}

html body:not(.ai-chat-mode) .command-hero .search-panel {
  width: min(1520px, 100%);
}

@media (min-width: 1600px) {
  html body:not(.ai-chat-mode) .home-layout {
    grid-template-columns: minmax(300px, 1.04fr) minmax(0, 2.58fr) minmax(190px, .5fr) !important;
    gap: clamp(18px, 1.55vw, 40px) !important;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-bar {
    flex-wrap: wrap !important;
    overflow: visible !important;
  }
}

/* At laptop and ordinary desktop widths, keep the news and tools together
   and move the utility cards into a full-width row instead of squeezing the
   category strip until it is clipped. */
@media (min-width: 981px) and (max-width: 1599px) {
  html body:not(.ai-chat-mode) .home-layout {
    grid-template-columns: minmax(270px, .9fr) minmax(0, 2fr) !important;
    grid-template-areas:
      "news tools"
      "stats stats" !important;
    gap: 18px !important;
  }

  html body:not(.ai-chat-mode) .home-layout > .news-column {
    grid-area: news;
  }

  html body:not(.ai-chat-mode) .home-layout > .tools-workspace {
    grid-area: tools;
  }

  html body:not(.ai-chat-mode) .home-layout > .stats-sidebar {
    grid-area: stats;
    position: relative !important;
    top: auto !important;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  html body:not(.ai-chat-mode) .stats-sidebar > :is(.news-stats-row, .insight-row, .stats-ai-entry, .stats-opinion-entry) {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-bar {
    flex-wrap: wrap !important;
    overflow: visible !important;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-pill {
    flex: 1 1 calc(50% - 8px) !important;
    justify-content: center;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-pill-shell {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 0;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-group-shell {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 0;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-pill-shell > .category-pill {
    width: 100%;
  }

  html:is(.viewport-compact, .viewport-tight) body:not(.ai-chat-mode) .tools-workspace .category-bar {
    flex-wrap: wrap !important;
    overflow: visible !important;
  }

  html:is(.viewport-compact, .viewport-tight) body:not(.ai-chat-mode) .tools-workspace .category-group-shell {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 0;
  }
}

@media (max-width: 980px) {
  html body:not(.ai-chat-mode) main,
  html body:not(.ai-chat-mode) .site-footer {
    width: min(calc(100% - 24px), 1180px) !important;
  }

  html body:not(.ai-chat-mode) .home-layout {
    grid-template-columns: 1fr !important;
    grid-template-areas: none !important;
  }

  html body:not(.ai-chat-mode) .home-layout > :is(.news-column, .tools-workspace, .stats-sidebar) {
    grid-area: auto !important;
  }

  html body:not(.ai-chat-mode) .stats-sidebar {
    position: relative !important;
    top: auto !important;
    display: block;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-bar {
    flex-wrap: wrap !important;
    overflow: visible !important;
  }
}

@media (max-width: 600px) {
  html body:not(.ai-chat-mode) .tools-workspace .category-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  html body:not(.ai-chat-mode) .tools-workspace .category-pill {
    flex: 0 0 auto !important;
  }
}

/* 20260821 keep the home search surface inside its calculated content lane. */
html body:not(.ai-chat-mode) .command-hero .search-panel {
  width: min(var(--ai-chat-search-width, 1520px), 100%) !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* 20260821 remove the stale left nudge from the homepage wordmark. */
html body:not(.ai-chat-mode):not([data-active-group="tutorial-knowledge"]) .command-hero .search-brand-lockup {
  transform: translate(-50%, -30px) !important;
}
