@font-face {
    font-family: 'Unilever Desire';
    src: url('src/fonts/UnileverDesire-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Unilever Desire';
    src: url('src/fonts/UnileverDesire-RegularItalic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
}

@font-face {
    font-family: 'Unilever Desire';
    src: url('src/fonts/UnileverDesire-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'Unilever Desire';
    src: url('src/fonts/UnileverDesire-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Unilever Desire';
    src: url('src/fonts/UnileverDesire-BoldItalic.ttf') format('truetype');
    font-weight: 700;
    font-style: italic;
}

:root {
    --color-earth: #F6F7F0;
    --color-clover: #2B911C;
    --color-clover-dark: #206D15;
    --color-clover-mid: #67DE56;
    --color-clover-light: #9AE98E;
    --color-clover-pale: #CCF4C7;
    --color-pebble: #DEDED7;
    --color-text: #1a1a1a;
    --color-text-secondary: #4a4a4a;
    --screen-padding: 40px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Unilever Desire', 'Aptos', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-earth);
    min-height: 100vh;
    min-height: 100dvh;
    /* Mobile viewport fix */
    color: var(--color-text);
    width: 100%;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.background-gradient {
    position: fixed;
    bottom: -170px;
    right: -360px;
    width: 1000px;
    height: auto;
    z-index: -1;
    pointer-events: none;
    opacity: 0.8;
}

/* Desktop: make the gradient background larger */
@media (min-width: 1025px) {
    .background-gradient {
        width: 1500px;
        bottom: -260px;
        right: -540px;
    }
}

.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--screen-padding);
    overflow-y: auto;
    width: 100%;
}

.screen.active {
    display: block;
    animation: fadeSlideUp 0.5s ease-out forwards;
}

/* Wizard screens (2-4): progress bar is a floating element (doesn't affect centering) */
#screen2,
#screen3,
#screen4 {
    position: relative;
}

#screen2 > .progress-bar-wrapper,
#screen3 > .progress-bar-wrapper,
#screen4 > .progress-bar-wrapper {
    position: absolute;
    top: 72px; /* visual spacing ABOVE the bar (so it sits a bit lower) */
    left: 0;
    right: 0;
    margin: 0;
    z-index: 5;
    pointer-events: none;
}

#screen2 .container,
#screen3 .container,
#screen4 .container {
    /* Center relative to the full viewport (not "below the bar") */
    min-height: calc(100vh - (2 * var(--screen-padding)));
    min-height: calc(100dvh - (2 * var(--screen-padding)));
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    /* Vertical alignment */
    justify-content: center;
    /* Horizontal alignment */
    min-height: calc(100vh - (2 * var(--screen-padding)));
    min-height: calc(100dvh - (2 * var(--screen-padding)));
    gap: 40px 80px;
    padding-bottom: env(safe-area-inset-bottom);
    /* iOS Home bar safety */
}

/* Left content area */
.content-left {
    flex: 1 1 400px;
    min-width: 300px;
    max-width: 500px;
}

