:root { 
  --color-ceramic: #fcfcfc;
  --color-obsidian: hsl(0, 5%, 7%);
  --color-hermes: hsl(24, 91%, 51%);

  --color-background: var(--color-ceramic);
  --color-text: var(--color-obsidian);
  --color-accent: var(--color-hermes);
  --color-accent-rgb: 255, 136, 0;

  /* Define a modular scale for typography */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  
  /* Line heights */
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Font weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-background: var(--color-obsidian);
    --color-text: var(--color-ceramic);
    --color-accent: hsl(24, 91%, 66%);
    --color-accent-rgb: 255, 153, 51;
  }
}

html, body {
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background-color: var(--color-background);
  color: var(--color-text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
  padding: 0 16px;
}

.page-wrapper {
  width: 100%;
  max-width: 800px;
  height: auto; /* changed from 100vh */
  max-height: 100vh; /* ensure it fits */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4vh 0; /* reduced padding */
  box-sizing: border-box;
  gap: 2vh;
}

.header {
  text-align: center;
  flex-shrink: 0;
  width: 100%;
  margin-bottom: 0;
}

.tagline {
  color: var(--color-text);
  text-align: center;
  font-size: clamp(var(--text-xl), 3vh, var(--text-2xl));
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  margin: 0 0 0.5vh 0;
}

.tagline span {
  color: var(--color-text);
  font-weight: var(--font-normal);
}

.subtag {
  color: var(--color-text);
  text-align: center;
  font-size: clamp(var(--text-sm), 2vh, var(--text-base));
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  margin: 0;
  opacity: 0.8;
}

.subtag span {
  color: var(--color-accent);
  font-weight: var(--font-medium); /* slightly bolder */
}

.content-container {
  width: 100%;
  max-width: 500px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto; /* don't grow or shrink */
  overflow: visible;
}

.overlap-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

.device-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 70vw; /* Limit width for large screens */
  height: auto;
  max-height: 40vh;
  margin: 0 auto 1vh;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  aspect-ratio: 3/4;
}

.features-container {
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: auto;
  flex-shrink: 0;
}

.feature {
  margin: 0 auto;
  transition: all 0.3s ease;
  padding: 1vh;
  border-radius: 4px;
  position: relative;
  opacity: 0;
  width: fit-content;
  max-width: 100%;
  display: none;
  text-align: center;
}

@keyframes progress {
  from { 
    width: 0; 
    left: 50%;
  }
  to { 
    width: calc(100% - 16px); 
    left: 50%;
  }
}

.feature.active {
  opacity: 1;
  position: relative;
  display: block;
}

.feature.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  height: 2px;
  width: 0;
  background-color: var(--color-accent);
  animation: progress 5s linear forwards;
  transform: translateX(-50%);
  max-width: calc(100% - 16px);
}

.feature h3 {
  margin: 0 0 0.25rem 0;
  font-size: clamp(var(--text-base), 2vh, var(--text-lg));
  font-weight: var(--font-medium);
  color: var(--color-text);
  transition: transform 0.3s ease;
}

.feature p {
  margin: 0;
  font-size: clamp(var(--text-xs), 1.5vh, var(--text-sm));
  line-height: var(--leading-normal);
  opacity: 0.8;
}

.feature h3, .feature p {
  width: 100%;
  text-align: center;
  max-width: 100%;
  white-space: normal;
}

.app-store-badge {
  height: 40px;
  width: auto;
  transition: transform 0.2s ease;
}

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

.footer {
  width: 100%;
  max-width: 1000px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 1vh;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 0.5vh;
}

.footer-links a {
  color: var(--color-text);
  text-decoration: none;
  opacity: 0.6;
  font-size: clamp(10px, 1.5vh, var(--text-xs));
}

.footer-links a:hover {
  color: var(--color-accent);
  opacity: 1;
}

.footer-copyright {
  color: var(--color-text);
  opacity: 0.6;
  font-size: clamp(10px, 1.5vh, var(--text-xs));
}

#video-player, .demo-youtube {
  position: absolute;
  width: 260%;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

/* For landscape mode */
@media (orientation: landscape) and (max-height: 500px) {
  .device-container {
    max-height: 70vh;
    max-width: 30vw; /* Narrower container in landscape */
  }

  .demo-youtube {
    width: 110%; /* Less aggressive cropping for landscape */
  }
}

/* Extra tall screens */
@media (min-aspect-ratio: 1/2) and (min-height: 800px) {
  .device-container {
    max-height: 45vh;
  }
}

/* Extra short screens */
@media (max-height: 600px) {
  .page-wrapper {
    padding: 2vh 0;
    gap: 1vh;
  }
  
  .device-container {
    max-height: 35vh;
  }
  
  .feature {
    padding: 0.5vh;
  }
  
  .footer-links {
    gap: 10px;
  }
  
  .footer-links a, .footer-copyright {
    font-size: 10px;
  }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
  .page-wrapper {
    flex-direction: row;
    justify-content: center;
    padding: 2vh 2vw;
    gap: 2vw;
    align-items: center;
  }
  
  .header {
    width: 25%;
    text-align: left;
    margin-bottom: 0;
  }
  
  .content-container {
    width: 40%;
    margin: 0 2vw;
  }
  
  .device-container {
    max-height: 70vh;
    margin-bottom: 0;
  }
  
  .footer {
    width: auto;
    margin-top: 0;
    position: static; /* not absolute anymore */
  }
  
  .cta {
    margin: 1vh 0;
  }
}
