/* CoffeeWatch Mobile CSS - Non-invasive mobile styles */
/* Only affects screens ≤ 1024px, preserving desktop experience */
/* Version 2.0 - Enhanced with continued optimization fixes */

/* Global box-sizing and text adjustment */
@media (max-width: 1024px) {
  html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }

  *, *::before, *::after {
    box-sizing: inherit;
  }
}

/* CSS Variables for consistent spacing and safe areas */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* Safe area variables for notched devices */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Dynamic header height */
  --header-height-mobile: 60px;

  /* Z-index system to prevent stacking issues */
  --z-base: 1;
  --z-content: 10;
  --z-dropdown: 100;
  --z-sticky: 500;
  --z-fixed: 1000;
  --z-modal-backdrop: 8000;
  --z-modal: 9000;
  --z-header: 9999;
}

/* Mobile-specific utilities */
@media (max-width: 1024px) {
  /* Critical: Prevent horizontal scroll at root level */
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  body {
    position: relative;
    min-height: 100vh;
  }

  /* Ensure proper stacking order for all sections */
  section {
    position: relative;
    isolation: isolate; /* Create new stacking context */
  }

  /* Container adjustments with safe overflow */
  .coffeewatch-container {
    max-width: 100%;
    width: 100%;
    position: relative;
  }

  /* Touch-friendly tap highlights */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Fix for viewport height issues (100vh problem) */
  .full-viewport, .hero-section {
    min-height: 100vh;
    min-height: 100svh; /* Small viewport height - iOS 15+ */
  }

  @supports (height: 100dvh) {
    .full-viewport, .hero-section {
      min-height: 100dvh; /* Dynamic viewport height - modern browsers */
    }
  }

  /* Ensure images and media don't cause overflow or overlaps */
  img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
    display: block;
    position: relative; /* Prevent absolute positioning issues */
    z-index: 1; /* Base z-index for images */
  }

  /* Ensure text content is always above images */
  p, h1, h2, h3, h4, h5, h6, .hero-text, .feature-text {
    position: relative;
    z-index: 2;
  }

  /* Fix for long words causing overflow */
  p, h1, h2, h3, h4, h5, h6, li, td, th {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
  }
}

