/*
 * FAP — Global Design Tokens & Base Styles
 * Task: TASK-001 (CSS tokens) + TASK-012 (typography)
 * Source: LEAD_REFERENCE.md
 *
 * TABLE OF CONTENTS
 *  1. CSS Custom Properties (Design Tokens)
 *  2. Dark Mode Overrides
 *  3. Base Reset & Typography
 *  4. Scrollbar
 *  5. Kadence Overrides — Variables
 *  6. Utility Classes
 *  7. Homepage Layout Wrapper
 *  8. Hero Section — TASK-003/004/005
 *  9. Global Buttons
 * 10. Sticky Audio Player — TASK-013
 * 11. Back to Top — TASK-015
 * 12. Scroll Reveal — TASK-015
 */


/* ============================================================
   1. CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   Default: Light Mode
   ============================================================ */

:root {
  /* Brand */
  --brand-1: #ad966c;
  /* gold sand */
  --brand-2: #c4660e;
  /* burnt orange */
  --brand-3: #FF7F00;
  /* vivid orange */

  /* Semantic */
  --primary: #FF7F00;
  --primary-600: #e57000;
  --primary-700: #c65f00;

  /* Accent */
  --accent-blue: #1f6feb;

  /* Misc UI */
  --hero-accent: #E67E22;
  /* hero title text */
  --secondary-btn: #748b9f;
  /* podcast card secondary button */
  --patreon: #f96854;
  --patreon-hover: #d84a38;

  /* Base */
  --white: #ffffff;
  --black: #000000;

  /* Grayscale — Light Mode */
  --gray-50: #fafafa;
  --gray-75: #f7f7f9;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-700: #333333;
  --gray-800: #1a1a1a;
  --gray-900: #000000;

  /* Semantic text / surface tokens — use these for color/background-color.
     These NEVER invert to the wrong value, unlike --black / --white. */
  --text-primary: #0a0a0a;
  /* body copy, headings  */
  --text-secondary: #1f1f1f;
  /* subtitles, meta      */
  --text-muted: #444444;
  /* descriptions, hints  */
  --surface: #ffffff;
  /* page background      */
  --surface-alt: #f5f5f5;
  /* cards, panels        */

  /* Layout */
  --container-max-width: 1500px;
  --sidebar-width: 260px;
  --header-height: 80px;

  /* Shape */
  --border-radius: 12px;
  --border-radius-pill: 24px;
  --border-radius-badge: 999px;

  /* Typography */
  --font-primary: 'Roboto', system-ui, sans-serif;
  --font-heading: 'Montserrat', sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);

  /* Transitions */
  --transition: all .3s cubic-bezier(.4, 0, .2, 1);

  /* Overlay */
  --overlay-bg: rgba(255, 255, 255, .92);
}


/* ============================================================
   2. DARK MODE OVERRIDES
   Applied via:
     a) @media (prefers-color-scheme: dark) — system preference
     b) .dark-mode — JS manual toggle (see fap-scripts.js)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --white: #111111;
    /* main dark background */
    --black: #ffffff;
    --gray-50: #0f0f0f;
    --gray-75: #141414;
    --gray-100: #1a1a1a;
    --gray-200: #222222;
    --gray-300: #333333;
    --gray-700: #bdbdbd;
    --gray-800: #e0e0e0;
    --gray-900: #f5f5f5;
    /* Semantic tokens — dark values */
    --text-primary: #f0f0f0;
    --text-secondary: #bdbdbd;
    --text-muted: #999999;
    --surface: #111111;
    --surface-alt: #1a1a1a;
    --overlay-bg: rgba(17, 17, 17, .92);
  }
}

.light-mode {
  --white: #ffffff;
  --black: #000000;
  --gray-50: #fafafa;
  --gray-75: #f7f7f9;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-700: #333333;
  --gray-800: #1a1a1a;
  --gray-900: #000000;
  /* Semantic tokens — light */
  --text-primary: #0a0a0a;
  --text-secondary: #1f1f1f;
  --text-muted: #444444;
  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --overlay-bg: rgba(255, 255, 255, .92);
}


