/* ==========================================================================
   glitch-fix.css  -  loads LAST (after smooth.css)

   Problem
   -------
   graphite.css / ui-final.css re-skin the dashboard with SOLID colors, but a
   number of controls were never added to their selector lists. Those controls
   still used the old translucent grey from glowauth-ui.css / scripts-redesign.css:

       background: rgba(113,113,113,.10-.12)   <- see-through, so it blends with
                                                  whatever is behind it
       :hover     { rgba(113,113,113,.28) + glow }  <- sticks "on" after a tap on
                                                  phones, and fades through
                                                  half-blended frames
       transition: background .2s              <- animates between translucent
                                                  values (visible two-tone flash)

   On phones the Copy ID button (and the other icon/copy buttons) therefore
   rendered as a lighter top half / darker bottom half.

   Fix
   ---
   1. Every affected control gets an opaque background from the graphite tokens.
   2. Hover colors only apply on devices that really hover (mouse/trackpad),
      so a tap never leaves a button stuck in its "hover" color.
   3. No background transitions on these controls (nothing to blend mid-way).
   4. Finished card-entrance animations no longer hold the card on a permanent
      GPU layer (animation-fill-mode: both -> backwards).
   ========================================================================== */

:root{
  --gf-btn:#191B20;        /* = --gr-card-2 */
  --gf-btn-hover:#24272E;  /* = --gr-hover  */
  --gf-btn-press:#202329;  /* = --gr-active */
  --gf-well:#0F1114;       /* inset row / input well */
  --gf-line:rgba(255,255,255,.11);
  --gf-line-hover:rgba(255,255,255,.15);
  --gf-text:#F3F4F6;
  --gf-danger:#2B1F23;
  --gf-danger-hover:#412729;
  --gf-danger-line:rgba(240,103,103,.38);
  --gf-danger-text:#fda4b4;
}

/* No grey tap flash on any control (Android Chrome draws a half-height box) */
button,a,[role="button"],summary,label,select{-webkit-tap-highlight-color:transparent}
button,[role="button"]{touch-action:manipulation}

/* --------------------------------------------------------------------------
   1. Script card: Copy ID button  (the one in the screenshot)
   -------------------------------------------------------------------------- */
html body #scriptsWorkspace .sc-copy-id{
  background:var(--gf-btn)!important;
  background-image:none!important;
  background-clip:border-box!important;
  border:1px solid var(--gf-line)!important;
  color:var(--gf-text)!important;
  box-shadow:none!important;
  filter:none!important;
  -webkit-backdrop-filter:none!important;backdrop-filter:none!important;
  opacity:1!important;
  transition:border-color .15s ease,color .15s ease,transform .12s ease!important;
}
html body #scriptsWorkspace .sc-copy-id svg{color:inherit!important;opacity:1!important}
html body #scriptsWorkspace .sc-copy-id:active{
  background:var(--gf-btn-press)!important;
  transform:scale(.94);
}
html body #scriptsWorkspace .sc-copy-id:focus-visible{
  outline:2px solid rgba(255,255,255,.55)!important;outline-offset:2px;
}

/* ID row the button sits in: solid well instead of rgba(3,3,3,.6) */
html body #scriptsWorkspace .sc-id{
  background:var(--gf-well)!important;
  border:1px solid rgba(255,255,255,.08)!important;
  box-shadow:none!important;
}

/* --------------------------------------------------------------------------
   2. Same leftover translucent buttons elsewhere in the GUI
      (file rows, key rows, generated keys, API, docs, clipboard dialog)
   -------------------------------------------------------------------------- */
html body :is(
  .file-row-actions a,
  .file-row-actions button,
  .panel-key-actions button,
  .panel-key-copy-plain,
  .script-item-copy-url,
  .script-item-copy-loader,
  .script-controls-load-more,
  .generated-key-copy,
  .generated-keys-copy-all,
  .clipboard-fallback-actions button,
  .api-copy-row button,
  .api-endpoint-line button,
  .docs-code-top button,
  .api-token-actions button
){
  background:var(--gf-btn)!important;
  background-image:none!important;
  border:1px solid var(--gf-line)!important;
  color:var(--gf-text)!important;
  box-shadow:none!important;
  filter:none!important;
  transition:border-color .15s ease,color .15s ease!important;
}

/* Destructive variants: keep the red meaning, but as solid colors */
html body :is(
  .file-row-actions .delete-btn,
  .panel-key-actions .panel-key-revoke,
  .panel-key-actions .panel-key-delete
){
  background:var(--gf-danger)!important;
  border-color:var(--gf-danger-line)!important;
  color:var(--gf-danger-text)!important;
  box-shadow:none!important;
}

html body :is(
  .file-row-actions button,
  .panel-key-actions button,
  .panel-key-copy-plain,
  .generated-key-copy,
  .generated-keys-copy-all
):disabled{opacity:.5!important;background:var(--gf-btn)!important}

/* Generated-key / selected-file round dismiss buttons: transparent -> solid */
html body :is(.generated-keys-dismiss,.selected-remove){
  background:var(--gf-btn)!important;
  border:1px solid var(--gf-line)!important;
  color:var(--gf-text)!important;
  box-shadow:none!important;
  transition:border-color .15s ease,color .15s ease!important;
}

