/* ============================================================================
   SUNDAY DINNER APP - UNIFIED DESIGN SYSTEM
   ============================================================================ */

/* COLOR PALETTE - Design Tokens */
:root {
    /* Primary Colors */
    --color-primary: #556B4D;
    --color-primary-dark: #475744;
    --color-primary-darker: #3D4A39;
    --color-primary-light: #9CAF88;
    --color-primary-lighter: #D4E0C5;

    /* Neutral Colors */
    --color-bg-primary: #EDE9E3;
    --color-bg-secondary: #FFFFFF;
    --color-text-primary: #333333;
    --color-text-secondary: #555555;
    --color-text-tertiary: #999999;
    --color-text-muted: #CCCCCC;

    /* State Colors */
    --color-border: #556B4D;
    --color-border-light: rgba(85, 107, 77, 0.15);
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-focus: rgba(156, 175, 136, 0.3);

    /* Semantic Colors (for future use) */
    --color-success: #8BA76B;
    --color-success-light: #E8F5E9;
    --color-warning: #D4A574;
    --color-warning-light: #FFF8F0;
    --color-error: #B87C6C;
    --color-error-light: #FFEBEE;
    --color-info: #556B4D;

    /* Typography */
    --font-serif: 'Georgia', 'Garamond', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

    /* Font Sizes */
    --font-size-h1: 3.5rem;
    --font-size-h2: 2.5rem;
    --font-size-h3: 1.8rem;
    --font-size-body: 1.0625rem;
    --font-size-small: 0.875rem;
    --font-size-caption: 0.75rem;

    /* Line Heights */
    --line-height-tight: 1.2;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.8;

    /* Spacing Scale (8px base) */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 2.5rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-quick: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms ease;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    line-height: var(--line-height-normal);
    display: block;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 400;
    line-height: 1.3;
}

h1 {
    font-size: var(--font-size-h1);
    margin-bottom: var(--space-lg);
    text-align: center;
    color: var(--color-text-primary);
    letter-spacing: 0.02em;
}

h2 {
    font-size: var(--font-size-h2);
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
}

h3 {
    font-size: var(--font-size-h3);
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 var(--space-md) 0;
    color: var(--color-text-secondary);
    line-height: var(--line-height-normal);
}

/* ============================================================================
   LAYOUT CONTAINERS
   ============================================================================ */

.page-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* ============================================================================
   WELCOME SECTION
   ============================================================================ */

.welcome-text {
    text-align: center;
    font-size: 1.25rem;
    color: var(--color-text-primary);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-2xl);
    line-height: 1.8;
}

/* ============================================================================
   INPUT STYLES
   ============================================================================ */

.input-container {
    display: flex;
    justify-content: center;
    margin: var(--space-2xl) 0 var(--space-sm) 0;
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.input-label {
    display: block;
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--space-sm);
}

.input-box {
    width: 100%;
    height: 150px;
    background-color: var(--color-bg-secondary);
    border: 2px inset var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    padding-bottom: 2.5rem;
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    color: var(--color-text-primary);
    resize: none;
    margin-bottom: var(--space-lg);
    transition: border-color var(--transition-quick), box-shadow var(--transition-quick);
}

.input-box::placeholder {
    color: #888888;
}

.input-box:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.input-box:disabled {
    background-color: #F5F5F5;
    border-color: var(--color-border-light);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
}

.input-note {
    margin-top: var(--space-sm);
    text-align: center;
    font-size: var(--font-size-small);
    color: var(--color-text-secondary);
    font-style: normal;
    font-weight: 500;
    opacity: 0.85;
}

/* ============================================================================
   BUTTON STYLES
   ============================================================================ */

.submit-button {
    display: block;
    margin: var(--space-md) auto 0.75rem;
    padding: var(--space-sm) var(--space-lg);
    max-width: 200px;
    background-color: var(--color-primary);
    color: var(--color-bg-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-quick), transform var(--transition-quick), box-shadow var(--transition-quick);
    box-shadow: var(--shadow-sm);
}

