/* ZC02 · Imperial Crown rhythm layer (Scope 08, 2026-11-27).
   One responsive spacing system for every /start page (home, features, themes, plans, academy), loaded by the
   /start layout AFTER the page bundles so it can settle their spacing. It only sets spacing, wrapping, alignment and
   the visual states that crown-motion.js toggles; colours come from the existing tokens (start.css / page bundles),
   so Evening Dark and Morning Light both follow. Motion uses transform/opacity only and is off under
   prefers-reduced-motion, where the same states appear without animation. */

body.ts{
  --cr-gutter:clamp(16px,4vw,32px);
  --wrap:min(1200px,100% - 2 * var(--cr-gutter));
  --cr-section-y:clamp(36px,4.5vw + 18px,96px);      /* 375 → 36 · 768 → 53 · 1366 → 80 · 1920 → 96 */
  --cr-section-y-tight:clamp(28px,3vw + 14px,64px);
  --cr-head-gap:clamp(8px,.6vw + 6px,14px);          /* eyebrow → title → lead */
  --cr-head-after:clamp(20px,2.2vw + 10px,44px);     /* section head → its content */
  --cr-card-pad:clamp(16px,1vw + 12px,26px);
  --cr-grid-gap:clamp(12px,1vw + 8px,22px);
  --cr-actions-after:clamp(18px,1.4vw + 12px,30px);  /* content → buttons */
  --cr-ease:cubic-bezier(.2,.7,.2,1);
  --cr-origin:left;
}
html[dir=rtl] body.ts{--cr-origin:right}

/* ---------- 1. Section rhythm ---------- */
body.ts.ts-page--home main .ts-section,
body.ts.ts-page--pricing main .ts-section,
body.ts.ts-page--themes main .ts-section{padding-block:var(--cr-section-y)}
body.ts.ts-page--pricing main .ts-section--tight,
body.ts.ts-page--themes main .ts-section--tight{padding-block:var(--cr-section-y-tight)}
body.ts.ts-page--pricing main .g05-family-bar-sec{padding-block-start:0}
body.ts .fu-section{padding-block:var(--cr-section-y)}
body.ts .fu-section--final{padding-block-end:calc(var(--cr-section-y) + 16px)}
body.ts .tsa-mastery-section{gap:var(--cr-head-after)}

/* ---------- 2. Heads: eyebrow → title → lead → content ---------- */
body.ts main :is(h1,h2,h3){text-wrap:balance}
body.ts main :is(.ts-lead,.g07-lead,.fu-lead,.tsa-section-sub,.tts-hero__lead){text-wrap:pretty}
body.ts main .ts-head{gap:var(--cr-head-gap);margin-block-end:var(--cr-head-after)}
body.ts main .ts-head .ts-eyebrow{margin-block-end:0}
body.ts.ts-page--home .g07-kicker{margin-block-end:var(--cr-head-gap)}
body.ts.ts-page--home .g07-head-row{row-gap:var(--cr-head-gap);margin-block-end:var(--cr-head-after)}
body.ts .fu-head{gap:var(--cr-head-gap) 32px;margin-block-end:var(--cr-head-after)}
body.ts .fu-title{margin-block-start:var(--cr-head-gap)}
body.ts .fu-hero__top{margin-block-end:calc(var(--cr-head-gap) + 6px)}
body.ts .fu-hero__lead{margin-block-start:var(--cr-head-gap)}
body.ts .g05-sec-head{gap:var(--cr-head-gap);margin-block-end:var(--cr-head-after)}
body.ts .tsa-section-title{margin:var(--cr-head-gap) 0}
body.ts .tsa-section-head{gap:var(--cr-head-gap) 18px}

/* ---------- 3. Cards, grids, actions ---------- */
body.ts :is(.fu-arch-grid,.tsa-paths-grid){gap:var(--cr-grid-gap)}
body.ts .fu-arch-card{padding:var(--cr-card-pad)}
body.ts :is(.g07-actions,.fu-hero__actions,.fu-final-box__actions,.tts-hero__actions){gap:var(--cr-actions-gap,10px) 12px}
body.ts .g07-jpanel__copy > .g07-actions,
body.ts .g07-ch1__editorial > .g07-actions{margin-block-start:var(--cr-actions-after)}

