/*
 * Route bindings
 * --------------
 * The older view sheets own layout and motion. This final layer binds their
 * visual surfaces to the semantic contract, keeping theme decisions out of
 * route geometry. Intentionally dark artifacts are restored in one place.
 */

html[data-design-system="halde"],
html[data-design-system="halde"] body,
html[data-design-system="halde"] #app,
html[data-design-system="halde"] #overlay{
  color:var(--text-primary);
  background-color:var(--bg-page);
}

html[data-design-system="halde"] body,
html[data-design-system="halde"] :is(
  .landing-page,
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
){
  color:var(--text-primary);
  background-color:var(--bg-page)!important;
  background-image:var(--texture-image)!important;
  background-blend-mode:var(--texture-blend)!important;
}

html[data-design-system="halde"] :is(
  .landing-page,
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
) > :is(.pnl,.crumbs,.pricing-plan-stack){
  color:var(--text-primary);
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] :is(
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
) :is(h1,h2,h3,h4,h5,h6,p,li,dd,blockquote,a,button,label,input,output){
  border-color:var(--border-default);
}

html[data-design-system="halde"] :is(
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
) :is(.lab,.mono,small,code,output,.catalog-kicker,.shelf-note){
  color:var(--text-secondary);
}

html[data-design-system="halde"] :is(
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
) :is(input,textarea,select){
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-paper)!important;
}

html[data-design-system="halde"] :is(
  .catalog-page,
  .profiles-page,
  .profile-page,
  .play-page,
  .pricing-v4
) :is(input,textarea)::placeholder{
  color:var(--text-tertiary)!important;
  opacity:1;
}

/* Landing surfaces */
html[data-design-system="halde"] .landing-page{
  --hero-field-ink:var(--text-primary);
  --hero-field-muted:var(--text-secondary);
  --hero-rule:var(--border-default);
}

html[data-design-system="halde"] .landing-page :is(
  .landing-hero-static,
  .recipe-stage,
  .dividend-stage,
  .breadth-stage,
  .closing-stage
){
  color:var(--text-primary);
  border-color:var(--border-default)!important;
  background-color:transparent!important;
}

html[data-design-system="halde"] .landing-page :is(
  .hero-kicker,
  .hero-dek,
  .hero-cmd-note,
  .recipe-dek,
  .trace-num,
  .trace-verb,
  .trace-mint,
  .dividend-dek,
  .breadth-heading p,
  .closing-dek,
  .closing-cmd-note
){
  color:var(--text-secondary)!important;
}

html[data-design-system="halde"] .landing-page :is(
  .trace-ledger-head,
  .trace-row,
  .trace-more,
  .trace-foot,
  .poster-head,
  .poster-flow,
  .poster-lines,
  .poster-team,
  .gives-cell,
  .breadth-heading,
  .breadth-rail,
  .breadth-live,
  .breadth-theater,
  .breadth-mint,
  .closing-rail,
  .closing-action
){
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] .landing-page :is(
  .dividend-poster,
  .breadth-theater,
  .breadth-mint
){
  background:color-mix(in srgb,var(--bg-paper) 72%,transparent)!important;
}

html[data-design-system="halde"] .landing-page :is(.trace-ledger-head,.trace-foot){
  background:color-mix(in srgb,var(--bg-surface-raised) 82%,var(--bg-surface));
}

html[data-design-system="halde"] .landing-page :is(.dividend-poster,.breadth-live,.closing-action){
  background:color-mix(in srgb,var(--bg-surface) 78%,transparent)!important;
}

html[data-design-system="halde"] .landing-page :is(
  .trace-rebuild,
  .trace-chip,
  .poster-chip,
  .breadth-chip
){
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-paper)!important;
}

html[data-design-system="halde"] .landing-page .breadth-action .breadth-browse[href="/feed"]{
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background-color:var(--bg-surface)!important;
  background-image:none!important;
  box-shadow:inset 0 -3px 0 var(--accent)!important;
}

/* Trace receipts stay lightly color-coded in both themes. The same receipt
   uses the same tint at its source and where Compose consumes it. */
html[data-design-system="halde"] .landing-page .trace-chip[data-chip]:not([data-chip="13"]){
  color:var(--text-primary)!important;
  border-color:color-mix(in srgb,var(--trace-receipt) 58%,var(--text-primary))!important;
  background:var(--trace-receipt)!important;
}

