/* 1. Fix the Vibe & Scrolling */
html {
    /* Prevents annoying "bounce" when you reach the top/bottom */
    overscroll-behavior: none;
    /* Smooths out text rendering on high-res Retina displays */
    -webkit-font-smoothing: antialiased;
}

/* 1. Global Styles & Typography */
* { box-sizing: border-box; }
body { 
    font-family: 'Georgia', serif; 
    background-color: #fdfcf8; 
    color: #1a1a1a; 
    margin: 0; 
    line-height: 1.6; 
}

body {
    /* Fallback for Safari < 15.4, which doesn't understand dvh */
    min-height: 100vh;
    /* Responsive height that accounts for iPad address bars */
    min-height: 100dvh;
    /* Safe area padding for iPads with notches/home bars */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 20px env(safe-area-inset-left);
}

.header-section { 
    text-align: center; 
    margin-bottom: 30px; 
    width: 100%; 
    padding-top: 20px;
}

h1 { 
    text-transform: uppercase; 
    letter-spacing: 8px; 
    font-weight: normal; 
    border-bottom: 1px solid #d4af37; 
    display: inline-block; 
    padding-bottom: 10px; 
    font-size: 1.6em; 
}

/* 2. Tab Navigation Logic (No JavaScript) */
.tab-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

/* Margin-based spacing fallback for Safari < 14.1 (no flexbox gap) */
.tab-controls .tab-label {
    margin: 0 7.5px;
}

@supports (gap: 1px) {
    .tab-controls {
        gap: 15px;
    }
    .tab-controls .tab-label {
        margin: 0;
    }
}

.tab-label {
    padding: 12px 25px;
    border: 1px solid #d4af37;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.85em;
    transition: all 0.3s ease;
    border-radius: 50px;
    color: #555;
    touch-action: manipulation;
    /* Prevents the grey highlight box when tapping on iOS */
    -webkit-tap-highlight-color: transparent;
    /* Ensures labels don't get selected like text when tapping fast */
    -webkit-user-select: none;
    user-select: none;
}

/* Hide the actual radio buttons */
input[type="radio"] { display: none; }

/* Style the active tab label */
#tab-reds:checked ~ .tab-controls label[for="tab-reds"],
#tab-whites:checked ~ .tab-controls label[for="tab-whites"],
#tab-spirits:checked ~ .tab-controls label[for="tab-spirits"],
#tab-quick-picks:checked ~ .tab-controls label[for="tab-quick-picks"] {
    background-color: #7a0019;
    color: #fdfcf8;
    border-color: #7a0019;
    box-shadow: 0 4px 10px rgba(122, 0, 25, 0.2);
}

/* Show/Hide content based on selection */
.tab-content { display: none; }

#tab-reds:checked ~ #reds-content,
#tab-whites:checked ~ #whites-content,
#tab-spirits:checked ~ #spirits-content,
#tab-quick-picks:checked ~ #quick-picks-content {
    display: block;
}

/* 3. The "Newspaper" Column Layout.
   Built by JS (column-layout.js) instead of native CSS multi-column: older
   Safari's column-balancing algorithm can ignore break-inside: avoid and
   slice a menu-item in half across the column boundary. JS measures real
   layout and moves whole items between two explicit columns, so there's
   never a native column break for the browser to get wrong. With JS
   disabled, content just renders in a single column. */
.menu-wrapper {
    max-width: 1100px;
    margin: auto;
}

/* Shared by .menu-wrapper and .spirits-grid once JS has split their
   children into two .menu-col containers. */
.js-two-col {
    display: flex;
    align-items: flex-start;
    gap: 60px;
}

.js-two-col > .menu-col {
    flex: 1 1 0;
    min-width: 0;
}