/* Right content area */
.content-right {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Center content area (for questions and upload screens) */
.content-center {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 24px;
    color: var(--color-text);
}

.intro-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.privacy-disclaimer {
    font-size: 0.8rem;
    color: #888;
    margin-top: 12px;
    font-style: italic;
    max-width: 400px;
}

.hashtag {
    font-weight: 600;
    color: var(--color-text);
}

/* Primary Button */
.btn-primary {
    background-color: var(--color-clover);
    color: white;
    border: 2px solid transparent;
    /* Identical width to secondary */
    padding: 14px 32px;
    /* Identical padding to secondary */
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-top: 24px;
    box-sizing: border-box;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:hover {
    background-color: var(--color-clover-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background-color: var(--color-clover-light);
    cursor: not-allowed;
}

/* Logo Image (Screen 1) */
.logo-image {
    max-width: 100%;
    width: 270px;
    height: auto;
    /* Removed border-radius and box-shadow to make it stand alone */
}

/* Wizard Progress Bar */
.progress-bar-wrapper {
    width: 100%;
    margin-bottom: 48px;
    /* High spacing for cleaner look */
}

.wizard-progress {
    display: flex;
    align-items: flex-start;
    /* Align to top so we can manually position line relative to icon */
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    position: relative;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    color: var(--color-clover-light);
    gap: 12px;
    transition: color 0.3s ease;
    flex: 0 0 auto;
}

.step-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: white;
    border: 2px solid var(--color-pebble);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.step-icon-mask {
    width: 24px;
    height: 24px;
    display: block;
    background-color: currentColor; /* follows .step-item color states (inactive/active/completed) */
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
}

.step-icon-food {
    -webkit-mask-image: url('src/img/FoodLover.svg');
    mask-image: url('src/img/FoodLover.svg');
}

.step-icon-growth {
    -webkit-mask-image: url('src/img/GrowthHunter.svg');
    mask-image: url('src/img/GrowthHunter.svg');
}

.step-icon-photo {
    -webkit-mask-image: url('src/img/Photo.svg');
    mask-image: url('src/img/Photo.svg');
}

.step-label {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    /* Added for vertical alignment */
    min-height: 2.4em;
    /* Height of 2 lines */
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-line {
    flex: 1;
    height: 2px;
    background-color: var(--color-pebble);
    margin: 0 8px;
    /* Center line relative to 48px icon: Top 23px = (48/2 - 2/2) */
    margin-top: 23px;
    position: relative;
    z-index: 1;
}

/* Active State */
.step-item.active {
    color: var(--color-clover);
}

.step-item.active .step-icon {
    border-color: var(--color-clover);
    background-color: var(--color-earth);
    color: var(--color-clover);
    box-shadow: 0 0 0 4px rgba(43, 145, 28, 0.1);
}

/* Completed State */
.step-item.completed {
    color: var(--color-clover);
}

.step-item.completed .step-icon {
    background-color: var(--color-clover);
    border-color: var(--color-clover);
    color: white;
}

/* Navigation Buttons */
.navigation-buttons {
    display: flex;
    gap: 20px;
    margin-top: 32px;
    width: 100%;
    justify-content: center;
    align-items: center;
    /* Ensure vertical center alignment */
}

.navigation-buttons button {
    min-width: 140px;
    /* Consistent width */
    margin: 0;
    justify-content: center;
}

/* Screen 2-4: Wizard Screens */
#screen2 .content-center,
#screen3 .content-center,
#screen4 .content-center {
    align-items: center;
    /* Center everything including questions */
    text-align: center;
}

#screen2 h1,
#screen3 h1 {
    text-align: center;
    width: 100%;
}

.question-block {
    margin-bottom: 32px;
    width: 100%;
    text-align: left;
    /* Keep question left aligned for readability */
}

.question-title {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
    margin-bottom: 8px;
}

.question-hint {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #6a6a6a;
    margin-bottom: 12px;
}

.question-input {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--color-pebble);
    border-radius: 8px;
    background-color: white;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.question-input:focus {
    outline: none;
    border-color: var(--color-clover);
}

.question-input::placeholder {
    color: #a0a0a0;
}

/* Screen 3: Upload */
.upload-area {
    width: 100%;
    background-color: white;
    border: 2px dashed var(--color-pebble);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    margin-bottom: 24px;
}

.upload-area:hover {
    border-color: var(--color-clover);
    background-color: var(--color-earth);
}

.upload-icon {
    color: var(--color-clover);
    margin-bottom: 16px;
}

.upload-area h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9rem;
    color: #6a6a6a;
}

.photo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.photo-preview-frame {
    position: relative;
    display: inline-block;
}

.photo-preview img {
    display: block;
    width: min(420px, 78vw);
    height: auto;
    max-height: min(46vh, 420px);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

.photo-change-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 2px solid rgba(222, 222, 215, 0.9);
    background: rgba(255, 255, 255, 0.92);
    color: var(--color-clover);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.photo-change-btn:hover {
    background: white;
    border-color: var(--color-clover-light);
}

.photo-change-btn:active {
    transform: scale(0.98);
}

.photo-preview.hidden {
    display: none;
}

/* Extra breathing room on photo step so the preview doesn't feel glued to the progress bar */
#screen4 .step-content {
    padding-top: 16px;
}

/* Secondary Button (white with green text) */
.btn-secondary {
    background-color: white;
    color: var(--color-clover);
    border: 2px solid var(--color-clover);
    padding: 14px 32px;
    /* Identical padding to primary */
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-secondary:hover {
    background-color: var(--color-earth);
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* Hide initial generate button when preview is shown */
.btn-generate-initial {
    display: block;
    margin: 24px auto 0 auto;
}

/* Screen 4: Loading */
.loading-content {
    text-align: center;
}

.progress-container {
    width: 100%;
    max-width: 500px;
    height: 8px;
    background-color: var(--color-pebble);
    border-radius: 4px;
    margin: 40px auto;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--color-clover);
    width: 0%;
    transition: width 0.5s ease;
}

.loading-status {
    font-size: 1rem;
    color: #6a6a6a;
}

/* Error state on loading screen */
.error-content {
    text-align: center;
}

.error-content.hidden {
    display: none;
}

.error-content h1 {
    margin-bottom: 16px;
}

.error-message {
    margin-bottom: 32px;
    color: #6a6a6a;
}

/* Screen 5: Results */
.combined-portrait {
    display: block;
    height: min(70vh, 760px);
    width: auto;
    max-width: min(44vw, 520px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    object-fit: cover;
}

/* Screen 6: Results Grid Layout */
.results-layout {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    grid-template-areas: "copy image";
    align-items: center;
    gap: 0 40px;
    width: 100%;
}

.results-copy {
    grid-area: copy;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.results-title {
    margin: 0;
}

.results-image-area {
    grid-area: image;
    display: flex;
    justify-content: center;
}

.results-text-area {
    margin: 0;
}

.button-group {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 520px;
}

.button-group .btn-primary,
.button-group .btn-secondary {
    margin-top: 0;
    flex: 1;
}

/* Responsive Design */

/* Screen 1: keep logo on the left as long as we are in 2-column layout (tablet + desktop) */
@media (min-width: 769px) {
    #screen1 .container {
        flex-direction: row-reverse;
    }
}

/* Tablet and smaller desktop */
@media (max-width: 1024px) {
    .container {
        gap: 30px 40px;
    }

    .content-left {
        flex: 1 1 350px;
    }

    .content-right {
        flex: 1 1 280px;
    }

    .logo-image {
        width: 300px;
    }
}

/* When content wraps to single column */
@media (max-width: 768px) {
    :root {
        --screen-padding: 20px;
    }

    .screen {
        min-height: 100dvh;
    }

    .container {
        flex-direction: column;
        text-align: left;
        gap: 20px;
        justify-content: center;
        /* Default to center for native feel */
        align-items: center;
        min-height: calc(100vh - (2 * var(--screen-padding)));
        min-height: calc(100dvh - (2 * var(--screen-padding)));
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }

    /* Force specific screens to top alignment if needed (removed for centering) */
    /* #screen2 .container,
    #screen3 .container {
        justify-content: flex-start;
        padding-top: 40px;
    } */

    .content-left {
        flex: none;
        width: 100%;
        max-width: 100%;
        order: 1;
    }

    .content-right {
        flex: none;
        width: 100%;
        max-width: 100%;
        order: 2;
        justify-content: flex-start;
    }

    .logo-image {
        width: 280px;
    }

    /* Screen 1: when stacked, show the logo above the text */
    #screen1 .content-right {
        order: 1;
        justify-content: center;
    }

    #screen1 .content-left {
        order: 2;
    }

    /* Screen 1: smaller logo when stacked */
    #screen1 .logo-image {
        width: 100%;
        max-width: 220px;
    }

    h1 {
        font-size: 1.75rem;
    }

    .combined-portrait {
        height: min(56vh, 640px);
        max-width: min(78vw, 420px);
    }

    /* Wizard progress bar: keep it high on mobile so it never overlaps centered content */
    #screen2 > .progress-bar-wrapper,
    #screen3 > .progress-bar-wrapper,
    #screen4 > .progress-bar-wrapper {
        top: calc(env(safe-area-inset-top) + 12px);
    }

    .wizard-progress {
        max-width: 360px;
    }

    .step-icon {
        width: 42px;
        height: 42px;
    }

    .step-icon-mask {
        width: 22px;
        height: 22px;
    }

    .step-line {
        /* Center line relative to 42px icon: Top 20px = (42/2 - 2/2) */
        margin-top: 20px;
    }

    .step-label {
        font-size: 0.8rem;
        min-height: 2.2em;
    }
}

