/* ==========================================================================
   TomeWorlds.com - Main Stylesheet
   Single-page marketing microsite for TomeWorlds iOS app
   ========================================================================== */

/* ==========================================================================
   1. Design Tokens (CSS Custom Properties)
   ========================================================================== */

:root {
  /* Color Palette - Backgrounds */
  --color-bg-primary: #0D0D0F;
  --color-bg-secondary: #16161A;
  --color-bg-tertiary: #1E1E24;

  /* Color Palette - Text */
  --color-text-primary: #EFEFEF;
  --color-text-secondary: #A0A0A8;
  --color-text-tertiary: #6B6B74;

  /* Color Palette - Accents */
  --color-accent-primary: #c12843;
  --color-accent-primary-hover: #d64560;
  --color-accent-secondary: #74b9ad;
  --color-accent-tertiary: #FF6B9D;

  /* Gradients */
  --color-gradient-start: #c12843;
  --color-gradient-end: #74b9ad;
  --gradient-text: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));

  /* Typography - Font Families */
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: "SF Pro Text", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, monospace;

  /* Typography - Font Sizes (using clamp for fluid sizing) */
  --text-hero: clamp(2.5rem, 8vw, 4.5rem);
  --text-h1: clamp(2rem, 5vw, 3rem);
  --text-h2: clamp(1.5rem, 3vw, 2rem);
  --text-h3: 1.25rem;
  --text-body: 1.0625rem;
  --text-body-small: 0.9375rem;
  --text-caption: 0.8125rem;

  /* Spacing Scale */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */
  --space-3xl: 4rem;     /* 64px */
  --space-4xl: 6rem;     /* 96px */
  --space-5xl: 8rem;     /* 128px */

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(124, 92, 255, 0.3);

  /* Layout */
  --container-max: 1120px;
  --container-padding: clamp(1rem, 5vw, 2rem);
  --section-spacing: clamp(4rem, 10vw, 8rem);
  --nav-height: 64px;
}

/* ==========================================================================
   2. Base / Reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul,
ol {
  list-style: none;
}

/* ==========================================================================
   3. Accessibility
   ========================================================================== */

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent-primary);
  color: white;
  z-index: 1001;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* Focus states */
:focus-visible {
  outline: 2px solid var(--color-accent-primary);
  outline-offset: 2px;
}

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

  html {
    scroll-behavior: auto;
  }
}

/* ==========================================================================
   4. Layout Utilities
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.section {
  padding-top: var(--section-spacing);
  padding-bottom: var(--section-spacing);
}

.section--alt {
  background-color: var(--color-bg-secondary);
}

/* ==========================================================================
   5. Typography
   ========================================================================== */

