/* === BASE STYLES === */
:root {
    --primary-color: #3a86ff;
    --secondary-color: #8338ec;
    --accent-color: #ff006e;
    --text-color: #2b2d42;
    --light-bg: #f8f9fa;
    --dark-bg: #212529;
    --error-color: #d90429;
    --success-color: #4cc9f0;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
    padding: 2rem;
    min-height: 100vh;
}

/* === TYPOGRAPHY === */
h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 1.5rem;
    background: linear-gradient(
        90deg,
        var(--primary-color),
        var(--secondary-color)
    );
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-align: center;
}

/* === FORM ELEMENTS === */
#query {
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 1rem;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1rem;
    display: block;
    transition: var(--transition);
}

#query:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
}

button {
    background: linear-gradient(
        135deg,
        var(--primary-color),
        var(--secondary-color)
    );
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    display: block;
    margin: 0 auto;
    box-shadow: var(--box-shadow);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

/* === LAYOUT === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Styling for the overall container holding engine options */
#engine-options-container {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

#engine-options-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--secondary-color);
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

/* Styling for each category group (the <fieldset> element) */
.engine-category {
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
    background-color: #fdfdfd;
}

/* Styling for the category title (the <legend> element) */
.engine-category legend {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-color);
    padding: 0 0.5rem;
    margin-left: -0.5rem; /* Negative margin to align with fieldset padding */
}

/* Styling for the grid container *inside* each fieldset (holds the checkboxes) */
.engine-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem; /* Space between legend and checkboxes */
}

/* Styles for the container that *was* the grid, now holds fieldsets */
#engine-choices {
    margin-bottom: 1rem;
}

.engine-choice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.engine-choice label {
    cursor: pointer;
    flex-grow: 1; /* Allow label to take space */
}

.engine-choice input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary-color); /* Color the checkmark */
    width: 1.2em;
    height: 1.2em;
}

.prefs-note,
.popup-note {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9em;
    color: #6c757d; /* Muted color */
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    #query {
        width: 90%;
    }
}

/* === ACCESSIBILITY === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

main {
    animation: fadeIn 0.5s ease-out forwards;
}

/* === ERROR STATES === */
.error {
    color: var(--error-color);
    border-color: var(--error-color) !important;
}

.success {
    color: var(--success-color);
}
