/* Non-Critical CSS - Loaded Asynchronously */

/* Wrap all text content to prevent overflow */
p, li, a, span, div {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Ensure long URLs and email addresses break */
a[href^="mailto:"],
a[href^="http"] {
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Sections */
section {
  padding: var(--spacing-md) 0;
  scroll-margin-top: 70px;
}

.section-description {
  font-size: clamp(1rem, 2vw, 1.1rem);
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Features Section */
.features {
  padding: var(--spacing-md) 0 var(--spacing-xl) 0;
}

.features > h2:first-of-type {
  position: relative;
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.features > h2:first-of-type::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.4;
}

/* Feature Card Layout */
.feature-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-xl);
  align-items: center;
  margin: var(--spacing-xl) 0;
}

.feature-screenshot {
  position: relative;
}

.feature-screenshot img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 600px;
  object-fit: contain;
  object-position: center;
  display: block;
  margin: 0 auto;
  border-radius: 16px;
  background: var(--bg-primary);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Carousel Container */
.carousel-container {
  max-width: 1100px;
  margin: var(--spacing-xl) auto;
  position: relative;
  outline: none;
}

.carousel-container:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.carousel-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: var(--bg-secondary);
  padding: var(--spacing-md);
  height: 65vh;
  min-height: 500px;
  max-height: 700px;
}

@media (max-width: 768px) {
  .carousel-wrapper {
    height: auto;
    min-height: auto;
    max-height: none;
  }
}

.carousel-track {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  height: 100%;
}

.carousel-slide {
  min-width: 100%;
  flex-shrink: 0;
  width: 100%;
  height: 100%;
}

.feature-card-carousel {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--spacing-xl);
  align-items: stretch;
  height: 100%;
}

.feature-screenshot-carousel {
  position: relative;
  order: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--spacing-sm);
  height: 100%;
  box-sizing: border-box;
}

.feature-screenshot-carousel img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 95%;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  display: block;
  margin: 0 auto;
  border-radius: 16px;
  background: var(--bg-primary);
  box-shadow: 0 6px 36px rgba(0, 0, 0, 0.15);
}

.feature-content-carousel {
  order: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: var(--spacing-md);
  padding-right: var(--spacing-lg);
  height: 100%;
  overflow-y: auto;
}

.feature-content-carousel h3 {
  font-size: clamp(1.3rem, 4vw, 2rem);
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--text-primary);
  font-weight: 700;
  position: relative;
  padding-bottom: var(--spacing-sm);
  flex-shrink: 0;
  display: inline-block;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.feature-content-carousel h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
}

.feature-list {
  list-style: disc;
  padding-left: 24px;
  padding-right: 24px;
  margin: var(--spacing-sm) 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.feature-list li {
  margin: 0 0 12px 0;
  line-height: 1.7;
  color: var(--text-primary);
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Carousel Controls */
.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  padding: 0 var(--spacing-md);
}

.carousel-button {
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  touch-action: manipulation;
}

.carousel-button:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  transform: scale(1.1);
}

.carousel-button:active:not(:disabled) {
  transform: scale(0.95);
}

.carousel-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.carousel-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.carousel-dots {
  display: flex;
  gap: 12px;
  align-items: center;
}

.carousel-dot {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: all 0.3s ease;
  flex-shrink: 0;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.carousel-dot::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  transition: all 0.3s ease;
}

.carousel-dot:hover::before {
  transform: scale(1.2);
  background: var(--accent);
  opacity: 0.6;
}

.carousel-dot.active::before {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-color: var(--accent);
}

.carousel-dot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Benefits Section */
.benefits {
  padding: var(--spacing-xl) 0;
  background: var(--surface);
  border-radius: 20px;
  margin: var(--spacing-lg) 0;
}

.benefits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
  max-width: 1200px;
  margin: 0 auto;
}

