/* ============================================================
   TRUETAP-UNIVERSE.CSS - Trust Universe (Sprint C prototype)

   Scoped entirely to the /labs/trust-universe/ route via .ttu-*
   classes on [data-ttu-root]. No global selectors, no Sprint A/B
   or ITT contamination. Visual identity: warm-white, editorial
   black type, restrained TrueTap orange, fine technical lines.
   ============================================================ */

[data-ttu-root] {
  --ttu-ink: var(--text-primary);
  --ttu-ink-soft: var(--text-secondary);
  --ttu-ink-muted: var(--text-muted);
  --ttu-accent: var(--accent);
  --ttu-line: rgba(17, 17, 17, 0.14);
  --ttu-line-soft: rgba(17, 17, 17, 0.08);
  --ttu-line-strong: rgba(17, 17, 17, 0.30);
  --ttu-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- Hero / intro ------------------------------------------- */

.ttu-hero {
  padding: calc(var(--nav-height) + clamp(2.5rem, 5vw, 4rem)) 0 clamp(1.5rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--ttu-line-soft);
}

.ttu-hero__eyebrow-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.ttu-flag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0.04em;
  color: var(--ttu-ink-muted);
  border: 1px solid var(--ttu-line);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.ttu-hero__title {
  font-size: var(--display-md);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: var(--weight-bold);
  max-width: 18ch;
  margin-bottom: var(--space-5);
}

.ttu-hero__lede {
  font-size: var(--text-md);
  line-height: var(--leading-loose);
  color: var(--ttu-ink-soft);
  max-width: 58ch;
  margin-bottom: var(--space-6);
}

.ttu-hero__actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.ttu-path-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  font-weight: var(--weight-semi);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ttu-accent);
  background: none;
  border: none;
  border-bottom: 1px solid var(--accent-mid);
  padding: 0 0 3px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.ttu-path-btn:hover,
.ttu-path-btn[aria-pressed="true"] {
  color: var(--accent-dark);
  border-color: var(--accent-dark);
}

.ttu-path-btn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ttu-accent);
}

.ttu-hint {
  font-size: 0.8125rem;
  color: var(--ttu-ink-muted);
}

/* ---- Stage layout -------------------------------------------- */

.ttu-stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(var(--space-8), 4vw, var(--space-16));
  align-items: start;
  padding: clamp(var(--space-8), 4vw, var(--space-12)) 0 clamp(var(--space-12), 5vw, var(--space-20));
}

.ttu-stage {
  position: relative;
  min-width: 0;
  aspect-ratio: 1100 / 740; /* reserve the map box before the SVG lands (no CLS) */
}

.ttu-stage__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* ---- Edges ----------------------------------------------------- */

.ttu-edge {
  stroke: var(--ttu-line-strong);
  stroke-width: 1;
  fill: none;
  opacity: 0.63;
  transition:
    stroke 260ms var(--ttu-ease),
    opacity 260ms var(--ttu-ease),
    stroke-dashoffset 620ms var(--ttu-ease);
}

.ttu-edge--cap {
  stroke: var(--ttu-line);
  opacity: 0.78;
}

.ttu-edge--cross {
  stroke: var(--ttu-line);
  stroke-dasharray: 2 5;
  opacity: 0.62;
}

.ttu-stage.is-emphatic .ttu-edge.is-dim {
  opacity: 0.10;
}

.ttu-edge.is-lit {
  stroke: var(--ttu-accent);
  stroke-width: 1.4;
  opacity: 0.9;
}

/* ---- Nodes ------------------------------------------------------ */

.ttu-node {
  cursor: pointer;
  outline: none;
  transition:
    opacity 420ms var(--ttu-ease),
    transform 560ms var(--ttu-ease);
}

.ttu-stage:not(.is-in) .ttu-node {
  opacity: 0;
}

.ttu-stage:not(.is-in) .ttu-edge {
  opacity: 0;
}

.ttu-node:focus-visible .ttu-focus-ring,
.ttu-node:focus-visible .ttu-cap__dot,
.ttu-node:focus-visible .ttu-domain__ring,
.ttu-node:focus-visible .ttu-core__ring {
  stroke: var(--ttu-accent);
  stroke-width: 2;
}

.ttu-stage.is-emphatic .ttu-node.is-dim {
  opacity: 0.26;
}

/* core */
.ttu-core__halo {
  fill: none;
  stroke: var(--ttu-line-soft);
  stroke-width: 1;
}

