/* ── Ingredient autocomplete dropdown ── */

.ing-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: var(--pico-background-color, #fff);
    border: 1px solid var(--pico-form-element-border-color, #ccc);
    border-top: none;
    width: 50%;
    min-width: 12rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.ing-suggestion {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--pico-color, #000);
}

.ing-suggestion:hover,
.ing-suggestion--active {
    background: var(--pico-primary-hover-background, #1a73e8);
    color: var(--pico-primary-inverse, #fff);
}

html.retro .ing-dropdown {
    border-color: var(--green-dim);
    background: var(--bg);
    box-shadow: 0 0 8px var(--green-faint);
}

html.retro .ing-suggestion {
    color: var(--green);
}

html.retro .ing-suggestion:hover,
html.retro .ing-suggestion--active {
    background: var(--green);
    color: var(--bg);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    align-items: start;
}

/* ── Theme toggle switch ── */

a:has(.theme-toggle) {
    display: flex;
    align-items: center;
    gap: 0.4em;
    text-decoration: none;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    position: relative;
    width: 2.2em;
    height: 1.2em;
    flex-shrink: 0;
}

.theme-toggle__track {
    position: absolute;
    inset: 0;
    border-radius: 1em;
    background: var(--pico-muted-border-color, #ccc);
    transition: background 0.2s;
}

.theme-toggle--on .theme-toggle__track {
    background: var(--pico-primary, #1a73e8);
}

.theme-toggle__thumb {
    position: absolute;
    left: 0.15em;
    width: 0.9em;
    height: 0.9em;
    border-radius: 50%;
    background: #fff;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.2s;
}

.theme-toggle--on .theme-toggle__thumb {
    left: calc(100% - 1.05em);
}

.theme-toggle__label {
    font-size: 0.8em;
    line-height: 1;
}

/* ── Retro 1980s terminal aesthetic ── */

html.retro {
    --green: #00ff41;
    --green-dim: #00c032;
    --green-faint: #003a0f;
    --bg: #000000;
    --font: "Courier New", Courier, monospace;

    /* Override Pico variables */
    --pico-font-family: var(--font);
    --pico-font-family-sans-serif: var(--font);
    --pico-background-color: var(--bg);
    --pico-color: var(--green);
    --pico-primary: var(--green);
    --pico-primary-background: var(--bg);
    --pico-primary-border: var(--green);
    --pico-primary-hover: var(--bg);
    --pico-primary-hover-background: var(--green);
    --pico-primary-hover-border: var(--green);
    --pico-primary-inverse: var(--bg);
    --pico-secondary: var(--green-dim);
    --pico-secondary-background: var(--bg);
    --pico-secondary-border: var(--green-dim);
    --pico-secondary-hover-background: var(--green-dim);
    --pico-secondary-inverse: var(--bg);
    --pico-contrast: var(--green);
    --pico-contrast-background: var(--bg);
    --pico-contrast-border: var(--green);
    --pico-contrast-hover-background: var(--green);
    --pico-contrast-inverse: var(--bg);
    --pico-card-background-color: var(--bg);
    --pico-card-border-color: var(--green-dim);
    --pico-card-box-shadow: 0 0 8px var(--green-dim);
    --pico-form-element-background-color: var(--bg);
    --pico-form-element-color: var(--green);
    --pico-form-element-border-color: var(--green-dim);
    --pico-form-element-active-border-color: var(--green);
    --pico-form-element-focus-color: var(--green);
    --pico-form-element-placeholder-color: var(--green-dim);
    --pico-table-border-color: var(--green-dim);
    --pico-muted-color: var(--green-dim);
    --pico-muted-border-color: var(--green-faint);
    --pico-h1-color: var(--green);
    --pico-h2-color: var(--green);
    --pico-h3-color: var(--green);
    --pico-h4-color: var(--green-dim);
    --pico-h5-color: var(--green-dim);
    --pico-h6-color: var(--green-dim);
    --pico-nav-element-spacing-vertical: 0.75rem;
}

html.retro body {
    background-color: var(--bg);
    color: var(--green);
    font-family: var(--font);
}

/* Scanline overlay */
html.retro body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(0, 0, 0, 0.15) 3px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

html.retro {
    background-color: var(--bg);
    min-height: 100vh;
}

html.retro nav {
    border-bottom: 1px solid var(--green-dim);
    flex-wrap: wrap;
    gap: 0.25rem;
}

html.retro nav > ul {
    flex-wrap: wrap;
}

html.retro nav a {
    text-decoration: none;
    color: var(--green) !important;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

@media (max-width: 480px) {
    html.retro nav a {
        letter-spacing: 0;
    }
}

html.retro nav a:hover {
    color: var(--bg) !important;
    background-color: var(--green);
    text-shadow: none;
}

html.retro h1,
html.retro h2,
html.retro h3,
html.retro h4,
html.retro h5,
html.retro h6 {
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

html.retro h1::before { content: "> "; }
html.retro h2::before { content: ">> "; }
html.retro h3::before { content: ">>> "; }

html.retro a {
    color: var(--green);
}

html.retro a:hover {
    color: var(--bg);
    background-color: var(--green);
    text-decoration: none;
}

html.retro button,
html.retro [role="button"] {
    font-family: var(--font) !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 0 !important;
}

html.retro article {
    border-radius: 0 !important;
    border: 1px solid var(--green-dim) !important;
    box-shadow: 0 0 6px var(--green-faint) !important;
    background-color: var(--bg) !important;
}

html.retro article:hover {
    border-color: var(--green) !important;
    box-shadow: 0 0 12px var(--green-dim) !important;
}

html.retro input,
html.retro select,
html.retro textarea {
    border-radius: 0 !important;
    background-color: var(--bg) !important;
    color: var(--green) !important;
    border-color: var(--green-dim) !important;
    font-family: var(--font) !important;
    caret-color: var(--green);
}

html.retro input:focus,
html.retro select:focus,
html.retro textarea:focus {
    border-color: var(--green) !important;
    box-shadow: 0 0 8px var(--green-dim) !important;
    outline: none !important;
}

html.retro table {
    border-collapse: collapse;
}

html.retro th {
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--green) !important;
}

html.retro td {
    border-bottom: 1px solid var(--green-faint) !important;
}

html.retro small {
    color: var(--green-dim);
}

html.retro strong {
    color: var(--green);
}

html.retro fieldset {
    border-color: var(--green-dim) !important;
    border-radius: 0 !important;
}

html.retro hgroup p {
    color: var(--green-dim);
}

html.retro .recipe-card footer [role="button"],
html.retro .recipe-card footer button {
    padding-left: 5px;
    padding-right: 5px;
}

html.retro a:has(.theme-toggle) {
    transition: none;
}

html.retro a:has(.theme-toggle):hover {
    color: var(--green);
    background-color: transparent;
}

html.retro a:has(.theme-toggle):hover .theme-toggle__label {
    color: var(--green);
    text-shadow: 0 0 6px var(--green);
}

html.retro .theme-toggle__track {
    background: var(--green-faint);
    border: 1px solid var(--green-dim);
}

html.retro .theme-toggle--on .theme-toggle__track {
    background: var(--green-faint);
    border-color: var(--green);
}

html.retro .theme-toggle__thumb {
    background: var(--green-dim);
}

html.retro .theme-toggle--on .theme-toggle__thumb {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* ── Print: always use plain readable styles, never retro ── */

@media print {
    html.retro {
        --pico-font-family: inherit;
        --pico-font-family-sans-serif: inherit;
        --pico-background-color: #fff;
        --pico-color: #000;
        --pico-primary: #000;
        --pico-h1-color: #000;
        --pico-h2-color: #000;
        --pico-h3-color: #000;
        --pico-h4-color: #000;
        --pico-h5-color: #000;
        --pico-h6-color: #000;
        --pico-table-border-color: #ccc;
        --pico-muted-color: #555;
    }

    html.retro body {
        background: #fff;
        color: #000;
        font-family: inherit;
    }

    html.retro body::before { display: none; }

    html.retro h1::before,
    html.retro h2::before,
    html.retro h3::before { content: ""; }

    html.retro h1, html.retro h2, html.retro h3,
    html.retro h4, html.retro h5, html.retro h6 {
        color: #000;
        text-transform: none;
        letter-spacing: normal;
    }

    html.retro a { color: #000; }

    html.retro th {
        color: #000;
        border-bottom: 1px solid #000 !important;
    }

    html.retro td {
        border-bottom: 1px solid #ccc !important;
    }

    html.retro nav,
    html.retro .theme-toggle,
    html.retro .theme-toggle__label {
        display: none;
    }
}
