/* ═══════════════════════════════════════════════════════════
   Theme Variables
   ═══════════════════════════════════════════════════════════ */

/* Coastal — pale blue-gray, deep navy, ocean blue accent */
:root,
html.theme-coastal {
  --bg:           #f2f5f9;
  --surface:      #fff;
  --surface-alt:  #eaeff6;
  --border:       #c4d0de;
  --border-light: #dce5f0;
  --text:         #18283c;
  --text-muted:   #6080a0;
  --text-subtle:  #3c5878;
  --accent:       #1864a8;
  --accent-hover: #104e88;
  --accent-fg:    #fff;
  --link:         #1864a8;
  --note-border:  #6aaad8;
  --nav-bg:       #18283c;
  --nav-border:   #18283c;
  --nav-text:     #e4edf8;
  --head-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --body-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm:    7px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --card-shadow:  0 1px 4px rgba(24,40,60,0.07);
  --step-num:     #6aaad8;
}

/* Coastal Dark — deep navy inversion */
html.theme-coastal-dark {
  --bg:           #0d1a2b;
  --surface:      #152236;
  --surface-alt:  #0d1a2b;
  --border:       #243d58;
  --border-light: #1a3048;
  --text:         #ddeaf8;
  --text-muted:   #6a9ac8;
  --text-subtle:  #a0c4e8;
  --accent:       #4aaae8;
  --accent-hover: #6abcf4;
  --accent-fg:    #0d1a2b;
  --link:         #4aaae8;
  --note-border:  #3a88c8;
  --nav-bg:       #070f1c;
  --nav-border:   #070f1c;
  --nav-text:     #c0d8f0;
  --head-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --body-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm:    7px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --card-shadow:  0 2px 8px rgba(0,0,0,0.4);
  --step-num:     #3a88c8;
}

/* ═══════════════════════════════════════════════════════════
   Base Reset
   ═══════════════════════════════════════════════════════════ */

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

body {
    font-family: var(--body-font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.18s, color 0.18s;
}

/* ── Nav ──────────────────────────────────────────────────── */

nav {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--nav-border);
    background: var(--nav-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

nav a {
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-home {
    font-weight: 600;
    color: var(--nav-text);
    letter-spacing: -0.01em;
    font-family: var(--head-font);
}

.nav-home:hover {
    opacity: 0.7;
}

/* ── Main layout ──────────────────────────────────────────── */

main {
    max-width: 860px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.75rem;
    letter-spacing: -0.02em;
    font-family: var(--head-font);
    color: var(--text);
}

/* ── Home page ────────────────────────────────────────────── */

.intro {
    padding: 3rem 0 2.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.5rem;
}

.intro h1 {
    margin-bottom: 0.5rem;
}

.intro p {
    color: var(--text-subtle);
    font-size: 1.05rem;
}

.sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--card-shadow);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.section-card:hover {
    border-color: var(--text-muted);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.section-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    font-family: var(--head-font);
}

.section-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.section-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 1rem;
}

/* ── Recipe index ─────────────────────────────────────────── */

.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    margin-bottom: 0.5rem;
}

.page-desc {
    color: var(--text-muted);
    font-size: 0.975rem;
    max-width: 560px;
    line-height: 1.6;
}

.count {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.4rem;
}

.recipe-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}

.recipe-list li a {
    display: block;
    padding: 0.65rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
    box-shadow: var(--card-shadow);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.recipe-list li a:hover {
    border-color: var(--text-muted);
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* ── Recipe detail ────────────────────────────────────────── */

.back {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.back:hover {
    color: var(--text);
}

.recipe-link {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    background: var(--accent);
    color: var(--accent-fg);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 2.25rem;
    transition: background 0.12s;
}

.recipe-link:hover {
    background: var(--accent-hover);
}

.recipe-img {
    display: block;
    max-width: 100%;
    border-radius: var(--radius-lg);
    margin-bottom: 2.25rem;
    border: 1px solid var(--border);
}

/* ── Section labels ───────────────────────────────────────── */

.notes h2,
.references h2,
.ingredients h2,
.steps h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.85rem;
    font-family: var(--head-font);
}

/* ── Notes ────────────────────────────────────────────────── */

.notes ul,
.references ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.references a {
    color: var(--link);
    text-decoration: none;
}

.references a:hover {
    text-decoration: underline;
}

.reference-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.reference-item input {
    flex: 1;
}

.note {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--note-border);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.925rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* ── Ingredients ──────────────────────────────────────────── */

.ingredients,
.steps {
    margin-bottom: 2rem;
}

.ingredients ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-left: 0.25rem;
}

.ingredients ul li {
    font-size: 0.925rem;
    color: var(--text);
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border-light);
}

