/*
 * Trinity36 V49.4 — sitewide responsive consistency layer
 * Loaded last. Repairs shared headers, price presentation, nested overflow,
 * membership-card balance, category navigation and mobile safe areas.
 */

:root {
  --v494-gold: #d7ac55;
  --v494-gold-bright: #f2d58b;
  --v494-line: rgba(216, 173, 86, .38);
  --v494-black: #050505;
  --v494-cream: #efe3c9;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* Storefront header: preserve the approved two-band system while preventing
   the mobile rail from starting off canvas or collapsing the logo to 0 × 0. */
#trinityImageHeader.trinity-v35-header {
  height: auto !important;
  min-height: 0 !important;
}

#trinityImageHeader .trinity-v35-shell,
#trinityImageHeader .trinity-v35-actions,
#trinityImageHeader .trinity-v35-search-wrap,
#trinityImageHeader .trinity-v35-search {
  min-width: 0 !important;
}

#trinityImageHeader .trinity-v35-brand {
  display: flex !important;
}

#trinityImageHeader .trinity-v35-brand img {
  display: block !important;
  object-fit: contain !important;
  object-position: center !important;
}

/* Advanced Research now uses the same visual language as the homepage:
   prominent Trinity brand, evenly divided bubble controls and assurance rail. */
body.trinity-research-page > header.site-header.trinity-v49-4-research-header {
  position: relative !important;
  inset-block-start: 0;
  z-index: 20 !important;
  isolation: isolate;
  contain: paint;
  display: block !important;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  color: var(--v494-cream);
  background: #030303 !important;
  border-block: 1px solid var(--v494-line);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

/* Product details are the primary modal. Keep the assistant from remaining
   interactable underneath that surface; it returns when the detail closes. */
body:has(#triProductOverlay.open) .knight-assistant-widget,
body:has(#triProductOverlay.active) .knight-assistant-widget,
body:has(#triProductOverlay[aria-hidden="false"]) .knight-assistant-widget {
  visibility: hidden !important;
  pointer-events: none !important;
}

.trinity-v49-4-header-shell {
  position: relative;
  z-index: 2;
  width: 100% !important;
  max-width: 1540px !important;
  min-height: 88px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  align-items: stretch;
  gap: 18px;
  padding: 8px clamp(16px, 2.5vw, 38px);
  background: #030303;
}

.trinity-v49-4-header-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--v494-cream);
  text-decoration: none;
}

.trinity-v49-4-header-brand img {
  display: block;
  width: min(124px, 52%);
  max-height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .22));
}

.trinity-v49-4-header-brand > span {
  min-width: 0;
  display: grid;
  gap: 2px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
}

.trinity-v49-4-header-brand b {
  color: #fff8e8;
  font-size: 1.08rem;
  letter-spacing: .12em;
}

.trinity-v49-4-header-brand small,
.trinity-v49-4-header-brand em {
  color: var(--v494-gold-bright);
  font: 700 .58rem/1.2 Arial, sans-serif;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.trinity-v49-4-header-brand em {
  color: #a99a7c;
  font-style: normal;
  letter-spacing: .07em;
}

.trinity-v49-4-header-actions {
  position: relative;
  z-index: 3;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(76px, 1fr));
  align-items: stretch;
  background: #030303;
  border-left: 1px solid rgba(216, 173, 86, .22);
}

.trinity-v49-4-bubble {
  appearance: none;
  min-width: 0;
  min-height: 70px;
  margin: 0;
  padding: 9px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--v494-cream) !important;
  background: transparent !important;
  border: 0 !important;
  border-right: 1px solid rgba(216, 173, 86, .22) !important;
  border-radius: 0 !important;
  text-decoration: none !important;
  cursor: pointer;
}

.trinity-v49-4-bubble > span {
  color: var(--v494-gold-bright);
  font: 400 1.35rem/1 Arial, sans-serif;
}

.trinity-v49-4-bubble > b {
  color: inherit;
  font: 700 clamp(.58rem, .72vw, .74rem)/1.1 Arial, sans-serif;
  letter-spacing: .055em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.trinity-v49-4-bubble:is(:hover, :focus-visible, .is-active) {
  color: var(--v494-gold-bright) !important;
  background: radial-gradient(circle, rgba(231, 187, 94, .13), transparent 72%) !important;
  outline: 1px solid rgba(240, 205, 126, .26);
  outline-offset: -7px;
}

.trinity-v49-4-research-rail {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 5vw, 72px);
  padding: 7px 18px;
  color: #b8aa8b;
  background: #080706;
  border-top: 1px solid rgba(216, 173, 86, .2);
  font: 700 .62rem/1.25 Arial, sans-serif;
  letter-spacing: .1em;
  text-align: center;
  text-transform: uppercase;
}

.trinity-v49-4-research-rail span::before {
  content: "✚";
  margin-right: 7px;
  color: var(--v494-gold);
}

