/* Canonical Griddim Network bootstrap specification. */
:root{
  --gn-left-width:220px;
  --gn-right-width:220px;

  /* Canonical right-rail / Agent-panel density, promoted from SubGridz. */
  --gn-rail-pad:0px;
  --gn-panel-pad:8px;
  --gn-panel-gap:5px;
  --gn-panel-title-gap:5px;
  --gn-panel-header-gap:6px;
  --gn-panel-button-gap:4px;
  --gn-panel-field-gap:4px;
  --gn-panel-section-gap:7px;
  --gn-panel-identity-gap:7px;
  --gn-panel-identity-pad-block:5px;
  --gn-panel-identity-pad-inline:7px;
  --gn-panel-avatar-size:112px;
  --gn-panel-header-control-size:27px;
  --gn-panel-action-height:27px;
  --gn-panel-input-pad:7px;
  --gn-panel-composer-gap:5px;
  --gn-panel-radius:4px;

  /* Canonical Workspace Agent Chat geometry and dark-theme defaults. */
  --gn-chat-host-pad:18px;
  --gn-chat-host-min-height:460px;
  --gn-chat-stack-min-height:420px;
  --gn-chat-conversation-min-height:300px;
  --gn-chat-message-gap:7px;
  --gn-chat-bubble-pad-block:8px;
  --gn-chat-bubble-pad-inline:10px;
  --gn-chat-avatar-size:38px;
  --gn-chat-bg:#07101a;
  --gn-chat-surface:#03080d;
  --gn-chat-bubble:#08131d;
  --gn-chat-user-bubble:#071923;
  --gn-chat-input:#02070c;
  --gn-chat-border:#203247;
  --gn-chat-text:#d5e4ee;
  --gn-chat-muted:#607587;
  --gn-chat-agent-accent:#ff2c98;
  --gn-chat-user-accent:#55e6ff;
}

[data-gn-shell-region="right"]:has(>.gn-agent-panel){
  padding:var(--gn-rail-pad)!important;
}

/*
 * Canonical desktop frame: the persistent right control rail owns the full
 * viewport height. Shared headers and footers terminate at its left edge;
 * consumer content remains in the first two visible columns.
 */
@media (min-width:901px){
  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"]) .gn2-header,
  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"]) .gn2-secondary-managed:not([data-gn-shell-region="header"]){
    width:calc(100% - var(--gn-right-width,220px))!important;
    max-width:calc(100% - var(--gn-right-width,220px))!important;
  }

  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"]) .gn-footer,
  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"]) :is(.site-footer:not([data-gn-shell-region="footer"]),.headline-ticker,.tg-stock-ticker){
    right:var(--gn-right-width,220px)!important;
  }

  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"])
  [data-gn-shell-frame="true"]>[data-gn-shell-region="header"]{
    grid-column:1/3!important;
    grid-row:1!important;
    width:auto!important;
    max-width:none!important;
  }

  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"])
  [data-gn-shell-frame="true"]>[data-gn-shell-region="footer"]{
    grid-column:1/3!important;
    grid-row:3!important;
    width:auto!important;
    max-width:none!important;
  }

  body:has([data-gn-shell-runtime][data-gn-shell-mode="two-rail"])
  [data-gn-shell-runtime][data-gn-shell-mode="two-rail"]>[data-gn-shell-region="right"]{
    position:fixed!important;
    inset:0 0 0 auto!important;
    z-index:2147481900!important;
    grid-column:3!important;
    grid-row:1/-1!important;
    width:var(--gn-right-width,220px)!important;
    min-width:var(--gn-right-width,220px)!important;
    max-width:var(--gn-right-width,220px)!important;
    height:100dvh!important;
    min-height:100dvh!important;
    max-height:100dvh!important;
    margin:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
  }
}


/* ============================================================
   CANONICAL DESKTOP RIGHT-RAIL COLLAPSE
   Right rail only. Mobile drawers and left rail are unaffected.
   ============================================================ */

.gn2-right-rail-toggle{
  display:none;
}

