/* ================= Base Styles ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    line-height: 1.8;
    color: #333;
    background-color: #fff8f5;
    font-family: 'Nunito Sans', sans-serif;
}

/* ================= Header Styles ================= */
header {
    background: linear-gradient(135deg, #C69F73, #F3E9D2);
    color: #4A2C2A;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 1rem 0;
    gap: 1.5rem;
}

nav a {
    color: #4A2C2A;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 0.6rem 1rem;
    border-radius: 50px;
    transition: all 0.3s;
    font-family: 'Pacifico', cursive;
    background: rgba(255,255,255,0.3);
}

nav a:hover, nav a.active {
    background: #A63A50;
    color: white;
    transform: translateY(-2px);
}

/* ================= Main Content ================= */
main {
    padding: 3rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ================= Home Page Styles ================= */
.welcome {
    text-align: center;
    margin-bottom: 4rem;
    background-color: #ffe8e0;
    padding: 2.5rem 2rem;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.welcome::after {
    content: "";
    display: block;
    width: 100px;
    height: 100px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="%23A63A50" opacity="0.2"/></svg>');
    position: absolute;
    right: 10%;
    top: 20%;
    z-index: -1;
}

.welcome h2 {
    font-size: 2.2rem;
    color: #5d4037;
    margin-bottom: 1rem;
}

.welcome p {
    font-size: 1.1rem;
    max-width: 1000px;
    margin: 0.5rem auto;
}

.welcome p.intro {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4e342e;
}

.welcome p.small-note {
    font-size: 0.95rem;
    color: #6d4c41;
    opacity: 0.9;
    font-style: italic;
}

.featured-recipes {
    margin-bottom: 4rem;
}

.featured-recipes h2 {
    text-align: center;
    font-size: 2rem;
    color: #5d4037;
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2.5rem;
    margin-top: 2.5rem;
}

.recipe-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
}

.recipe-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(90deg, #A63A50, #C69F73);
}

.recipe-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.recipe-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.recipe-card h3 {
    background: linear-gradient(135deg, #F3E9D2, #F9F5F0);
    padding: 1rem;
    text-align: center;
    font-family: 'Pacifico', cursive;
    color: #4A2C2A;
    margin: 0;
    font-size: 1.4rem;
}

/* ================= Recipes Page Styles ================= */
.recipe-intro {
    background-color: #fff0e6;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 3rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.recipe-intro p {
    font-size: 1.1rem;
    color: #5d4037;
    margin-bottom: 1rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.recipe-intro .note {
    font-style: italic;
    color: #8d6e63;
    font-size: 1rem;
}

.search-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.search-container input {
    padding: 0.5rem;
    width: 60%;
    max-width: 500px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
}

.search-container button {
    padding: 0.5rem 1rem;
    background-color: #6d4c41;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.search-container button:hover {
    background-color: #8d6e63;
}

.recipe-list {
    margin-bottom: 3rem;
}

.recipe-section {
    margin-bottom: 2rem;
}

details {
    background-color: white;
    border-radius: 6px;
    margin-top: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

summary {
    cursor: pointer;
    font-size: 1.0rem;
    font-weight: bold;
    padding: 1.2rem 1.2rem 1.2rem 2.5rem;
    background-color: #8d6e63;
    color: white;
    border-radius: 6px;
    transition: all 0.3s;
    position: relative;
}

summary:hover {
    background-color: #6d4c41;
}

details[open] summary {
    background-color: #5d4037;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

summary::marker {
    display: none;
}

.recipe-image {
    display: block;
    margin: 1.5rem auto;
    max-width: 80%;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.recipe-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    margin: 1em 0;
}

.recipe-table th {
    background: #C69F73;
    color: white;
    font-weight: 700;
    padding: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.recipe-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #F3E9D2;
}

.recipe-table tr:nth-child(even) {
    background-color: rgba(243, 233, 210, 0.3);
}

/* ================= Video Section ================= */
.video-section {
    margin: 3rem auto;
    max-width: 800px;
    padding: 0 2rem;
}

.video-container {
    position: relative;
    max-width: 800px;
    margin: 1.5rem auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

#video-poster {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#video-poster:hover {
    transform: scale(1.02);
}

.video-description {
    max-width: 800px;
    margin: 1rem auto;
    padding: 1.5rem;
    background-color: rgba(255, 248, 240, 0.8);
    border-radius: 8px;
}

/* ================= Form Page Styles ================= */
.form-page {
    position: relative;
}

.form-section {
    max-width: 800px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #5d4037;
}

.form-group label.required:after {
    content: " *";
    color: #d32f2f;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-group button:focus {
    outline: 2px solid #6d4c41;
    outline-offset: 2px;
}

.form-group input.invalid:focus,
.form-group textarea.invalid:focus {
    outline-color: #d32f2f;
}

.invalid {
    border-color: #d32f2f !important;
    background-color: #fff5f5;
}

.error-message {
    display: block;
    color: #d32f2f;
    font-size: 0.85rem;
    margin-top: 0.3rem;
    height: 1.2rem;
}

.char-counter {
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.3rem;
}

.char-counter span {
    font-weight: bold;
}

fieldset {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    margin: 0.5rem 0;
}

legend {
    padding: 0 0.5rem;
    font-weight: bold;
    color: #5d4037;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.submit-btn, .reset-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-btn {
    background-color: #6d4c41;
    color: white;
}

.submit-btn:hover {
    background-color: #8d6e63;
}

.reset-btn {
    background-color: #e0e0e0;
    color: #333;
}

.reset-btn:hover {
    background-color: #d0d0d0;
}

.submit-btn.processing {
    background-color: #ff9800 !important;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
}

.submit-btn.processing::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loadingShimmer 1.5s infinite;
}

.submit-btn.success {
    background-color: #4caf50 !important;
    animation: pulseSuccess 0.5s 2;
}

.form-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease-out;
}

.form-status.error {
    background-color: #ffebee;
    color: #d32f2f;
    border: 1px solid #d32f2f;
}

.form-status.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #2e7d32;
}

.fallback-container {
    margin-top: 2rem;
    padding: 1rem;
    background: #fff3e0;
    border: 1px solid #ffb74d;
}

/* ================= Footer Styles ================= */
footer {
    background-color: #6d4c41;
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
    font-size: 0.95rem;
    position: relative;
}

footer::before {
    content: "";
    display: block;
    width: 100%;
    height: 30px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10"><circle cx="10" cy="5" r="3" fill="%23F3E9D2"/><circle cx="30" cy="3" r="2" fill="%23F3E9D2"/><circle cx="50" cy="6" r="4" fill="%23F3E9D2"/><circle cx="70" cy="4" r="3" fill="%23F3E9D2"/><circle cx="90" cy="7" r="2" fill="%23F3E9D2"/></svg>');
    background-repeat: repeat-x;
    opacity: 0.6;
}

footer a {
    color: #fff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ================= Accessibility ================= */
.skip-link {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #6d4c41;
    color: white;
    padding: 12px 24px;
    z-index: 100;
    transition: top 0.4s ease, opacity 0.3s ease;
    border-radius: 0 0 8px 8px;
    font-weight: bold;
    text-decoration: none;
    opacity: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.skip-link:focus {
    top: 0;
    opacity: 1;
}

.accessibility-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    font-family: 'Arial', sans-serif;
    background: rgba(255,255,255,0.9);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.accessibility-toggle:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.accessibility-toggle button {
    background-color: #6d4c41;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
}

.accessibility-toggle button:hover {
    background-color: #8d6e63;
    transform: translateY(-2px);
}

.accessibility-toggle button:focus {
    outline: 2px solid #5d4037;
    outline-offset: 2px;
}

.accessibility-toggle button[aria-pressed="true"] {
    background-color: #5d4037;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #5d4037;
}

#contrastToggle::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zm0 16c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7z"/><path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
}

#fontToggle::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9 4v3h5v12h3V7h5V4H9zm-6 8h3v7h3v-7h3V9H3v3z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
}

/* ================= High Contrast Mode ================= */
.high-contrast, 
.high-contrast * {
    background-color: black !important;
    color: yellow !important;
    border-color: yellow !important;
}

.high-contrast a {
    color: yellow !important;
    text-decoration: underline;
}

.high-contrast input,
.high-contrast textarea,
.high-contrast select,
.high-contrast button {
    background-color: black !important;
    color: yellow !important;
    border: 2px solid yellow !important;
}

.high-contrast input::placeholder,
.high-contrast textarea::placeholder {
    color: #cccc00 !important;
}

.high-contrast label,
.high-contrast .char-counter,
.high-contrast .error-message {
    color: yellow !important;
}

.high-contrast .submit-btn,
.high-contrast .reset-btn {
    background-color: yellow !important;
    color: black !important;
    border: 2px solid black !important;
}

.high-contrast button:hover,
.high-contrast button:focus {
    background-color: yellow !important;
    color: black !important;
    border-color: black !important;
}

.high-contrast details,
.high-contrast summary {
    background-color: black !important;
    color: yellow !important;
    border-color: yellow !important;
}

.high-contrast summary::before {
    color: yellow !important;
}

.high-contrast .video-description {
    color: yellow !important;
    background-color: black !important;
}

.high-contrast .form-status.error {
    background-color: black !important;
    color: yellow !important;
    border-color: yellow !important;
}

.high-contrast .form-status.success {
    background-color: black !important;
    color: lime !important;
    border-color: lime !important;
}

.high-contrast .submit-btn.processing {
    background-color: black !important;
    color: yellow !important;
    border: 2px solid yellow !important;
}

.high-contrast .submit-btn.processing::after {
    background: linear-gradient(90deg, transparent, rgba(255,255,0,0.6), transparent);
}

.high-contrast .submit-btn.success {
    background-color: yellow !important;
    color: black !important;
    border: 2px solid black !important;
}

.high-contrast fieldset {
    border-color: yellow !important;
}

.high-contrast legend {
    color: yellow !important;
}

.high-contrast .invalid {
    border-color: red !important;
    outline: 3px solid red !important;
}

.high-contrast {
    scrollbar-color: yellow black;
}

.high-contrast ::selection {
    background: yellow;
    color: black;
}

.high-contrast :focus {
    outline: 3px solid yellow !important;
    outline-offset: 2px;
}

.high-contrast .recipe-card:hover,
.high-contrast .recipe-card:focus-within {
    outline: 3px solid yellow;
}

.high-contrast img {
    filter: contrast(1.2) brightness(0.9);
}

.high-contrast .accessibility-toggle {
    background: black !important;
    border: 2px solid yellow !important;
}

.high-contrast .accessibility-toggle button {
    background-color: black !important;
    color: yellow !important;
    border: 2px solid yellow !important;
}

.high-contrast .accessibility-toggle button:hover {
    background-color: yellow !important;
    color: black !important;
}

.high-contrast .accessibility-toggle button[aria-pressed="true"] {
    background-color: yellow !important;
    color: black !important;
    box-shadow: 0 0 0 2px black, 0 0 0 4px yellow !important;
}

.high-contrast .skip-link {
    background: yellow !important;
    color: black !important;
    border: 2px solid black !important;
}

/* ================= Large Font Mode ================= */
.large-font {
    font-size: 1.25em;
    line-height: 1.5;
}

.large-font h1 {
    font-size: calc(2.8rem * 1.25);
}

.large-font h2 {
    font-size: 2.6rem;
}

.large-font h3 {
    font-size: 2rem;
}

.large-font summary {
    font-size: calc(1.5rem * 1.25);
}

.large-font .video-description {
    font-size: calc(1rem * 1.25);
}

.large-font legend {
    font-size: 1.5rem;
}

/* ================= Responsive Design ================= */
@media (max-width: 600px) {
    body {
        font-size: 14px;
    }

    nav ul {
        flex-direction: column;
    }

    .radio-group {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-buttons {
        flex-direction: column;
    }

    .submit-btn,
    .reset-btn {
        width: 100%;
    }

    .form-status {
        font-size: 0.9rem;
        padding: 0.8rem;
    }
    
    .welcome::after {
        display: none;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    body {
        font-size: 16px;
    }
}

@media (min-width: 901px) {
    body {
        font-size: 18px;
    }
}

@media (min-width: 768px) {
    body.form-page {
        background-image: url('../images/form-bg.jpg');
        background-size: cover;
        background-position: center;
    }

    body.form-page::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: inherit;
        background-size: cover;
        background-position: center;
        filter: blur(8px);
        z-index: -1;
    }

    .form-section {
        background-color: rgba(255, 255, 255, 0.85);
    }
}

/* ================= Print Styles ================= */
@media print {
    nav,
    header,
    footer,
    .search-container,
    .video-section,
    .accessibility-toggle,
    .recipe-card img,
    .recipe-image img,
    .form-group input[type="checkbox"],
    .form-group input[type="radio"],
    .form-buttons,
    .recipe-card::before,
    .welcome::after,
    footer::before {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000;
        background: #fff !important;
        line-height: 1.4;
        padding: 0.5in;
    }

    main, .form-section {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
        background: transparent !important;
        box-shadow: none !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        font-weight: normal;
    }

    img {
        max-width: 50% !important;
        height: auto !important;
        display: block;
        margin: 0 auto;
        page-break-inside: avoid;
        filter: grayscale(100%) !important;
    }

    table {
        width: 100%;
        border-collapse: collapse;
        margin: 1em 0;
    }
    
    th, td {
        border: 1px solid #ddd;
        padding: 0.5em;
        text-align: left;
    }
    
    th {
        background-color: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    details {
        display: block !important;
    }
    
    summary {
        display: block !important;
        list-style: none;
    }
    
    summary::before, summary::marker {
        display: none !important;
    }

    .form-group {
        margin-bottom: 1em;
    }
    
    .form-group label {
        display: block;
        font-weight: bold;
    }
    
    input[type="text"],
    input[type="email"],
    textarea {
        border: 1px solid #ddd;
        padding: 0.3em;
        background: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    input[type="checkbox"]:checked + label:before,
    input[type="radio"]:checked + label:before {
        content: "✓ ";
    }

    .char-counter {
        display: none;
    }

    h1, h2, h3, h4 {
        page-break-after: avoid;
    }
    
    table, img, .recipe-section, .form-group, details {
        page-break-inside: avoid;
    }

    @page {
        size: auto;
        margin: 0.5in;
        
        @top-center {
            content: "Bubble Tea Receptek";
            font-size: 12pt;
            font-weight: bold;
        }
        
        @bottom-right {
            content: counter(page) " / " counter(pages);
            font-size: 10pt;
        }
    }
}

/* ================= Animations ================= */
@keyframes loadingShimmer {
    100% {
        left: 100%;
    }
}

@keyframes pulseSuccess {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}