/* JS toggle — class applied to <html> by fap-scripts.js */
.dark-mode {
  --white: #111111;
  --black: #ffffff;
  --gray-50: #0f0f0f;
  --gray-75: #141414;
  --gray-100: #1a1a1a;
  --gray-200: #222222;
  --gray-300: #333333;
  --gray-700: #bdbdbd;
  --gray-800: #e0e0e0;
  --gray-900: #f5f5f5;
  /* Semantic tokens — dark */
  --text-primary: #f0f0f0;
  --text-secondary: #bdbdbd;
  --text-muted: #999999;
  --surface: #111111;
  --surface-alt: #1a1a1a;
  --overlay-bg: rgba(17, 17, 17, .92);
}



/* ============================================================
   3. BASE RESET & TYPOGRAPHY — TASK-012
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  /* was --gray-800; now uses semantic token */
  background-color: var(--surface);
  /* was --white; now uses semantic token */
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-primary);
  /* was --gray-900 */
  line-height: 1.2;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover,
a:focus {
  color: var(--primary-600);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ============================================================
   4. SCROLLBAR
   Thin, primary-colored thumb on gray-200 track
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--gray-200);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-600);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--gray-200);
}


/* ============================================================
   5. KADENCE VARIABLE OVERRIDES
   Map Kadence's own CSS vars to our design tokens so that
   any Kadence component that uses its own variables
   automatically respects our brand colors.
   ============================================================ */

:root {
  /* Kadence palette vars → our brand */
  --global-palette1: var(--primary);
  --global-palette2: var(--primary-600);
  --global-palette3: var(--gray-800);
  --global-palette4: var(--gray-700);
  --global-palette5: var(--gray-300);
  --global-palette6: var(--gray-200);
  --global-palette7: var(--gray-100);
  --global-palette8: var(--white);
  --global-palette9: var(--black);

  /* Kadence body font */
  --global-body-font-family: var(--font-primary);
  --global-heading-font-family: var(--font-heading);

  /* Kadence content width */
  --global-content-width: var(--container-max-width);
}


/* ============================================================
   5b. DARK MODE BACKGROUND OVERRIDES
   Kadence's Customizer writes hardcoded hex values for body
   background as inline <style> in <head>, which beats our
   external file by cascade order. !important is required here
   specifically to override those Kadence inline styles.
   Applied for BOTH OS preference and JS toggle paths.
   ============================================================ */

@media (prefers-color-scheme: dark) {

  body,
  #page,
  #wrapper,
  #inner-wrap,
  #masthead,
  #footer-wrap {
    background-color: #111111 !important;
    color: #f0f0f0 !important;
  }
}

.dark-mode body,
.dark-mode #page,
.dark-mode #wrapper,
.dark-mode #inner-wrap,
.dark-mode #masthead,
.dark-mode #footer-wrap {
  background-color: #111111 !important;
  color: #f0f0f0 !important;
}

/* Ensure light-mode class fully resets when explicitly toggled */
.light-mode body,
.light-mode #page,
.light-mode #wrapper,
.light-mode #inner-wrap,
.light-mode #masthead,
.light-mode #footer-wrap {
  background-color: #ffffff !important;
  color: #0a0a0a !important;
}



/* ============================================================
   6. UTILITY CLASSES
   ============================================================ */

.jk-container {
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ============================================================
   7. HOMEPAGE LAYOUT WRAPPER
   ============================================================ */

.jk-homepage {
  max-width: var(--container-max-width);
  margin-inline: auto;
  display: grid;
  gap: 4rem;
  padding-block: 2rem;
  padding-inline: 1rem;
}

/* Remove Kadence's default inner content padding on the homepage */
.jk-homepage~* .content-wrap,
.home #inner-wrap>.content-wrap {
  padding: 0;
  max-width: none;
}


/* ============================================================
   8. HERO SECTION — TASK-003 (layout), TASK-004 (animation), TASK-005 (CTA)
   ============================================================ */

/* .jk-homepage-hero — no padding needed, homepage grid gap handles spacing */

