/**
 * ==========================================================================
 * @fileOverview
 * Canonical legal surface stylesheet for the Legal Help Center.
 * This file preserves the current /legal/ presentation while removing the
 * remaining dependency on the research page surface contract.
 * @author
 * QueryKey Cases Web Team
 * @maintainer
 * Cases Engineering Lead
 * @usage
 * Load on /legal/ and related legal help routes as the single page-level
 * stylesheet entrypoint.
 * @dependencies
 * None. Legal surface styles are owned directly here.
 * @notes
 * - Intentionally mirrors the current live appearance.
 * - Includes the legal playbook card/detail presentation used by
 *   /assets/js/legal-playbooks.js.
 * @license
 * QueryKey is a trademark of Farrel Wilson. All rights reserved.
 * @timestamp
 * 2026-03-16 00:00:00 UTC
 * ========================================================================== */

body.p-legal {
  --ri-bg: #f8fafc;
  --ri-panel: #fff;
  --ri-panel-alt: #f1f5f9;
  --ri-border: #d9e2ec;
  --ri-border-strong: #c3ced8;
  --ri-text: #1e293b;
  --ri-dim: #64748b;
  --ri-accent: #f59e0b;
  --ri-accent-soft: #fbbf24;
  --ri-blue: #4d82ff;
  --ri-green: #059669;
  --ri-danger: #dc2626;
  --ri-gradient: linear-gradient(90deg, #f59e0b, #fbbf24);
  --ri-shadow: 0 4px 14px -4px rgb(15 23 42 / 12%);
  --ri-radius: 14px;
  --ri-transition: 0.25s cubic-bezier(.4, 0, .2, 1);
  --font-mono: ui-monospace, sfmono-regular, menlo, consolas, "Liberation Mono", monospace;
  background: var(--ri-bg);
  color: var(--ri-text);
}

.p-legal .ri-main {
  width: 100%;
  overflow: hidden;
}

.p-legal h1,
.p-legal h2,
.p-legal h3 {
  font-weight: 600;
  line-height: 1.15;
}

.p-legal p {
  line-height: 1.55;
}

.p-legal .ri-hero {
  padding: 4.5rem 1.5rem 2.5rem;
  position: relative;
}

.p-legal .ri-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 25% 35%, rgb(255 165 0 / 25%), transparent 60%), radial-gradient(circle at 80% 20%, rgb(11 79 156 / 18%), transparent 55%);
  pointer-events: none;
}

.p-legal .ri-hero-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.p-legal .ri-hero-title {
  font-size: clamp(2.2rem, 4.4vw, 3.4rem);
  margin: 0 0 1rem;
  background: linear-gradient(90deg, #1e293b, #334155 45%, #f59e0b);
  background-clip: text;
  color: transparent;
}

.p-legal .ri-hero-lede {
  font-size: 1.1rem;
  color: var(--ri-dim);
  margin: 0 0 1.75rem;
}

.p-legal .ri-search-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.p-legal .ri-search-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ri-dim);
}

.p-legal .ri-search-bar {
  display: flex;
  align-items: center;
  background: var(--ri-panel);
  border: 1px solid var(--ri-border);
  padding: 0.65rem 0.75rem 0.65rem 0.9rem;
  border-radius: 50px;
  gap: 0.6rem;
  box-shadow: var(--ri-shadow);
}

.p-legal .ri-search-bar:focus-within {
  border-color: var(--ri-accent);
  box-shadow: 0 0 0 3px rgb(245 158 11 / 25%);
}

.p-legal .ri-search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ri-text);
  font-size: 0.95rem;
}

.p-legal .ri-search-bar .ri-search-btn {
  appearance: none;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  border-radius: 30px;
  padding: 0.55rem 1.15rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(145deg, var(--ri-blue) 0%, #2563eb 100%);
  box-shadow:
    0 2px 8px rgb(37 99 235 / 38%),
    inset 0 1px 0 rgb(255 255 255 / 22%);
  transition: background var(--ri-transition), box-shadow var(--ri-transition), filter var(--ri-transition), transform var(--ri-transition);
}

.p-legal .ri-search-bar .ri-search-btn:hover {
  filter: brightness(1.06);
  box-shadow:
    0 4px 14px rgb(37 99 235 / 48%),
    inset 0 1px 0 rgb(255 255 255 / 26%);
}

.p-legal .ri-search-bar .ri-search-btn:active {
  transform: translateY(1px);
  filter: brightness(0.96);
}

.p-legal .ri-search-bar .ri-search-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgb(77 130 255 / 45%),
    0 2px 8px rgb(37 99 235 / 38%),
    inset 0 1px 0 rgb(255 255 255 / 22%);
}