/* Small tablets and large phones (481px - 768px) */
@media (max-width: 768px) {

  /* Header Section Mobile - Fixed with safe areas and proper stacking */
  .header-section {
    position: fixed !important; /* 避免 sticky 造成的额外占位空白 */
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(var(--header-height-mobile) + var(--safe-top));
    padding: var(--safe-top) 20px 0 20px;
    z-index: var(--z-header); /* Ensure header is always on top */
    background-color: #F9F6F2;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform: translateZ(0); /* Force hardware acceleration */
    will-change: transform;
  }

  .logo-section {
    gap: 8px;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
  }

  .logo-text {
    font-size: 20px;
    line-height: 24px;
  }

  .download-button {
    width: 100px;
    height: 32px;
  }

  /* Hero Section Mobile - Fixed visibility and overflow issues */
  .hero-section {
    margin-top: calc(var(--header-height-mobile) + var(--safe-top));
    height: auto;
    min-height: calc(100vh - var(--header-height-mobile) - var(--safe-top));
    min-height: calc(100svh - var(--header-height-mobile) - var(--safe-top));
    border-radius: 0;
    margin-left: 0;
    margin-right: 0;
    position: relative;
    overflow: visible; /* Ensure content is not clipped */
    /* Lighten top overlay to avoid excessive dark area on mobile */
    background: linear-gradient(180deg, rgba(147, 98, 78, 0.28) 0%, rgba(0, 0, 0, 0) 70%) !important;
  }

  @supports (height: 100dvh) {
    .hero-section {
      min-height: calc(100dvh - var(--header-height-mobile) - var(--safe-top));
    }
  }

  .hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    /* Disable dark multiply effect on mobile to reduce black area */
    mix-blend-mode: normal !important;
    opacity: 1 !important;
    filter: brightness(1.06);
  }

  .hero-content {
    position: relative;
    z-index: 1;
    padding: 40px 20px 20px; /* 合理的顶部间距，避免内容太靠上 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* 从顶部开始排列，避免垂直居中造成的空白 */
    min-height: auto; /* 不强制最小高度，让内容自然流动 */
  }

  .hero-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px; /* 缩小与标题的间距 */
  }

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

  /* Hero text - Optimized for mobile readability */
  .hero-text {
    text-align: center;
    padding: 0 16px;
    max-width: 100%;
  }

  .hero-text h1 {
    font-size: clamp(26px, 7vw, 32px); /* Better mobile scaling */
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance; /* Auto-balance line breaks */
    margin-bottom: 12px;
    font-weight: 700;
  }

  .hero-text h1 span {
    display: block;
  }

  .hero-text h1 span:first-child {
    font-size: clamp(22px, 5.5vw, 28px);
    margin-bottom: 4px;
    opacity: 0.95;
  }

  .hero-text h1 span:last-child {
    font-size: clamp(24px, 6vw, 30px);
  }

  .hero-text p {
    font-size: clamp(14px, 3.8vw, 16px);
    line-height: 1.5;
    max-width: 35ch;
    margin: 8px auto 20px;
    opacity: 0.9;
    padding: 0;
  }

  /* App Store CTA Button - Properly centered and accessible */
  .app-store-badge {
    position: relative !important;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    margin: 16px auto 24px;
    z-index: 10;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    top: auto !important;
  }

  /* Ensure button image is responsive */
  .app-store-badge img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
  }

  /* Touch feedback for CTA */
  .app-store-badge:active {
    transform: scale(0.96) !important;
    opacity: 0.9;
  }

  /* Force override any absolute positioning */
  .hero-section .app-store-badge[style*="position: absolute"],
  .hero-section .app-store-badge[style*="position:absolute"] {
    position: relative !important;
    inset: auto !important;
    transform: none !important;
  }

  /* Features Section Mobile - Fixed overflow and visibility */
  .features-section {
    padding: 30px 20px; /* 减少上下padding避免大片空白 */
    overflow: visible;
    position: relative;
    background-color: #FAF7F4; /* 确保背景不透明，避免内容重叠 */
    z-index: 2; /* 确保在hero之上 */
  }

  .features-section h2 {
    font-size: clamp(24px, 5vw, 28px);
    text-align: center;
    margin-bottom: 30px;
    word-wrap: break-word;
  }

  .features-container {
    gap: 30px;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .feature-item {
    display: flex;
    flex-direction: column !important;
    gap: 20px;
    text-align: center;
    overflow: visible;
    position: relative;
  }

  .feature-item.reverse {
    flex-direction: column !important;
  }

  .feature-item img {
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto;
    border-radius: 20px;
    display: block;
  }

  .feature-text {
    padding: 0;
  }

  .feature-text h3 {
    font-size: clamp(18px, 4vw, 22px);
    margin-bottom: 12px;
  }

  .feature-text p {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
  }

  .divider {
    width: 60%;
    margin: 20px auto;
  }

  /* Apple Watch Section Mobile */
  .watch-section {
    padding: 30px 20px; /* 减少padding避免空白 */
    text-align: center;
    position: relative;
    z-index: 2;
    background-color: #FAF7F4; /* 确保背景不透明 */
  }

  .watch-section h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin-bottom: 16px;
  }

  .watch-section p {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
    margin-bottom: 24px;
  }

  .watch-section img {
    width: 100%;
    max-width: 320px;
    height: auto;
  }

  /* iOS Widgets Section Mobile */
  .widgets-section {
    padding: 30px 20px; /* 减少padding */
    text-align: center;
    position: relative;
    z-index: 2;
    background-color: #FAF7F4;
  }

  .widgets-section h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin-bottom: 16px;
  }

  .widgets-section p {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
    margin-bottom: 24px;
  }

  .widgets-section img {
    width: 100%;
    max-width: 320px;
    height: auto;
  }

  /* Smart Reminders Section Mobile */
  .reminders-section {
    display: flex;
    flex-direction: column;
    padding: 30px 20px; /* 减少padding */
    gap: 20px;
    text-align: center;
    position: relative;
    z-index: 2;
    background-color: #FAF7F4;
  }

  .reminders-section img {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }

  .reminders-text h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin-bottom: 12px;
  }

  .reminders-text p,
  .reminders-text li {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
  }

  .reminders-text ul {
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
  }

  /* AI Section Mobile */
  .ai-section {
    display: flex;
    flex-direction: column;
    padding: 30px 20px; /* 减少padding */
    gap: 20px;
    text-align: center;
    position: relative;
    z-index: 2;
    background-color: #FAF7F4;
  }

  .ai-content {
    padding: 0;
  }

  .coming-soon {
    font-size: 12px;
    padding: 4px 12px;
  }

  .ai-content h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin: 16px 0;
  }

  .ai-content p {
    font-size: clamp(14px, 3.5vw, 16px);
    line-height: 1.5;
  }

  .ai-section img {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }

  /* Why Section Mobile */
  .why-section {
    padding: 30px 20px; /* 减少padding */
    min-height: auto;
    position: relative;
    z-index: 3; /* 确保在其他内容之上 */
    background-color: #FAF7F4; /* 不透明背景防止内容透视 */
  }

  .why-section h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin-bottom: 12px;
  }

  .why-section > p {
    font-size: clamp(14px, 3.5vw, 16px);
    margin-bottom: 30px;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0;
  }

  .feature-card {
    padding: 20px;
    min-height: auto;
  }

  .feature-card .emoji {
    font-size: 28px;
    margin-bottom: 12px;
  }

  .feature-card h4 {
    font-size: clamp(16px, 3.8vw, 18px);
    margin-bottom: 10px;
  }

  .feature-card p {
    font-size: clamp(13px, 3.2vw, 14px);
    line-height: 1.4;
  }

  /* Download Section Mobile */
  .download-section {
    padding: 60px 20px 0;
    min-height: auto;
    /* 建立独立层叠上下文，并整体提升层级，盖住上一区块的装饰图 */
    position: relative;
    z-index: var(--z-fixed);
    isolation: isolate;
    overflow: hidden; /* 防止外部元素渗入 */
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .download-content {
    padding: 40px 20px;
    text-align: center;
    /* 强制从绝对定位回到文档流，避免与大图/页尾重叠 */
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 560px;
    margin: 12px auto 0; /* 与上方图片保持安全间距，避免“字和图堆在一起” */
    /* 始终在该区背景图之上 */
    position: relative !important;
    z-index: 3 !important;
  }

  .download-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
  }

  .download-content h2 {
    font-size: clamp(24px, 5vw, 28px);
    margin-bottom: 12px;
  }

  .download-content p {
    font-size: clamp(14px, 3.5vw, 16px);
    margin-bottom: 24px;
  }

  .app-store {
    width: 160px;
    margin: 0 auto;
  }

  /* 下载区背景图置于底层，避免覆盖文本/按钮 */
  .wave-bg {
    position: relative !important;
    z-index: 0 !important;
    width: 100% !important;
    max-width: 560px !important;
    height: auto !important;
    max-height: 420px !important;
    object-fit: contain !important;
    margin: 0 auto 16px !important; /* 给下方文案留间距 */
  }

  /* Footer Mobile - Enhanced design and spacing */
  .footer {
    padding: 32px 16px calc(32px + var(--safe-bottom)) 16px;
    position: relative;
    z-index: var(--z-content);
    background: linear-gradient(180deg, rgba(147, 98, 78, 0.03) 0%, rgba(147, 98, 78, 0.06) 100%);
  }

  /* Footer sections reorganized for mobile */
  .footer-top {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 640px;
    margin: 0 auto;
  }

  /* App Store download link - prominent placement */
  .footer-download-link {
    order: -1;
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
  }

  /* 重置页尾内可能的绝对定位，避免覆盖主体 */
  .footer-top > img,
  .footer-top .footer-download-link {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    margin: 0 auto 16px !important;
    z-index: 1 !important;
  }

  .footer-download-link img {
    width: 140px;
    height: auto;
  }

  /* Main footer content */
  .footer-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }

  /* Brand section */
  .footer-left {
    text-align: center;
  }

  .footer-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  .footer-logo img {
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }

  .footer-logo span {
    font-size: 20px;
    font-weight: 600;
    color: #333;
  }

  .footer-left p {
    font-size: 13px;
    line-height: 1.5;
    max-width: 38ch;
    margin: 0 auto;
    color: #666;
    opacity: 0.95;
  }

  /* Footer links - horizontal layout on mobile */
  .footer-links {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 48px;
  }

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

  .footer-column > img {
    width: 20px;
    height: 20px;
    margin: 0 auto 8px;
    opacity: 0.7;
  }

  .footer-column h5 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 8px 0;
    color: #666;
    opacity: 0.9;
  }

  .footer-column a {
    display: block;
    font-size: 14px;
    padding: 6px 0;
    min-height: 32px;
    line-height: 20px;
    color: #333;
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s ease;
  }

  .footer-column a:active {
    opacity: 1;
    color: #93624E;
  }

  /* Visual separator */
  .footer::before {
    content: "";
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(147, 98, 78, 0.2), transparent);
    margin: 24px auto;
    max-width: 200px;
  }

  /* Bottom section with copyright and social */
  .footer-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(147, 98, 78, 0.1);
    text-align: center;
  }

  .footer-bottom p {
    font-size: 12px;
    color: #666;
    opacity: 0.8;
  }

  /* Social links with better touch targets */
  .social-links {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
  }

  .social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    /* 加深背景提升与浅底的对比度（去掉边框） */
    background: rgba(147, 98, 78, 0.22);
    border: none;
    transition: all 0.2s ease;
  }

  .social-links a:active {
    background: rgba(147, 98, 78, 0.15);
    transform: scale(0.95);
  }

  .social-links a img {
    width: 20px;
    height: 20px;
    opacity: 1; /* 移除过度透明，保证清晰 */
    filter: none;
  }
}