/* ---------- 4. Phones (≤ 767px): readable heads, full-width CTA stacks, no edge-glued rails ---------- */
@media (max-width:767px){
  body.ts.ts-page--home main .ts-section{padding-block:calc(var(--cr-section-y) - 8px)}
  body.ts.ts-page--home .g07-head-row{gap:var(--cr-head-gap);margin-block-end:var(--cr-head-after)}
  body.ts.ts-page--home .g07-head-row__aside{display:block}
  body.ts.ts-page--home .g07-kicker{font-size:.74rem}
  body.ts.ts-page--home .g07-h2{font-size:clamp(1.28rem,5.4vw,1.6rem);line-height:1.3}
  body.ts.ts-page--home .g07-lead{font-size:.94rem;line-height:1.65}
  body.ts .fu-head{grid-template-columns:minmax(0,1fr)}
  body.ts :is(.g07-actions,.fu-hero__actions,.fu-final-box__actions,.tts-hero__actions){flex-direction:column;align-items:stretch}
  body.ts :is(.g07-actions,.fu-hero__actions,.fu-final-box__actions,.tts-hero__actions) > :is(a,button){inline-size:100%;justify-content:center;text-align:center}
  /* scroll rails keep a gutter at both ends instead of touching the screen edge */
  body.ts.ts-page--home .g07-journey__rail{scroll-padding-inline:12px}
}
@media (max-width:359px){
  body.ts{--cr-head-after:18px;--cr-card-pad:14px}
  body.ts.ts-page--home .g07-h2{font-size:1.22rem}
}

/* Floating contact button clears a fixed bottom bar (crown-motion.js sets the lift only while the bar shows). */
html body.ts.cr-fab-lift .aio-contact-parent .aio-contact-trigger{bottom:var(--cr-fab-bottom,76px) !important}
/* first paint already starts above the plans bar (measured 375: 239px · ≥768: 152px), so the JS refinement does not shift it */
html body.ts.ts-page--pricing:not(.cr-fab-lift) .aio-contact-parent .aio-contact-trigger{bottom:152px !important}
@media (max-width:767px){html body.ts.ts-page--pricing:not(.cr-fab-lift) .aio-contact-parent .aio-contact-trigger{bottom:239px !important}}

