/* =====================================================================
   Terra Vita Hub v444 — Site-wide UI coherence lock
   Purpose: one visible institutional product language across public,
   protected and reviewer surfaces. This layer only normalises presentation:
   spacing, cards, buttons, containers, typography rhythm and search cards.
   It does not change routing, auth, Supabase, SQL, protected data access,
   review logic, readiness posture or institutional authority boundaries.
   ===================================================================== */

:root{
  --tvh-coh-ink:#0A2A43;
  --tvh-coh-navy:#082E49;
  --tvh-coh-teal:#0B7D73;
  --tvh-coh-teal-soft:rgba(11,125,115,.105);
  --tvh-coh-paper:#F8F6EC;
  --tvh-coh-paper-2:#FFFDF6;
  --tvh-coh-card:rgba(255,255,255,.92);
  --tvh-coh-muted:#5D707A;
  --tvh-coh-line:rgba(10,42,67,.135);
  --tvh-coh-line-strong:rgba(11,125,115,.23);
  --tvh-coh-shadow:0 22px 60px rgba(10,42,67,.075);
  --tvh-coh-radius-xl:32px;
  --tvh-coh-radius-lg:26px;
  --tvh-coh-radius-md:18px;
  --tvh-coh-container:1180px;
  --tvh-coh-wide:1440px;
}

*{box-sizing:border-box;}
html{scroll-padding-top:96px;}
body{
  min-width:320px;
  background:linear-gradient(180deg,var(--tvh-coh-paper-2) 0%,var(--tvh-coh-paper) 720px,var(--tvh-coh-paper) 100%) !important;
  color:var(--tvh-coh-ink) !important;
}

/* Page width and left/right relief */
:where(main,.tvh-main,.tvh-page-shell,.wrap,.page-wrap,.container,.tvh-container,.workspace-shell,.protected-shell){
  width:100%;
}
:where(.tvh-container,.wrap,.container,.tvh-page-shell,.workspace-shell,.protected-shell){
  max-width:var(--tvh-coh-wide) !important;
  margin-left:auto !important;
  margin-right:auto !important;
  padding-left:clamp(22px,4vw,54px) !important;
  padding-right:clamp(22px,4vw,54px) !important;
}
:where(.tvh-page-shell > section,.tvh-main > section,.wrap > section,.container > section){
  margin-left:auto;
  margin-right:auto;
}

/* Consistent page hero rhythm */
:where(.hero,.tvh-hero,.page-header,.tvh-review-surfaces-hero,.workspace-hero,.protected-hero){
  margin-left:auto;
  margin-right:auto;
  padding-top:clamp(44px,6vw,84px) !important;
  padding-bottom:clamp(22px,3vw,38px) !important;
}
:where(.hero p,.tvh-hero p,.page-header p,.page-summary,.lead,.lede,.tvh-review-surfaces-hero p){
  max-width:78ch;
  line-height:1.68 !important;
}

/* One card grammar across public, governance and protected surfaces */
:where(.tvh-card,.tile,.panel,.card,.surface-card,.route-card,.diagram-card,.next-block,.module-shell,.room-context-card,.room-live-feed,.live-pack-overview,.v410-ers-surface,.table-wrap,.finding,.kpi,.mode,.evcard,.ir-card,.readiness-card,.substrate-card){
  background:var(--tvh-coh-card) !important;
  border:1px solid var(--tvh-coh-line) !important;
  border-radius:var(--tvh-coh-radius-xl) !important;
  box-shadow:var(--tvh-coh-shadow) !important;
}
:where(.tvh-card,.tile,.panel,.card,.surface-card,.route-card,.diagram-card,.next-block,.room-context-card,.room-live-feed,.live-pack-overview,.v410-ers-surface,.table-wrap,.finding,.kpi,.mode,.ir-card,.readiness-card,.substrate-card){
  padding:clamp(24px,3vw,42px) !important;
}
:where(.tile,.panel,.card,.tvh-card,.surface-card,.route-card){
  overflow:hidden;
}
:where(.tile > *:first-child,.panel > *:first-child,.card > *:first-child,.tvh-card > *:first-child){
  margin-top:0 !important;
}
:where(.tile > *:last-child,.panel > *:last-child,.card > *:last-child,.tvh-card > *:last-child){
  margin-bottom:0 !important;
}

/* Grids should breathe the same way */
:where(.grid,.tvh-card-grid,.cards,.card-grid,.route-grid,.module-grid,.review-grid,.resource-grid,.diagram-grid,.stats-grid){
  gap:clamp(20px,2.4vw,34px) !important;
}
:where(.grid,.tvh-card-grid,.cards,.card-grid,.route-grid,.module-grid,.review-grid,.resource-grid,.diagram-grid){
  align-items:stretch;
}