@media (min-width:901px){

  /* Edge control while rail is open. */
  .gn2-right-rail-toggle{
    display:flex;
    position:fixed;
    top:50%;
    right:var(--gn-right-width,220px);
    z-index:2147481950;
    align-items:center;
    justify-content:center;
    width:18px;
    height:42px;
    padding:0;
    transform:translateY(-50%);
    border:1px solid #38526b;
    border-right:0;
    border-radius:5px 0 0 5px;
    background:#0b1722;
    color:#72ffc1;
    font:900 14px/1 Arial,sans-serif;
    cursor:pointer;
  }

  .gn2-right-rail-toggle:hover,
  .gn2-right-rail-toggle:focus-visible{
    border-color:#55e6ff;
    color:#55e6ff;
  }

  .gn2-right-rail-toggle:focus-visible{
    outline:2px solid #4affaa;
    outline-offset:2px;
  }


  /* Collapse the canonical shell's third column. */
  [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]{
    grid-template-columns:
      var(--gn-left-width,220px)
      minmax(0,1fr)
      0px!important;
  }


  /* Expand global/site headers into the released 220px. */
  body:has(
    [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  ) .gn2-header,

  body:has(
    [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  ) .gn2-secondary-managed:not([data-gn-shell-region="header"]){
    width:100%!important;
    max-width:100%!important;
  }


  /* Expand ticker/footer surfaces to the viewport edge. */
  body:has(
    [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  ) .gn-footer,

  body:has(
    [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  ) :is(
    .site-footer:not([data-gn-shell-region="footer"]),
    .headline-ticker,
    .tg-stock-ticker
  ){
    right:0!important;
  }


  /* Collapse the fixed full-height Agent rail itself. */
  body:has(
    [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  )
  [data-gn-shell-runtime][data-gn-shell-mode="two-rail"]
  >[data-gn-shell-region="right"]{
    width:0!important;
    min-width:0!important;
    max-width:0!important;
    overflow:visible!important;
  }


  /* Hide Agent-panel content, but retain the edge reopen control. */
  [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  >[data-gn-shell-region="right"]
  >:not(.gn2-right-rail-toggle){
    display:none!important;
  }


  /* Reopen tab moves flush against viewport edge. */
  [data-gn-shell-runtime][data-gn-shell-mode="two-rail"][data-gn-canonical-right-collapsed="true"]
  >[data-gn-shell-region="right"]
  >.gn2-right-rail-toggle{
    right:0;
  }


  /* YCWR / canonical light skin. */
  [data-gn-shell-theme="light"] .gn2-right-rail-toggle,
  body[data-gn-site="ycwr"] .gn2-right-rail-toggle{
    border-color:#d2cede;
    background:#f8f7fb;
    color:#6042ba;
  }
}

@media (max-width:900px){
  .gn2-right-rail-toggle{
    display:none!important;
  }
}


/* ============================================================
   CANONICAL SECONDARY HEADER
   Desktop presentation is ad-space only.
   Source/status DOM remains available for mobile drawer plumbing.
   Future shared content should be introduced here, not per-site.
   ============================================================ */

@media (min-width:901px){

  body[data-gn-site] .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:0!important;
  }

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-source,

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-status,

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-toggle,

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-shell-drawer-controls{
    display:none!important;
  }

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-ad{
    display:flex!important;
    position:static!important;
    inset:auto!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    margin:0!important;
    transform:none!important;
  }
}

/* Mobile keeps canonical drawer/navigation controls.
   The source itself remains visually hidden but continues to feed
   the generated mobile menu. */
@media (max-width:900px){
  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-source,

  body[data-gn-site]
  .gn2-secondary-managed[data-gn-secondary-mode="ad-only"]
  >.gn2-secondary-status{
    display:none!important;
  }
}


/* ============================================================
   CANONICAL DORMANT SECONDARY HEADER
   Retained for future shared advertising/network content.
   Current DOM contains only the original ad slot.
   The complete bar is intentionally hidden until reactivated
   centrally from the canonical network layer.
   ============================================================ */

body[data-gn-site]
.gn2-secondary-managed[data-gn-secondary-mode="dormant-ad-slot"]{
  display:none!important;
}

/* With the secondary bar dormant, mobile shell controls live
   directly below the primary global header. */
@media (max-width:900px){

  [data-gn-shell-runtime]{
    --gn-shell-drawer-top:48px!important;
  }

  .gn2-shell-drawer-fallback{
    top:52px!important;
  }

  .gn2-shell-drawer-backdrop{
    inset-block-start:48px!important;
  }
}
