/* Main CSS - Layout and Core Styles */

/* Lausanne font-face declarations */
@font-face {
  font-family: 'Lausanne';
  src: url('../public/fonts/Lausanne-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lausanne';
  src: url('../public/fonts/Lausanne-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lausanne';
  src: url('../public/fonts/Lausanne-Semibold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lausanne';
  src: url('../public/fonts/Lausanne-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Colors */
  --color-bg: #0D0D0D;
  --color-bg-card: #1A1A1A;
  --color-white: #FFFFFF;
  --color-gold: #B2955C;
  --color-blue: #7EB5D6;
  --color-orange: #E85D3C;
  --color-grid: #2A2A2A;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #9A9A9A;
  --color-text-accent: #B2955C;

  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 40px;
  --spacing-xl: 64px;

  /* Chart dimensions */
  --chart-width: 960px;
  --chart-height: 540px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: 'Lausanne', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Scrollytelling Layout */
.scrollytelling-container {
  position: relative;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
}

.chart-wrapper {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* Brand Logo */
.brand-logo {
  position: absolute;
  top: 24px;
  left: 32px;
  z-index: 10;
  opacity: 0.9;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.brand-logo:hover {
  opacity: 1;
}

.brand-logo img {
  height: 32px;
  width: auto;
  display: block;
  filter: invert(1);
}

.chart-container {
  width: var(--chart-width);
  height: var(--chart-height);
  max-width: 60vw;
  max-height: 70vh;
  position: absolute;
  right: 5%;
  transition: opacity 0.4s ease;
  z-index: 1;
}

/* Scroll Steps */
.scroll-steps {
  position: relative;
  z-index: 2;
  pointer-events: none;
  margin-top: -100vh; /* Pull up to overlap with sticky chart */
}

.step {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: var(--spacing-xl);
  padding-left: 8%;
}

.step-content {
  max-width: 420px;
  pointer-events: auto;
  background: rgba(13, 13, 13, 0.85);
  padding: var(--spacing-md);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

/* CTA Step - centered */
.step-cta {
  justify-content: center;
  padding-left: var(--spacing-xl);
}

.step-cta .step-content {
  max-width: 600px;
  text-align: center;
  background: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: var(--spacing-lg);
}

/* Grid View Container - single card displayed at a time */
#grid-view,
.grid-container {
  display: none;
  width: 100%;
  max-width: 100%;
  padding: 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.4s ease;
  z-index: -1; /* Start behind main chart, JS will bring to front when active */
}

.grid-chart {
  background: var(--color-bg-card);
  border-radius: 0;
  padding: var(--spacing-lg);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: visible;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.grid-chart .concentration-chart {
  width: 100%;
  height: 100%;
}

/* Active step indicator */
.step.step-active .step-content {
  /* Optional: add subtle highlight for active step */
}

/* Grid step - taller to allow scrolling through 3 cards */
.step[data-step="grid"] {
  min-height: 300vh;
  align-items: flex-start;
}

.step[data-step="grid"] .step-content {
  position: sticky;
  top: 24px;
  transform: none;
  margin-top: 50vh;
}

/* Responsive */
@media (max-width: 1400px) {
  .chart-container {
    max-width: 55vw;
    right: 3%;
  }

  .step {
    padding-left: 5%;
  }

  .step-content {
    max-width: 380px;
  }
}

@media (max-width: 1200px) {
  :root {
    --chart-width: 800px;
    --chart-height: 450px;
  }

  .chart-container {
    max-width: 50vw;
  }
}

@media (max-width: 1024px) {
  /* Stack layout on tablet */
  .chart-wrapper {
    align-items: flex-start;
    padding-top: 10vh;
  }

  .chart-container {
    position: relative;
    right: auto;
    max-width: 90vw;
    max-height: 45vh;
  }

  .step {
    padding: var(--spacing-lg);
    padding-top: 55vh;
    align-items: flex-start;
  }

  .step-content {
    max-width: 100%;
    background: rgba(13, 13, 13, 0.95);
  }

  #grid-view,
  .grid-container {
    grid-template-columns: 1fr;
    max-width: 90vw;
  }
}

@media (max-width: 768px) {
  :root {
    --chart-width: 100%;
    --chart-height: 280px;
  }

  /* Stack logo above chart in column layout */
  .chart-wrapper {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 24px;
  }

  .brand-logo {
    position: static;
    align-self: flex-start;
    margin-left: 16px;
    margin-bottom: 12px;
    z-index: auto;
  }

  .brand-logo img {
    height: 36px;
  }

  .brand-logo.scrolled-away {
    opacity: 0;
    transform: translateY(-100%);
    pointer-events: none;
  }

  .chart-container {
    max-width: 100vw;
    max-height: 50vh;
  }

  .step {
    padding: var(--spacing-sm) var(--spacing-md);
    padding-top: 56vh;
    min-height: 80vh;
  }

  .step-content {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .step-cta {
    padding-left: var(--spacing-md);
  }

  .step-cta .step-content {
    padding: var(--spacing-md);
  }

  .step[data-step="grid"] {
    min-height: 250vh;
  }

  .step[data-step="grid"] .step-content {
    margin-top: 52vh;
  }

  .scroll-indicator {
    bottom: 24px;
    font-size: 12px;
  }

  .scroll-indicator svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  .chart-wrapper {
    padding-top: 20px;
  }

  .brand-logo {
    margin-left: 12px;
  }

  .brand-logo img {
    height: 32px;
  }

  .chart-container {
    max-height: 45vh;
    max-width: 100vw;
  }

  .step {
    padding: var(--spacing-xs) var(--spacing-sm);
    padding-top: 50vh;
    min-height: 75vh;
  }
}

/* Sticky Footer CTA */
.sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sticky-footer.visible {
  transform: translateY(0);
}

.sticky-footer-inner {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px 32px;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(178, 149, 92, 0.3);
}

.sticky-footer-text {
  font-family: 'Lausanne', sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: var(--color-text-primary);
}

.sticky-footer-button {
  font-family: 'Lausanne', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-bg);
  background: var(--color-gold);
  padding: 10px 24px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sticky-footer-button:hover {
  background: #C4A86E;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .sticky-footer-inner {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    text-align: center;
  }

  .sticky-footer-text {
    font-size: 14px;
  }

  .sticky-footer-button {
    width: 100%;
    text-align: center;
    padding: 12px 20px;
    font-size: 15px;
  }
}

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

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.5s ease;
  z-index: 10;
}

.scroll-indicator svg {
  animation: bounceDown 1.5s ease-in-out infinite;
}

.scroll-indicator.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes bounceDown {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

/* Text Fade-In Animation */
/* First step starts hidden and fades in via JS trigger */
[data-step="orientation"] .step-content {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease-out, transform 1s ease-out;
}

[data-step="orientation"] .step-content.visible {
  opacity: 1;
  transform: translateY(0);
}

/* All other steps are visible by default */
.step:not([data-step="orientation"]) .step-content {
  opacity: 1;
}

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

/* 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;
}