[data-theme="light"] body.trinity-research-page > header.site-header.trinity-v49-4-research-header {
  color: #5b3d18;
  background: #fffaf1 !important;
}

[data-theme="light"] .trinity-v49-4-header-shell,
[data-theme="light"] .trinity-v49-4-header-actions {
  background: #fffaf1;
}

[data-theme="light"] .trinity-v49-4-header-brand {
  color: #5b3d18;
}

[data-theme="light"] .trinity-v49-4-header-brand b {
  color: #3a2814;
}

[data-theme="light"] .trinity-v49-4-bubble {
  color: #5b3d18 !important;
  border-color: rgba(133, 91, 31, .2) !important;
}

[data-theme="light"] .trinity-v49-4-research-rail {
  color: #6e5738;
  background: #f3eadc;
}

/* Research result containment: no badge, title, table or imported source may
   make a dossier wider than its panel. */
.trinity-research-page,
.trinity-research-page main,
.trinity-research-page .tv49-portal,
.trinity-research-page .tv49-panel,
.trinity-research-page .tv49-results,
.trinity-research-page .tv49-result,
.trinity-research-page .tv49-result-head,
.trinity-research-page .tv49-result-title,
.trinity-research-page .tv49-badgerow,
.trinity-research-page .tv49-tier,
.trinity-research-page .tv49-tier-body,
.trinity-research-page .tv49-catalog {
  box-sizing: border-box;
  min-width: 0 !important;
  max-width: 100% !important;
}

.trinity-research-page .tv49-result,
.trinity-research-page .tv49-result * {
  min-width: 0;
}

.trinity-research-page .tv49-result-title,
.trinity-research-page .tv49-badgerow {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.trinity-research-page .tv49-result-title h3 {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.trinity-research-page .tv49-badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.trinity-research-page .tv49-term-chip {
  max-width: 100%;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.trinity-research-page :is(p, li, dd, a, summary, figcaption) {
  overflow-wrap: anywhere;
}

/* Catalog cards: use fewer, wider desktop columns so every plan name and
   price qualifier remains readable. */
body.trinity-storefront #cardCatalog {
  width: 100% !important;
  max-width: 1160px !important;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)) !important;
  gap: 16px !important;
}

@media (min-width: 1100px) {
  html body.trinity-storefront #cardCatalog.card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }
}

body.trinity-storefront #cardCatalog .product-card,
body.trinity-storefront #cardCatalog .prices,
body.trinity-storefront #cardCatalog .price-box,
body.trinity-storefront #cardCatalog .kit-price-box {
  min-width: 0 !important;
}

body.trinity-storefront #cardCatalog .price-box :is(span, small, strong),
body.trinity-storefront #cardCatalog .kit-price-box :is(span, small, strong) {
  max-width: 100%;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* Five premium stacks should form an intentional 2 + 2 + 1 composition. */
@media (min-width: 1181px) {
  body.trinity-storefront #membershipCardsGrid .membership-package-card:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
    justify-self: stretch !important;
    width: 100% !important;
  }

  body.trinity-storefront #membershipCardsGrid .membership-package-card:last-child:nth-child(odd) .membership-package-vials {
    justify-self: center !important;
    max-inline-size: 430px !important;
  }
}

/* The assistant uses the same explicit plan hierarchy as the catalog instead
   of squeezing a combined sentence into fixed table columns. */
.templar-price-table {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: auto !important;
  border-collapse: separate !important;
  border-spacing: 0 7px !important;
  font-size: 12px !important;
}

.templar-price-table tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 9px;
  border: 1px solid rgba(216, 173, 86, .25);
  background: rgba(0, 0, 0, .2);
}

.templar-price-table th,
.templar-price-table td {
  width: auto !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  text-align: left !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
}