.submit-button:hover:not(:disabled) {
    background-color: var(--color-primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.submit-button:active:not(:disabled) {
    background-color: var(--color-primary-darker);
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.submit-button:disabled {
    background-color: #E8E8E8;
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.submit-button:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================================================
   LAYOUT - THREE COLUMN WITH SIDE GALLERIES
   ============================================================================ */

.page-layout {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    flex: 0 0 auto;
}

.content-center {
    flex: 0 1 600px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: var(--space-lg);
    min-width: 0;
}

.gallery-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 280px;
    min-width: 0;
}

.gallery-left {
    order: -1;
}

.gallery-right {
    order: 1;
}

.gallery-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    padding: 0;
    background-color: var(--color-bg-primary);
}

/* ============================================================================
   GALLERY STYLES
   ============================================================================ */

.gallery img,
.gallery-side img,
.gallery-bottom img {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    object-fit: cover;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-radius var(--transition-normal);
}

/* Phase 3: Proportional border radius based on image size */
.gallery-img[data-size="220px"],
.gallery-img[data-size="200px"] {
    border-radius: 12px;
}

.gallery-img[data-size="180px"] {
    border-radius: 10px;
}

.gallery-img[data-size="160px"] {
    border-radius: 8px;
}

/* Phase 5: Proportional hover scaling - Desktop only */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .gallery-img[data-size="220px"]:hover,
    .gallery-img[data-size="200px"]:hover {
        transform: scale(1.08);
        box-shadow: var(--shadow-lg);
    }

    .gallery-img[data-size="180px"]:hover {
        transform: scale(1.10);
        box-shadow: var(--shadow-lg);
    }

    .gallery-img[data-size="160px"]:hover {
        transform: scale(1.12);
        box-shadow: var(--shadow-lg);
    }
}

/* ============================================================================
   MODAL STYLES
   ============================================================================ */

dialog {
    padding: var(--space-md);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

.modal h2 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: var(--font-size-h2);
    text-align: center;
    color: var(--color-text-primary);
    grid-column: 1 / -1;
}

.modal h3 {
    margin-top: 0;
    margin-bottom: var(--space-sm);
    text-align: center;
    color: var(--color-text-primary);
    grid-column: 1 / -1;
}

.modal form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.modal-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.modal-fieldset legend {
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
    padding: 0;
    font-size: var(--font-size-body);
}

.fieldset-label {
    display: block;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-body);
}

/* Required field indicator - adds red asterisk after labels for required inputs */
.fieldset-label[for][for*="servings"]::after,
.fieldset-label[for][for*="cooking"]::after,
.fieldset-label[for][for*="time"]::after {
    content: " *";
    color: var(--color-error);
    font-weight: 600;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
}

.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
}

.checkbox-group label,
.radio-group label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--font-size-body);
    color: var(--color-text-primary);
}

.checkbox-group input[type="checkbox"],
.radio-group input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}

.checkbox-group input[type="checkbox"]:focus-visible,
.radio-group input[type="radio"]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

select {
    width: 75%;
    padding: var(--space-sm);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    color: var(--color-text-primary);
    background-color: var(--color-bg-secondary);
    cursor: pointer;
    transition: border-color var(--transition-quick);
    text-align: left;
}

select:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-color: var(--color-primary);
}

input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border-light);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-quick);
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: var(--shadow-md);
}

input[type="range"]::-webkit-slider-thumb:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-quick);
}

input[type="range"]::-moz-range-thumb:hover {
    box-shadow: var(--shadow-md);
}

input[type="range"]::-moz-range-thumb:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

input[type="range"]::-moz-range-track {
    background: transparent;
    border: none;
}

input[type="range"]:focus {
    outline: none;
}

.range-wrapper {
    display: flex;
    align-items: center;
    width: 85%;
}

.range-wrapper input[type="range"] {
    width: 100%;
}

.range-legend {
    display: flex;
    justify-content: space-between;
    width: 85%;
    margin-top: var(--space-xs);
    font-size: var(--font-size-small);
    color: var(--color-text-secondary);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-md);
    grid-column: 1 / -1;
}

.modal-actions button {
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-quick), transform var(--transition-quick), box-shadow var(--transition-quick);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-actions button[value="cancel"] {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 2px solid var(--color-border);
}

.modal-actions button[value="cancel"]:hover {
    background-color: var(--color-border-light);
}

.modal-actions button.primary {
    background-color: var(--color-primary);
    color: var(--color-bg-secondary);
    box-shadow: var(--shadow-sm);
}

