/* style.css */

/* --- CSS Variables for Theming --- */
:root {
    /* Light Mode (Beige/Brown) */
    --bg-color-light: #F5F5DC; /* Beige */
    --text-color-light: #5D4037; /* Dark Brown */
    --container-bg-light: #FFFFFF; /* White */
    --accent-color-light: #A1887F; /* Lighter Brown */
    --border-color-light: #D7CCC8; /* Very Light Brown/Grey */
    --button-bg-light: #8D6E63; /* Medium Brown */
    --button-text-light: #FFFFFF; /* White */
    --link-color-light: #795548; /* Strong Brown */
    --subtle-pattern-light: linear-gradient(45deg, rgba(161, 136, 127, 0.03) 25%, transparent 25%, transparent 75%, rgba(161, 136, 127, 0.03) 75%),
                           linear-gradient(-45deg, rgba(161, 136, 127, 0.03) 25%, transparent 25%, transparent 75%, rgba(161, 136, 127, 0.03) 75%);
    --subtle-pattern-size: 30px 30px;

    /* Dark Mode (Beige/Brown) */
    --bg-color-dark: #3E2723; /* Very Dark Brown */
    --text-color-dark: #EFEBE9; /* Light Beige/Off-white */
    --container-bg-dark: #4E342E; /* Dark Brown Container */
    --accent-color-dark: #A1887F; /* Lighter Brown (can reuse) */
    --border-color-dark: #5D4037; /* Mid-Dark Brown */
    --button-bg-dark: #A1887F; /* Lighter Brown Button */
    --button-text-dark: #212121; /* Very Dark Grey/Black */
    --link-color-dark: #BCAAA4; /* Lighter Brown Link */
    --subtle-pattern-dark: linear-gradient(45deg, rgba(239, 235, 233, 0.02) 25%, transparent 25%, transparent 75%, rgba(239, 235, 233, 0.02) 75%),
                          linear-gradient(-45deg, rgba(239, 235, 233, 0.02) 25%, transparent 25%, transparent 75%, rgba(239, 235, 233, 0.02) 75%);

    /* Default to Light Mode variables */
    --bg-color: var(--bg-color-light);
    --text-color: var(--text-color-light);
    --container-bg: var(--container-bg-light);
    --accent-color: var(--accent-color-light);
    --border-color: var(--border-color-light);
    --button-bg: var(--button-bg-light);
    --button-text: var(--button-text-light);
    --link-color: var(--link-color-light);
    --subtle-pattern: var(--subtle-pattern-light);
}

/* Apply Dark Mode variables */
body.dark-mode {
    --bg-color: var(--bg-color-dark);
    --text-color: var(--text-color-dark);
    --container-bg: var(--container-bg-dark);
    --accent-color: var(--accent-color-dark);
    --border-color: var(--border-color-dark);
    --button-bg: var(--button-bg-dark);
    --button-text: var(--button-text-dark);
    --link-color: var(--link-color-dark);
    --subtle-pattern: var(--subtle-pattern-dark);
}

/* --- Sticky Footer Setup --- */
html { height: 100%; }
body {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    /* Adjusted Padding: More generous top/bottom */
    padding: 30px 20px 70px 20px; /* Increased bottom padding for theme btn */
    box-sizing: border-box; /* Ensure padding is included in height calc */
}
.content-wrapper { flex: 1 0 auto; }
footer { flex-shrink: 0; }

/* --- General Body & Layout Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.7;
    margin: 0;
    background-color: var(--bg-color);
    background-image: var(--subtle-pattern);
    background-size: var(--subtle-pattern-size);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.content-wrapper {
    max-width: 800px;
    /* Removed top/bottom margin from here, handled by body padding */
    margin: 0 auto;
    /* Slightly increased padding */
    padding: 30px;
    background-color: var(--container-bg);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* --- Typography --- */
h1, h2, h3 {
    color: var(--text-color);
    margin-bottom: 0.8em;
    font-weight: 600;
}
h1 { text-align: center; font-size: 2.2em; margin-bottom: 1em; }
h2 { font-size: 1.8em; border-bottom: 2px solid var(--accent-color); padding-bottom: 5px; margin-top: 1.5em; }
h3 { font-size: 1.3em; color: var(--accent-color); margin-top: 1.2em; }
p { margin-bottom: 1.2em; }
a { color: var(--link-color); text-decoration: none; transition: color 0.2s ease; }
a:hover { text-decoration: underline; opacity: 0.8; }

/* --- Widget Specific Styling (Overrides Removed) --- */
#r4-widget-form-container {
    text-align: center;
    /* Increased bottom margin */
    margin-bottom: 40px;
    margin-top: 20px; /* Added top margin */
}

#r4-widget-form {
    display: inline-block;
    padding: 20px;
    /* Let widget control its background */
    /* background-color: var(--bg-color); REMOVED */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
    text-align: left;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    transition: border-color 0.3s ease;
}