/* Mobile phones (≤ 480px) - Fine-tuned optimizations */
@media (max-width: 480px) {

  /* Even smaller adjustments for small phones */
  .header-section {
    height: 56px;
    padding: var(--safe-top) 16px 0 16px;
  }

  .logo-text {
    font-size: 18px;
  }

  .download-button {
    width: 90px;
    height: 30px;
  }

  /* Hero optimizations for small screens */
  .hero-section {
    min-height: calc(100vh - 56px - var(--safe-top));
    min-height: calc(100svh - 56px - var(--safe-top));
    padding: 16px 16px; /* 顶部再收紧 */
  }

  @supports (height: 100dvh) {
    .hero-section {
      min-height: calc(100dvh - 56px - var(--safe-top));
    }
  }

  .hero-content {
    padding: 30px 16px 16px; /* 适当的顶部间距 */
  }

  .hero-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 8px; /* 更紧凑 */
  }

  /* Hero text further optimized for small screens */
  .hero-text h1 {
    font-size: clamp(24px, 8vw, 30px);
    margin-bottom: 8px;
  }

  .hero-text h1 span:first-child {
    font-size: clamp(20px, 6vw, 26px);
  }

  .hero-text h1 span:last-child {
    font-size: clamp(22px, 7vw, 28px);
  }

  .hero-text p {
    font-size: 14px;
    line-height: 1.4;
    margin: 6px auto 16px;
  }

  .app-store-badge {
    width: 140px;
    margin: 12px auto 20px;
  }

  /* Smaller padding for all sections - compact but not cramped */
  .features-section,
  .watch-section,
  .widgets-section,
  .reminders-section,
  .ai-section,
  .why-section {
    padding: 24px 16px; /* 进一步减少padding避免空白 */
  }

  /* Feature cards even more compact */
  .feature-card {
    padding: 16px;
  }

  .feature-card .emoji {
    font-size: 24px;
  }

  /* Footer adjustments for small screens */
  .footer {
    padding: 24px 16px calc(24px + var(--safe-bottom)) 16px;
  }

  .footer-download-link img {
    width: 130px;
  }

  .footer-links {
    flex-direction: column;
    gap: 24px;
    text-align: center;
  }

  .footer-column {
    padding: 8px 0;
  }

  .footer-bottom {
    margin-top: 24px;
    padding-top: 16px;
  }

  .social-links a {
    width: 36px;
    height: 36px;
  }
}