.benefit-item {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.benefit-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.benefit-item h3 {
  font-size: clamp(1.1rem, 3vw, 1.25rem);
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--text-primary);
  font-weight: 600;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.benefit-item p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* App Store Badge */
.app-store-badge {
  display: inline-block;
  transition: transform 0.2s ease, opacity 0.2s ease;
  text-decoration: none;
  line-height: 0;
}

.app-store-badge:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.app-store-badge:active {
  transform: translateY(0);
}

.app-store-badge-img {
  height: 60px;
  width: auto;
  display: block;
  max-width: 100%;
}

@media (max-width: 480px) {
  .app-store-badge-img {
    height: 50px;
  }
}

/* Show/hide badges based on color scheme */
.app-store-badge-dark {
  display: block;
}

.app-store-badge-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .app-store-badge-dark {
    display: none;
  }
  
  .app-store-badge-light {
    display: block;
  }
}

.hero-support {
  margin-top: var(--spacing-sm);
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* CTA Sections */
.features-cta,
.support-cta {
  text-align: center;
  margin: var(--spacing-xl) 0 var(--spacing-md) 0;
  padding: var(--spacing-md) 0;
}

.features-cta .button,
.support-cta .button {
  display: inline-block;
}

.notice strong {
  color: var(--accent);
}

/* Support Section */
.support {
  border-top: 1px solid var(--border);
  padding-top: var(--spacing-lg);
}

.support ol {
  margin: var(--spacing-sm) 0;
  padding-left: 24px;
}

.support ol li {
  margin: 0 0 8px 0;
  line-height: 1.6;
}

.support ul {
  margin: var(--spacing-sm) 0;
  padding-left: 24px;
}

.support ul li {
  margin: 0 0 8px 0;
  line-height: 1.6;
}

/* FAQ Items */
.faq-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--spacing-sm);
  background: var(--bg-secondary);
  margin: 12px 0;
  transition: all 0.2s;
}

.faq-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.faq-item summary:hover {
  background: var(--bg-primary);
}

.faq-item[open] summary {
  margin-bottom: var(--spacing-sm);
  color: var(--accent);
}

.faq-item p {
  padding: 0 8px;
  margin: 0;
  line-height: 1.6;
  color: var(--text-secondary);
}

.faq-item a {
  color: var(--accent);
  text-decoration: underline;
}

/* About Section */
.about {
  border-top: 1px solid var(--border);
  padding-top: var(--spacing-lg);
}

.about-story {
  margin: var(--spacing-md) 0;
}

.about-story p {
  margin: 0 0 var(--spacing-sm) 0;
  line-height: 1.7;
  color: var(--text-primary);
}

.easter-egg-note {
  font-style: italic;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
}

.about-bio {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border-radius: 16px;
}

.bio-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.bio-memoji {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bio-text {
  flex: 1;
  min-width: 200px;
}

.bio-text p {
  margin: 0 0 var(--spacing-sm) 0;
  line-height: 1.7;
  color: var(--text-primary);
}

.bio-links {
  margin-top: var(--spacing-sm);
  font-size: 0.95rem;
}

.bio-links a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.bio-links a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.about-contact {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
}

.about-contact p {
  margin: 0;
  line-height: 1.7;
  color: var(--text-primary);
}

/* Privacy Section */
.privacy {
  border-top: 1px solid var(--border);
  padding-top: var(--spacing-lg);
}

.privacy ul {
  margin: var(--spacing-sm) 0;
  padding-left: 24px;
}

.privacy ul li {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

.privacy strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--spacing-xl);
  background: var(--bg-secondary);
}