.ingredients ul li::before {
    content: "·  ";
    color: var(--step-num);
}

/* ── Steps ────────────────────────────────────────────────── */

.steps ol {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    counter-reset: steps;
    padding-left: 0;
}

.step-item {
    counter-increment: steps;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem 0.75rem 3rem;
    font-size: 0.925rem;
    line-height: 1.55;
    white-space: pre-wrap;
    position: relative;
    box-shadow: var(--card-shadow);
}

.step-item::before {
    content: counter(steps);
    position: absolute;
    left: 1rem;
    top: 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--step-num);
    width: 1.25rem;
    text-align: center;
}

/* ── Admin ────────────────────────────────────────────────── */

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

.admin-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
    font-family: var(--head-font);
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-subtle);
    margin-bottom: 0.35rem;
}

.field .optional {
    font-weight: 400;
    color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    font-family: inherit;
    background: var(--surface-alt);
    color: var(--text);
    transition: border-color 0.12s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--text-muted);
}

.field textarea {
    resize: vertical;
}

.admin-card button {
    padding: 0.55rem 1.25rem;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s;
}

.admin-card button:hover {
    background: var(--accent-hover);
}

.admin-card button.delete-btn {
    background: #dc2626;
}

.admin-card button.delete-btn:hover {
    background: #b91c1c;
}

.admin-card-full {
    margin-top: 1.5rem;
}

.list-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: flex-start;
}

.list-item input,
.list-item textarea {
    flex: 1;
}

.remove-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.65rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
}

.remove-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-subtle);
}

.add-field-btn {
    padding: 0.4rem 0.85rem;
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.add-field-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-subtle);
}

.admin-msg {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.admin-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════
   Coastal hover accents (shared light + dark)
   ═══════════════════════════════════════════════════════════ */

.section-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(24,100,168,0.10);
}

.recipe-list li a:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 2px 8px rgba(24,100,168,0.08);
}

.step-item:hover {
    border-color: var(--accent);
}


/* ═══════════════════════════════════════════════════════════
   Theme Switcher Widget
   ═══════════════════════════════════════════════════════════ */

.theme-switcher {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}

.theme-switcher-toggle {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    transition: background 0.12s, transform 0.12s;
    line-height: 1;
}

.theme-switcher-toggle:hover {
    background: var(--accent-hover);
    transform: scale(1.08);
}

.theme-switcher-panel {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.4rem;
    box-shadow: 0 6px 24px rgba(0,0,0,0.14);
    min-width: 148px;
}

.theme-switcher-panel.open {
    display: flex;
}

.theme-switcher-panel button {
    padding: 0.4rem 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--body-font);
    cursor: pointer;
    text-align: left;
    transition: background 0.1s, border-color 0.1s;
    white-space: nowrap;
}

.theme-switcher-panel button:hover {
    background: var(--surface-alt);
    border-color: var(--border);
}

.theme-switcher-panel button.active {
    font-weight: 600;
    border-color: var(--accent);
    color: var(--accent);
}

/* ── References page ─────────────────────────────────────── */

.references-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.references-list li a {
    display: block;
    padding: 0.65rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--link);
    font-size: 0.95rem;
    box-shadow: var(--card-shadow);
    transition: border-color 0.12s, box-shadow 0.12s;
}

.references-list li a:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(24,100,168,0.08);
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 600px) {
    main {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    .recipe-list {
        grid-template-columns: 1fr 1fr;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .theme-switcher {
        bottom: 1rem;
        right: 1rem;
    }
}