/* Labels and metadata */
:where(.tvh-eyebrow,.eyebrow,.section-kicker,.kicker,.k,.badge,.pill,.status,.tag,.chip,.meta,.tvh-ord,.source-note){
  letter-spacing:.13em !important;
  text-transform:uppercase !important;
}
:where(.tvh-eyebrow,.eyebrow,.section-kicker,.kicker,.k){
  color:var(--tvh-coh-teal) !important;
  font-weight:850 !important;
  margin-bottom:14px !important;
}
:where(.badge,.pill,.status,.tag,.chip){
  border:1px solid var(--tvh-coh-line) !important;
  border-radius:999px !important;
  padding:.55rem .8rem !important;
}

/* Buttons and links read as the same product */
:where(.tvh-cta-primary,.tvh-cta-ghost,.tvh-cta,.btn,.btn-primary,.btn-secondary,.button,.cbtn,.hub-return a,.tile a,.tvh-detail-card .tvh-detail-badge){
  border-radius:999px !important;
  text-decoration:none !important;
}
:where(.tvh-cta-primary,.btn-primary,.btn.primary,.button.primary,.tile a[href]:last-child,.tvh-card a[href]:last-child){
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.45rem;
  min-height:44px;
  padding:12px 18px !important;
  background:var(--tvh-coh-navy) !important;
  color:var(--tvh-coh-paper-2) !important;
  border:1px solid var(--tvh-coh-navy) !important;
  font-weight:850 !important;
}
:where(.tvh-cta-ghost,.btn-secondary,.btn.ghost,.button.ghost,.hub-return a){
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.45rem;
  min-height:44px;
  padding:12px 18px !important;
  background:#fff !important;
  color:var(--tvh-coh-ink) !important;
  border:1px solid var(--tvh-coh-line) !important;
  font-weight:800 !important;
}
:where(.tvh-cta-primary,.tvh-cta-ghost,.btn,.button,.tile a[href]:last-child,.tvh-card a[href]:last-child){
  transition:transform .16s ease,box-shadow .16s ease,background .16s ease,color .16s ease,border-color .16s ease;
}
:where(.tvh-cta-primary,.tvh-cta-ghost,.btn,.button,.tile a[href]:last-child,.tvh-card a[href]:last-child):hover{
  transform:translateY(-1px);
  box-shadow:0 12px 28px rgba(10,42,67,.12);
}

/* Forms/search fields */
:where(input,select,textarea){
  border:1px solid var(--tvh-coh-line) !important;
  border-radius:18px !important;
  min-height:46px;
  background:#fff !important;
  color:var(--tvh-coh-ink) !important;
}
:where(input:focus,select:focus,textarea:focus){
  outline:3px solid var(--tvh-coh-teal-soft) !important;
  border-color:var(--tvh-coh-line-strong) !important;
}

/* Search/results consistency */
:where(.tvh-search-command,.tvh-search-assurance-box,.tvh-result-grid > a,.tvh-detail-card,.tvh-review-step,.tvh-empty-results){
  border-radius:var(--tvh-coh-radius-lg) !important;
  border:1px solid var(--tvh-coh-line) !important;
  background:var(--tvh-coh-card) !important;
  box-shadow:var(--tvh-coh-shadow) !important;
}
:where(.tvh-search-command,.tvh-search-assurance-box,.tvh-detail-card,.tvh-review-step,.tvh-empty-results){
  padding:clamp(20px,2.4vw,34px) !important;
}

/* Tables */
:where(table){
  border-collapse:separate;
  border-spacing:0;
  width:100%;
}
:where(th,td){
  border-bottom:1px solid var(--tvh-coh-line);
  padding:14px 16px;
  vertical-align:top;
}
:where(th){
  color:var(--tvh-coh-ink);
  font-weight:850;
  background:rgba(10,42,67,.035);
}

/* Header/footer consistency without changing nav logic */
:where(.tvh-header,header.site){
  background:rgba(255,253,246,.96) !important;
  border-bottom:1px solid var(--tvh-coh-line) !important;
}
:where(.tvh-footer,footer.site,footer){
  border-top:1px solid var(--tvh-coh-line);
}

/* Preserve compactness on small screens */
@media (max-width:900px){
  :where(.tvh-container,.wrap,.container,.tvh-page-shell,.workspace-shell,.protected-shell){
    padding-left:20px !important;
    padding-right:20px !important;
  }
  :where(.tvh-card,.tile,.panel,.card,.surface-card,.route-card,.diagram-card,.next-block){
    border-radius:24px !important;
  }
}

@media (max-width:560px){
  :where(.tvh-container,.wrap,.container,.tvh-page-shell,.workspace-shell,.protected-shell){
    padding-left:18px !important;
    padding-right:18px !important;
  }
  :where(.tvh-cta-primary,.tvh-cta-ghost,.btn,.button,.tile a[href]:last-child,.tvh-card a[href]:last-child){
    width:auto;
    max-width:100%;
    white-space:normal;
    text-align:left;
  }
}