.jk-hero__container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 3rem;
}

/* ── Text column ── */

.jk-hero__title {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--hero-accent);
  margin-bottom: .75rem;
}

.jk-hero__title span {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: .25rem;
}

.jk-hero__subtitle {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.jk-hero__description {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.jk-hero__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

/* ── Mascot column — TASK-004 ── */

.jk-hero__image {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Orange radial glow behind mascot */
.jk-hero__image::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 90%;
  height: 75%;
  margin: auto;
  background: var(--hero-accent);
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  z-index: 0;
}

.jk-hero__image img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  height: auto;
  transform: scaleX(-1);
  /* mirror mascot */
  animation: jkHeroFloat 4s ease-in-out infinite;
}

/* Floating animation — TASK-004 */
@keyframes jkHeroFloat {

  0%,
  100% {
    transform: scaleX(-1) translateY(0);
  }

  50% {
    transform: scaleX(-1) translateY(-12px);
  }
}

/* Respect reduced motion — LEAD_REFERENCE.md constraint */
@media (prefers-reduced-motion: reduce) {
  .jk-hero__image img {
    animation: none;
  }
}

/* ── Hero responsive ── */
@media (max-width: 768px) {
  .jk-hero__container {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .jk-hero__image {
    order: -1;
    /* image stacks above text on mobile */
    max-width: 320px;
    margin-inline: auto;
    margin-bottom: 1.5rem;
  }

  .jk-hero__buttons {
    justify-content: center;
  }

  .jk-hero__title {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .jk-hero__title {
    font-size: 1.75rem;
  }

  .jk-hero__title span {
    font-size: 1.2rem;
  }
}


/* ============================================================
   9. GLOBAL BUTTONS — TASK-005 (Browse Episodes CTA)
   Border radius: 12px standard, 24px pill, 999px badge
   ============================================================ */

.jk-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .8rem 1.75rem;
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.jk-btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.jk-btn--primary:hover,
.jk-btn--primary:focus-visible {
  background: var(--primary-700);
  border-color: var(--primary-700);
  color: #fff;
  transform: translateY(-2px);
}

.jk-btn--outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.jk-btn--outline:hover,
.jk-btn--outline:focus-visible {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

.jk-btn--pill {
  border-radius: var(--border-radius-pill);
}

.jk-btn--patreon {
  background: var(--patreon);
  color: #fff;
  border-color: var(--patreon);
}

.jk-btn--patreon:hover,
.jk-btn--patreon:focus-visible {
  background: var(--patreon-hover);
  border-color: var(--patreon-hover);
  color: #fff;
}


/* ============================================================
   10. STICKY AUDIO PLAYER — TASK-013
   ============================================================ */

.jk-sticky-player {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--primary);
  color: #fff;
  padding: .75rem 1.25rem;
  display: none;
  /* JS adds .active class to show */
  align-items: center;
  gap: 1rem;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .25);
  z-index: 9999;
}

.jk-sticky-player.active {
  display: flex;
}

.jk-sticky-player__title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.jk-sticky-player audio {
  flex-shrink: 0;
  width: 300px;
  max-width: 50%;
}

.jk-sticky-player__close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: .25rem .5rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: .8;
  transition: opacity .2s;
}

.jk-sticky-player__close:hover {
  opacity: 1;
}

@media (max-width: 600px) {
  .jk-sticky-player {
    flex-wrap: wrap;
  }

  .jk-sticky-player audio {
    width: 100%;
    max-width: 100%;
    order: 3;
  }
}


/* ============================================================
   11. BACK TO TOP — TASK-015
   ============================================================ */

.jk-back-to-top {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}

.jk-back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.jk-back-to-top:hover {
  background: var(--primary-700);
}


/* ============================================================
   12. SCROLL REVEAL — TASK-015
   Elements with .jk-reveal start invisible and slide up on enter.
   JS (IntersectionObserver) adds .revealed when in viewport.
   ============================================================ */

.jk-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .5s ease, transform .5s ease;
}

.jk-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .jk-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}