@media (min-width: 900px) {
    /* When a tab only has a single category block (e.g. Spirits, Quick Picks),
       JS never splits it into two columns (see column-layout.js) — center it
       instead of leaving it full-width. .single-category is a JS-applied
       fallback for Safari < 15.4, which doesn't support :has(). */
    .menu-wrapper:has(> .category-block:only-child),
    .menu-wrapper.single-category {
        display: flex;
        justify-content: center;
    }

    .menu-wrapper:has(> .category-block:only-child) > .category-block,
    .menu-wrapper.single-category > .category-block {
        width: 100%;
        max-width: 620px;
    }
}

.category-block {
    margin-bottom: 50px;
    text-align: center;
}

h2 { 
    font-style: italic; 
    font-weight: normal; 
    font-size: 2.2em; 
    margin: 0 0 10px 0; 
    color: #7a0019; 
    border-bottom: 1px double #d4af37;
    padding-bottom: 10px;
    display: inline-block;
}

.tier-divider { 
    margin: 15px 0; 
    color: #d4af37; 
    font-size: 1.2em; 
    letter-spacing: 12px; 
    opacity: 0.8;
}

.menu-item {
    margin-bottom: 22px;
}

.producer { 
    display: block; 
    text-transform: uppercase; 
    font-size: 0.8em; 
    letter-spacing: 2px; 
    color: #555; 
    margin-bottom: 3px;
}
.wine-info { font-size: 1.15em; display: block; font-weight: 500; }
.vintage { font-size: 0.95em; color: #777; margin-left: 3px; }

.tier-Fancy .wine-info {
    letter-spacing: 0.5px;
}

/* 4. Wine/Spirit Detail Popup */
.wine-name-link {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    border-bottom: 1px dotted #d4af37;
    padding: 0;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.detail-modal-overlay {
    display: none;
    position: fixed;
    /* Fallback for Safari < 14.1, which doesn't understand the inset shorthand */
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    background: rgba(26, 26, 26, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.detail-modal-overlay.open {
    display: flex;
}

.detail-modal {
    position: relative;
    background: #fdfcf8;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 35px 30px 30px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.detail-modal h3 {
    font-style: italic;
    font-weight: normal;
    font-size: 1.5em;
    color: #7a0019;
    margin: 0 0 8px 0;
}

.detail-modal-subtitle {
    color: #777;
    font-size: 0.95em;
    margin: 0 0 15px 0;
}

.detail-modal-description,
.detail-modal-fun-fact,
.detail-modal-food-pairings {
    text-align: left;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

#quick-picks-body {
    text-align: left;
    line-height: 1.5;
}

#quick-picks-body h3 {
    font-style: italic;
    font-weight: normal;
    font-size: 1.4em;
    color: #7a0019;
    margin: 0 0 14px 0;
}

#quick-picks-body h4 {
    font-style: italic;
    font-weight: normal;
    font-size: 1.1em;
    color: #7a0019;
    margin: 28px 0 10px 0;
    border-top: 1px solid #d4af37;
    padding-top: 16px;
}

#quick-picks-body p {
    margin: 0 0 12px 0;
}

.quick-picks-table-wrap {
    overflow-x: auto;
    margin-bottom: 12px;
}

.quick-picks-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9em;
}

.quick-picks-table th,
.quick-picks-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #e5ddc8;
    vertical-align: top;
}

.quick-picks-table th {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75em;
    color: #555;
    border-bottom: 1px solid #d4af37;
    white-space: nowrap;
}

.detail-modal-close {
    position: absolute;
    top: 8px;
    right: 14px;
    background: none;
    border: none;
    padding: 4px;
    font-size: 1.6em;
    line-height: 1;
    color: #7a0019;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Login page */
.login-block {
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.login-form label {
    display: block;
    margin: 10px 0 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8em;
    color: #555;
}

.login-form input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    font: inherit;
    font-size: 16px; /* 16px+ stops iOS Safari zooming in on focus */
    border: 1px solid #d4af37;
    border-radius: 6px;
    background: #fff;
}

.login-error {
    color: #7a0019;
    margin: 10px 0 0;
}

/* Marks alcohol-free bottles on the menu and in Help Me Decide results */
.na-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    font-size: 0.65em;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #2f6b3a;
    border: 1px solid #2f6b3a;
    border-radius: 50px;
    vertical-align: middle;
    white-space: nowrap;
}

