/* ============================================================
   VITALITY — SHARED UI LAYER (glass + bento hybrid)
   Component classes used across all pages. Builds on
   design-tokens.css variables; loaded after page CSS so it
   wins on equal specificity.

   Components:
     .v-card            glass surface w/ hover lift + glow
     .v-card--gradient  1px gradient border variant
     .v-bento           responsive mini-tile grid
     .v-pill            badge (accent) / .v-pill--success
     .v-cta             glowing gradient button / --ghost
     .v-section-head    label + heading block
     .v-reveal          scroll reveal (JS adds html.v-anim + .is-in)
   ============================================================ */

:root {
  --v-ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Violet-only ramp — no off-palette hues; the site is monochrome purple */
  --v-border-grad: linear-gradient(135deg,
      rgba(181, 123, 255, 0.9),
      rgba(145, 71, 255, 0.18) 45%,
      rgba(109, 40, 217, 0.75));
}

/* ---- Glass card ---- */
.v-card {
  position: relative;
  background: var(--el-card-bg);
  border: 1px solid var(--el-card-border);
  border-radius: var(--el-card-radius);
  box-shadow: var(--el-shadow-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.35s var(--v-ease),
              border-color 0.35s var(--v-ease),
              box-shadow 0.35s var(--v-ease);
}
.v-card:hover {
  transform: translateY(-4px);
  border-color: var(--el-hairline-strong);
  box-shadow: var(--el-shadow-card), var(--el-glow-violet);
}

/* ---- Gradient-border card ---- */
.v-card--gradient {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--el-bg-2), var(--el-bg-2)) padding-box,
    var(--v-border-grad) border-box;
}
.v-card--gradient:hover {
  border-color: transparent;
  background:
    linear-gradient(#100c1c, #100c1c) padding-box,
    var(--v-border-grad) border-box;
}

/* ---- Bento grid of mini stat tiles ---- */
.v-bento {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.v-bento-item {
  background: rgba(145, 71, 255, 0.07);
  border: 1px solid rgba(145, 71, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
  transition: background 0.25s var(--v-ease), border-color 0.25s var(--v-ease);
}
.v-bento-item:hover {
  background: rgba(145, 71, 255, 0.13);
  border-color: rgba(145, 71, 255, 0.3);
}
.v-bento-item strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--text-light);
}

/* ---- Pills ---- */
.v-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--el-violet-bright);
  background: rgba(145, 71, 255, 0.12);
  border: 1px solid rgba(145, 71, 255, 0.28);
}
.v-pill--success {
  color: #d9c2ff;
  background: rgba(145, 71, 255, 0.2);
  border-color: rgba(181, 123, 255, 0.45);
}

/* ---- CTA buttons ---- */
.v-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--el-violet-deep), var(--el-violet) 55%, var(--el-violet-bright));
  background-size: 160% 160%;
  background-position: 0% 50%;
  box-shadow: 0 4px 24px -4px rgba(var(--el-accent-rgb), 0.45);
  transition: background-position 0.45s var(--v-ease),
              box-shadow 0.35s var(--v-ease),
              transform 0.35s var(--v-ease);
}
.v-cta:hover {
  background-position: 100% 50%;
  box-shadow: 0 6px 32px -4px rgba(var(--el-accent-rgb), 0.65);
  transform: translateY(-2px);
  color: #fff;
}
.v-cta--ghost {
  background: transparent;
  border: 1px solid rgba(var(--el-accent-rgb), 0.45);
  color: var(--el-violet-bright);
  box-shadow: none;
}
.v-cta--ghost:hover {
  background: rgba(var(--el-accent-rgb), 0.1);
  border-color: var(--el-violet);
  color: var(--el-violet-bright);
  box-shadow: 0 4px 24px -8px rgba(var(--el-accent-rgb), 0.4);
}

/* ---- Section head ---- */
.v-section-head { margin-bottom: var(--space-2xl); }
.v-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--el-violet-bright);
  margin-bottom: var(--space-sm);
}
.v-section-head h1,
.v-section-head h2 {
  font-family: var(--font-heading);
  color: var(--text-light);
  letter-spacing: -0.02em;
}
.v-section-head .v-sub {
  color: var(--text-dim);
  max-width: 60ch;
  margin-top: var(--space-sm);
}

