/* WeSearch navigation + reading-flow repair, 2026-08-23.
   This is intentionally the final homepage sheet: one header, one mobile dock,
   one compact discovery row. It also restores readable light-theme surfaces
   after older inline boot rules. */

:root {
  --ux-bg: #0b0c0b;
  --ux-panel: #111310;
  --ux-text: #f0eee7;
  --ux-muted: #a8aaa3;
  --ux-line: rgba(240, 238, 231, 0.18);
  --ux-accent: #d93a34;
}

html[data-theme="light"] {
  --ux-bg: #f4f1e8;
  --ux-panel: #fffdf7;
  --ux-text: #171815;
  --ux-muted: #595c55;
  --ux-line: rgba(23, 24, 21, 0.2);
  --ux-accent: #b72d28;
}

html[data-theme="journalist"] {
  --ux-bg: #f0e6c9;
  --ux-panel: #fff8dc;
  --ux-text: #241e16;
  --ux-muted: #5c5142;
  --ux-line: rgba(36, 30, 22, 0.24);
  --ux-accent: #8d211b;
}

html[data-theme="light"]:not([data-layout="magazine"]),
html[data-theme="light"]:not([data-layout="magazine"]) body,
html[data-theme="journalist"]:not([data-layout="magazine"]),
html[data-theme="journalist"]:not([data-layout="magazine"]) body {
  background: var(--ux-bg) !important;
  color: var(--ux-text) !important;
}

html:not([data-layout="magazine"]) #site-header.uw-head,
html:not([data-layout="magazine"]) header.uw-head,
html:not([data-layout="magazine"]) .uw-dock,
#uw-more-sheet .uw-more-card {
  background: var(--ux-bg) !important;
  border-color: var(--ux-line) !important;
}

html.uw-menu-open,
html.uw-menu-open body {
  overflow: hidden !important;
}

html:not([data-layout="magazine"]) :where(a, button, input, summary):focus-visible {
  outline: 2px solid var(--ux-accent) !important;
  outline-offset: 3px !important;
}

.uw-mark,
.uw-more-card a,
.uw-more-card button[data-tab] {
  color: var(--ux-text) !important;
}

.uw-rail a,
.uw-more > summary,
.uw-beats a,
.uw-dock > * {
  color: var(--ux-muted) !important;
}

.uw-rail a:hover,
.uw-rail a[aria-current="page"],
.uw-more[open] > summary,
.uw-beats a:hover,
.uw-beats a[aria-current="page"],
.uw-dock > *.is-on {
  color: var(--ux-text) !important;
}

html:not([data-layout="magazine"]) .uw-find .search-input,
html:not([data-layout="magazine"]) #search-input {
  color: var(--ux-text) !important;
  border-bottom-color: var(--ux-line) !important;
}

html:not([data-layout="magazine"]) #search-input::placeholder {
  color: var(--ux-muted) !important;
  opacity: 0.82;
}

.uw-lattice-first {
  margin: 0.45rem 0 1.1rem !important;
  padding: 0.7rem 0 0 !important;
}

.uw-lattice-first .uw-lat-row {
  margin-bottom: 0.35rem;
}

.uw-lattice-first .uw-lat-pills a {
  min-height: 34px;
  padding: 0.34rem 0.55rem;
}

#uw-more-sheet {
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

#uw-more-sheet .uw-more-card {
  max-height: min(46rem, calc(100dvh - 3.5rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.36);
}

#uw-more-sheet .uw-more-x {
  color: var(--ux-text);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