html[data-design-system="halde"] .landing-page :is(
  .trace-rebuild,
  .trace-chip,
  .poster-chip,
  .breadth-chip
):is(:hover,:focus-visible),
html[data-design-system="halde"] .landing-page :is(.poster-chip,.breadth-chip).is-active,
html[data-design-system="halde"] .landing-page .poster-chip[aria-pressed="true"]{
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-surface)!important;
  box-shadow:inset 0 -3px 0 var(--accent)!important;
}

html[data-design-system="halde"] .landing-page .play-mark{
  color:inherit!important;
  padding:.02em .12em .06em!important;
  background:linear-gradient(
    transparent 10%,
    color-mix(in srgb,var(--accent) 22%,transparent) 10% 90%,
    transparent 90%
  )!important;
  box-shadow:none!important;
  text-decoration:none!important;
  -webkit-box-decoration-break:clone;
  box-decoration-break:clone;
}

/* The shared landing highlight supersedes heading-specific play emphasis. */
html[data-design-system="halde"] :is(h1,h2,h3,h4,h5,h6) .play-mark{
  color:var(--accent)!important;
  background:transparent!important;
  box-shadow:none!important;
  text-decoration:none!important;
}

html[data-design-system="halde"] #rote-bridge-title .play-mark{
  color:inherit!important;
}

html[data-design-system="halde"] .landing-page :is(.is-ember,.is-ember b){
  color:var(--accent)!important;
}

/* A compact profile URI remains an inverse artifact, not a copy command. */
html[data-design-system="halde"] .signature-uri{
  color:var(--command-text)!important;
  border-color:var(--artifact-rule)!important;
  background:var(--command-bg)!important;
}

html[data-design-system="halde"] .signature-uri .mono{
  color:var(--command-text)!important;
}

/* Dark artifacts retain contrast in both system modes. */
html[data-design-system="halde"] :is(
  .living-terminal,
  .artist-portrait,
  .artist-live,
  .specimen-glyph,
  .maker-tile.is-selected,
  .rote-curtain-before,
  .play-cover,
  .play-hero-cover
){
  --lt-paper:var(--artifact-bg);
  --lt-ink:var(--artifact-text);
  --lt-dim:var(--artifact-muted);
  --lt-faint:var(--artifact-faint);
  --lt-line:var(--artifact-rule);
  --lt-accent:var(--accent);
  color:var(--artifact-text)!important;
  border-color:var(--artifact-rule)!important;
  background-color:var(--artifact-bg)!important;
}

/* Migrated play details use the same page-aware terminal as the landing:
   white in light mode, navy in dark mode. It is deliberately not bound to
   the legacy always-dark artifact rule above. */

html[data-design-system="halde"] :is(
  .lt-window,
  .living-terminal,
  .artist-portrait,
  .artist-live,
  .specimen-glyph,
  .maker-tile.is-selected,
  .rote-curtain-before,
  .play-cover,
  .play-hero-cover
) :is(h1,h2,h3,h4,p,b,strong,span,small,.lab,.mono,code,button,a){
  color:inherit;
  border-color:var(--artifact-rule);
}

html[data-design-system="halde"] :is(.lt-window,.living-terminal) :is(.lt-strip,.lt-chat,.lt-composer,.lt-transport){
  border-color:var(--artifact-rule)!important;
}

/* Integrated terminals are part of the page field—not black terminal cards.
   They inherit the active page palette in both light and dark modes. */