/* Basic structure assuming input/button are direct children or similar */
#r4-widget-form input[type="text"],
#r4-widget-form input[type="search"] {
     padding: 12px;
     border-radius: 5px;
     border: 1px solid var(--border-color);
     /* Let widget control its colors */
     /* background-color: var(--container-bg); REMOVED */
     /* color: var(--text-color); REMOVED */
     width: 100%;
     box-sizing: border-box;
     margin-bottom: 10px;
     transition: border-color 0.2s ease, box-shadow 0.2s ease;
 }

 #r4-widget-form input[type="text"]:focus,
 #r4-widget-form input[type="search"]:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(161, 136, 127, 0.2); /* Use accent color with transparency */
    outline: none;
 }

 #r4-widget-form button {
     padding: 12px 18px;
     cursor: pointer;
     /* Let widget control its colors */
     /* background-color: var(--widget-button-bg-attempt); REMOVED */
     /* color: var(--widget-button-text-attempt); REMOVED */
     border: none; /* Assuming widget adds its own if needed */
     border-radius: 5px;
     font-weight: bold;
     transition: opacity 0.2s ease; /* Changed from background-color */
     width: 100%;
     box-sizing: border-box;
 }
 #r4-widget-form button:hover {
    opacity: 0.85;
 }

 /* Links inside the widget */
 #r4-widget-form div { /* Assuming links are inside a div */
    margin-top: 15px;
    text-align: center;
 }
 #r4-widget-form div a {
    /* Let widget control its colors */
    /* color: var(--widget-link-color-attempt); REMOVED */
    margin: 0 5px;
    font-size: 0.9em;
    display: inline-block;
    margin-bottom: 5px;
 }
 #r4-widget-form div a:hover {
     text-decoration: underline;
     opacity: 0.8;
 }

/* Loading Placeholder Animation */
#r4-widget-form .loading-placeholder {
    text-align: center;
    color: var(--accent-color);
    position: relative;
    min-height: 50px; /* Give it some height */
    display: flex;
    align-items: center;
    justify-content: center;
}
#r4-widget-form .loading-placeholder::before {
    content: '';
    /* Removed absolute positioning, handled by flex */
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px; /* Space between spinner and text */
}
@keyframes spin { to { transform: rotate(360deg); } }


/* Media Query for Larger Screens (Widget Layout) */
@media (min-width: 600px) {
    #r4-widget-form {
        padding: 25px;
    }
    #r4-widget-form input[type="text"],
    #r4-widget-form input[type="search"] {
        width: calc(100% - 120px); /* Leave space for button */
        margin-bottom: 0; /* Remove bottom margin */
        margin-right: 8px; /* Add right margin */
        display: inline-block;
        vertical-align: middle;
    }
    #r4-widget-form button {
        width: 100px; /* Fixed width for button */
        display: inline-block;
        vertical-align: middle;
    }
     #r4-widget-form div { /* Containing links */
        text-align: left; /* Align links left */
     }
}


/* --- Theme Switcher --- */
.theme-switcher {
    position: fixed;
    bottom: 15px;
    left: 15px;
    /* Adjusted padding and size for emoji */
    padding: 5px;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--button-bg);
    color: var(--button-text); /* Color still useful for potential fallback/tooltip */
    border: none;
    border-radius: 50%; /* Make it circular */
    cursor: pointer;
    /* Increased font size for emoji */
    font-size: 1.5em;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
}
.theme-switcher:hover {
     opacity: 0.9;
     transform: scale(1.1); /* Slight grow effect */
}

/* --- Separator --- */
hr.section-divider {
    border: none;
    height: 1px;
    background-image: linear-gradient(to right, transparent, var(--accent-color), transparent);
    opacity: 0.6;
    margin: 40px 0;
}

/* --- Terms of Service Section Styling (for terms.html page) --- */
.terms-content {
    padding: 10px;
    font-size: 0.95em;
}
.terms-content strong { color: var(--accent-color); }
.terms-content h2 { margin-top: 0; border-bottom-style: solid; }
/* Specific div holding NYCDOE info */
.terms-content .nycdoc-info-box {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--bg-color); /* Use body bg for contrast */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.terms-content .nycdoc-info-box h4 {
    margin-top: 0;
    color: var(--accent-color);
}
.terms-content .nycdoc-info-box p { margin-bottom: 10px; }


/* --- NYCDOE Link/Button --- */
.nycdoc-link {
    display: inline-block;
    background-color: var(--button-bg);
    color: var(--button-text) !important;
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px; /* Reduced top margin slightly */
    transition: background-color 0.2s ease, opacity 0.2s ease;
    vertical-align: middle;
}
.nycdoc-link:hover { opacity: 0.85; text-decoration: none; }
.nycdoc-link img {
    height: 1.2em;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

/* --- Back to Top Button --- */
#back-to-top {
    position: fixed;
    bottom: 15px; /* Keep it near bottom */
    right: 15px;
    padding: 0; /* Remove padding, size controlled by width/height */
    height: 40px; /* Match theme switcher */
    width: 40px;  /* Match theme switcher */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-color);
    color: var(--container-bg); /* Icon color */
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    line-height: 1;
}
#back-to-top.visible { opacity: 0.7; visibility: visible; }
#back-to-top:hover { opacity: 1; transform: scale(1.1); }
#back-to-top svg { /* Style the SVG icon inside */
    width: 18px;
    height: 18px;
}

/* --- Footer --- */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85em;
    color: var(--accent-color);
    transition: border-color 0.3s ease, color 0.3s ease;
}