/* 5. Help Me Decide */
.decide-button {
    margin-top: 18px;
    padding: 10px 26px;
    font: inherit;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #fdfcf8;
    background-color: #d4af37;
    border: 1px solid #d4af37;
    border-radius: 50px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.decide-question {
    font-size: 1.15em;
    margin: 10px 0 16px 0;
}

/* Margins instead of flex gap: gap isn't supported on Safari < 14.1 */
.decide-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: -5px;
}

.decide-option {
    margin: 5px;
    padding: 10px 18px;
    font: inherit;
    font-size: 0.95em;
    color: #1a1a1a;
    background: none;
    border: 1px solid #d4af37;
    border-radius: 50px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.decide-option-count {
    margin-left: 8px;
    font-size: 0.8em;
    color: #777;
}

.decide-option-skip {
    color: #777;
    border-style: dashed;
}

.decide-results {
    margin-top: 10px;
}

.decide-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid #e5ddc8;
}

.decide-nav-button {
    font: inherit;
    font-size: 0.85em;
    color: #7a0019;
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.decide-nav-button:disabled {
    color: #ccc;
    cursor: default;
}

@media (hover: hover) {
    .decide-option:hover { background-color: #f5efdc; }
    .decide-button:hover { background-color: #c29e2c; border-color: #c29e2c; }
}

/* Tablet touch optimization */
@media (hover: none) {
    .tab-label { padding: 15px 30px; font-size: 1em; }
    .menu-item { margin-bottom: 28px; }
    .decide-option { padding: 12px 22px; }
}

/* Keep iOS from enlarging text on its own when a phone is turned sideways */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* 6. Phones (portrait). Must stay LAST in the file so it overrides the touch rules above.
   600px catches every iPhone in portrait (iPhone 16 Pro = 402px, Pro Max = 440px) but no
   iPad in any orientation (narrowest, iPad mini portrait = 744px), so iPad is untouched. */
@media (max-width: 600px) {
    /* Side gutter so text never touches the screen edge; respects the notch in landscape */
    body {
        padding-left: 16px;
        padding-right: 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .header-section {
        margin-bottom: 20px;
        padding-top: 12px;
    }

    h1 {
        font-size: 1.3em;
        letter-spacing: 5px;
    }

    .decide-button {
        margin-top: 14px;
    }

    /* Tabs: a 2 x 2 grid instead of one row that runs off both edges.
       Margins instead of gap (gap: 0 cancels the desktop gap) for older Safari. */
    .tab-controls {
        flex-wrap: wrap;
        gap: 0;
        margin: 0 -4px 24px;
    }

    .tab-controls .tab-label {
        flex: 1 1 calc(50% - 8px);
        margin: 4px;
        padding: 10px 8px;
        font-size: 0.75em;
        letter-spacing: 1px;
        text-align: center;
        white-space: nowrap;
    }

    h2 {
        font-size: 1.8em;
    }

    .tier-divider {
        letter-spacing: 8px;
    }

    .menu-item {
        margin-bottom: 22px;
    }

    /* Long "PRODUCER | REGION" lines: smaller and tighter so they wrap less */
    .producer {
        font-size: 0.72em;
        letter-spacing: 1px;
    }

    .wine-info {
        font-size: 1.05em;
    }

    .na-badge {
        margin-left: 6px;
    }

    /* Popups use more of the small screen */
    .detail-modal-overlay {
        padding: 12px;
    }

    .detail-modal {
        max-height: 85vh;
        padding: 30px 20px 22px;
    }

    .decide-option {
        padding: 10px 16px;
        font-size: 0.9em;
    }
}