html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated,
html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-window{
  --lt-paper:transparent!important;
  --lt-strip:transparent!important;
  --lt-ink:var(--text-primary)!important;
  --lt-dim:var(--text-secondary)!important;
  --lt-faint:var(--text-tertiary)!important;
  --lt-line:var(--border-default)!important;
  --lt-accent:var(--accent)!important;
  --lt-ok:var(--positive)!important;
  --lt-bad:var(--danger)!important;
  color:var(--text-primary)!important;
  border-color:var(--border-default)!important;
  background:transparent!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-body{
  --lt-ink:var(--text-primary)!important;
  --lt-dim:var(--text-secondary)!important;
  --lt-faint:var(--text-tertiary)!important;
  color:var(--lt-ink)!important;
  background:transparent!important;
  text-shadow:none!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-line{
  color:var(--lt-dim)!important;
  text-shadow:none!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-line:is(.cmd,.say,.ask){
  color:var(--lt-ink)!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-line:is(.save,.uri){
  color:var(--lt-accent)!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-line.ok{
  color:var(--lt-ok)!important;
}

html[data-design-system="halde"] .landing-hero-static .hero-terminal-integrated .lt-line.bad{
  color:var(--lt-bad)!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility{
  color:var(--text-secondary)!important;
  border-color:var(--border-default)!important;
  background:color-mix(in srgb,var(--bg-surface) 84%,transparent)!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility :is(.compatibility-label,.harness-brand){
  color:var(--text-secondary)!important;
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility .harness-brand[data-simskin]:is(.is-active,:hover,:focus-visible){
  color:var(--text-on-accent)!important;
  border-color:var(--accent)!important;
  background:var(--accent)!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility :is(.harness-brand b,.harness-brand small){
  color:inherit!important;
  opacity:1!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility .harness-mark{
  color:var(--text-primary)!important;
  opacity:1!important;
}

html[data-design-system="halde"] .landing-page .hero-compatibility .harness-mark svg{
  fill:currentColor;
}

html[data-design-system="halde"][data-theme="dark"] .landing-page .hero-compatibility .hermes-image{
  filter:grayscale(1) invert(1) contrast(1.12);
}

@media (prefers-color-scheme:dark){
  html[data-design-system="halde"][data-theme="system"] .landing-page .hero-compatibility .hermes-image{
    filter:grayscale(1) invert(1) contrast(1.12);
  }
}

/* Curtain: each half is a designed artifact; only its shared contract varies. */
html[data-design-system="halde"] .rote-curtain{
  border-color:var(--border-strong)!important;
  box-shadow:var(--shadow-soft);
}

html[data-design-system="halde"] .rote-curtain-after{
  color:var(--curtain-after-ink,var(--text-on-accent))!important;
  background:
    radial-gradient(circle at 78% 22%,rgba(255,255,255,.78),transparent 33%),
    linear-gradient(145deg,color-mix(in srgb,var(--accent-soft) 58%,var(--bg-paper)),var(--accent-soft))!important;
}

/* The dark-theme olive field is a dark surface. Its explanatory copy uses
   white; the nested Play remains a separate white document with black ink. */
html[data-design-system="halde"][data-theme="dark"] .rote-curtain-after{
  --curtain-after-ink:#fff;
  --curtain-after-muted:rgba(255,255,255,.72);
}

@media (prefers-color-scheme:dark){
  html[data-design-system="halde"][data-theme="system"] .rote-curtain-after{
    --curtain-after-ink:#fff;
    --curtain-after-muted:rgba(255,255,255,.72);
  }
}

html[data-design-system="halde"] .rote-curtain-line span{
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-paper)!important;
  box-shadow:var(--shadow-soft);
}

/* Feed */
html[data-design-system="halde"] .catalog-page .catalog-intro-grid,
html[data-design-system="halde"] .catalog-page .catalog-philosophy,
html[data-design-system="halde"] .catalog-page .featured-play,
html[data-design-system="halde"] .catalog-page .shelf-head,
html[data-design-system="halde"] .catalog-page .catalog-table-head,
html[data-design-system="halde"] .catalog-page .catalog-maker-head,
html[data-design-system="halde"] .catalog-page .catalog-row{
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] .catalog-page .catalog-intro-actions p{
  color:var(--text-secondary)!important;
}

html[data-design-system="halde"] .catalog-page .catalog-search{
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-paper)!important;
}

html[data-design-system="halde"] .catalog-page .catalog-filters .chip{
  color:var(--text-secondary)!important;
  border-color:var(--border-default)!important;
  background:transparent!important;
}

html[data-design-system="halde"] .catalog-page .catalog-filters .chip:is(:hover,.on){
  color:var(--text-inverse)!important;
  border-color:var(--bg-inverse)!important;
  background:var(--bg-inverse)!important;
}

html[data-design-system="halde"] .catalog-page .catalog-row:hover{
  background:color-mix(in srgb,var(--text-primary) 4%,transparent)!important;
}

/* Maker atlas and profiles */
html[data-design-system="halde"] .profiles-page :is(
  .talent-hero,
  .talent-section-head,
  .atlas-guide,
  .maker-field,
  .maker-tile,
  .maker-specimen,
  .specimen-stats,
  .specimen-proof,
  .signature-uri,
  .live-row,
  .pair-card,
  .rising-card,
  .identity-key-item,
  .ladder-rung
),
html[data-design-system="halde"] .profile-page :is(
  .artist-copy,
  .artist-kicker,
  .artist-metrics,
  .artist-actions,
  .profile-section-head,
  .profile-play,
  .influence-number,
  .remix-ledger,
  .instrument,
  .authorization-sheet,
  .identity-relation-grid,
  .identity-person-link
){
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] .profiles-page :is(.maker-tile,.pair-card,.rising-card,.identity-key-item),
html[data-design-system="halde"] .profile-page :is(.profile-play,.instrument,.authorization-sheet,.identity-person-link){
  color:var(--text-primary);
  background:color-mix(in srgb,var(--bg-paper) 62%,transparent)!important;
}

html[data-design-system="halde"] .profiles-page .maker-tile:is(:hover,.is-selected){
  --tile-ink:var(--text-primary);
  color:var(--text-primary)!important;
  border-color:var(--border-strong)!important;
  background:var(--bg-surface)!important;
  box-shadow:inset 0 -3px 0 var(--accent)!important;
}

html[data-design-system="halde"] .profiles-page .maker-tile:is(:hover,.is-selected) :is(.lab,b,small){
  color:inherit!important;
}

html[data-design-system="halde"] .profiles-page .ladder-rung:last-child{
  color:var(--artifact-text)!important;
  background:var(--artifact-bg)!important;
}

html[data-design-system="halde"] .profiles-page .ladder-rung:last-child :is(h3,p,b,small,.lab){
  color:inherit!important;
}

html[data-design-system="halde"] .profiles-page :is(.specimen-open,.signature-cover .cover-play){
  color:var(--artifact-text)!important;
  border-color:var(--artifact-rule)!important;
  background:var(--artifact-bg-raised)!important;
}

html[data-design-system="halde"] .profiles-page .specimen-open{
  padding:10px 0 8px!important;
  color:var(--text-primary)!important;
  border:0!important;
  border-bottom:1px solid var(--border-strong)!important;
  background:transparent!important;
  box-shadow:inset 0 -2px 0 var(--accent)!important;
  text-decoration:none;
}

html[data-design-system="halde"] .profiles-page :is(.maker-tile.is-selected,.specimen-glyph),
html[data-design-system="halde"] .profile-page :is(.artist-portrait,.artist-live){
  background-image:radial-gradient(circle at 2px 2px,color-mix(in srgb,var(--artifact-text) 5%,transparent) 0 .4px,transparent .65px)!important;
}

html[data-design-system="halde"] .profile-page :is(.artist-copy p,.artist-metrics span,.profile-section-head p,.profile-play p,.instrument small,.identity-person-link small),
html[data-design-system="halde"] .profiles-page :is(.talent-hero p,.atlas-guide p,.maker-tile small,.specimen-head p,.maker-signature p,.live-row small,.pair-card p,.rising-card p,.ladder-rung p){
  color:var(--text-secondary)!important;
}

html[data-design-system="halde"] .profile-page .artist-actions .ta{
  color:var(--accent)!important;
  border-color:currentColor!important;
  background:transparent!important;
}

html[data-design-system="halde"] .profile-page .artist-actions .ta:is(:hover,:focus-visible){
  color:var(--text-on-accent)!important;
  border-color:var(--accent)!important;
  background:var(--accent)!important;
}

/* Play detail */
html[data-design-system="halde"] .play-page :is(
  .play-hero,
  .play-hero-copy,
  .play-proof,
  .play-actions,
  .play-section-head,
  .play-requirements,
  .play-steps,
  .play-step,
  .play-lineage,
  .play-related,
  .play-related-card
){
  border-color:var(--border-default)!important;
}

html[data-design-system="halde"] .play-page :is(.play-hero-copy p,.play-section-head p,.play-step p,.play-related-card p){
  color:var(--text-secondary)!important;
}

/* Pricing uses semantic roles; route-specific layout lives in the pricing
   view sheet. The retired calculator selectors intentionally do not live in
   this global theme layer. */
html[data-design-system="halde"] .pricing-v4{
  --pv4-bg:var(--bg-page);
  --pv4-panel:var(--artifact-bg-raised);
  --pv4-deep:var(--artifact-bg);
  --pv4-ink:var(--text-primary);
  --pv4-paper:var(--bg-paper);
  --pv4-muted:var(--text-secondary);
  --pv4-accent:var(--accent);
}

/* Native controls and forced-colour fallback. */
html[data-design-system="halde"] input[type="range"]{
  accent-color:var(--accent);
}

@media (forced-colors:active){
  html[data-design-system="halde"] *{
    border-color:CanvasText;
  }
}
