/* =========================================================
   Elio's Journal - Core Theme
   ========================================================= */

:root {
    --bg-main: #171413;
    --bg-panel: rgba(39, 32, 29, 0.92);
    --bg-panel-solid: #27201d;
    --bg-panel-soft: rgba(58, 47, 41, 0.78);
    --bg-input: rgba(22, 18, 16, 0.82);

    --text-main: #f3eee8;
    --text-soft: #c9beb3;
    --text-muted: #9f9388;

    --border-soft: rgba(203, 184, 159, 0.16);
    --border-mid: rgba(203, 184, 159, 0.28);
    --border-strong: rgba(166, 214, 157, 0.35);

    --accent-moss: #88b98a;
    --accent-moss-strong: #a8d8a3;
    --accent-ember: #d7a76b;
    --accent-ember-soft: #b98753;
    --accent-danger: #d66b6b;
    --accent-link: #b9ddb1;

    --shadow-deep: 0 12px 35px rgba(0, 0, 0, 0.38);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.24);
    --glow-moss: 0 0 0 1px rgba(168, 216, 163, 0.14), 0 0 18px rgba(136, 185, 138, 0.10);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-body: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
    --font-heading: "Georgia", "Times New Roman", serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top, rgba(89, 116, 87, 0.10), transparent 35%),
        radial-gradient(circle at bottom right, rgba(185, 135, 83, 0.08), transparent 30%),
        linear-gradient(180deg, #1b1715 0%, #141110 100%);
    color: var(--text-main);
    margin: 0;
    line-height: 1.45;
}

/* =========================================================
   Typography
   ========================================================= */

h1,
h2,
h3 {
    margin-top: 0;
    color: #f7f1e9;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
}

h1 {
    font-size: clamp(2rem, 3vw, 2.8rem);
    margin-bottom: 0.4rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

a {
    color: var(--accent-link);
    text-decoration: none;
    transition: color 0.18s ease, opacity 0.18s ease;
}

a:hover {
    color: #d9f0d2;
    text-decoration: none;
}

p {
    color: var(--text-soft);
}

/* =========================================================
   Optional page wrapper
   Add a container around content if you want:
   <main class="page-shell"> ... </main>
   ========================================================= */

.page-shell {
    padding: 10px;
    width: calc(100vw - 150px);
    max-width: 85vw;
    box-sizing: border-box;

    background: rgba(20, 17, 16, 0.30);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 24px;
    backdrop-filter: blur(4px);
}

/* =========================================================
   Status / helper blocks
   ========================================================= */

.loading,
.error,
.empty {
    padding: 16px 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    color: var(--text-soft);
    box-shadow: var(--shadow-soft);
}

.error {
    border-color: rgba(214, 107, 107, 0.40);
    color: #ffd5d5;
}

/* =========================================================
   Category Layout
   ========================================================= */

#category-list {
    margin-top: 20px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.category-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text-main);
    background: linear-gradient(180deg, rgba(50, 35, 28, 0.92), rgba(28, 21, 18, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    border-color: rgba(201, 162, 111, 0.35);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.category-card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.category-card-media {
    position: absolute;
    inset: 0;
}

.category-card-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 1.2s ease-in-out, transform 6s ease;
    transform: scale(1.03);
}

.category-card-bg.is-visible {
    opacity: 1;
    transform: scale(1.07);
}

.category-card-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.10) 0%, rgba(0, 0, 0, 0.28) 100%);
    pointer-events: none;
}

.category-card-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background:
        linear-gradient(180deg, rgba(64, 43, 33, 0.98), rgba(40, 28, 22, 0.98));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.category-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: #f5ede4;
    margin: 0;
    overflow-wrap: anywhere;
}

.category-count {
    flex-shrink: 0;
    font-size: 0.92rem;
    font-weight: 500;
    color: rgba(231, 212, 190, 0.82);
    white-space: nowrap;
}
/* =========================================================
   Recipe Cards
   ========================================================= */

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.recipe-card {
    display: block;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(56, 46, 40, 0.96), rgba(33, 27, 24, 0.98));
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.recipe-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-moss), var(--accent-ember));
    opacity: 0.75;
}

.recipe-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-deep), var(--glow-moss);
    background:
        linear-gradient(180deg, rgba(66, 54, 46, 0.98), rgba(38, 31, 27, 1));
}

.recipe-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff4e8;
    margin-bottom: 0.35rem;
}

.recipe-meta,
.recipe-description {
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* =========================================================
   Modal Shell
   ========================================================= */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    padding: 2rem 1rem;
    overflow-y: auto;
    background:
        radial-gradient(circle at top, rgba(71, 105, 68, 0.10), transparent 30%),
        rgba(8, 7, 7, 0.74);
    backdrop-filter: blur(6px);
}

.modal-content {
    position: relative;
    width: min(1100px, 92vw);
    margin: 0 auto;
    background:
        linear-gradient(180deg, rgba(52, 43, 37, 0.98), rgba(31, 25, 22, 0.98));
    border: 1px solid var(--border-mid);
    border-radius: 18px;
    padding: 1.35rem 1.35rem 1.5rem;
    box-sizing: border-box;
    box-shadow:
        0 18px 60px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 0 26px rgba(136, 185, 138, 0.08);
}