.modal-actions button.primary:hover {
    background-color: var(--color-primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.modal-actions button:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================================================
   ERROR PAGE STYLES
   ============================================================================ */

.error-container {
    max-width: 600px;
    margin: var(--space-3xl) auto;
    padding: var(--space-xl);
    background-color: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.error-container h1 {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: var(--space-md);
}

.error-container p {
    font-size: var(--font-size-body);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xl);
}

.error-container a {
    display: inline-block;
    padding: var(--space-sm) var(--space-lg);
    background-color: var(--color-primary);
    color: var(--color-bg-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: background-color var(--transition-quick);
}

.error-container a:hover {
    background-color: var(--color-primary-dark);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* TABLET LANDSCAPE (1024px) */
@media (max-width: 1024px) {
    .page-layout {
        flex-direction: column;
        padding: var(--space-sm);
    }

    .gallery-side {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-md);
        max-width: 100%;
    }

    .gallery-side img {
        aspect-ratio: 1 / 1;
        object-fit: cover;
        max-width: 200px;
        height: auto;
    }

    .gallery-left,
    .gallery-right {
        order: unset;
    }
}

/* TABLET PORTRAIT (768px) */
@media (max-width: 768px) {
    :root {
        --font-size-h1: 2.5rem;
        --font-size-h2: 1.8rem;
        --font-size-h3: 1.3rem;
        --space-3xl: 2rem;
    }

    .page-layout {
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-sm);
    }

    .content-center {
        padding: var(--space-md);
    }

    .gallery-side {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-md);
    }

    .input-container {
        margin: var(--space-2xl) 0 var(--space-xs) 0;
    }

    .input-box {
        height: 120px;
    }

    .submit-button {
        min-height: 48px;
    }

    .gallery-bottom {
        gap: var(--space-sm);
    }
}

/* MOBILE LANDSCAPE (600px) - PHASE 1 & 2 */
@media (max-width: 600px) {
    :root {
        --font-size-h1: 2.25rem;
        --font-size-body: 0.95rem;
    }

    .welcome-text {
        font-size: 1rem;
        margin-bottom: var(--space-xl);
    }

    .input-container {
        margin: var(--space-xl) 0;
    }

    .input-box {
        height: 110px;
    }

    /* Phase 2: Responsive scaling - 70% of desktop */
    .gallery-img[data-size="220px"],
    .gallery-img[data-size="200px"] {
        width: 154px !important;
        height: 154px !important;
    }

    .gallery-img[data-size="180px"] {
        width: 126px !important;
        height: 126px !important;
    }

    .gallery-img[data-size="160px"] {
        width: 112px !important;
        height: 112px !important;
    }

    .gallery-bottom {
        gap: 0.75rem;
    }
}

/* SMALL MOBILE (480px) - PHASE 1 */
@media (max-width: 480px) {
    :root {
        --font-size-h1: 2rem;
        --font-size-body: 0.95rem;
    }

    h1 {
        margin-bottom: var(--space-md);
        line-height: 1.25;
    }

    .welcome-text {
        font-size: 0.95rem;
        margin-top: var(--space-md);
        margin-bottom: var(--space-lg);
    }

    .input-container {
        margin: var(--space-lg) 0;
    }

    .input-box {
        height: 85px;
        padding: var(--space-sm);
    }

    .submit-button {
        min-height: 48px;
        padding: 0.5rem var(--space-sm);
        font-size: 0.95rem;
    }

    .gallery-side img,
    .gallery-bottom img {
        width: 100px;
        height: 100px;
    }

    .gallery-bottom {
        gap: 0.5rem;
        padding: var(--space-md);
    }
}

/* EXTRA SMALL MOBILE (375px) - PHASE 1 & 2 */
@media (max-width: 375px) {
    :root {
        --font-size-h1: 1.75rem;
        --font-size-body: 0.9rem;
    }

    body {
        padding: 0;
    }

    h1 {
        margin-bottom: 0.75rem;
        line-height: 1.3;
        letter-spacing: 0.01em;
    }

    .welcome-text {
        font-size: 0.9rem;
        margin-top: var(--space-sm);
        margin-bottom: var(--space-md);
        line-height: 1.6;
    }

    .page-layout {
        padding: var(--space-sm);
        gap: var(--space-sm);
        min-height: auto;
    }

    .content-center {
        padding: var(--space-md);
    }

    .input-container {
        margin: var(--space-md) 0;
    }

    .input-wrapper {
        padding: 0 0;
    }

    .input-box {
        height: 80px;
        padding: 0.75rem;
        font-size: 0.95rem;
        border-radius: 4px;
    }

    .input-box::placeholder {
        color: #888888;
        font-size: 0.85rem;
    }

    .submit-button {
        min-height: 44px;
        padding: 0.5rem var(--space-sm);
        font-size: 0.9rem;
        margin: var(--space-md) auto 0;
    }

    .gallery-side img,
    .gallery-bottom img {
        width: 90px;
        height: 90px;
    }

    .gallery-bottom {
        gap: 0.4rem;
        padding: var(--space-md) var(--space-sm);
    }

    .gallery-bottom img {
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }
}

/* PHASE 2: TOUCH OPTIMIZATION (all mobile) */
@media (max-width: 768px) {
    .submit-button {
        min-height: 48px;
    }
}

/* PHASE 3: FINE-TUNING */
@media (max-width: 768px) {
    h1 {
        line-height: 1.25;
    }

    .gallery-side img,
    .gallery-bottom img {
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }

    .input-container {
        margin: var(--space-xl) 0;
    }
}