/* Landscape orientation fixes */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    min-height: 350px;
  }

  .hero-content {
    padding: 20px;
  }

  .hero-logo {
    width: 50px;
    height: 50px;
    margin-bottom: 10px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  a, button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Better hover states for touch */
  a:active, button:active {
    opacity: 0.8;
    transform: scale(0.98);
  }
}

/* Legal Pages Mobile Styles */
@media (max-width: 768px) {
  .legal-container {
    padding-top: 70px !important;
    padding-bottom: 40px !important;
  }

  .legal-content {
    max-width: 100% !important;
    padding: 0 20px !important;
    margin: 0 !important;
  }

  .legal-header h1 {
    font-size: clamp(24px, 6vw, 32px) !important;
    margin-bottom: 20px !important;
  }

  .legal-section {
    margin-bottom: 24px !important;
  }

  .legal-section h2 {
    font-size: clamp(18px, 4.5vw, 22px) !important;
    margin-bottom: 12px !important;
  }

  .legal-section h3 {
    font-size: clamp(16px, 4vw, 20px) !important;
    margin-bottom: 10px !important;
  }

  .legal-section p,
  .legal-section li {
    font-size: clamp(14px, 3.5vw, 16px) !important;
    line-height: 1.6 !important;
  }

  .legal-section ul,
  .legal-section ol {
    padding-left: 20px !important;
  }

  /* Contact Form Mobile - Enhanced for better usability */
  .contact-form, form {
    display: grid !important;
    gap: 16px !important;
    padding: 20px !important;
    margin: 0 !important;
    border-radius: 12px !important;
  }

  .form-group {
    margin-bottom: 20px !important;
    display: grid !important;
    gap: 6px !important;
  }

  .form-group label {
    font-size: 14px !important;
    font-weight: 500 !important;
    margin-bottom: 6px !important;
    color: #333 !important;
  }

  .form-group input,
  .form-group textarea,
  .form-group select,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important; /* Critical: Prevents zoom on iOS */
    padding: 12px !important;
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    background-color: #fff !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  /* Focus states for better accessibility */
  input:focus,
  textarea:focus,
  select:focus {
    outline: 2px solid #93624E !important;
    outline-offset: 2px !important;
    border-color: #93624E !important;
  }

  .form-group textarea,
  textarea {
    min-height: 120px !important;
    resize: vertical !important;
  }

  .submit-button,
  button[type="submit"],
  input[type="submit"] {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    margin-top: 10px !important;
    background-color: #93624E !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  /* Active state for touch feedback */
  .submit-button:active,
  button:active {
    transform: scale(0.98) !important;
    opacity: 0.9 !important;
  }

  /* Better touch targets for checkboxes and radio buttons */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px !important;
    min-height: 20px !important;
    margin-right: 8px !important;
  }
}