/* ---- Scroll reveal ----
   Visible by default (no-JS safe). scripts/vitality-ui.js adds
   html.v-anim only when motion is allowed, then .is-in per element. */
html.v-anim .v-reveal {
  opacity: 0;
  transform: translateY(18px);
}
html.v-anim .v-reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s var(--v-ease) var(--v-delay, 0ms),
              transform 0.6s var(--v-ease) var(--v-delay, 0ms);
}

/* ---- Accordion (FAQ) ---- */
.v-acc-item {
  overflow: hidden;
  margin-bottom: 12px;
}
.v-acc-item summary,
.v-acc-item .v-acc-q {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  font-family: var(--font-heading);
  font-size: 1.02rem;
  color: var(--text-light);
}
.v-acc-item summary::-webkit-details-marker { display: none; }
.v-acc-item summary::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--el-violet-bright);
  border-bottom: 2px solid var(--el-violet-bright);
  transform: rotate(45deg);
  transition: transform 0.3s var(--v-ease);
}
.v-acc-item[open] summary::after { transform: rotate(225deg); }
.v-acc-item .v-acc-a {
  padding: 0 22px 20px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ---- Step timeline (how-it-works) ---- */
.v-steps { counter-reset: vstep; }
.v-step {
  position: relative;
  padding-left: 64px;
  margin-bottom: var(--space-xl);
  counter-increment: vstep;
}
.v-step::before {
  content: counter(vstep, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--el-violet-bright);
  background: rgba(145, 71, 255, 0.1);
  border: 1px solid rgba(145, 71, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.v-step::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 46px;
  bottom: -26px;
  width: 1px;
  background: linear-gradient(180deg, rgba(145, 71, 255, 0.35), transparent);
}
.v-step:last-child::after { display: none; }

/* ============================================================
   PAGE UPGRADES — restyle existing page classes to the new
   direction. !important needed to beat inner-pages.css.
   ============================================================ */

/* Download page: featured card gets the gradient border */
body.cairn-site .download-card.featured {
  border: 1px solid transparent !important;
  border-color: transparent !important;
  background:
    linear-gradient(#100c1c, #100c1c) padding-box,
    var(--v-border-grad) border-box !important;
}
body.cairn-site .download-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: var(--el-glow-violet) !important;
}
body.cairn-site .download-card .featured-badge {
  background: rgba(145, 71, 255, 0.2);
  border: 1px solid rgba(181, 123, 255, 0.45);
  color: #d9c2ff !important;
}

/* FAQ page: flat list -> glass accordion cards w/ animated open */
body.cairn-site .faq-item {
  background: var(--el-card-bg) !important;
  border: 1px solid var(--el-card-border) !important;
  border-radius: 14px !important;
  margin-bottom: 12px;
  transition: border-color 0.3s var(--v-ease), background 0.3s var(--v-ease);
  interpolate-size: allow-keywords;
}
body.cairn-site .faq-item:hover,
body.cairn-site .faq-item.active {
  border-color: rgba(145, 71, 255, 0.35) !important;
}
body.cairn-site .faq-item.active {
  background: rgba(145, 71, 255, 0.05) !important;
}
body.cairn-site .faq-question { padding: 20px 22px; }
body.cairn-site .faq-answer {
  display: block !important;
  height: 0;
  overflow: hidden;
  padding: 0 22px !important;
  transition: height 0.4s var(--v-ease);
}
body.cairn-site .faq-item.active .faq-answer {
  height: auto;
  padding-bottom: 22px !important;
}

/* Docs / how-it-works: flat feature & utility lists -> glass cards */
body.cairn-site .feature,
body.cairn-site .utility {
  background: var(--el-card-bg) !important;
  border: 1px solid var(--el-card-border) !important;
  border-radius: 14px !important;
  padding: 22px 24px !important;
  margin-bottom: 14px;
  transition: border-color 0.3s var(--v-ease);
}
body.cairn-site .feature:hover,
body.cairn-site .utility:hover {
  border-color: rgba(145, 71, 255, 0.35) !important;
}
body.cairn-site .requirement {
  transition: border-color 0.3s var(--v-ease);
}
body.cairn-site .requirement:hover {
  border-color: rgba(145, 71, 255, 0.35) !important;
}

/* FAQ icon: components.css draws a CSS-bar plus via ::before/::after
   while the markup also contains a literal "+" — both rendered, giving a
   doubled icon. Keep the text glyph, kill the bars. */
.faq-icon::before,
.faq-icon::after {
  display: none !important;
  content: none !important;
}

/* ToS / affiliate / docs steps: cairn-site.css turns these into cards
   (border + surface) but inner-pages.css still zeroes their horizontal
   padding as if they were prose — text ends up jammed against the card
   edge. Cards get card padding. */
body.cairn-site .tos-section {
  padding: 28px 30px !important;
  margin-bottom: 18px;
}
body.cairn-site .tos-section:last-of-type { border-bottom: 1px solid var(--cr-hairline) !important; }
body.cairn-site .affiliate-step,
body.cairn-site .step {
  padding: 22px 26px !important;
}
body.cairn-site .tos-section h2 { margin-top: 0 !important; }

/* Shader plasma canvas: full brightness fights body text on inner pages
   and pops in abruptly after JS load. Dim it on inner pages and ease it
   in everywhere for a consistent tone. */
/* Single source of truth for plasma brightness — the scattered
   `opacity: 0.5 !important` rules in components/elevated/cairn-* were
   removed; tune per-page with --v-shader-max only. */
#vitality-shader-bg {
  opacity: 0;
  animation: v-shader-in 1.6s ease-out 0.15s forwards;
  /* lvh = large viewport: keep the canvas covering the extra strip Android
     reveals when the URL bar hides, instead of showing background there */
  height: 100lvh !important;
}
@keyframes v-shader-in {
  to { opacity: var(--v-shader-max, 0.5); }
}
/* Inner pages: keep the plasma as quiet atmosphere, not a light show */
body.inner-page { --v-shader-max: 0.25; }
/* Homepage: one even glow level for the whole page — per-section scrims
   (hero radials, cinematic vignette) were removed so this is the only
   thing controlling brightness */
body.cairn-home { --v-shader-max: 0.35; }

/* Affiliate steps have no .step-content wrapper — h3 and p are direct
   flex children of .step, putting a huge heading inline with its text.
   Grid: number in col 1, heading + copy stacked in col 2. */
body.cairn-site .affiliate-steps .step {
  display: grid !important;
  grid-template-columns: auto 1fr;
  column-gap: 18px;
  align-items: start;
}
body.cairn-site .affiliate-steps .step .step-number { grid-row: 1 / span 2; }
body.cairn-site .affiliate-steps .step h3 {
  margin: 0 0 6px !important;
  font-size: 1.05rem !important;
  font-family: var(--font-heading) !important;
}
body.cairn-site .affiliate-steps .step p { margin: 0 !important; }

/* ---- Fallbacks ---- */
@media (prefers-reduced-motion: reduce) {
  .v-card, .v-card:hover, .v-cta, .v-cta:hover, .v-bento-item {
    transition: none;
    transform: none;
  }
  html.v-anim .v-reveal { opacity: 1; transform: none; }
}
html.no-gpu .v-card,
html.no-gpu .v-card:hover {
  transform: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html.no-gpu .v-cta,
html.no-gpu .v-cta:hover {
  box-shadow: none;
  transform: none;
}

/* Touch devices: backdrop-filter blur is a major scroll-jank source on
   Android GPUs (30+ blurred surfaces compositing every frame). The card
   backgrounds are near-opaque anyway — drop the blur, keep the look. */
@media (pointer: coarse) {
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .v-bento { grid-template-columns: repeat(2, 1fr); }
  .v-step { padding-left: 52px; }
  .v-cta { width: 100%; }
}

/* Docs on phones: sidebar (search + full nav) stacked before the content,
   forcing a screen of scrolling before anything readable. Content first,
   sidebar becomes an index below it. */
@media (max-width: 900px) {
  .documentation-container { display: flex !important; flex-direction: column; }
  .documentation-container .documentation-content { order: 1; }
  .documentation-container .documentation-sidebar { order: 2; }
}
