:root {
    --bg-primary: #0F172A;
    --color-brand: #F8FAFC;
    --color-royal: #3B82F6;
    --color-text-muted: #94A3B8;
    --color-border: #334155;
    
    /* 動態過渡貝茲曲線 */
    --transition-smooth: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-transform: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

/* 明亮模式 (Light Theme) 變數 */
body.light-theme {
    --bg-primary: #F8FAFC;
    --color-brand: #0F172A;
    --color-royal: #2563EB;
    --color-text-muted: #64748B;
    --color-border: #E2E8F0;
}
body.light-theme .phone-mockup {
    background-color: #FFFFFF;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1), 0 0 0 8px #E2E8F0, 0 0 0 9px #CBD5E1;
}
body.light-theme .nav-bar {
    background: rgba(248, 250, 252, 0.8);
}
body.light-theme .browser-content,
body.light-theme .real-app-iframe {
    background-color: #FFFFFF;
}

/* Theme Toggle Button Styles */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--color-brand);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}
.theme-toggle-btn:hover {
    background-color: rgba(148, 163, 184, 0.2);
}
body .icon-sun { display: none; }
body .icon-moon { display: block; }
body.light-theme .icon-sun { display: block; }
body.light-theme .icon-moon { display: none; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--color-brand);
    overflow: hidden; /* Prevent body scroll, use main-container instead */
}

/* 1. 頂部多功能快速導覽列 */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    padding: 0 4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    z-index: 1000;
}

.nav-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-brand);
}

.nav-menu {
    display: flex;
    gap: 2.5rem;
}

.nav-item {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    padding: 0.5rem 0;
    transition: var(--transition-smooth);
}

.nav-item:hover, .nav-item.active {
    color: var(--color-royal);
}

/* 導覽啟用底線動畫 */
.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-royal);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

.btn-cta {
    background-color: var(--color-brand);
    color: var(--bg-primary); /* Dark text on white background */
    text-decoration: none;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.btn-cta:hover {
    background-color: var(--color-royal);
    color: white; /* Switch to white text on blue background */
    border-color: var(--color-royal);
}

/* 2. 主容器佈局 */
.main-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* 左側滾動敘事欄 */
.left-scroll-column {
    width: 50%;
    padding: 0 4rem;
    display: flex;
    flex-direction: column;
}

.scroll-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0.2;
    color: var(--color-text-muted);
    transform: scale(0.95);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    scroll-snap-align: center;
}

.scroll-section.active {
    opacity: 1;
    color: var(--color-brand);
    transform: scale(1);
}

.scroll-section h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.scroll-section h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.scroll-section p {
    font-size: 1rem;
    color: var(--color-text-muted);
    line-height: 1.8;
    margin-bottom: 2rem;
    max-width: 95%;
}

.btn-primary {
    background-color: var(--color-royal);
    color: white;
    border: none;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    display: inline-block;
    background-color: transparent;
    color: var(--color-royal);
    border: 1px solid var(--color-royal);
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
    margin-top: 10px;
}

.btn-secondary:hover {
    background-color: var(--color-royal);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* 右側固定展示欄 */
.right-fixed-column {
    width: 50%;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at 50% 50%, rgba(37, 99, 235, 0.05) 0%, transparent 60%);
    pointer-events: none; /* Let left side handle scrolling if cursor is on right */
}

/* 3. 手機模擬器 (Phone Mockup) */
.phone-mockup {
    width: 375px;
    height: 812px;
    background-color: #000;
    border-radius: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 8px #1E293B, 0 0 0 9px #334155;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    transition: var(--transition-transform);
    pointer-events: auto; /* Allow interacting with iframe if desired, though usually promotional sites disable it */
}

/* (Removed Notch to prevent obscuring the iframe UI) */

.browser-content {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 32px;
    overflow: hidden;
    background-color: #0F172A; /* Fallback */
}

/* 4. 產品畫面切換邏輯 (UI View with IFRAMES) */
.ui-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-view.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.real-app-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: #0F172A;
}

