/* GTS Trading — shared eased transitions + loading-skeleton treatment.
 *
 * Pure presentation: no selectors here change layout, markup requirements
 * or business logic, and every animated/transitioned rule is neutralised
 * under prefers-reduced-motion at the bottom of this file.
 *
 * Uses the existing theme tokens (--txt, --surf, --line, --cyan, --card)
 * already defined in app.html's inline :root and in gts-theme.css, with
 * literal fallbacks so this file never errors on a page (calendar.html,
 * history.html) that only defines some of those names under different
 * tokens.
 */

/* ---------------------------------------------------------------------
 * 1. Fade-in for freshly rendered content.
 * Several modules (gts-live.js, the analytics -ui.js tabs) rebuild a
 * container's innerHTML wholesale rather than patching individual nodes.
 * A CSS animation (unlike a transition) replays automatically whenever a
 * matching element is newly inserted into the DOM - including right after
 * an innerHTML swap - so this gives every refreshed stat tile, card and
 * table row a brief, tasteful fade without touching any render function.
 * --------------------------------------------------------------------- */
@keyframes gtsFadeIn{from{opacity:0}to{opacity:1}}

.card,
.item,
.gpa-card,
.gpa-stat,
.gpa-tr{
  animation:gtsFadeIn 220ms ease-out;
}

/* Analytics sub-view switches (Overview / Calendar / Plan vs actual / the
 * placeholder body that Costs, Follow-Through, Setup performance,
 * Expectancy, Symbols, Drawdown, Streaks and Weekday all render into) are
 * shown/hidden with a plain style.display toggle in app.html. The same
 * "animate on insertion" trick fades each one in the instant it stops
 * being display:none, again with no JS change required. */
#an-ov,#an-ph,#an-cal,#an-plan{
  animation:gtsFadeIn 200ms ease-out;
}

/* ---------------------------------------------------------------------
 * 2. Hover / focus polish for buttons, chips and cards.
 * --------------------------------------------------------------------- */
.card,
.btn,
.chip,
.acctBtn,
.acctAction,
.gear,
.info,
.tgl,
.item,
.pchip,
.saveBtn,
.gts-news-row,
.box-wrap,
.gpa-periods button,
.gpa-tabs button{
  transition:border-color 180ms ease-out,background-color 180ms ease-out,
    color 180ms ease-out,box-shadow 180ms ease-out,transform 180ms ease-out,filter 180ms ease-out;
}
a.newsEntry,a.planEntry{transition:border-color 180ms ease-out}

/* A plain, non-clickable card gets only the faintest lift - just enough to
 * read as alive, not as "click me". Cards and rows that ARE clickable
 * (marked with data-pos by gts-live.js, or naturally interactive controls)
 * get the same cyan accent the rest of the app already uses for focus. */

