/* Luna UI — vanilla port of shadcn/ui + Magic UI.
   Sources: ui.shadcn.com (accordion, badge, button, card, input, sheet, tabs)
   and magicui.design (shimmer-button, border-beam, magic-card, marquee,
   blur-fade, number-ticker, animated-grid, dot-pattern, bento-grid, animated-beam).
   Apple-dark brand. Motion is decorative and off when reduced-motion is set. */

:root {
  --ui-spot: rgba(100, 210, 255, 0.16);
  --ui-dot: rgba(255, 255, 255, 0.16);
  --ui-shimmer: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] {
  --ui-spot: rgba(0, 113, 227, 0.14);
  --ui-dot: rgba(0, 0, 0, 0.14);
  --ui-shimmer: rgba(255, 255, 255, 0.85);
}

/* Dot pattern — Magic UI. Sits behind page content. */
html {
  background-color: var(--bg, #0b0b0e);
}

body[data-layout="marketing"] {
  background-color: transparent;
}

body[data-layout="marketing"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--ui-dot) 1px, transparent 1.15px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 10%, transparent 78%);
}

/* Navbar — shadcn-style glass bar */
.site-header {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom-color: var(--border);
}

html[data-theme="light"] .site-header,
html[data-theme="light"] .site-header.is-scrolled {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
}

@media (max-width: 899px) {
  .site-header .nav {
    position: relative;
    padding-right: 46px;
  }

  .menu-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    margin-top: -22px;
  }
}

/* Sheet — shadcn side panel for the mobile menu */
.mobile-menu {
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(20rem, calc(100% - 4.5rem));
  padding: calc(var(--nav-h) + 8px) 18px calc(24px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid var(--border);
  border-radius: 18px 0 0 18px;
  box-shadow: -28px 0 80px rgba(0, 0, 0, 0.38);
  transform: translateX(12px);
}

.mobile-menu.is-open {
  transform: none;
}

.mobile-menu a:not(.btn) {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 12px 10px;
  min-height: 44px;
  border-radius: 10px;
}

.mobile-menu a:not(.btn):hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

body:has(.mobile-menu.is-open)::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(0, 0, 0, 0.48);
  pointer-events: none;
}

/* Shimmer button — Magic UI, brand blue. A sliding highlight, not a large spinning layer. */
.btn-store,
.affiliate-primary {
  background-image:
    linear-gradient(110deg, transparent 32%, var(--ui-shimmer) 50%, transparent 68%),
    linear-gradient(180deg, #3aa0ff, var(--brand-2));
  background-size: 220% 100%, 100% 100%;
  background-position: 130% 0, 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 24px -16px rgba(10, 132, 255, 0.9);
  animation: ui-shimmer-slide 3.2s ease-in-out infinite;
}

.btn-secondary,
.btn-ghost,
.affiliate-head button,
.affiliate-tabs button {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.btn-secondary:hover,
.btn-ghost:hover {
  border-color: color-mix(in srgb, var(--brand-1) 55%, var(--border));
}

/* Badge */
.section-label,
.price-badge,
.iq-kicker,
.logo-strip-icons span,
.ui-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  letter-spacing: 0.08em;
}

.price-badge {
  letter-spacing: 0.06em;
}

.logo-strip-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.logo-strip-icons span {
  letter-spacing: 0.01em;
  text-transform: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Card + magic card spotlight */
.tile,
.pain-card,
.price-card,
.step-card,
.iq-card,
.iq-q,
.blog-list > li,
.tool-list a,
.content-cta,
.content-prose .toc,
.affiliate-card,
.tool-card,
.tools-grid > a,
.tools-grid > article {
  position: relative;
  background-image: radial-gradient(
    420px circle at var(--ui-x, 50%) var(--ui-y, 0%),
    var(--ui-spot),
    transparent 42%
  );
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.blog-list > li {
  margin-bottom: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 16px;
  background-color: color-mix(in srgb, var(--surface) 86%, transparent);
}

.content-cta {
  overflow: hidden;
  background-color: color-mix(in srgb, var(--surface) 88%, transparent);
}

.tile:hover,
.pain-card:hover,
.price-card:hover,
.step-card:hover,
.iq-card:hover {
  border-color: color-mix(in srgb, var(--brand-1) 45%, var(--border));
}

/* Bento — keep the grid, quiet the hover jump so it does not shift layout */
.bento .tile {
  transition: border-color 0.2s ease;
}

.bento .tile:hover {
  transform: none;
}

/* Border beam is already on featured prices. Give the blog CTA the same edge. */
.content-cta > .border-beam,
.tile.span-2 > .border-beam {
  border-radius: inherit;
}

/* Inputs — shadcn */
.affiliate-card input:not([type="checkbox"]):not([type="radio"]),
.buy-redeem-field input,
.iq-search input,
.iq-form input,
.iq-form select,
.iq-form textarea,
.tool-page input:not([type="checkbox"]):not([type="radio"]),
.tool-page textarea,
.tool-page select,
.tools-page input:not([type="checkbox"]):not([type="radio"]),
.tools-page textarea,
.tools-page select,
main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
main textarea,
main select {
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

main input:not([type="checkbox"]):not([type="radio"]):focus,
main textarea:focus,
main select:focus,
.affiliate-card input:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.28);
}

/* Tabs — shadcn list on the question categories */
.iq-segments {
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}

.iq-segment[aria-current="page"],
.iq-segment[aria-selected="true"] {
  background: color-mix(in srgb, var(--text) 12%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.iq-segment:hover {
  transform: none;
}

/* Accordion — shadcn details/summary */
.faq-list {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  overflow: hidden;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
}

.faq-item:last-child {
  border-bottom: 0;
}

.faq-item summary::after {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  opacity: 0.7;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  content: "";
  transform: rotate(180deg);
}

/* Number ticker digits do not change width while they count */
[data-count] {
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* Offscreen loops stay stopped. luna-ui.js toggles is-paused. */
.hired-marquee.is-paused .hired-marquee__track,
.reviews-marquee.is-paused .reviews-marquee__track,
.hero.is-paused::after {
  animation-play-state: paused;
}

/* Animated grid on the home hero */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 72% 58% at 50% 18%, #000 15%, transparent 72%);
  animation: ui-grid-drift 22s linear infinite;
}

/* Animated beam: interview audio → Luna → suggestion */
.ui-beam {
  margin: 4px 0 28px;
}

.ui-beam-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr) 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.ui-beam-node {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
}

.ui-beam-line {
  position: relative;
  height: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-1) 35%, var(--border));
  overflow: hidden;
}

.ui-beam-particle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 18px;
  height: 2px;
  margin-top: -1px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff, var(--brand-1));
  animation: ui-beam-travel 2.4s linear infinite;
}