@media (min-width: 800px) {
  html:not([data-layout="magazine"]) .uw-nav {
    grid-template-columns: auto minmax(0, 1fr) minmax(12.5rem, 20rem) auto auto;
    column-gap: clamp(0.7rem, 1.2vw, 1.1rem);
  }

  .uw-rail {
    gap: 0.7rem;
    min-width: 0;
  }
  .uw-rail-links {
    min-width: 0;
    overflow: hidden;
  }
  html:not([data-layout="magazine"]) .uw-find {
    background: var(--ux-bg, #0B0C0B);
    z-index: 2;
  }

  .uw-beats {
    gap: 0.2rem;
    padding-top: 0.15rem;
  }

  html:not([data-layout="magazine"]) .uw-lead .uw-hed,
  html:not([data-layout="magazine"]) .uw-lead .ed-title {
    max-width: 24ch !important;
    font-size: clamp(2.35rem, 4vw, 3.55rem) !important;
    line-height: 1.01 !important;
  }
}

@media (max-width: 799px) {
  /* Beats live in More on phones. Removing the duplicate horizontal rail
     returns an entire row to the story without deleting any destination. */
  html:not([data-layout="magazine"]) .uw-beats {
    display: none !important;
  }

  html:not([data-layout="magazine"]) .uw-nav {
    min-height: 3.35rem !important;
  }

  html:not([data-layout="magazine"]) .uw-dock {
    min-height: calc(3.8rem + env(safe-area-inset-bottom)) !important;
    padding: 0.2rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom)) !important;
  }

  html:not([data-layout="magazine"]) .uw-dock::before,
  html:not([data-layout="magazine"]) .uw-dock > * > i {
    display: none !important;
  }

  html:not([data-layout="magazine"]) .uw-dock > * {
    min-height: 48px !important;
    justify-content: center;
    gap: 0 !important;
    padding: 0.55rem 0.15rem 0.35rem !important;
    font-size: 0.64rem !important;
    letter-spacing: 0.08em !important;
    border-top: 2px solid transparent !important;
  }

  html:not([data-layout="magazine"]) .uw-dock > *.is-on {
    border-top-color: var(--ux-accent) !important;
    background: color-mix(in srgb, var(--ux-text) 6%, transparent) !important;
  }

  #uw-more-sheet .uw-more-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 0 0.45rem;
    padding: 0.8rem 0.8rem calc(1rem + env(safe-area-inset-bottom));
  }

  #uw-more-sheet .uw-more-group {
    grid-column: 1 / -1;
    padding: 0.9rem 0.35rem 0.25rem;
  }

  #uw-more-sheet .uw-more-card a,
  #uw-more-sheet .uw-more-card button[data-tab] {
    min-height: 48px;
    padding: 0.72rem 0.5rem;
    font-size: 0.96rem;
    line-height: 1.2;
    border-bottom: 1px solid var(--ux-line);
  }

  #uw-more-sheet .uw-more-x {
    position: sticky;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    top: 0;
    z-index: 2;
    margin-bottom: -44px;
  }

  .uw-lattice-first {
    overflow: hidden;
    margin: 0.15rem 0 0.85rem !important;
    padding-top: 0.55rem !important;
  }

  .uw-lattice-first .uw-lat-row {
    display: block;
    padding-left: 0.75rem;
  }

  .uw-lattice-first .uw-lat-k {
    display: block;
    margin-bottom: 0.35rem;
  }

  .uw-lattice-first .uw-lat-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 0.75rem 0.25rem 0;
    scrollbar-width: none;
  }

  .uw-lattice-first .uw-lat-pills::-webkit-scrollbar {
    display: none;
  }

  .uw-lattice-first .uw-lat-pills a {
    flex: 0 0 auto;
    min-height: 40px;
  }

  html:not([data-layout="magazine"]) .uw-lead,
  html:not([data-layout="magazine"]) .uw-lead-body {
    min-height: 17.25rem !important;
  }

  html:not([data-layout="magazine"]) .uw-lead-body {
    padding: 3.65rem 0.9rem 0.9rem !important;
  }

  html:not([data-layout="magazine"]) .uw-lead .uw-hed,
  html:not([data-layout="magazine"]) .uw-lead .ed-title {
    font-size: clamp(1.65rem, 7.2vw, 2.15rem) !important;
    line-height: 1.04 !important;
  }

  html:not([data-layout="magazine"]) body {
    padding-bottom: calc(4.1rem + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 350px) {
  html:not([data-layout="magazine"]) .uw-mark-word {
    font-size: 0.9rem;
  }

  html:not([data-layout="magazine"]) .uw-dock > * {
    font-size: 0.58rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #uw-more-sheet {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
