/* ==========================================================================
   TextBrew.ai - Custom Stylesheet
   Zero-build approach: loaded alongside CDN Tailwind CSS
   Brand: purple (#9E77ED / #7C3AED)
   Font: Inter (Google Fonts)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Skip Link (accessibility)
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
}

.skip-link:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  width: auto;
  height: auto;
  padding: 0.75rem 1.25rem;
  background: var(--brand-600, #7C3AED);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  outline: 2px solid #fff;
}

/* --------------------------------------------------------------------------
   1. CSS Custom Properties
   -------------------------------------------------------------------------- */

:root {
  /* Brand palette (purple scale) */
  --brand-50:  #F4EBFF;
  --brand-100: #E9D5FF;
  --brand-200: #D8B4FE;
  --brand-300: #C084FC;
  --brand-400: #A855F7;
  --brand-500: #9E77ED;
  --brand-600: #7C3AED;
  --brand-700: #6D28D9;
  --brand-800: #5B21B6;
  --brand-900: #4C1D95;
  --brand-950: #2E1065;

  /* Primary accent */
  --brand-primary: #7C3AED;

  /* Neutral surface tokens */
  --surface-bg:   #ffffff;
  --surface-fg:   #0f172a;
  --surface-muted: #f8fafc;
  --surface-border: #e2e8f0;

  /* Theme transition shorthand */
  --transition-theme: background-color 300ms ease,
                      color 300ms ease,
                      border-color 300ms ease,
                      box-shadow 300ms ease;
}

html.dark {
  /* Inverted brand palette for dark mode */
  --brand-50:  #4C1D95;
  --brand-100: #5B21B6;
  --brand-200: #6D28D9;
  --brand-300: #7C3AED;
  --brand-400: #A855F7;
  --brand-500: #9E77ED;
  --brand-600: #C084FC;
  --brand-700: #D8B4FE;
  --brand-800: #E9D5FF;
  --brand-900: #F4EBFF;
  --brand-950: #FAF5FF;

  --surface-bg:     #0f172a;
  --surface-fg:     #f1f5f9;
  --surface-muted:  #1e293b;
  --surface-border: #334155;
}

/* --------------------------------------------------------------------------
   2. FOUC Prevention
   -------------------------------------------------------------------------- */

html:not(.theme-loaded) body {
  visibility: hidden;
}

html.theme-loaded body {
  visibility: visible;
}

/* --------------------------------------------------------------------------
   3. Base / Reset Enhancements
   -------------------------------------------------------------------------- */

html {
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  transition: var(--transition-theme);
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--surface-bg);
  color: var(--surface-fg);
}

/* --------------------------------------------------------------------------
   4. Navigation - Scrolled Shadow
   -------------------------------------------------------------------------- */

.nav-scrolled {
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1),
              0 1px 2px -1px rgb(0 0 0 / 0.1);
  border-bottom-color: var(--surface-border);
}

html.dark .nav-scrolled {
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4),
              0 1px 2px -1px rgb(0 0 0 / 0.3);
}

/* --------------------------------------------------------------------------
   4b. Mobile Menu
   -------------------------------------------------------------------------- */

#mobile-menu {
  max-height: 0;
  transition: max-height 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

#mobile-menu.open {
  max-height: 32rem;
}

/* --------------------------------------------------------------------------
   5. Cookie Consent Banner
   -------------------------------------------------------------------------- */

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1),
              opacity 400ms ease;
}

.cookie-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   6. Browser Frame Mockup
   -------------------------------------------------------------------------- */

.browser-frame {
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  background-color: var(--surface-bg);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
              0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.browser-frame__bar {
  position: relative;
  height: 2.5rem;
  background-color: var(--surface-muted);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  padding-left: 1rem;
}

.browser-frame__bar::before {
  content: '';
  display: inline-flex;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  background-color: #ef4444;
  box-shadow:
    1.25rem 0 0 #eab308,
    2.5rem 0 0 #22c55e;
}

html.dark .browser-frame {
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.35),
              0 8px 10px -6px rgb(0 0 0 / 0.25);
}

/* --------------------------------------------------------------------------
   7. Scroll Reveal Animations
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(2rem);
  transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger support via CSS variable set by JS */
.reveal[style*="--reveal-delay"] {
  transition-delay: var(--reveal-delay);
}