.text-hero {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.text-h1 {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.text-h2 {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.text-h3 {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 600;
  line-height: 1.3;
}

.text-body {
  font-size: var(--text-body);
  line-height: 1.6;
}

.text-body-small {
  font-size: var(--text-body-small);
  line-height: 1.5;
}

.text-caption {
  font-size: var(--text-caption);
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-tertiary {
  color: var(--color-text-tertiary);
}

.text-center {
  text-align: center;
}

.text-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================================================
   6. Components - Navigation
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(13, 13, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.nav.scrolled {
  border-bottom-color: var(--color-bg-tertiary);
  background: rgba(13, 13, 15, 0.95);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav__logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.nav__logo-text {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.nav__cta {
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  background: white;
  color: #0D0D0F;
  font-weight: 600;
  border-radius: var(--radius-full);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.nav__cta:hover {
  background: #E8E8E8;
  transform: scale(1.02);
}

/* ==========================================================================
   7. Components - Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-xl);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  min-height: 44px;
  min-width: 44px;
}

.btn--primary {
  background: var(--color-accent-primary);
  color: white;
}

.btn--primary:hover {
  background: var(--color-accent-primary-hover);
  transform: scale(1.02);
}

.btn--ghost {
  color: var(--color-text-tertiary);
}

.btn--ghost:hover {
  color: var(--color-accent-primary);
}

/* App Store Badge */
.app-store-badge {
  display: inline-block;
  transition: transform 0.2s ease;
}

.app-store-badge:hover {
  transform: scale(1.02);
}

.app-store-badge img {
  height: 52px;
  width: auto;
}

/* ==========================================================================
   8. Components - Cards
   ========================================================================== */

.card {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card__icon {
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-md);
  color: var(--color-accent-primary);
  object-fit: contain;
}

.card__title {
  margin-bottom: var(--space-sm);
}

.card__body {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   9. Section - Hero
   ========================================================================== */

.hero {
  position: relative;
  padding-top: calc(var(--nav-height) + var(--space-5xl));
  padding-bottom: var(--space-4xl);
  background:
    radial-gradient(ellipse at center top, rgba(124, 92, 255, 0.05) 0%, transparent 50%),
    var(--color-bg-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  top: -8%;
  right: -10%;
  width: 900px;
  height: auto;
  object-fit: contain;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.hero__inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3xl);
  align-items: center;
}

@media (min-width: 900px) {
  .hero__inner {
    grid-template-columns: 1fr 1fr;
  }
}

.hero__content {
  max-width: 560px;
}

.hero__logo {
  height: 80px;
  width: auto;
  margin-bottom: var(--space-lg);
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-lg);
}

.hero__eyebrow::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--color-accent-primary);
  border-radius: 50%;
}

.hero__headline {
  margin-bottom: var(--space-lg);
}

.hero__subheadline {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

.hero__cta-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  align-items: flex-start;
}

.hero__cta-secondary {
  color: var(--color-text-tertiary);
  font-size: var(--text-body-small);
  transition: color 0.2s ease;
}

.hero__cta-secondary:hover {
  color: var(--color-accent-primary);
}

.hero__device {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero__mockup {
  max-width: 320px;
  width: 100%;
  transform-style: preserve-3d;
  transform: perspective(1000px) rotateX(0deg) rotateY(0deg);
  transition: transform 0.1s ease-out;
  filter: drop-shadow(var(--shadow-lg));
  will-change: transform;
}

.hero__mockup.tilt-reset {
  transition: transform 0.5s ease-out;
}

.hero__mockup-placeholder {
  width: 100%;
  aspect-ratio: 9/19.5;
  background: linear-gradient(135deg, var(--color-bg-secondary), var(--color-bg-tertiary));
  border-radius: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-caption);
}

.hero__mockup-image {
  width: 100%;
  height: auto;
  border-radius: 40px;
  display: block;
}

/* ==========================================================================
   10. Section - Problem Statement
   ========================================================================== */

.problem {
  position: relative;
  text-align: left;
  overflow: hidden;
}

.problem__bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 700px;
  height: auto;
  object-fit: contain;
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
}

.problem__content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.problem__header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.problem__headline {
  margin-bottom: 0;
}

.problem__icon {
  height: 80px;
  width: auto;
  flex-shrink: 0;
}

.problem__body {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   11. Section - Features
   ========================================================================== */

.features__header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.features__eyebrow {
  font-size: var(--text-caption);
  color: var(--color-accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

.features__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

@media (min-width: 768px) {
  .features__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .features__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Feature card icon colors */
.features__grid .card:nth-child(1) .card__icon { color: var(--color-accent-primary); }
.features__grid .card:nth-child(2) .card__icon { color: var(--color-accent-tertiary); width: 40px; height: 40px; }
.features__grid .card:nth-child(3) .card__icon { color: #FFFFFF; width: 40px; height: 40px; }
.features__grid .card:nth-child(4) .card__icon { color: #FFFFFF; }
.features__grid .card:nth-child(5) .card__icon { color: var(--color-accent-primary); }
.features__grid .card:nth-child(6) .card__icon { color: var(--color-accent-secondary); }

/* ==========================================================================
   12. Section - Screenshots
   ========================================================================== */

.screenshots {
  overflow: hidden;
}

.screenshots__header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.screenshots__gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-md) 0;
  margin: 0 calc(var(--container-padding) * -1);
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.screenshots__gallery::-webkit-scrollbar {
  display: none;
}

.screenshots__item {
  flex: 0 0 auto;
  width: 280px;
  scroll-snap-align: start;
}

.screenshots__image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: block;
  object-fit: cover;
}

/* ==========================================================================
   13. Section - Use Cases
   ========================================================================== */

.use-cases__header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.use-cases__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

@media (min-width: 768px) {
  .use-cases__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .use-cases__grid .card:last-child {
    grid-column: span 2;
    max-width: 560px;
    margin: 0 auto;
  }
}

.use-case__icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  color: var(--color-accent-primary);
}

.use-cases__grid .card:nth-child(2) .use-case__icon { color: var(--color-accent-secondary); }
.use-cases__grid .card:nth-child(3) .use-case__icon { color: var(--color-accent-tertiary); }

.use-case__title {
  margin-bottom: var(--space-sm);
}

.use-case__body {
  color: var(--color-text-secondary);
}

/* ==========================================================================
   14. Section - Comparison
   ========================================================================== */

.comparison__header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.comparison__subheadline {
  color: var(--color-text-secondary);
  margin-top: var(--space-md);
}

.comparison__points {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  align-items: center;
  margin-bottom: var(--space-2xl);
}

@media (min-width: 768px) {
  .comparison__points {
    flex-direction: row;
    justify-content: center;
  }
}

.comparison__point {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.comparison__check {
  width: 24px;
  height: 24px;
  color: var(--color-accent-tertiary);
}

.comparison__seo {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-body-small);
}

/* ==========================================================================
   15. Section - FAQ
   ========================================================================== */

.faq__header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.faq__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  max-width: 800px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .faq__grid {
    gap: var(--space-2xl);
  }
}

.faq__item {
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-bg-tertiary);
}

.faq__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq__question {
  color: var(--color-text-primary);
  margin-bottom: var(--space-md);
}

.faq__answer {
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   16. Section - Download CTA
   ========================================================================== */

.download {
  text-align: center;
}

.download__headline {
  margin-bottom: var(--space-md);
}

.download__subheadline {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

.download__devices {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  color: var(--color-text-tertiary);
  font-size: var(--text-caption);
}

.download__device-icon {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   16. Footer
   ========================================================================== */

.footer {
  background: var(--color-bg-secondary);
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--color-bg-tertiary);
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
}

@media (min-width: 768px) {
  .footer__inner {
    flex-direction: row;
    justify-content: space-between;
  }
}

.footer__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-body-small);
}

.footer__logo-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.footer__links {
  display: flex;
  gap: var(--space-xl);
}

.footer__link {
  color: var(--color-text-tertiary);
  font-size: var(--text-body-small);
  transition: color 0.2s ease;
}

.footer__link:hover {
  color: var(--color-text-secondary);
}

.footer__copyright {
  width: 100%;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--text-caption);
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-bg-tertiary);
}

@media (min-width: 768px) {
  .footer__copyright {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
  }
}

/* ==========================================================================
   17. Animations
   ========================================================================== */

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered hero animations */
.hero__eyebrow {
  animation: fadeInDown 0.5s ease-out;
  animation-fill-mode: both;
}

.hero__headline {
  animation: fadeInDown 0.5s ease-out 0.15s;
  animation-fill-mode: both;
}

.hero__subheadline {
  animation: fadeInDown 0.5s ease-out 0.3s;
  animation-fill-mode: both;
}

.hero__cta-group {
  animation: fadeInDown 0.5s ease-out 0.45s;
  animation-fill-mode: both;
}

.hero__device {
  animation: fadeInDown 0.6s ease-out 0.6s;
  animation-fill-mode: both;
}

/* ==========================================================================
   18. Utility Classes
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   19. Scroll Fade-In Animations
   ========================================================================== */

.fade-in-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children animation */
.fade-in-section.is-visible .card,
.fade-in-section.is-visible .faq__item,
.fade-in-section.is-visible .comparison__point {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.fade-in-section.is-visible .card:nth-child(1),
.fade-in-section.is-visible .faq__item:nth-child(1),
.fade-in-section.is-visible .comparison__point:nth-child(1) { animation-delay: 0.1s; }

.fade-in-section.is-visible .card:nth-child(2),
.fade-in-section.is-visible .faq__item:nth-child(2),
.fade-in-section.is-visible .comparison__point:nth-child(2) { animation-delay: 0.2s; }

.fade-in-section.is-visible .card:nth-child(3),
.fade-in-section.is-visible .faq__item:nth-child(3),
.fade-in-section.is-visible .comparison__point:nth-child(3) { animation-delay: 0.3s; }

.fade-in-section.is-visible .card:nth-child(4),
.fade-in-section.is-visible .faq__item:nth-child(4) { animation-delay: 0.4s; }

.fade-in-section.is-visible .card:nth-child(5),
.fade-in-section.is-visible .faq__item:nth-child(5) { animation-delay: 0.5s; }

.fade-in-section.is-visible .card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