.btn:focus-visible,
.chip:focus-visible,
.acctBtn:focus-visible,
.acctAction:focus-visible,
.card:focus-visible,
.tab:focus-visible,
.gpa-periods button:focus-visible,
.gpa-tabs button:focus-visible{
  outline:2px solid var(--cyan,#38BDF8);
  outline-offset:2px;
}

/* ---------------------------------------------------------------------
 * 3. Modal / sheet / popover open-close.
 * These already toggle a `.open` class; here they additionally fade and
 * settle into place instead of popping, while staying functionally
 * identical (still non-interactive and hidden from assistive tech when
 * closed).
 * --------------------------------------------------------------------- */
.sheetWrap,.infoWrap{
  transition:opacity 200ms ease-out;
}
.sheetWrap:not(.open),.infoWrap:not(.open){opacity:0}
.sheetWrap.open,.infoWrap.open{opacity:1}
.sheet,.infoPop{
  transition:transform 220ms ease-out;
}
.sheetWrap:not(.open) .sheet{transform:translateY(14px)}
.infoWrap:not(.open) .infoPop{transform:translateY(8px) scale(.98)}

/* ---------------------------------------------------------------------
 * 4. Loading skeleton.
 * A subtle pulsing placeholder line, theme-aware via the same --surf
 * token cards already use (falling back through the local token names
 * calendar.html/history.html each define under --line/--s1/--surface).
 * --------------------------------------------------------------------- */
@keyframes gtsSkeletonPulse{0%{opacity:.45}50%{opacity:.9}100%{opacity:.45}}
.gts-skel-line{
  height:14px;
  margin:9px 0;
  border-radius:6px;
  background:var(--surf,var(--s1,var(--surface,#232B38)));
  animation:gtsSkeletonPulse 1.4s ease-in-out infinite;
}
.gts-skel-line:first-child{margin-top:0}
.gts-skel-line:last-child{margin-bottom:0}

/* Visually hidden but still announced - used to keep a "Loading…" message
 * available to assistive tech once the visible text is replaced by
 * skeleton bars. */
.gts-sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
}

/* ---------------------------------------------------------------------
 * 5. Respect reduced motion: every animation/transition above becomes
 * instant, and elements that default to a transitioned "hidden" state
 * (the sheet/popover opacity, above) still end up fully visible/hidden
 * with no in-between frame.
 * --------------------------------------------------------------------- */
@media (prefers-reduced-motion:reduce){
  .card,.item,.gpa-card,.gpa-stat,.gpa-tr,
  #an-ov,#an-ph,#an-cal,#an-plan,
  .btn,.chip,.acctBtn,.acctAction,.gear,.info,.tgl,.tab,
  .pchip,.saveBtn,.gts-news-row,.box-wrap,
  a.newsEntry,a.planEntry,
  .gpa-periods button,.gpa-tabs button,
  .sheetWrap,.infoWrap,.sheet,.infoPop,
  .gts-skel-line{
    animation:none!important;
    transition:none!important;
  }
}

.card:hover{border-color:var(--mute,#5C6672)}
.card[data-pos]:hover,.item[data-pos]:hover,.card.hero:hover{border-color:var(--cyan,#38BDF8)}
.acctBtn:not(.on):hover,.acctAction:hover{border-color:var(--cyan,#38BDF8)}
.gear:hover,.info:hover{border-color:var(--cyan,#38BDF8);color:var(--cyan,#38BDF8)}
.gpa-periods button:hover,.gpa-tabs button:hover{color:var(--txt,#E8EAED)}

/* Same "lights up as you pass over/tap it" treatment, extended to the
   elements the rest of the app already had it on didn't cover:
   - .gts-news-row (news list rows, built by gts-news-ui.js) is built
     exactly like .item above - border:0 with only a border-bottom row
     separator - so it gets the identical treatment: recolour that one
     line to cyan, same as .item[data-pos]:hover. (An earlier pass at
     this used a filled background tint instead, which read as the whole
     row lighting up solid blue - inconsistent with every other list row
     in the app and was corrected here.)
   - .pchip - the pill-shaped choice/toggle chips used throughout Settings
     and the plan picker.
   - .saveBtn - the solid filled action buttons; a border wouldn't read
     against their own filled background, so this gets a brightness lift
     instead, matching the transform-lift treatment already used for the
     filled Wendy/feedback FABs elsewhere.
   - .box-wrap - product box art (marketplace.html).
   - .btn.primary/.btn.ghost - the main CTA button class shared by
     index.html, marketplace.html, plans.html, onboarding.html and others
     (login/create-account/start-trial/marketplace links) never had a
     hover state anywhere on the site at all. */
.gts-news-row:hover{border-color:var(--cyan,#38BDF8)}
.pchip:hover{border-color:var(--cyan,#38BDF8)}
.saveBtn:hover{filter:brightness(1.08);border-color:var(--cyan,#38BDF8)}
.box-wrap:hover{border-color:var(--cyan,#38BDF8)}
.btn.primary:hover{filter:brightness(1.08)}
.btn.ghost:hover{border-color:var(--cyan,#38BDF8);color:var(--cyan,#38BDF8)}

/* An in-place update of one dashboard card (gts-live.js patchDash) must not
 * replay the entrance fade: that fade, applied to a whole rebuilt dashboard,
 * was the flicker. */
.gts-patched,.gts-patched .card,.gts-patched .item{animation:none}