/* Hero view fallback if no iframe */
.hero-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* 切換性能優化 */
.is-switching .ui-view {
    transition-duration: 0.3s !important;
}

  /* 5. 響應式佈局 (手機/平板) - 點擊切換與陰影展開 */
  .story-nav-left, .story-nav-right {
      display: none;
  }
  .story-nav-left.disabled, .story-nav-right.disabled {
      display: none !important;
  }
  .card-collapse-bar {
      display: none;
  }

  @media (max-width: 968px) {
      .nav-bar { padding: 0 1rem; white-space: nowrap; }
      .nav-logo { font-size: 1.1rem; white-space: nowrap; }
      .btn-cta { padding: 0.4rem 0.8rem; }
      .nav-menu { display: none; }
  
      .main-container {
          display: block;
          overflow: hidden; /* Lock scroll completely */
          position: relative;
      }
      
      /* --- 左右點擊區 (Story Navigation) --- */
      .story-nav-left, .story-nav-right {
          display: flex;
          align-items: center;
          position: absolute;
          top: 64px; /* below nav */
          height: calc(100vh - 64px);
          width: 20%; /* 20% of screen width for clicking */
          z-index: 50; /* Above iframe, below cards */
          cursor: pointer;
      }
      .story-nav-left { 
          left: 0; 
          justify-content: flex-start;
          padding-left: 10px;
      }
      .story-nav-right { 
          right: 0; 
          justify-content: flex-end;
          padding-right: 10px;
      }
      
      .story-nav-arrow {
          width: 40px;
          height: 40px;
          background: rgba(15, 23, 42, 0.6);
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          color: white;
          backdrop-filter: blur(4px);
          border: 1px solid rgba(255,255,255,0.2);
          box-shadow: 0 4px 12px rgba(0,0,0,0.3);
          transition: transform 0.2s, background 0.2s;
          pointer-events: none; /* Let the parent handle clicks */
      }
      .story-nav-left:active .story-nav-arrow {
          transform: scale(0.9) translateX(-5px);
          background: rgba(15, 23, 42, 0.8);
      }
      .story-nav-right:active .story-nav-arrow {
          transform: scale(0.9) translateX(5px);
          background: rgba(15, 23, 42, 0.8);
      }
      .story-nav-arrow svg {
          width: 24px;
          height: 24px;
      }
      
      body.light-theme .story-nav-arrow {
          background: rgba(255, 255, 255, 0.8);
          color: var(--color-brand);
          border-color: rgba(0,0,0,0.1);
      }

      /* --- 背景互動 APP --- */
      .right-fixed-column {
          position: fixed;
          top: 0;
          left: 0;
          width: 100%;
          height: 100vh;
          padding-top: 64px;
          background: var(--bg-primary);
          z-index: 1;
          display: flex;
          align-items: center;
          justify-content: center;
          pointer-events: auto; /* Always interactive */
      }
      .phone-mockup {
          width: 320px;
          height: 650px;
          transform: scale(0.85);
          transform-origin: center center;
          box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
      }
      
      /* --- 文字卡片區 (Top-Anchored) --- */
      .left-scroll-column {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          z-index: 100; /* Above story-nav */
          pointer-events: none; /* Let clicks pass through column */
      }
      
      .scroll-section {
          position: absolute;
          top: 80px; /* Below nav bar */
          left: 1.5rem;
          width: calc(100% - 3rem);
          pointer-events: none;
          padding: 1.2rem;
          background: rgba(15, 23, 42, 0.95);
          backdrop-filter: blur(12px);
          border: 1px solid var(--color-border);
          border-radius: 16px;
          box-shadow: 0 10px 30px rgba(0,0,0,0.5);
          opacity: 0;
          /* Start off-screen top */
          transform: translateY(-120%);
          transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      }
      body.light-theme .scroll-section {
          background: rgba(255, 255, 255, 0.95);
      }
      
      /* Only active card is visible, slide down with delay so background app shows first */
      .scroll-section.active {
          opacity: 1;
          pointer-events: auto;
          transform: translateY(0);
          transition-delay: 0.4s; /* Delay entrance to show app first */
      }
      
      /* When active but collapsed, remove delay so it responds instantly */
      .scroll-section.active.is-collapsed {
          transition-delay: 0s;
      }
      
      .card-collapse-bar {
          display: flex;
          justify-content: center;
          align-items: center;
          margin-top: 12px;
          padding-top: 12px;
          border-top: 1px solid rgba(255,255,255,0.1);
          cursor: pointer;
          touch-action: none; /* Prevent default touch behavior for drag */
      }
      body.light-theme .card-collapse-bar {
          border-top-color: rgba(0,0,0,0.1);
      }
      
      .drag-handle-text {
          font-size: 0.8rem;
          color: rgba(255, 255, 255, 0.6);
          letter-spacing: 0.05em;
          font-weight: 500;
          transition: color 0.3s;
      }
      body.light-theme .drag-handle-text {
          color: rgba(0, 0, 0, 0.5);
      }
      .card-collapse-bar:active .drag-handle-text {
          color: rgba(255, 255, 255, 1);
      }
      body.light-theme .card-collapse-bar:active .drag-handle-text {
          color: rgba(0, 0, 0, 0.8);
      }

      /* Adjust headers for mobile */
      .scroll-section h1 {
          font-size: 2rem;
          margin-bottom: 1rem;
      }
      .scroll-section h2 {
          font-size: 1.5rem;
          margin-bottom: 1rem;
      }
      
      /* Mobile Action Button placement */
      .scroll-section .section-action {
          display: none; /* Hide default action button on mobile by default to avoid clutter */
      }

      /* Collapsed State (Swipe UP) */
      .scroll-section.is-collapsed .scroll-section-content {
          display: none; /* Hide content */
      }
      .scroll-section.is-collapsed {
          padding-top: 0;
          /* Push it up so only the bottom edge is visible */
          transform: translateY(calc(-100% + 40px));
          /* Strong shadow indicating it's clickable */
          box-shadow: 0 15px 30px rgba(0,0,0,0.5);
          cursor: pointer;
      }
      body.light-theme .scroll-section.is-collapsed {
          box-shadow: 0 15px 30px rgba(0,0,0,0.2);
      }
      
      .scroll-section.is-collapsed .card-collapse-bar {
          border-top: none;
          margin-top: 0;
          padding-top: 1.2rem; /* some padding inside */
          pointer-events: none; /* Let the whole card handle the click */
      }
      
      /* Show action button at bottom right when collapsed (previewing app) */
      .scroll-section.active.is-collapsed .section-action {
          display: block;
          position: fixed;
          bottom: 20px;
          right: 20px;
          z-index: 1000;
          animation: fade-in-up 0.4s ease forwards;
          pointer-events: auto;
      }
      .scroll-section.active.is-collapsed .section-action .btn-primary,
      .scroll-section.active.is-collapsed .section-action .btn-secondary {
          box-shadow: 0 8px 24px rgba(0,0,0,0.4);
      }
  }

  @keyframes fade-in-up {
      from { opacity: 0; transform: translateY(10px); }
      to { opacity: 1; transform: translateY(0); }
  }