/* ---------- 4b. Morning Light contrast (status badges were tuned for Evening Dark only: 1.07:1 on the light page) ---------- */
html[data-theme=light] body.ts :where(.ts-badge:not(.ts-edition__flag)){color:var(--gold-deep)}
/* edition flags sit on a dark scrim over the theme preview image */
html[data-theme=light] body.ts .ts-edition__flag{color:#f3d995;background:rgba(7,7,10,.78);border-color:rgba(243,217,149,.45)}
html[data-theme=light] body.ts .ts-badge--ok{color:#064d2c;border-color:rgba(11,107,63,.38);background:rgba(95,211,154,.16)}
html[data-theme=light] body.ts :is(.ts-badge--pending,.ts-badge--soon){color:#7a4700;border-color:rgba(122,71,0,.36);background:rgba(240,179,90,.18)}
html[data-theme=light] body.ts .ts-badge--off{color:#9b1026;border-color:rgba(155,16,38,.34);background:rgba(255,42,77,.1)}
/* overlay pill on the (always dark) theme preview image */
html[data-theme=light] body.ts .ts-edition__live-pill{color:#f7f2e8;background:rgba(7,7,10,.72)}
/* the product-shot frame stays dark in both themes, so its caption keeps the dark-theme ink */
html[data-theme=light] body.ts .ts-shot figcaption{color:#d9d2c4}
html[data-theme=light] body.ts .ts-shot figcaption :is(strong,b){color:#f7f2e8}
html[data-theme=light] body.ts .ts-shot :is(.ts-badge--ok){color:#bff3d8;border-color:rgba(95,211,154,.4);background:rgba(95,211,154,.08)}

/* ---------- 5. Focus ---------- */
body.ts :is(.g07-jstep,.fu-flow-node,.fu-arch-card,.fu-arch-chip,.tsa-pill,[data-tsa-chapter-jump]):focus-visible{
  outline:2px solid var(--gold);outline-offset:3px
}
body.ts .fu-arch-card{cursor:pointer}

/* ---------- 6. Motion states (crown-motion.js) ---------- */

/* 6a. Home · journey Build → Sell → Manage → Analyze → Grow: the path lights step by step up to the chosen stage. */
body.ts.ts-page--home .g07-jstep{position:relative}
body.ts.ts-page--home .g07-jstep::after{
  content:"";position:absolute;inset-inline:12px;inset-block-end:3px;block-size:3px;border-radius:3px;
  background:linear-gradient(90deg,var(--gold-2),var(--crimson));
  transform:scaleX(0);transform-origin:var(--cr-origin);
  transition:transform .34s var(--cr-ease) calc(var(--cr-i,0) * 85ms)
}
body.ts.ts-page--home .g07-jstep.cr-lit::after{transform:scaleX(1)}
body.ts.ts-page--home .g07-jstep.cr-lit:not([aria-selected=true]) .g07-jstep__num{border-color:var(--gold-2);color:var(--gold)}
body.ts.ts-page--home .g07-journey.cr-touched .g07-jpanel[data-active]{animation:cr-rise .32s var(--cr-ease) both}

/* 6b. Features · order signal: storefront → order → inventory → reports → governance. */
body.ts .fu-flow-node{position:relative;isolation:isolate}
body.ts .fu-flow-node::before{
  content:"";position:absolute;inset:-1px;z-index:-1;border-radius:inherit;pointer-events:none;
  background:linear-gradient(120deg,color-mix(in srgb,var(--fu-accent) 26%,transparent),transparent 70%);
  opacity:0;transition:opacity .3s var(--cr-ease)
}
body.ts .fu-flow-node.cr-lit::before{opacity:1}
body.ts .fu-flow-node.cr-lit .fu-flow-node__n{background:var(--fu-accent);color:#fff}
body.ts .fu-flow-node.cr-pulse{animation:cr-pulse .42s var(--cr-ease)}
body.ts .fu-flow-bar__steps.cr-tracing .fu-flow-node:not(.cr-lit){opacity:.62}
body.ts .fu-flow-node{transition:transform .16s ease,border-color .16s ease,opacity .2s ease}

/* 6c. Features · architecture map: the chosen layer or engine lights the engines it is linked to. */
body.ts .fu-arch-chip{transition:opacity .2s ease,box-shadow .2s ease,border-color .2s ease,transform .2s var(--cr-ease)}
body.ts .fu-arch-chip.cr-rel{border-color:var(--fu-accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--fu-accent) 45%,transparent)}
body.ts .fu-arch-chip.cr-rel.cr-pop{animation:cr-pop .4s var(--cr-ease) calc(var(--cr-i,0) * 55ms) both}
body.ts .fu-arch-chip.cr-src{border-color:var(--fu-accent);background:color-mix(in srgb,var(--fu-accent) 30%,var(--fu-surface-2))}
body.ts .fu-arch-grid.cr-relating .fu-arch-chip:not(.cr-rel):not(.cr-src){opacity:.42}
body.ts .fu-arch-card.cr-linked:not(.is-focused){border-color:color-mix(in srgb,var(--fu-accent) 60%,var(--fu-border));border-style:dashed}
body.ts .cr-rel-readout{
  margin-block-start:var(--cr-grid-gap);padding:12px 16px;border-radius:14px;border:1px solid var(--fu-border,var(--line));
  background:var(--fu-surface,transparent);color:var(--fu-ink-soft,var(--ivory-2));font-size:.9rem;line-height:1.6
}
body.ts .cr-rel-readout strong{color:var(--fu-ink,var(--ivory))}
body.ts .cr-rel-readout .cr-rel-names{color:var(--fu-gold,var(--gold));font-weight:700}

/* 6d. Academy · switching path category re-flows the grid in place; chapter jumps glide the active marker. */
body.ts .tsa-path-card.cr-out{opacity:0;transform:translateY(8px) scale(.97);transition:opacity .16s ease,transform .16s ease}
body.ts .tsa-path-card.cr-in{animation:cr-rise .34s var(--cr-ease) calc(var(--cr-i,0) * 45ms) both}
body.ts [data-tsa-visible-paths-count].cr-bump{animation:cr-pop .36s var(--cr-ease)}
body.ts [data-tsa-chapter-jump]{transition:background-color .2s ease,border-color .2s ease,color .2s ease}
body.ts [data-tsa-chapter-jump].is-active{position:relative}
body.ts [data-tsa-chapter-jump].is-active.cr-just{animation:cr-nudge .32s var(--cr-ease)}

@keyframes cr-rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@keyframes cr-pop{0%{transform:scale(1)}45%{transform:scale(1.07)}100%{transform:scale(1)}}
@keyframes cr-pulse{0%{transform:scale(1)}40%{transform:scale(1.035)}100%{transform:scale(1)}}
@keyframes cr-nudge{0%{transform:translateX(0)}40%{transform:translateX(calc(var(--cr-dir,1) * 4px))}100%{transform:none}}
html[dir=rtl] body.ts{--cr-dir:-1}

@media (prefers-reduced-motion:reduce){
  body.ts.ts-page--home .g07-jstep::after,
  body.ts .fu-flow-node::before,
  body.ts .fu-arch-chip,
  body.ts .tsa-path-card.cr-out{transition:none}
  body.ts.ts-page--home .g07-journey.cr-touched .g07-jpanel[data-active],
  body.ts .fu-flow-node.cr-pulse,
  body.ts .fu-arch-chip.cr-rel.cr-pop,
  body.ts .tsa-path-card.cr-in,
  body.ts [data-tsa-visible-paths-count].cr-bump,
  body.ts [data-tsa-chapter-jump].is-active.cr-just{animation:none}
}