.templar-price-table th {
  color: var(--v494-gold-bright) !important;
  font-size: 11px !important;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.templar-price-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.templar-price-option {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 7px 8px;
  border: 1px solid rgba(216, 173, 86, .2);
  background: rgba(216, 173, 86, .045);
}

.templar-price-option small {
  color: #b9ae98;
  font-size: 11px;
  line-height: 1.25;
  text-transform: uppercase;
}

.templar-price-option strong {
  color: #fff3d3;
  font: 700 15px/1.15 Georgia, "Times New Roman", serif;
}

/* Safe area for persistent phone navigation and assistant launcher. */
@media (max-width: 700px) {
  body.trinity-storefront {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  #trinityImageHeader .trinity-v35-shell {
    width: 100vw !important;
    max-width: 100vw !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
    padding: 0 !important;
  }

  #trinityImageHeader .trinity-v35-brand {
    width: 100% !important;
    min-width: 0 !important;
    height: 56px !important;
    padding: 3px 14px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #trinityImageHeader .trinity-v35-brand img {
    width: 142px !important;
    height: 50px !important;
    max-width: 52vw !important;
    max-height: 50px !important;
    margin: 0 auto !important;
    inset: auto !important;
    transform: none !important;
  }

  #trinityImageHeader .trinity-v35-actions {
    width: 100% !important;
    min-height: 62px !important;
    display: flex !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 7px;
    padding: 0 7px !important;
    border-top: 1px solid rgba(216, 173, 86, .2);
    border-left: 0 !important;
    scrollbar-width: none;
  }

  #trinityImageHeader .trinity-v35-actions::-webkit-scrollbar {
    display: none;
  }

  #trinityImageHeader .trinity-v35-search-wrap,
  #trinityImageHeader .trinity-v35-bubble {
    flex: 0 0 72px !important;
    scroll-snap-align: start;
  }

  #trinityImageHeader .trinity-v35-bubble {
    min-height: 60px !important;
    padding: 7px 4px !important;
    font-size: .55rem !important;
  }

  #trinityCinematicHero,
  #brandHeroStage,
  #brandHeroRig {
    box-sizing: border-box;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: clip !important;
  }

  #trinityCinematicHero .tri-hero-actions,
  #trinityCinematicHero .primary-button {
    max-width: calc(100vw - 32px) !important;
    white-space: normal !important;
  }

  #categories.category-strip {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    overflow: visible !important;
  }

  #categories.category-strip > button {
    width: auto !important;
    min-width: 0 !important;
    min-height: 94px !important;
    border-bottom: 1px solid var(--line);
  }

  #categories.category-strip > button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  body.trinity-storefront #cardCatalog {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  body.trinity-storefront #cardCatalog .membership-product-card {
    grid-column: 1 / -1 !important;
  }

  .trinity-v49-4-header-shell {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0;
  }

  .trinity-v49-4-header-brand {
    width: 100%;
    min-height: 58px;
    justify-content: center;
    padding: 4px 14px;
  }

  .trinity-v49-4-header-brand img {
    width: 104px;
    max-height: 50px;
  }

  .trinity-v49-4-header-brand > span {
    display: grid;
  }

  .trinity-v49-4-header-actions {
    width: 100%;
    min-height: 62px;
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 7px;
    padding: 0 7px;
    border-top: 1px solid rgba(216, 173, 86, .2);
    border-left: 0;
    scrollbar-width: none;
  }

  .trinity-v49-4-header-actions::-webkit-scrollbar {
    display: none;
  }

  .trinity-v49-4-bubble {
    flex: 0 0 72px;
    min-height: 60px;
    padding: 6px 4px;
    scroll-snap-align: start;
  }

  .trinity-v49-4-bubble > span {
    font-size: 1.15rem;
  }

  .trinity-v49-4-bubble > b {
    font-size: .53rem;
  }

  .trinity-v49-4-research-rail {
    min-height: 30px;
    justify-content: flex-start;
    gap: 20px;
    overflow-x: auto;
    padding-inline: 14px;
    white-space: nowrap;
  }

  .trinity-research-page .tv49-result {
    width: 100% !important;
    overflow: hidden;
  }

  .trinity-research-page .tv49-badge {
    flex: 0 1 auto;
    font-size: 9px;
  }

  .trinity-research-page .tv49-catalog .tv49-table-wrap {
    overflow: visible;
    border: 0;
  }

  .trinity-research-page .tv49-catalog .tv49-table,
  .trinity-research-page .tv49-catalog .tv49-table tbody,
  .trinity-research-page .tv49-catalog .tv49-table tr {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .trinity-research-page .tv49-catalog .tv49-table thead {
    display: none;
  }

  .trinity-research-page .tv49-catalog .tv49-table tr {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid var(--tri-line);
    border-radius: 8px;
    overflow: hidden;
  }

  .trinity-research-page .tv49-catalog .tv49-table tbody th {
    grid-column: 1 / -1;
    padding: 11px 12px;
    background: var(--tri-surface-2);
  }

  .trinity-research-page .tv49-catalog .tv49-table td {
    min-width: 0;
    padding: 10px 12px;
    border-bottom: 0;
    border-top: 1px solid var(--tri-line);
  }

  .trinity-research-page .tv49-catalog .tv49-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--tri-muted);
    font: 700 11px/1.2 var(--tri-serif);
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .trinity-research-page .tv49-catalog .tv49-table td[data-label="Stock"] {
    grid-column: 1 / -1;
  }

  .knight-assistant-panel {
    right: 0 !important;
    width: min(348px, calc(100vw - 24px)) !important;
    max-height: calc(100dvh - 164px) !important;
    overflow: auto !important;
  }

  .templar-price-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  .trinity-v49-4-header-brand img {
    width: 94px;
  }

  .trinity-v49-4-header-brand b {
    font-size: .94rem;
  }

  .trinity-v49-4-header-brand small,
  .trinity-v49-4-header-brand em {
    font-size: .51rem;
  }
}
  background: #030303;