/* Dark shell theme: keep the CTA clearly blue with slightly lifted luminance */
:is(html[data-theme='dark'], html.dark-mode) body.p-legal .ri-search-bar .ri-search-btn,
body.dark-mode.p-legal .ri-search-bar .ri-search-btn {
  background: linear-gradient(145deg, #6b93ff 0%, #3d74ff 55%, #2563eb 100%);
  box-shadow:
    0 2px 10px rgb(15 23 42 / 45%),
    0 1px 0 rgb(255 255 255 / 18%) inset;
}

:is(html[data-theme='dark'], html.dark-mode) body.p-legal .ri-search-bar .ri-search-btn:hover,
body.dark-mode.p-legal .ri-search-bar .ri-search-btn:hover {
  filter: brightness(1.08);
  box-shadow:
    0 5px 18px rgb(15 23 42 / 55%),
    0 1px 0 rgb(255 255 255 / 22%) inset;
}

:is(html[data-theme='dark'], html.dark-mode) body.p-legal .ri-search-bar .ri-search-btn:focus-visible,
body.dark-mode.p-legal .ri-search-bar .ri-search-btn:focus-visible {
  box-shadow:
    0 0 0 3px rgb(147 180 255 / 55%),
    0 2px 10px rgb(15 23 42 / 45%),
    inset 0 1px 0 rgb(255 255 255 / 18%);
}

.p-legal .ri-search-icon {
  width: 20px;
  height: 20px;
  color: var(--ri-dim);
  display: flex;
}

.p-legal .ri-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.p-legal .ri-chip {
  background: var(--ri-panel-alt);
  border: 1px solid var(--ri-border);
  color: var(--ri-dim);
  padding: 0.45rem 0.85rem;
  font-size: 0.65rem;
  line-height: 1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--ri-transition);
  position: relative;
}

.p-legal .ri-chip.is-active {
  background: var(--ri-accent);
  color: #fff;
  border-color: var(--ri-accent);
  font-weight: 600;
}

.p-legal .ri-chip:hover {
  border-color: var(--ri-accent);
  color: #1e293b;
}

.p-legal .ri-hero-footnote {
  font-size: 0.75rem;
  color: var(--ri-dim);
  margin: 0;
}

.p-legal .ri-streams {
  padding: 3.5rem 1.5rem 1rem;
  max-width: 1320px;
  margin: 0 auto;
}

.p-legal .ri-section-head {
  margin: 0 0 1.75rem;
}

.p-legal .ri-section-head h2 {
  font-size: 1.9rem;
  margin: 0 0 0.4rem;
  color: #0f172a;
}

.p-legal .ri-section-sub {
  font-size: 0.9rem;
  color: var(--ri-dim);
  margin: 0;
}

.p-legal .ri-results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.25rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--ri-border);
  background: var(--ri-panel-alt);
  border-radius: 14px;
}

.p-legal .ri-result-count {
  font: 600 0.8rem/1.2 system-ui, sans-serif;
  color: var(--ri-text);
}

.p-legal .ri-results-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.p-legal .ri-view-toggle {
  display: inline-flex;
  background: var(--ri-panel);
  border: 1px solid var(--ri-border);
  padding: 2px;
  border-radius: 10px;
}

.p-legal .ri-view-toggle .vt-btn {
  background: none;
  border: 0;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  border-radius: 8px;
  font: 600 0.7rem/1 system-ui, sans-serif;
  color: var(--ri-dim);
}

.p-legal .ri-view-toggle .vt-btn.is-active {
  background: var(--ri-accent);
  color: #fff;
}

.p-legal .ri-sort-label {
  font: 600 0.55rem/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ri-dim);
}

.p-legal .ri-sort-label select {
  font: 600 0.65rem/1.1 system-ui, sans-serif;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--ri-border);
  border-radius: 8px;
  background: var(--ri-panel);
  color: var(--ri-text);
}

