/* ===== CVALVINO WINE RECOMMENDATION SYSTEM ===== */
/* Enhanced Mobile-Responsive Design for iPhone & Android */

/* ===== ROOT VARIABLES ===== */
:root {
    --primary-burgundy: #6B3A47;
    --secondary-pink: #D47B8D;
    --accent-red: #C76B7D;
    --hover-pink: #E89CAB;
    --text-white: #FFFFFF;
    --text-dark: #6B3A47;
    --input-blue: #A8D5DB;
    --shadow: 2px 2px 10px rgba(0,0,0,0.4);
    --border-radius: 15px;
    --transition: all 0.3s ease;
}

/* ===== GLOBAL RESET & BASE STYLES ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(135deg, var(--primary-burgundy) 0%, #8B4A52 100%);
    color: var(--text-white);
    font-family: 'Georgia', serif;
    line-height: 1.6;
    min-height: 100vh;
    padding: 10px;
    overflow-x: hidden;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-white);
    margin-bottom: 1rem;
    font-weight: bold;
}

h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 1.5rem;
}

h2 {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
}

h3 {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
}

p {
    margin-bottom: 1rem;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

/* ===== CONTAINER & LAYOUT ===== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.container {
    background-color: var(--secondary-pink);
    padding: clamp(15px, 4vw, 30px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    color: var(--text-dark);
}

/* ===== NAVIGATION ===== */
nav {
    background-color: var(--secondary-pink);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

nav a {
    color: var(--text-dark);
    margin: 5px 10px;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 8px;
    transition: var(--transition);
    display: inline-block;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

nav a:hover {
    background-color: var(--accent-red);
    color: var(--text-white);
    transform: translateY(-2px);
}

/* ===== BUTTONS ===== */
.btn {
    background-color: var(--accent-red);
    color: var(--text-white);
    font-weight: bold;
    border: none;
    border-radius: 8px;
    padding: clamp(12px, 3vw, 18px) clamp(20px, 5vw, 30px);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
}

.btn:hover, .btn:focus {
    background-color: var(--hover-pink);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    width: 100%;
    margin-top: 20px;
}

.btn-secondary {
    background-color: transparent;
    border: 2px solid var(--accent-red);
    color: var(--accent-red);
}

.btn-secondary:hover {
    background-color: var(--accent-red);
    color: var(--text-white);
}

.back-button {
    margin-bottom: 20px;
    margin-right: 10px;
}

/* ===== FORMS ===== */
.form-container {
    background-color: var(--secondary-pink);
    padding: clamp(20px, 5vw, 30px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    color: var(--text-dark);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(15px, 4vw, 25px);
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.form-group label {
    color: var(--text-dark);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: clamp(10px, 3vw, 15px);
    border-radius: 8px;
    border: 2px solid var(--text-dark);
    background-color: var(--input-blue);
    color: var(--text-dark);
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    transition: var(--transition);
    min-height: 44px; /* iOS touch target minimum */
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(196, 79, 93, 0.2);
}

.form-group select[multiple] {
    min-height: 120px;
}

.form-group small {
    color: var(--text-dark);
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.8;
}

/* ===== WINE CARDS & RESULTS ===== */
.wine-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.wine-container {
    display: flex;
    flex-direction: column;
    background-color: var(--secondary-pink);
    color: var(--text-dark);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: var(--transition);
}

.wine-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.wine-image {
    text-align: center;
    margin-bottom: 15px;
}

.wine-image img {
    width: clamp(80px, 20vw, 120px);
    height: auto;
    border-radius: 8px;
}

.wine-details h3 {
    color: var(--text-dark);
    margin-bottom: 15px;
    font-size: clamp(1.1rem, 3vw, 1.4rem);
}

.wine-details p {
    margin: 8px 0;
    line-height: 1.5;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
}

.wine-details strong {
    font-weight: bold;
    color: var(--primary-burgundy);
}

.vivino-button {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: #800000;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    transition: var(--transition);
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vivino-button:hover {
    background-color: #a00000;
    transform: translateY(-2px);
}

/* ===== ERROR & SUCCESS MESSAGES ===== */
.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #c62828;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.success-message {
    background-color: #e8f5e8;
    color: #2e7d32;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2e7d32;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

/* ===== LOADING STATES ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Mobile First - Base styles above are for mobile */

/* Small Mobile (iPhone SE, older Android) */
@media (max-width: 375px) {
    body {
        padding: 5px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .wine-container {
        padding: 15px;
    }

    h1 {
        font-size: 1.6rem;
    }
}

/* Large Mobile (iPhone 12/13/14, modern Android) */
@media (min-width: 376px) and (max-width: 767px) {
    .wine-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .wine-image {
        flex: 0 0 120px;
        margin-right: 20px;
        margin-bottom: 0;
    }

    .wine-details {
        flex: 1;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    body {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wine-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .wine-image {
        flex: 0 0 150px;
        margin-right: 20px;
        margin-bottom: 0;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    body {
        padding: 30px;
    }

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

    .wine-results {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }

    .wine-container {
        flex-direction: row;
        align-items: flex-start;
    }

    .wine-image {
        flex: 0 0 150px;
        margin-right: 20px;
        margin-bottom: 0;
    }
}

/* ===== DEVICE-SPECIFIC OPTIMIZATIONS ===== */

/* iOS Safari specific */
@supports (-webkit-touch-callout: none) {
    .form-group input,
    .form-group select {
        -webkit-appearance: none;
        border-radius: 8px;
    }

    .btn {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Android Chrome specific */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: .001dpcm) {
    .form-group select {
        background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23722F37' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 12px;
        padding-right: 40px;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode - Preserve wine colors with better contrast */
@media (prefers-contrast: high) {
    :root {
        --primary-burgundy: #6B3A47;
        --secondary-pink: #D47B8D;
        --accent-red: #C76B7D;
        --text-white: #FFFFFF;
        --text-dark: #6B3A47;
        --input-blue: #A8D5DB;
        --shadow: 4px 4px 15px rgba(0,0,0,0.6);
    }
}

/* Focus indicators for keyboard navigation */
.btn:focus,
.form-group input:focus,
.form-group select:focus,
nav a:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
    body {
        background: white;
        color: black;
        padding: 0;
    }

    .btn,
    nav,
    .vivino-button {
        display: none;
    }

    .wine-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden { display: none; }
.visible { display: block; }

/* ===== ANIMATION CLASSES ===== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