.site-footer .wrap {
  padding: var(--spacing-md);
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.site-footer a:hover {
  opacity: 0.8;
}

/* Responsive - Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
  .feature-card-carousel {
    gap: var(--spacing-lg);
  }

  .feature-content-carousel h3 {
    font-size: clamp(1.5rem, 3.5vw, 1.75rem);
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  section {
    padding: var(--spacing-sm) 0;
  }

  .features {
    padding: var(--spacing-sm) 0 var(--spacing-lg) 0;
  }

  .features > h2:first-of-type {
    font-size: clamp(1.3rem, 5vw, 1.5rem);
    margin-bottom: var(--spacing-md);
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .carousel-wrapper {
    padding: var(--spacing-md);
    height: auto;
    min-height: auto;
    max-height: none;
  }

  .carousel-track {
    height: auto;
  }

  .carousel-slide {
    height: auto;
  }

  .feature-card-carousel {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    min-height: auto;
    height: auto;
  }

  .feature-screenshot-carousel {
    order: 1;
    padding: var(--spacing-sm);
    min-height: auto;
    height: auto;
    max-height: 40vh;
  }

  .feature-content-carousel {
    order: 2;
    padding: var(--spacing-sm);
    overflow-y: visible;
    height: auto;
    min-height: 0;
  }

  .feature-screenshot-carousel img {
    height: auto;
    max-height: 100%;
    width: 100%;
    object-fit: contain;
  }

  .feature-content-carousel h3 {
    font-size: clamp(1.3rem, 5vw, 1.5rem);
    margin: 0 0 var(--spacing-sm) 0;
  }

  .feature-list {
    padding-left: 20px;
    margin: var(--spacing-sm) 0;
    overflow-y: visible;
    min-height: 0;
  }

  .feature-list li {
    font-size: clamp(0.9rem, 3vw, 0.95rem);
    margin: 0 0 10px 0;
  }

  .carousel-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.75rem;
  }

  .carousel-dot {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .carousel-dot::before {
    width: 10px;
    height: 10px;
  }

  .carousel-dot.active::before {
    width: 12px;
    height: 12px;
  }

  .benefits {
    padding: var(--spacing-md) 0;
    margin: var(--spacing-md) 0;
    border-radius: 16px;
  }

  .benefits-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .benefit-item {
    padding: var(--spacing-sm);
  }

  .benefit-item h3 {
    font-size: 1.1rem;
  }

  .support h1,
  .about h1,
  .privacy h1 {
    font-size: clamp(1.5rem, 6vw, 1.8rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .about-story p {
    font-size: clamp(0.95rem, 2.5vw, 1rem);
  }

  .about-bio {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm);
  }

  .bio-content {
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-sm);
  }

  .bio-memoji {
    width: 100px;
    height: 100px;
    margin: 0 auto;
  }

  .bio-text {
    min-width: auto;
  }

  .faq-item {
    padding: 12px;
  }

  .site-footer .wrap {
    text-align: center;
    padding: var(--spacing-md) var(--spacing-sm);
  }
}

@media (max-width: 480px) {
  .feature-content-carousel h3 {
    font-size: clamp(1.2rem, 5vw, 1.3rem);
  }

  .feature-list li {
    font-size: clamp(0.85rem, 3vw, 0.9rem);
  }

  .feature-screenshot img {
    max-height: 300px;
  }

  .feature-screenshot-carousel img {
    max-height: 100%;
    max-width: 100%;
  }

  .carousel-wrapper {
    padding: var(--spacing-sm);
  }

  .carousel-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.5rem;
  }

  .notice {
    padding: 12px;
    font-size: clamp(0.8rem, 3vw, 0.85rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Very Small Screens (< 360px) */
@media (max-width: 360px) {
  .wrap {
    padding: 0 0.75rem;
  }

  .site-header .wrap {
    padding: 12px 0.75rem;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .carousel-wrapper {
    padding: 0.75rem;
  }

  .feature-content-carousel {
    padding: 0.75rem;
  }

  .feature-screenshot-carousel {
    padding: 0.75rem;
  }

  .carousel-controls {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }

  .carousel-button {
    width: 44px;
    height: 44px;
  }

  .section-description {
    font-size: 0.9rem;
  }
}

/* Print Styles */
@media print {
  .site-header,
  .site-footer,
  .skip-link {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .feature-screenshot-carousel img {
    max-height: 400px;
  }
}