@media (max-width: 480px) {
  .legal-container {
    padding-top: 60px !important;
    padding-bottom: 30px !important;
  }

  .legal-content {
    padding: 0 16px !important;
  }

  .legal-header h1 {
    font-size: 24px !important;
  }

  .legal-section h2 {
    font-size: 18px !important;
  }

  .legal-section h3 {
    font-size: 16px !important;
  }

  .legal-section p,
  .legal-section li {
    font-size: 14px !important;
  }

  .contact-form {
    padding: 16px !important;
  }
}

/* Print styles (bonus) */
@media print {
  .header-section,
  .download-button,
  .app-store-badge,
  .app-store {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  .hero-section {
    page-break-after: always;
  }
}

/* Smooth transitions and micro-interactions */
@media (max-width: 1024px) {
  /* Base transitions for all interactive elements */
  a, button, .download-button, .app-store-badge {
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
  }

  /* Enhanced button hover states (for devices with hover) */
  @media (hover: hover) and (pointer: fine) {
    .app-store-badge:hover,
    .download-button:hover {
      transform: translateY(-2px);
      filter: brightness(1.05);
    }

    .footer-column a:hover {
      opacity: 1;
      color: #93624E;
    }

    .social-links a:hover {
      background: rgba(147, 98, 78, 0.12);
      transform: translateY(-2px);
    }
  }

  /* Subtle entrance animations */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Apply entrance animations to hero elements */
  .hero-logo {
    animation: fadeIn 0.6s ease-out;
  }

  .hero-text h1 {
    animation: fadeInUp 0.7s ease-out 0.1s both;
  }

  .hero-text p {
    animation: fadeInUp 0.7s ease-out 0.2s both;
  }

  .app-store-badge {
    animation: fadeInUp 0.7s ease-out 0.3s both;
  }

  /* Pulse animation for CTA button */
  @keyframes subtlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
  }

  .app-store-badge {
    animation: fadeInUp 0.7s ease-out 0.3s both, subtlePulse 3s ease-in-out infinite 2s;
  }

  /* Disable animations for users who prefer reduced motion */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation: none !important;
      transition: none !important;
    }
  }
}