/* Mobile */
@media (max-width: 600px) {
    :root {
        --screen-padding: 16px;
    }

    /* (padding is controlled via --screen-padding) */

    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
        margin-bottom: 20px;
    }

    .intro-text,
    .question-hint {
        font-size: 1rem;
        /* Better readability */
    }

    /* Make buttons full width for better touch targets */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 16px 24px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .btn-secondary {
        margin-bottom: 12px;
    }

    /* Photo step: keep Back + Generate side-by-side on mobile */
    #screen4 #uploadNavButtons {
        flex-direction: row;
        gap: 12px;
    }

    #screen4 #uploadNavButtons .btn-primary,
    #screen4 #uploadNavButtons .btn-secondary {
        width: auto;
        flex: 1;
        margin: 0;
    }

    /* Optimization for questions */
    .question-block {
        margin-bottom: 36px;
    }

    .question-title {
        font-size: 1.15rem;
        margin-bottom: 12px;
    }

    .question-input {
        font-size: 16px;
        /* Prevents auto-zoom on iOS */
        padding: 14px;
        min-height: 120px;
        /* Larger tap area */
    }

    /* Logo optimization */
    .logo-image {
        width: 100%;
        max-width: 280px;
        margin-top: 20px;
    }

    .content-right {
        justify-content: center;
        padding-top: 10px;
    }

    /* Upload area optimization */
    .upload-area {
        padding: 30px 20px;
        border-width: 2px;
    }

    .combined-portrait {
        height: min(52vh, 560px);
        max-width: min(86vw, 380px);
    }

    /* Screen 6 Results Mobile Layout - Single Viewport Optimized */
    .results-layout {
        display: flex;
        flex-direction: column;
        text-align: center;
        min-height: 100dvh;
        justify-content: center;
        /* Center content vertically */
        padding-top: 28px;
        padding-bottom: 20px;
        gap: 16px;
        /* consistent compact gap */
    }

    /* Let title/text/buttons participate as direct flex children again (keeps the old ordering) */
    .results-copy {
        display: contents;
    }

    .results-title {
        order: 1;
        font-size: 1.4rem;
        margin-bottom: 0;
        /* Let gap handle spacing */
        line-height: 1.2;
    }

    .results-image-area {
        order: 2;
        margin-bottom: 0;
        margin: 0;
    }

    .results-text-area {
        order: 3;
        margin-bottom: 0;
    }

    .results-text-area .intro-text {
        font-size: 0.9rem;
        margin-bottom: 0;
    }

    .button-group {
        order: 4;
        display: flex;
        flex-direction: row;
        gap: 10px;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }

    .button-group .btn-primary,
    .button-group .btn-secondary {
        width: auto;
        flex: 1;
        margin: 0;
        padding: 12px 6px;
        /* Compact padding */
        font-size: 0.9rem;
        min-width: 0;
        /* Allow shrinking if needed */
        white-space: nowrap;
    }

    /* Screen 1: make everything more compact so it fits in one viewport */
    #screen1 .container {
        gap: 14px;
        /* Create a clean hero layout:
           - logo sits centered in the free space above the copy
           - copy + CTA stay visible at the bottom (with safe-area padding) */
        justify-content: flex-start;
        align-items: stretch;
        min-height: calc(100vh - (2 * var(--screen-padding)));
        min-height: calc(100dvh - (2 * var(--screen-padding)));
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }

    #screen1 .content-right {
        flex: 1 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #screen1 .content-left {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        margin-top: auto;
    }

    #screen1 h1 {
        font-size: 1.45rem;
        line-height: 1.2;
        margin-bottom: 12px;
    }

    #screen1 .intro-text {
        font-size: 0.92rem;
        line-height: 1.45;
        margin-bottom: 10px;
    }

    #screen1 .btn-primary {
        margin-top: 12px;
        padding: 12px 18px;
        font-size: 0.95rem;
    }

    #screen1 .privacy-disclaimer {
        font-size: 0.72rem;
        margin-top: 8px;
    }

    #screen1 .logo-image {
        max-width: 200px;
        margin-top: 0;
    }

    #screen1 .content-right {
        padding-top: 0;
    }
}