.p-legal .vt-btn:focus,
.p-legal .ri-sort-label select:focus {
  outline: 2px solid var(--ri-accent);
  outline-offset: 2px;
}

.p-legal .streams-grid {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.p-legal .stream-card {
  background: var(--ri-panel);
  border: 1px solid var(--ri-border);
  padding: 1.1rem 1.15rem 1.05rem;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
  transition: var(--ri-transition);
  cursor: pointer;
}

.p-legal .stream-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgb(255 255 255 / 40%), transparent 62%);
  pointer-events: none;
  opacity: 0.18;
}

.p-legal .stream-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  border: 1px solid transparent;
  background: linear-gradient(transparent, transparent) padding-box, linear-gradient(120deg, rgb(245 158 11 / 26%), rgb(14 98 224 / 22%), rgb(245 158 11 / 26%)) border-box;
  opacity: 0;
  transition: 0.5s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}

.p-legal .stream-card:hover,
.p-legal .stream-card:focus-within {
  box-shadow: 0 8px 18px -10px rgb(15 23 42 / 16%);
  border-color: rgb(245 158 11 / 38%);
  transform: translateY(-2px);
}

.p-legal .stream-card:hover::after,
.p-legal .stream-card:focus-within::after {
  opacity: 1;
}

.p-legal .stream-card:focus-visible {
  outline: 3px solid rgb(247 144 29 / 55%);
  outline-offset: 2px;
}

.p-legal .stream-card.is-selected {
  border-color: rgb(247 144 29 / 50%);
  box-shadow: 0 16px 30px rgb(247 144 29 / 10%);
  transform: translateY(-2px);
}

.p-legal .stream-card h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0.4px;
  color: #0f172a;
}

.p-legal .sc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.p-legal .sc-next {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--ri-panel-alt);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  color: var(--ri-accent);
  font-weight: 600;
}

.p-legal .sc-progress {
  height: 4px;
  background: var(--ri-panel-alt);
  border-radius: 4px;
  overflow: hidden;
}

.p-legal .sc-progress .bar {
  height: 100%;
  background: var(--ri-gradient);
}

.p-legal .sc-insight {
  font-size: 0.78rem;
  color: #334155;
  margin: 0.1rem 0 0.2rem;
}

.p-legal .sc-upcoming {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ri-dim);
  margin-top: auto;
}

.p-legal .sc-upcoming .label {
  color: var(--ri-accent);
  font-weight: 600;
}

.p-legal .ri-playbook-detail {
  margin-top: 1.25rem;
  background: var(--ri-panel);
  border: 1px solid var(--ri-border);
  border-radius: 18px;
  box-shadow: 0 6px 18px -4px rgb(15 23 42 / 18%);
  padding: 1.1rem 1.15rem;
  position: relative;
  overflow: hidden;
  transition: var(--ri-transition);
}

.p-legal .ri-playbook-detail::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgb(255 255 255 / 70%), transparent 60%);
  pointer-events: none;
  opacity: 0.35;
}

.p-legal .ri-playbook-detail:hover,
.p-legal .ri-playbook-detail:focus-within {
  border-color: var(--ri-accent);
}

.p-legal .ri-detail-kicker {
  margin: 0;
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ri-dim);
  position: relative;
  z-index: 1;
}