/* --------------------------------------------------------------------------
   3. Hover: only on devices that can truly hover. On touch screens :hover
      sticks after a tap and leaves the button in a different shade.
   -------------------------------------------------------------------------- */
@media (hover:hover) and (pointer:fine){
  html body #scriptsWorkspace .sc-copy-id:hover{
    background:var(--gf-btn-hover)!important;
    border-color:var(--gf-line-hover)!important;
  }
  html body :is(
    .file-row-actions a,
    .file-row-actions button,
    .panel-key-actions button,
    .panel-key-copy-plain,
    .script-item-copy-url,
    .script-item-copy-loader,
    .script-controls-load-more,
    .generated-key-copy,
    .generated-keys-copy-all,
    .clipboard-fallback-actions button,
    .api-copy-row button,
    .api-endpoint-line button,
    .docs-code-top button,
    .api-token-actions button,
    .generated-keys-dismiss,
    .selected-remove
  ):hover:not(:disabled){
    background:var(--gf-btn-hover)!important;
    border-color:var(--gf-line-hover)!important;
    color:#fff!important;
    box-shadow:none!important;
  }
  html body :is(
    .file-row-actions .delete-btn,
    .panel-key-actions .panel-key-revoke,
    .panel-key-actions .panel-key-delete
  ):hover:not(:disabled){
    background:var(--gf-danger-hover)!important;
    border-color:rgba(240,103,103,.6)!important;
    color:#fff!important;
  }
}

/* Touch screens: undo graphite/ui-final hover shades that stay stuck after a tap */
@media (hover:none),(pointer:coarse){
  html body #scriptsWorkspace .sc-card:hover{transform:none!important}
  html body #scriptsWorkspace .sc-dock .sc-act:not(.is-danger):hover{
    background:var(--gr-card-2,var(--gf-btn))!important;
    border-color:var(--gr-line-h,var(--gf-line))!important;
    color:var(--gr-t1,var(--gf-text))!important;
  }
  html body #scriptsWorkspace .sc-dock .sc-act:not(.is-danger):hover svg{color:var(--v1,#c0c0c0)!important}
  html body #scriptsWorkspace .sc-dock .sc-act.is-danger:hover{
    background:rgba(240,103,103,.09)!important;
    border-color:rgba(240,103,103,.38)!important;
    color:#fda4b4!important;
  }
  html body :is(
    .secondary-btn,.logout-btn,.editor-cancel-btn,.shop-header-button,.pn-icon-btn,
    .rp-hwid-btn,.provider-mini-btn,.edit-btn,.key-copy-list-button,.shop-close-button
  ):hover:not(:disabled){
    background:var(--gr-card-2,var(--gf-btn))!important;
    border-color:var(--gr-line-h,var(--gf-line))!important;
    color:var(--gr-t1,var(--gf-text))!important;
  }
  html body :is(.sc-act,.sc-copy-id,.sc-gear,.secondary-btn,.pn-icon-btn):active{
    background:var(--gr-active,var(--gf-btn-press))!important;
  }
}

/* --------------------------------------------------------------------------
   4. Card entrance animation: don't keep finished cards on a GPU layer.
      "both" = fill forwards, which pins opacity/transform on the card for good
      and is a known cause of off-color / seam artifacts on mobile Chrome.
      "backwards" renders the identical end state without the pinned layer.
   -------------------------------------------------------------------------- */
html body .dashboard-section:not(.hidden) :is(.card,.dashboard-home-card,.execution-stat-card,.platform-stat-card,.api-stat,.controls-summary-card,.docs-topic,.provider-card,.sc-card),
html body .dashboard-section:not(.hidden) :is(.card,.dashboard-home-card,.execution-stat-card,.platform-stat-card,.api-stat,.controls-summary-card,.docs-topic,.provider-card,.sc-card):nth-child(2),
html body .dashboard-section:not(.hidden) :is(.card,.dashboard-home-card,.execution-stat-card,.platform-stat-card,.api-stat,.controls-summary-card,.docs-topic,.provider-card,.sc-card):nth-child(3),
html body .dashboard-section:not(.hidden) :is(.card,.dashboard-home-card,.execution-stat-card,.platform-stat-card,.api-stat,.controls-summary-card,.docs-topic,.provider-card,.sc-card):nth-child(n+4){
  animation-fill-mode:backwards!important;
}

/* Number / icon badges are fixed squares. In a flex or grid row on a narrow screen they were squeezed sideways while the
   row stretched them tall, which turned them into tall pills (e.g. the "01" in API Plans). They never shrink or stretch now. */
html body .shop-section-index,
html body .key-panel-picker-icon,
html body .docs-topic-icon,
html body .pn-num,
html body .key-generator-empty-icon,
html body .api-project-icon,
html body .api-token-symbol,
html body .execution-asset-icon,
html body .recent-execution-icon,
html body .script-item-glyph,
html body .shop-plan-icon,
html body .api-plan-glyph,
html body .api-created-icon,
html body .key-expiry-preview-icon,
html body .script-controls-empty-icon,
html body .sc-type {
  flex: 0 0 auto !important;
  align-self: flex-start;
  min-width: 0;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}
html body .shop-section-index { width: 44px !important; height: 44px !important; min-width: 44px; }
@media (max-width: 520px) {
  html body .shop-section-index { width: 38px !important; height: 38px !important; min-width: 38px; }
}