.ttu-core__ring {
  fill: var(--bg-white);
  stroke: var(--ttu-ink);
  stroke-width: 1.4;
  transition: stroke 240ms var(--ttu-ease), fill 240ms var(--ttu-ease);
}

.ttu-core__label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  fill: var(--ttu-ink);
}

.ttu-core__sub {
  font-size: 6.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  fill: var(--ttu-ink-muted);
}

.ttu-node--core:hover .ttu-core__ring,
.ttu-node--core.is-active .ttu-core__ring {
  stroke: var(--ttu-accent);
  fill: var(--accent-light);
}

/* domains */
.ttu-domain__ring {
  fill: var(--bg-white);
  stroke: var(--ttu-line-strong);
  stroke-width: 1.1;
  transition: stroke 240ms var(--ttu-ease), fill 240ms var(--ttu-ease);
}

.ttu-domain__dot {
  fill: var(--ttu-ink);
  transition: fill 240ms var(--ttu-ease);
}

.ttu-domain__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: rgba(17, 17, 17, 0.82);
  transition: fill 240ms var(--ttu-ease);
}

.ttu-node--domain:hover .ttu-domain__ring,
.ttu-node--domain.is-active .ttu-domain__ring {
  stroke: var(--ttu-accent);
  fill: var(--accent-light);
}

.ttu-node--domain:hover .ttu-domain__dot,
.ttu-node--domain.is-active .ttu-domain__dot,
.ttu-node--domain.is-path-lit .ttu-domain__dot {
  fill: var(--ttu-accent);
}

.ttu-node--domain.is-active .ttu-domain__label {
  fill: var(--ttu-ink);
}

/* capabilities */
.ttu-cap__dot {
  fill: var(--bg-white);
  stroke: rgba(17, 17, 17, 0.34);
  stroke-width: 1.1;
  transition: stroke 220ms var(--ttu-ease), fill 220ms var(--ttu-ease);
}

.ttu-cap__label {
  font-size: 10.5px;
  font-weight: 500;
  fill: #3d3d3d;
  transition: fill 220ms var(--ttu-ease);
}

.ttu-node--cap:hover .ttu-cap__dot,
.ttu-node--cap.is-active .ttu-cap__dot {
  stroke: var(--ttu-accent);
  fill: var(--accent-light);
  stroke-width: 1.6;
}

.ttu-node--cap:hover .ttu-cap__label,
.ttu-node--cap.is-active .ttu-cap__label {
  fill: var(--ttu-ink);
}

/* ---- Path of Trust ---------------------------------------------- */

.ttu-pathseg {
  stroke: var(--ttu-accent);
  stroke-width: 1.6;
  opacity: 0;
  transition: opacity 420ms var(--ttu-ease);
}

.ttu-pathseg.is-lit {
  opacity: 0.85;
}

.ttu-pathstate {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--ttu-accent);
  opacity: 0;
  transition: opacity 320ms var(--ttu-ease);
}

.ttu-pathstate.is-on {
  opacity: 1;
}

.ttu-stage.is-path .ttu-node {
  opacity: 0.18;
}

.ttu-stage.is-path .ttu-edge {
  opacity: 0.07;
}

.ttu-stage.is-path .ttu-node.is-path-lit {
  opacity: 1;
}

.ttu-node.is-path-lit .ttu-cap__dot,
.ttu-node.is-path-lit .ttu-core__ring {
  stroke: var(--ttu-accent);
  stroke-width: 1.8;
  fill: var(--accent-light);
}

/* ---- Detail panel ------------------------------------------------- */

.ttu-panel {
  border-left: 1px solid var(--ttu-line);
  padding-left: clamp(var(--space-5), 2vw, var(--space-8));
  min-height: 300px;
  position: sticky;
  top: calc(var(--nav-height) + var(--space-6));
}

.ttu-panel__eyebrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: 0.6875rem;
  font-weight: var(--weight-semi);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ttu-accent);
  margin-bottom: var(--space-3);
}

.ttu-panel__step {
  font-weight: var(--weight-medium);
  letter-spacing: 0.1em;
  color: var(--ttu-ink-muted);
}

.ttu-panel__title {
  font-size: var(--text-2xl);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-4);
}

.ttu-panel__desc {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ttu-ink-soft);
  margin-bottom: var(--space-5);
}

.ttu-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-6);
}