.p-legal #playbookDetailTitle {
  margin: 0.35rem 0 0.45rem;
  color: #0f172a;
  font-size: 1.02rem;
  letter-spacing: 0.4px;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-summary {
  margin: 0.1rem 0 0.2rem;
  color: #334155;
  font-size: 0.78rem;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-answer-title,
.p-legal .ri-detail-applies-title,
.p-legal .ri-detail-qa-title {
  margin: 0.7rem 0 0.35rem;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ri-dim);
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-answer {
  margin: 0;
  color: #1e293b;
  font-size: 0.72rem;
  line-height: 1.55;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-chip {
  border-radius: 6px;
  border: 1px solid var(--ri-border);
  background: var(--ri-panel-alt);
  color: var(--ri-accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
}

.p-legal .ri-detail-applies,
.p-legal .ri-detail-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.66rem;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-applies {
  color: #334155;
}

.p-legal .ri-detail-points {
  color: #64748b;
  margin-top: 0.75rem;
}

.p-legal .ri-detail-applies li,
.p-legal .ri-detail-points li {
  position: relative;
  padding-left: 0.9rem;
}

.p-legal .ri-detail-applies li::before,
.p-legal .ri-detail-points li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.38rem;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
}

.p-legal .ri-detail-applies li::before {
  background: #475569;
  box-shadow: 0 0 0 3px rgb(71 85 105 / 18%);
}

.p-legal .ri-detail-points li::before {
  background: var(--ri-accent);
  box-shadow: 0 0 0 3px rgb(245 158 11 / 25%);
}

.p-legal .ri-detail-qa {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.2rem;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-qa-item {
  border: 1px solid var(--ri-border);
  border-radius: 10px;
  background: rgb(255 255 255 / 72%);
  padding: 0.55rem 0.65rem;
}

.p-legal .ri-detail-qa-item h4 {
  margin: 0;
  font-size: 0.68rem;
  color: #0f172a;
  letter-spacing: 0.02em;
}

.p-legal .ri-detail-qa-item p {
  margin: 0.32rem 0 0;
  font-size: 0.66rem;
  line-height: 1.5;
  color: #334155;
}

.p-legal .ri-detail-source {
  display: inline-flex;
  align-items: center;
  margin-top: 0.7rem;
  color: #1d4ed8;
  text-decoration: underline;
  font-size: 0.66rem;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-actions-wrap {
  margin-top: 0.95rem;
  position: relative;
  z-index: 1;
}

.p-legal .ri-detail-actions-title {
  margin: 0 0 0.45rem;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ri-dim);
  font-weight: 600;
}

.p-legal .ri-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.p-legal .ri-detail-action,
.p-legal .ri-detail-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ri-border);
  border-radius: 10px;
  background: var(--ri-panel-alt);
  color: #334155;
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 600;
  transition: var(--ri-transition);
}

.p-legal .ri-detail-action {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.68rem;
}

.p-legal .ri-detail-back {
  appearance: none;
  cursor: pointer;
  margin-bottom: 0.8rem;
  position: relative;
  z-index: 1;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  padding: 0.38rem 0.85rem;
}

.p-legal .ri-detail-action:hover,
.p-legal .ri-detail-action:focus-visible,
.p-legal .ri-detail-back:hover,
.p-legal .ri-detail-back:focus-visible {
  border-color: var(--ri-accent);
  background: var(--ri-accent);
  color: #fff;
  outline: none;
}

.p-legal .ri-playbook-detail.is-focused {
  margin-top: 0.25rem;
}

.p-legal .ri-results-bar.is-hidden {
  display: none;
}

.p-legal .ri-streams.is-focused .streams-grid,
.p-legal .ri-streams.is-focused .ri-results-bar {
  display: none !important;
}

.p-legal .ri-utility {
  padding: 2.2rem 1.5rem 3.5rem;
  background: #f1f5f9;
  border-top: 1px solid var(--ri-border);
}

.p-legal .util-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.p-legal .util-link {
  background: var(--ri-panel);
  border: 1px solid var(--ri-border);
  color: #334155;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--ri-transition);
}

.p-legal .util-link:hover {
  background: var(--ri-accent);
  color: #fff;
  border-color: var(--ri-accent);
}

@media (width <= 1100px) {
  .p-legal .ri-hero-inner {
    flex-direction: column;
  }
}

@media (width <= 780px) {
  .p-legal .ri-streams {
    padding: 3.2rem 1.1rem 1rem;
  }

  .p-legal .ri-hero {
    padding: 3.5rem 1.1rem 2rem;
  }
}

@media (width <= 720px) {
  .p-legal .ri-playbook-detail {
    padding: 0.95rem;
  }
}

@media (width <= 560px) {
  .p-legal .ri-search-bar {
    flex-wrap: wrap;
    border-radius: 24px;
  }

  .p-legal .ri-search-bar input {
    order: 2;
    width: 100%;
  }

  .p-legal .ri-search-bar .ri-search-btn {
    order: 3;
    width: 100%;
  }

  .p-legal .ri-search-icon {
    order: 1;
  }
}