.recipe-modal-content,
.import-recipe-modal-content {
    width: min(1100px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.85rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-soft);
}

.modal-header h2,
#recipeModalTitle {
    margin: 0;
}

.modal-close {
    cursor: pointer;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-soft);
    transition: transform 0.18s ease, color 0.18s ease;
}

.modal-close:hover {
    color: #ffd0d0;
    transform: scale(1.15);
}

.recipe-modal-body {
    padding: 0.5rem 0 0;
}

/* =========================================================
   Recipe Form
   ========================================================= */

.recipe-form-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
}

.recipe-form-section:first-child {
    margin-top: 0.5rem;
}

.recipe-form-section h3,
.recipe-form-section h4 {
    margin-bottom: 0.85rem;
    color: #f3eadf;
}

.recipe-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group.checkbox-group {
    justify-content: flex-end;
}

.form-group label {
    font-weight: 600;
    color: #eadfd4;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid rgba(220, 205, 187, 0.14);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-main);
    box-sizing: border-box;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #8f837a;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: rgba(220, 205, 187, 0.24);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(168, 216, 163, 0.55);
    box-shadow: 0 0 0 3px rgba(136, 185, 138, 0.16);
    background: rgba(26, 21, 19, 0.95);
}

.form-group textarea {
    min-height: 110px;
    resize: vertical;
}

.form-group select[multiple] {
    min-height: 140px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.form-group input[type="checkbox"] {
    width: auto;
    min-width: 18px;
    min-height: 18px;
    accent-color: var(--accent-moss);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
}

.field-help {
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.section-header-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* =========================================================
   Buttons
   ========================================================= */

button,
.button,
.modal-actions button,
.section-header-inline button {
    appearance: none;
    border: 1px solid rgba(166, 214, 157, 0.22);
    border-radius: 10px;
    padding: 0.72rem 1rem;
    background:
        linear-gradient(180deg, rgba(74, 108, 74, 0.96), rgba(48, 74, 48, 0.96));
    color: #eff8ee;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
    transition:
        transform 0.16s ease,
        filter 0.16s ease,
        box-shadow 0.16s ease,
        border-color 0.16s ease;
}

button:hover,
.button:hover,
.modal-actions button:hover,
.section-header-inline button:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28), 0 0 12px rgba(136, 185, 138, 0.10);
}

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

button.secondary,
.button.secondary {
    background:
        linear-gradient(180deg, rgba(96, 77, 60, 0.96), rgba(66, 51, 40, 0.96));
    border-color: rgba(215, 167, 107, 0.22);
    color: #fff1df;
}

button.danger,
.button.danger {
    background:
        linear-gradient(180deg, rgba(130, 54, 54, 0.96), rgba(95, 38, 38, 0.96));
    border-color: rgba(214, 107, 107, 0.32);
    color: #fff1f1;
}

button:disabled,
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-soft);
}

/* =========================================================
   Existing Images Area
   ========================================================= */

.existing-images-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.existing-image-item {
    background: rgba(20, 17, 16, 0.38);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 0.85rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.existing-image-item:hover {
    border-color: var(--border-strong);
    box-shadow: var(--glow-moss);
    transform: translateY(-1px);
}

.existing-image-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    background: #161210;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.existing-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.primary-image-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(168, 216, 163, 0.14);
    color: #d8f0d5;
    border: 1px solid rgba(168, 216, 163, 0.18);
}

/* =========================================================
   Scrollbars
   ========================================================= */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(18, 15, 14, 0.85);
}

::-webkit-scrollbar-thumb {
    background: rgba(108, 97, 89, 0.85);
    border-radius: 999px;
    border: 2px solid rgba(18, 15, 14, 0.85);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(142, 131, 120, 0.95);
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 800px) {
    body {
        padding: 14px;
    }

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

    .modal {
        padding: 1rem 0.5rem;
    }

    .modal-content,
    .recipe-modal-content,
    .import-recipe-modal-content {
        width: min(100%, 96vw);
        padding: 1rem;
        border-radius: 14px;
    }

    .modal-actions {
        justify-content: stretch;
    }

    .modal-actions button,
    .modal-actions .button {
        width: 100%;
    }
}

.category-card {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 14px;
    min-height: 110px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(135deg, rgba(95, 70, 56, 0.55), rgba(44, 31, 24, 0.55));
    text-decoration: none;
    color: var(--text-main);
    isolation: isolate;
}

.category-card-media {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.category-card-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transform: scale(1.03);
    transition: opacity 1.2s ease-in-out;
    opacity: 0;
}

.category-card-bg.is-visible {
    opacity: 1;
}

.category-card-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(15, 11, 10, 0.18) 0%, rgba(15, 11, 10, 0.55) 100%),
        linear-gradient(135deg, rgba(90, 62, 44, 0.22), rgba(24, 18, 16, 0.25));
}

.category-card-content {
    position: relative;
    z-index: 1;
    padding: 16px;
}

.category-card h3,
.category-card p {
    position: relative;
    z-index: 1;
    margin: 0;
}

.category-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.category-card p {
    color: rgba(255, 255, 255, 0.82);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}