.ui-beam-line + .ui-beam-node + .ui-beam-line .ui-beam-particle {
  animation-delay: 0.4s;
}

@media (max-width: 699px) {
  .ui-beam-row {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .ui-beam-node {
    width: min(100%, 280px);
  }

  .ui-beam-line {
    width: 2px;
    height: 28px;
  }

  .ui-beam-particle {
    width: 2px;
    height: 12px;
    left: 0;
    top: 0;
    margin-top: 0;
    animation-name: ui-beam-travel-y;
  }
}

/* Blur fade when a block enters view. Base state stays visible so a missed
   animation cannot leave the section at opacity 0. Transform does not shift layout. */
@media (prefers-reduced-motion: no-preference) {
  .tile.is-in,
  .pain-card.is-in,
  .price-card.is-in,
  .step-card.is-in,
  .content-cta.is-in,
  .more-guides.is-in,
  .ui-beam.is-in,
  .blog-list > li.is-in,
  .tool-list a.is-in,
  .iq-card.is-in {
    animation: ui-blur-fade 0.7s ease both;
  }
}

@keyframes ui-shimmer-slide {
  to {
    background-position: -30% 0, 0 0;
  }
}

@keyframes ui-grid-drift {
  to {
    background-position: 56px 56px, 56px 56px;
  }
}

@keyframes ui-beam-travel {
  from {
    transform: translateX(-24px);
  }
  to {
    transform: translateX(72px);
  }
}

@keyframes ui-beam-travel-y {
  from {
    transform: translateY(-8px);
  }
  to {
    transform: translateY(28px);
  }
}

@keyframes ui-blur-fade {
  from {
    opacity: 0.72;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-store,
  .affiliate-primary,
  .hero::after,
  .ui-beam-particle,
  .border-beam > span,
  .tile,
  .pain-card,
  .price-card,
  .step-card,
  .content-cta,
  .more-guides,
  .ui-beam {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }

  .faq-item summary::after {
    transition: none;
  }
}

/* Phones: glass, masks, and looping layers repaint the whole viewport on scroll. */
@media (max-width: 767px) {
  .site-header,
  .site-header.is-scrolled,
  html[data-theme="light"] .site-header,
  html[data-theme="light"] .site-header.is-scrolled,
  .mobile-menu,
  .mobile-sticky {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg, #0b0b0e);
  }

  body[data-layout="marketing"]::before {
    content: none;
  }

  .hero::after,
  .border-beam > span,
  .ui-beam-particle,
  .btn-store,
  .affiliate-primary,
  .hired-marquee__track,
  .reviews-marquee__group,
  .tile.is-in,
  .pain-card.is-in,
  .price-card.is-in,
  .step-card.is-in,
  .content-cta.is-in,
  .more-guides.is-in,
  .ui-beam.is-in,
  .blog-list > li.is-in,
  .tool-list a.is-in,
  .iq-card.is-in {
    animation: none;
  }

  .hero::after,
  .border-beam {
    mask-image: none;
    -webkit-mask-image: none;
  }
}