.ttu-panel__chip {
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ttu-ink-soft);
  background: none;
  border: 1px solid var(--ttu-line);
  border-radius: var(--radius-full);
  padding: 5px 11px;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.ttu-panel__chip:hover {
  border-color: var(--ttu-accent);
  color: var(--ttu-accent);
}

/* ---- Explorer (semantic list / mobile adaptation) ------------------ */

.ttu-explorer {
  border-top: 1px solid var(--ttu-line);
  padding-top: clamp(var(--space-8), 4vw, var(--space-12));
  padding-bottom: clamp(var(--space-12), 5vw, var(--space-20));
}

.ttu-explorer__core {
  margin-bottom: var(--space-8);
}

.ttu-xcore {
  font-size: 0.8125rem;
  font-weight: var(--weight-semi);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ttu-ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--ttu-line-strong);
  padding: 0 0 2px;
  cursor: pointer;
}

.ttu-xdomain {
  border-bottom: 1px solid var(--ttu-line-soft);
  padding: var(--space-5) 0;
}

.ttu-xdomain__btn {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.ttu-xdomain__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  letter-spacing: -0.01em;
  color: var(--ttu-ink);
}

.ttu-xdomain__count {
  font-size: 0.75rem;
  color: var(--ttu-ink-muted);
}

.ttu-xdomain__btn .ttu-xdomain__name::after {
  content: "+";
  margin-left: var(--space-3);
  font-weight: var(--weight-regular);
  color: var(--ttu-accent);
}

.ttu-xdomain__btn[aria-expanded="true"] .ttu-xdomain__name::after {
  content: "\2013";
}

.ttu-xdomain__btn.is-active .ttu-xdomain__name,
.ttu-xdomain__btn:hover .ttu-xdomain__name {
  color: var(--ttu-accent);
}

.ttu-xdomain__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ttu-xdomain__list li {
  margin-top: var(--space-4);
}

.ttu-xnode {
  color: var(--ttu-ink);
  text-decoration: none;
  font-weight: var(--weight-medium);
  border-bottom: 1px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.ttu-xnode:hover,
.ttu-xnode.is-active {
  color: var(--ttu-accent);
  border-bottom-color: var(--accent-mid);
}

.ttu-xdomain__desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--ttu-ink-muted);
  margin-top: 2px;
  max-width: 52ch;
}

/* The explorer is always in-flow: it is the no-JS fallback, the
   screen-reader structure, the mobile adaptation AND the desktop
   capability index below the map. Clipping it on JS init would cause
   a layout shift, so no sr-only rule exists here by design. */

/* mobile accordion: only after JS enhancement; without JS every
   domain list stays expanded and readable. */
@media (max-width: 860px) {
  .ttu-explorer.is-enhanced .ttu-xdomain__list {
    display: none;
  }

  .ttu-explorer.is-enhanced .ttu-xdomain.is-open .ttu-xdomain__list {
    display: block;
  }
}

/* ---- Tablet / mobile -------------------------------------------- */