/* --------------------------------------------------------------------------
   8. Character Stagger Animation
   -------------------------------------------------------------------------- */

[data-char-stagger] {
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.3em;
}

[data-char-stagger] .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em);
  transition: opacity 400ms ease, transform 400ms ease;
}

[data-char-stagger].active .char {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   9. FAQ Accordion
   -------------------------------------------------------------------------- */

[data-faq-item] {
  border-bottom: 1px solid var(--surface-border);
}

[data-faq-question] {
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.5;
}

[data-faq-question]:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

[data-faq-answer] {
  overflow: hidden;
  height: 0;
  transition: height 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-faq-answer-inner] {
  padding-bottom: 1.25rem;
  color: var(--surface-fg);
  opacity: 0.8;
  line-height: 1.75;
}

[data-faq-icon] {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 1rem;
  transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-faq-item].open [data-faq-icon] {
  transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   10. Pricing Toggle
   -------------------------------------------------------------------------- */

[data-pricing-toggle] {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: 9999px;
  padding: 0.25rem;
  background-color: var(--surface-muted);
  border: 1px solid var(--surface-border);
}

[data-pricing-toggle] [data-period] {
  padding: 0.5rem 1.5rem;
  border-radius: 9999px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  background: transparent;
  color: var(--surface-fg);
  opacity: 0.6;
  transition: background-color 250ms ease,
              color 250ms ease,
              opacity 250ms ease;
}

[data-pricing-toggle] [data-period].active {
  background-color: var(--brand-500);
  color: #ffffff;
  opacity: 1;
}

html.dark [data-pricing-toggle] [data-period].active {
  background-color: var(--brand-400);
  color: #0f172a;
}

/* Price value crossfade */
[data-price-value] {
  transition: opacity 200ms ease, transform 200ms ease;
}

[data-price-value].switching {
  opacity: 0;
  transform: translateY(-0.25rem);
}

/* --------------------------------------------------------------------------
   11. Blog Prose Styles
   -------------------------------------------------------------------------- */

.prose {
  max-width: 72ch;
  line-height: 1.8;
  color: var(--surface-fg);
}

.prose h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 1rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.prose h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose a {
  color: var(--brand-500);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 200ms ease;
}

.prose a:hover {
  color: var(--brand-600);
}

html.dark .prose a {
  color: var(--brand-400);
}

html.dark .prose a:hover {
  color: var(--brand-300);
}

.prose strong {
  font-weight: 700;
}

.prose blockquote {
  border-left: 4px solid var(--brand-500);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--surface-fg);
  opacity: 0.85;
}

.prose ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.prose ol {
  list-style: decimal;
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose li::marker {
  color: var(--brand-500);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.875em;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background-color: var(--surface-muted);
  border: 1px solid var(--surface-border);
}

.prose pre {
  overflow-x: auto;
  padding: 1.25rem;
  border-radius: 0.5rem;
  background-color: var(--surface-muted);
  border: 1px solid var(--surface-border);
  margin-bottom: 1.5rem;
}

.prose pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: 0.875rem;
  line-height: 1.7;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.prose figure {
  margin: 1.5rem 0;
}

.prose figcaption {
  font-size: 0.875rem;
  text-align: center;
  color: var(--surface-fg);
  opacity: 0.6;
  margin-top: 0.5rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--surface-border);
  margin: 2rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

.prose th,
.prose td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface-border);
  text-align: left;
}

.prose th {
  font-weight: 600;
  background-color: var(--surface-muted);
}

/* --------------------------------------------------------------------------
   12. 3D Tilt Card Base
   -------------------------------------------------------------------------- */

[data-tilt] {
  transform-style: preserve-3d;
  transition: transform 200ms ease;
}

/* --------------------------------------------------------------------------
   13. Gradient Shift
   -------------------------------------------------------------------------- */

[data-gradient-shift] {
  transition: background-position 100ms linear;
  background-size: 200% 200%;
}

/* --------------------------------------------------------------------------
   14. Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  [data-char-stagger] .char {
    opacity: 1;
    transform: none;
    transition: none;
  }

  [data-faq-answer] {
    transition: none;
  }

  [data-faq-icon] {
    transition: none;
  }

  [data-tilt] {
    transition: none;
  }

  [data-gradient-shift] {
    transition: none;
  }

  .cookie-banner {
    transition: none;
  }

  [data-price-value] {
    transition: none;
  }
}
