/* ===================================================================
   Upload / Home Page — PixRemix v2.1
   Page-specific styles wrapped in @layer pages.
   Uses design tokens from variables.css.
   =================================================================== */

@layer pages {

  /* --- Hero Section --- */
  .upload-hero {
    text-align: center;
    padding: var(--space-8) 0 var(--space-4);
  }

  .upload-hero h1 {
    margin-bottom: var(--space-3);
  }

  .upload-hero-sub {
    font-size: var(--text-lg);
    color: var(--neutral-600);
    max-width: 540px;
    margin: 0 auto var(--space-2);
    line-height: var(--leading-relaxed);
  }

  .upload-hero-price {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--accent);
    margin: 0;
  }

  /* --- Alerts (scoped to upload page) --- */
  .upload-alerts {
    max-width: 480px;
    margin: 0 auto var(--space-4);
  }

  .ai-gen-bar.ai-gen-blocked {
    max-width: 480px;
    margin: 0 auto var(--space-4);
    background: linear-gradient(90deg, #ffeaea 0%, #ffd6d6 100%);
    color: #a94442;
    border: 1.5px solid #ffb3b3;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .discount-alert {
    max-width: 480px;
    margin: 0 auto var(--space-4);
    background: var(--surface-warm);
    color: var(--neutral-900);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    box-shadow: var(--shadow-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .discount-alert-invalid {
    max-width: 480px;
    margin: 0 auto var(--space-4);
    background: var(--color-alert-error-bg);
    color: var(--color-alert-error-text);
    border: 2px solid var(--error);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    box-shadow: var(--shadow-sm);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  /* --- Upload Form --- */
  .upload-form {
    max-width: 480px;
    margin: 0 auto;
    gap: var(--space-5);
  }

  .upload-form-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--neutral-900);
    margin-bottom: var(--space-1);
  }

  /* --- Upload Zone (drag & drop) --- */
  .upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-6);
    border: 2px dashed var(--neutral-200);
    border-radius: var(--radius-xl);
    background: var(--surface-cream);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    text-align: center;
    min-height: 200px;
  }

  .upload-zone:hover,
  .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--surface-warm);
    box-shadow: 0 0 0 4px var(--accent-glow);
  }

  .upload-zone-icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    stroke: var(--neutral-400);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke var(--duration-fast) var(--ease-out);
  }

  .upload-zone:hover .upload-zone-icon,
  .upload-zone.dragover .upload-zone-icon {
    stroke: var(--accent);
  }

  .upload-zone-text {
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--neutral-900);
    margin-bottom: var(--space-1);
  }

  .upload-zone-browse {
    color: var(--accent);
    font-weight: var(--weight-semibold);
    text-decoration: underline;
    cursor: pointer;
  }

  .upload-zone-hint {
    font-size: var(--text-sm);
    color: var(--neutral-400);
    margin-top: var(--space-2);
  }

  .upload-zone-example {
    font-size: var(--text-sm);
    color: var(--neutral-400);
    text-decoration: underline;
    margin-top: var(--space-2);
    transition: color var(--duration-fast) var(--ease-out);
  }

  .upload-zone-example:hover {
    color: var(--accent);
  }

  /* Mobile camera text */
  .upload-zone-mobile {
    display: none;
  }

  @media (max-width: 768px) {
    .upload-zone-desktop {
      display: none;
    }
    .upload-zone-mobile {
      display: block;
    }
  }

  /* Hidden real file input */
  .upload-file-input {
    display: none;
  }

  /* --- Upload Preview (after file selected) --- */
  .upload-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: var(--space-5);
    border: 2px solid var(--success);
    border-radius: var(--radius-xl);
    background: var(--surface-cream);
    gap: var(--space-3);
  }

  .upload-preview.active {
    display: flex;
  }

  .upload-preview-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-md);
    object-fit: contain;
  }

  .upload-preview-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--neutral-900);
    word-break: break-all;
    text-align: center;
  }

  .upload-preview-change {
    font-size: var(--text-sm);
    color: var(--accent);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
  }

  .upload-preview-change:hover {
    color: var(--accent-hover);
  }

  /* --- Style Tiles --- */
  .style-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
  }

  /* Hidden radio */
  .style-radio {
    display: none;
    appearance: none;
    -webkit-appearance: none;
  }

  .style-tile {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
    aspect-ratio: 1;
    background: var(--neutral-50);
  }

  .style-tile:hover {
    transform: scale(1.03);
    border-color: var(--neutral-400);
  }

  .style-radio:checked + .style-tile {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
  }

  .style-tile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .style-tile-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-1) var(--space-2);
    background: rgba(255, 255, 255, 0.92);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-align: center;
    color: var(--neutral-900);
  }

  /* Countdown badge on style tile */
  .style-tile .countdown-badge {
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    z-index: 2;
    font-size: 0.6rem;
    animation: pulse-badge 2s infinite;
  }

  @keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
  }

  .style-tile[data-last-chance="true"] {
    border-color: #ff6b6b;
  }

  /* --- Form Reassurance --- */
  .form-reassurance {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    font-size: var(--text-sm);
    color: var(--neutral-600);
  }

  .reassurance-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--success);
    font-weight: var(--weight-medium);
  }

  .reassurance-item svg {
    width: 16px;
    height: 16px;
    stroke: var(--success);
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  /* --- CTA Button overrides --- */
  .upload-btn {
    font-size: var(--text-lg);
    padding: var(--space-4) var(--space-8);
    min-height: 52px;
    animation: subtle-pulse 2.5s ease-in-out infinite;
  }

  @keyframes subtle-pulse {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: var(--shadow-glow); }
  }

  .upload-btn:disabled {
    background: var(--neutral-200);
    color: var(--neutral-400);
    border-color: var(--neutral-200);
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
  }

  /* --- Terms Notice --- */
  .terms-notice {
    font-size: var(--text-xs);
    color: var(--neutral-400);
    text-align: center;
    line-height: var(--leading-normal);
  }

  .terms-notice a {
    color: var(--neutral-400);
    text-decoration: underline;
  }

  .terms-notice a:hover {
    color: var(--accent);
  }

  /* --- Trust Bar --- */
  .upload-trust-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
    padding: var(--space-5) 0;
    flex-wrap: wrap;
  }

  .upload-trust-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--neutral-600);
    white-space: nowrap;
  }

  .upload-trust-item svg {
    width: 18px;
    height: 18px;
    stroke: var(--success);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  /* Divider dots between trust items */
  .upload-trust-divider {
    width: 4px;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--neutral-200);
    flex-shrink: 0;
  }

  @media (max-width: 520px) {
    .upload-trust-bar {
      gap: var(--space-3);
    }
    .upload-trust-divider {
      display: none;
    }
    .upload-trust-item {
      font-size: var(--text-xs);
    }
  }

  /* --- How It Works Section --- */
  .hiw-section {
    max-width: var(--container-max);
    margin: var(--space-8) auto;
    padding: var(--space-8) var(--space-4);
    text-align: center;
  }

  .hiw-section h2 {
    margin-bottom: var(--space-2);
  }

  .hiw-subtitle {
    color: var(--neutral-600);
    margin-bottom: var(--space-8);
  }

  .hiw-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-6);
  }

  .hiw-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-5);
  }

  .hiw-step-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-warm);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-4);
  }

  .hiw-step-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .hiw-step-num {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
  }

  .hiw-step h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2);
  }

  .hiw-step p {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    line-height: var(--leading-relaxed);
  }

  /* --- Before / After Examples (horizontal scroll) --- */
  .examples-section {
    max-width: var(--container-wide);
    margin: var(--space-8) auto;
    padding: 0 var(--space-4);
  }

  .examples-section h2 {
    text-align: center;
    margin-bottom: var(--space-2);
  }

  .examples-subtitle {
    text-align: center;
    color: var(--neutral-600);
    margin-bottom: var(--space-6);
  }

  .examples-scroll {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-4);
    scrollbar-width: thin;
  }

  .example-card {
    flex: 0 0 260px;
    scroll-snap-align: start;
    background: var(--surface-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-100);
    overflow: hidden;
    transition: box-shadow var(--duration-normal) var(--ease-out);
  }

  .example-card:hover {
    box-shadow: var(--shadow-md);
  }

  .example-card-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    aspect-ratio: 2 / 1;
  }

  .example-card-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .example-card-body {
    padding: var(--space-3) var(--space-4);
  }

  .example-card-style {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* --- Use Cases Section --- */
  .use-cases-section {
    max-width: var(--container-max);
    margin: var(--space-8) auto;
    padding: var(--space-6) var(--space-4);
    text-align: center;
  }

  .use-cases-section h2 {
    margin-bottom: var(--space-2);
  }

  .use-cases-subtitle {
    color: var(--neutral-600);
    margin-bottom: var(--space-8);
  }

  .use-cases-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-5);
  }

  .use-case-card {
    background: var(--surface-white);
    padding: var(--space-6) var(--space-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-100);
    text-align: center;
    transition: transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
  }

  .use-case-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
  }

  .use-case-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-warm);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
  }

  .use-case-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .use-case-card h3 {
    font-size: var(--text-base);
    margin-bottom: var(--space-2);
  }

  .use-case-card p {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    line-height: var(--leading-relaxed);
  }

  /* --- Why Choose / Product Overview Section --- */
  .why-section {
    max-width: var(--container-max);
    margin: var(--space-8) auto;
    padding: var(--space-8) var(--space-4);
    background: var(--surface-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    text-align: center;
  }

  .why-section h2 {
    margin-bottom: var(--space-2);
  }

  .why-subtitle {
    color: var(--neutral-600);
    margin-bottom: var(--space-8);
  }

  .why-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--space-6);
  }

  .why-card {
    padding: var(--space-5);
  }

  .why-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-warm);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-4);
  }

  .why-card-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .why-card h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2);
  }

  .why-card p {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    line-height: var(--leading-relaxed);
  }

  /* --- FAQ Section (uses global styles, add spacing) --- */
  .upload-faq {
    max-width: var(--container-max);
    margin: var(--space-8) auto;
  }

  /* --- SEO Content --- */
  .seo-content {
    max-width: var(--container-max);
    margin: var(--space-8) auto;
    padding: var(--space-6) var(--space-4);
  }

  .seo-content h2 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-4);
    text-align: center;
  }

  .seo-content p {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
    text-align: center;
  }

  /* --- Final CTA Section --- */
  .final-cta {
    max-width: 640px;
    margin: var(--space-8) auto var(--space-6);
    padding: var(--space-10) var(--space-6);
    text-align: center;
    background-color: var(--accent);
    background-image: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
  }

  .final-cta h2 {
    font-size: var(--text-3xl);
    color: var(--surface-white);
    margin-bottom: var(--space-3);
  }

  .final-cta p {
    font-size: var(--text-lg);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--space-6);
  }

  .final-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    background: var(--surface-white);
    color: var(--neutral-900);
    border: 2px solid var(--surface-white);
    border-radius: var(--radius-md);
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transition: transform var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
  }

  .final-cta-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
    color: var(--neutral-900);
  }

  .final-cta-note {
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.85);
  }

  /* --- Floating CTA (mobile only) --- */
  .floating-cta {
    position: fixed;
    bottom: -80px;
    left: 0;
    right: 0;
    z-index: var(--z-overlay);
    display: flex;
    justify-content: center;
    padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    transition: bottom var(--duration-moderate) var(--ease-out);
    pointer-events: none;
  }

  .floating-cta.visible {
    bottom: calc(var(--tab-bar-height) + var(--space-2));
    pointer-events: auto;
  }

  .floating-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    background: var(--accent);
    color: var(--surface-white);
    border-radius: var(--radius-full);
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
  }

  .floating-cta-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
    color: var(--surface-white);
  }

  .floating-cta-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  @media (min-width: 769px) {
    .floating-cta {
      display: none;
    }
  }

  /* --- Disabled Button Tooltip --- */
  .disabled-button-tooltip {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1.5px solid #ffb74d;
    color: #e65100;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-align: center;
    animation: tooltipFadeIn var(--duration-normal) var(--ease-out);
  }

  @keyframes tooltipFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* --- Dynamic style preview backgrounds (from template inline style) --- */
  /* These are injected via template <style> block */

  /* --- Mobile Adjustments --- */
  @media (max-width: 768px) {
    .upload-hero {
      padding: var(--space-5) 0 var(--space-2);
    }

    .upload-hero-sub {
      font-size: var(--text-base);
    }

    .style-tiles {
      grid-template-columns: repeat(3, 1fr);
    }

    .hiw-steps {
      grid-template-columns: 1fr;
      gap: var(--space-4);
    }

    .use-cases-grid {
      grid-template-columns: 1fr;
    }

    .why-grid {
      grid-template-columns: 1fr;
    }

    .final-cta {
      margin: var(--space-6) var(--space-2);
      padding: var(--space-8) var(--space-4);
    }

    .final-cta h2 {
      font-size: var(--text-2xl);
    }

    .final-cta-btn {
      width: 100%;
      font-size: var(--text-base);
    }

    .example-card {
      flex: 0 0 220px;
    }
  }

  /* --- Small mobile --- */
  @media (max-width: 400px) {
    .style-tiles {
      grid-template-columns: repeat(2, 1fr);
      gap: var(--space-2);
    }
  }
}