@media (max-width: 1100px) {
  .ttu-stage-wrap {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
}

@media (max-width: 860px) {
  .ttu-stage-wrap {
    display: block;
    padding-bottom: var(--space-10);
  }

  /* mobile uses the explorer, not the SVG map */
  .ttu-stage {
    display: none;
  }

  .ttu-panel {
    position: static;
    border-left: none;
    border-top: 1px solid var(--ttu-line);
    padding-left: 0;
    padding-top: var(--space-6);
    min-height: 0;
    margin-top: var(--space-8);
  }
}

@media (max-width: 860px) {
  .ttu-explorer {
    padding-bottom: var(--space-10);
  }

  /* the single detail panel moves inside the expanded domain it
     belongs to - accordion and detail read as one interaction */
  .ttu-xdomain > .ttu-panel {
    position: static;
    border-left: none;
    border-top: 1px solid var(--ttu-line);
    padding-left: 0;
    padding-top: var(--space-5);
    margin: var(--space-5) 0 var(--space-2);
    min-height: 0;
  }

  /* no duplicated selected title + description: the accordion row
     keeps the highlighted title, the panel owns the description */
  .ttu-xdomain li.is-selected .ttu-xdomain__desc {
    display: none;
  }

  .ttu-xnode.is-active {
    font-weight: var(--weight-semi);
  }
}

/* ---- Reduced motion ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .ttu-node,
  .ttu-edge,
  .ttu-pathseg,
  .ttu-pathstate,
  .ttu-core__ring,
  .ttu-domain__ring,
  .ttu-cap__dot {
    transition: none !important;
  }

  .ttu-stage:not(.is-in) .ttu-node,
  .ttu-stage:not(.is-in) .ttu-edge {
    opacity: 1;
  }
}

/* ============================================================
   HOMEPAGE INTEGRATION MODE (data-ttu-mode="homepage")
   The same system presented as a compact production section.
   Failure safety: without a built map the stage/panel reserve
   nothing and the semantic index carries the section.
   ============================================================ */

/* Sprint D flow polish: the section reads ecosystem -> universe ->
   identity solutions without interstitial dead space. */
[data-ttu-mode="homepage"].section {
  padding-top: clamp(2rem, 3.5vw, 2.75rem);
  padding-bottom: clamp(2.25rem, 4vw, 3.25rem);
}

/* the static ecosystem section becomes the concise breadth
   introduction (cards/routes untouched; reverted on rollback) */
.eco-compact {
  padding-top: clamp(2rem, 3.5vw, 2.75rem) !important;
  padding-bottom: clamp(2rem, 3.5vw, 2.75rem) !important;
}

.eco-compact .eco-panel {
  min-height: 230px;
  padding: var(--space-8) var(--space-6);
}

[data-ttu-mode="homepage"] .section-intro {
  margin-bottom: var(--space-8);
}

[data-ttu-mode="homepage"] .ttu-stage-wrap {
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas:
    "action panel"
    "stage panel";
  column-gap: clamp(var(--space-8), 4vw, var(--space-16));
  padding-top: 0;
  padding-bottom: 0;
}

[data-ttu-mode="homepage"] .ttu-stage {
  grid-area: stage;
  aspect-ratio: auto; /* reserved only once the map is built */
}

[data-ttu-mode="homepage"] .ttu-stage.is-map-active {
  aspect-ratio: 1100 / 740;
}

[data-ttu-mode="homepage"] .ttu-panel {
  grid-area: panel;
  min-height: 0;
}

[data-ttu-mode="homepage"] .ttu-panel:empty {
  display: none; /* no empty editorial shell before/without the map */
}

/* trace control: deliberate inline action above the graph,
   left-aligned with the visualization, never a big CTA */
[data-ttu-mode="homepage"] .ttu-path-row {
  grid-area: action;
  padding-bottom: var(--space-4);
}

[data-ttu-mode="homepage"] .ttu-path-btn {
  visibility: hidden;
}

[data-ttu-mode="homepage"].is-built .ttu-path-btn {
  visibility: visible;
}

[data-ttu-mode="homepage"] .ttu-explorer {
  border-top: none;
  padding-top: var(--space-6);
  padding-bottom: 0;
}

/* homepage storytelling dim: surroundings stay readable while a
   branch is inspected; selected path remains clearly dominant */
[data-ttu-mode="homepage"] .ttu-stage.is-emphatic .ttu-node.is-dim {
  opacity: 0.32;
}

/* desktop: once the accessible SVG map exists, the large textual
   index steps aside (it remains the no-JS/failure/kill-switch
   fallback and the mobile interface). */
@media (min-width: 861px) {
  [data-ttu-mode="homepage"] .ttu-explorer.is-map-active {
    display: none;
  }
}

/* mobile: dense explorer, no interstitial gap, trace is desktop-only */
@media (max-width: 860px) {
  [data-ttu-mode="homepage"].section {
    padding-top: clamp(1.75rem, 6vw, 2.25rem);
    padding-bottom: clamp(2rem, 7vw, 2.75rem);
  }

  [data-ttu-mode="homepage"] .section-intro {
    margin-bottom: var(--space-4);
  }

  [data-ttu-mode="homepage"] .ttu-stage-wrap {
    display: block;
    padding: 0;
  }

  [data-ttu-mode="homepage"] .ttu-path-btn {
    display: none;
  }

  [data-ttu-mode="homepage"] .ttu-explorer {
    padding-top: var(--space-3);
  }

  [data-ttu-mode="homepage"] .ttu-explorer__core {
    margin-bottom: var(--space-4);
  }

  [data-ttu-mode="homepage"] .ttu-xdomain {
    padding: var(--space-3) 0;
  }

  [data-ttu-mode="homepage"] .ttu-xdomain__list li {
    margin-top: var(--space-3);
  }
}