/* Fix for iOS safe areas (notched devices) */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .footer {
      padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
  }
}

/* ===== DEBUG UTILITIES ===== */
/* Add class="debug" to body to enable visual debugging */
.debug * {
  outline: 1px dashed rgba(255, 0, 0, 0.3) !important;
  outline-offset: -1px !important;
}

.debug .header-section {
  outline-color: rgba(0, 255, 0, 0.5) !important;
  outline-width: 2px !important;
}

.debug .hero-section {
  outline-color: rgba(0, 0, 255, 0.5) !important;
  outline-width: 2px !important;
}

.debug .footer {
  outline-color: rgba(255, 0, 255, 0.5) !important;
  outline-width: 2px !important;
}

/* Debug info overlay */
.debug::before {
  content: "Debug Mode | Viewport: " attr(data-viewport) " | DPR: " attr(data-dpr);
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  background: rgba(255, 255, 0, 0.9);
  color: #000;
  padding: 4px 8px;
  font-size: 12px;
  font-family: monospace;
  z-index: 10000;
  text-align: center;
}

/* Highlight overflow issues */
.debug [style*="overflow: hidden"] {
  background: rgba(255, 0, 0, 0.1) !important;
}

/* Show safe area boundaries */
@supports (padding: env(safe-area-inset-top)) {
  .debug::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border-top: var(--safe-top) solid rgba(0, 255, 0, 0.3);
    border-bottom: var(--safe-bottom) solid rgba(0, 255, 0, 0.3);
    border-left: var(--safe-left) solid rgba(0, 255, 0, 0.3);
    border-right: var(--safe-right) solid rgba(0, 255, 0, 0.3);
    z-index: 9998;
  }
}