/* global color scheme */
:root {
    --app-nav-rail-width: 4.75rem;
    --app-nav-rail-link-size: 3rem;

    /* reference palette - Pantone 2026 Cloud Dancer-inspired */
    --app-palette-accent-600: #8A5F3F;
    --app-palette-accent-100: #EAD8C6;
    --app-palette-neutral-100: #F5F2EA;
    --app-palette-neutral-900: #2D2A26;
    --app-palette-muted-100: #E8E3DA;

    /* semantic tokens */
    --app-color-rail: var(--app-palette-neutral-100);
    --app-color-active: var(--app-palette-accent-600);
    --app-color-active-bg: var(--app-palette-accent-100);
    --app-color-hover-bg: var(--app-palette-muted-100);
    --app-color-text: var(--app-palette-neutral-900);
}

[data-bs-theme="dark"] {
    --app-palette-accent-600: #D7B08C;
    --app-palette-accent-100: #463528;
    --app-palette-neutral-100: #181818; /* rail background */
    --app-palette-neutral-900: #F5F2EA;
    --app-palette-muted-100: #262626;   /* hover background */
}

/* for navbar */
.recipe-navbar {
    background-color:#6C739C;
}

.app-nav-drawer {
    --bs-offcanvas-width: min(84vw, 20rem);
    background: var(--app-color-rail);
    color: var(--app-color-text);
    border-right: 1px solid var(--bs-border-color);
}

.app-nav-drawer-header {
    gap: 0.75rem;
    /* 0.875rem left inset lines the hamburger up with the rail's centered links */
    padding: 1rem 0.875rem;
}

.app-nav-drawer-brand {
    min-width: 0;
    overflow: hidden;
    font-size: 1rem;
    font-weight: 700;
    color: var(--app-color-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav-drawer .offcanvas-body {
    padding: 0.25rem 0.875rem 1rem;
}

.app-nav-drawer-list {
    gap: 0.75rem;
}

.app-nav-drawer-link {
    display: flex;
    align-items: center;
    min-height: var(--app-nav-rail-link-size, 3rem);
    padding: 0 0.75rem 0 0;
    border-radius: 0.5rem;
    color: var(--app-color-text);
}

.app-nav-drawer-link:hover,
.app-nav-drawer-link:focus-visible {
    color: var(--app-color-active);
    background: var(--app-color-hover-bg);
}

.app-nav-drawer-link.active {
    color: var(--app-color-active);
    background: var(--app-color-active-bg);
    box-shadow: inset 0 0 0 1px rgba(138, 95, 63, 0.2);
}

.app-nav-drawer-icon {
    display: inline-flex;
    flex: 0 0 var(--app-nav-rail-link-size, 3rem);
    align-items: center;
    justify-content: center;
    width: var(--app-nav-rail-link-size, 3rem);
    height: var(--app-nav-rail-link-size, 3rem);
    font-size: 1.65rem; /* keep in sync with .app-rail-link i */
    line-height: 1;
}

/* nav rail - for sidebar navigation */
.app-nav-rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    width: var(--app-nav-rail-width);
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem 0.75rem;
    background: var(--app-color-rail);
    border-right: 1px solid var(--bs-border-color);
}

.app-nav-rail-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.app-nav-rail-main {
    flex: 1 1 auto;
}

.app-nav-rail-bottom {
    margin-top: auto;
}

.app-rail-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--app-nav-rail-link-size);
    height: var(--app-nav-rail-link-size);
    border: 0;
    border-radius: 0.5rem;
    color: var(--app-color-text);
    background: transparent;
    text-decoration: none;
}

.app-rail-link i {
    font-size: 1.65rem;
    line-height: 1;
}

.app-rail-link:hover,
.app-rail-link:focus-visible {
    color: var(--app-color-active);
    background: var(--app-color-hover-bg);
}

.app-rail-link:focus:not(:focus-visible) {
    outline: 0;
}

.app-rail-link:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 0.15rem rgba(200, 78, 39, 0.3);
}

.app-rail-link.active {
    color: var(--app-color-active);
    background: var(--app-color-active-bg);
    box-shadow: inset 0 0 0 1px rgba(138, 95, 63, 0.2);
}

.app-rail-button {
    padding: 0;
}

.app-rail-link.dropdown-toggle::after {
    display: none;
}

@media (min-width: 992px) {
    .app-shell-header,
    .app-shell-main {
        padding-left: calc(var(--app-nav-rail-width) + (var(--bs-gutter-x, 1.5rem) * 0.5));
    }

    .offcanvas-backdrop.show {
        opacity: 0;
    }

    /* nav drawer opens as the rail expanding, not a sheet sliding in over it.
       Closed state parks the (hidden) panel at rail width with no translate;
       .showing/.show grow it to full width; .hiding shrinks it back. */
    .app-nav-drawer.offcanvas-start {
        width: var(--app-nav-rail-width);
        transform: none;
        transition: width 0.3s ease-in-out;
    }

    /* must stay after the rule above (equal specificity, order-dependent) */
    .app-nav-drawer.showing,
    .app-nav-drawer.show:not(.hiding) {
        width: var(--bs-offcanvas-width);
    }

    .app-nav-drawer.showing,
    .app-nav-drawer.hiding {
        overflow: hidden;
    }

    /* keep content laid out at final width so labels are revealed, not reflowed */
    .app-nav-drawer .offcanvas-header,
    .app-nav-drawer .offcanvas-body {
        width: var(--bs-offcanvas-width);
    }
}

/* must be (0,2,0) and placed after the block above to beat the width transition */
@media (prefers-reduced-motion: reduce) {
    .app-nav-drawer.offcanvas-start {
        transition: none;
    }
}

/* for navbar toggler focus */
.navbar-toggler:focus:not(:focus-visible) {
    box-shadow: none;
}

.navbar-toggler:focus-visible {
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.35);
}


/* Nunito font for all */
body {
    font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1,
h2,
h3 {
    font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-weight: 600;
}

/* Login */
.form-signin {
    max-width: 330px;
    padding: 1rem;
}

.form-signin .form-floating:focus-within {
    z-index: 2;
}

.form-signin input[name="username"] {
    margin-bottom: -1px;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.form-signin input[name="password"] {
    margin-bottom: 10px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.auth-card {
    max-width: 30rem;
}

.settings-card {
    max-width: 46rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--bs-secondary-color);
}

.auth-divider::before,
.auth-divider::after {
    flex: 1;
    content: "";
    border-top: 1px solid var(--bs-border-color);
}

.theme-icon,
.theme-icon-active {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

[data-bs-theme-value].active .theme-icon:last-child {
    display: block !important;
}


/* inherit Nunito font in recipe detail sections too */
.recipe-detail-section pre {
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.parsed-ingredient,
.parsed-ingredient-section {
    line-height: 1.5;
}

.parsed-ingredient-section {
    font-weight: 700;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
}

#parsed-ingredients .parsed-ingredient-section:first-child {
    margin-top: 0;
}

.recipe-scale-input {
    width: 6rem;
}


/* for carousel */
.carousel-image {
    height: 600px;
    object-fit: cover;
}

.carousel-caption-panel {
    background-color: rgba(0, 0, 0, 0.68);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.carousel-caption-panel p {
    margin-bottom: 0;
}

/* for Gallery */
.gallery-card-img {
    height: 260px;
    object-fit: cover;
    width: 100%;
}

/* for name in recipe list */
.recipe-list-name {
    text-decoration: none;
    color: inherit;
}


/* for recipe list search and sort styling*/
.recipe-controls {
    top: 56px;
    z-index: 100;
}

.recipe-controls .form-control,
.recipe-controls .form-select {
    border-color: var(--bs-border-color);
}

.recipe-controls .form-control:focus,
.recipe-controls .form-select:focus {
    border-color: #8E9A98;
    box-shadow: 0 0 0 0.2rem rgba(142, 154, 152, 0.35);
}



/* recipe detail table */
.recipe-detail-table {
    table-layout: fixed;
    width: 100%;
}

.recipe-detail-table th:first-child,
.recipe-detail-table td:first-child {
    width: 7rem;
}

.recipe-detail-table td,
.recipe-detail-table a {
    overflow-wrap: anywhere;
}



/* Recipe Detail Photos */
.recipe-photo-gallery {
    --primary-photo-size: 250px;
    --photo-gap: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: var(--photo-gap);
}

.recipe-primary-photo {
    width: var(--primary-photo-size);
    height: var(--primary-photo-size);
    object-fit: cover;
    border-radius: 0.375rem;
    cursor: zoom-in;
}

.recipe-photo-thumbs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--photo-gap);
    width: var(--primary-photo-size);
}

.recipe-photo-thumbs-mobile {
    display: none;
}

.recipe-photo-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.25rem;
    background-color: #fff;
    cursor: zoom-in;
}

.recipe-photo-more {
    aspect-ratio: 1 / 1;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #f8f9fa;
    font-weight: 700;
    color: #495057;
}

.photo-modal-image {
    max-height: 80vh;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.hidden-photo-modal-thumb {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

@media (max-width: 575.98px) {
    .recipe-photo-gallery {
        --primary-photo-size: min(68vw, 320px);
    }

    .recipe-photo-thumbs-desktop {
        display: none;
    }

    .recipe-photo-thumbs-mobile {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--photo-gap);
        width: calc(var(--primary-photo-size) / 3);
    }
}



/* for recipe chat*/
#recipeChatPanel .offcanvas-body {
    min-height: 0;
    box-sizing: border-box;
}

.chat-status {
    flex: 0 0 auto;
    padding: 0 0 0.75rem 0;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-right: 0.25rem;
}

.chat-composer {
    flex: 0 0 auto;
    display: grid;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

#chat-message-input {
    min-height: 80px;
    resize: vertical;
}

.chat-message-user {
    background: #f6f8d9;
    color: #5a5f1a;
    margin-left: 2rem;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.chat-message-assistant {
    background: #eaf2ff;
    color: #17406b;
    margin-right: 2rem;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}



@media (min-width: 992px) {
    .recipe-chat {
        position: sticky;
        top: calc(56px + 3rem);
        height: calc(100dvh - 56px - 3rem);
        border-left: 1px solid var(--bs-border-color);
        padding-left: 1.5rem;
        background: var(--bs-body-bg);
        color: var(--bs-body-color);
    }

    #recipeChatPanel {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    #recipeChatPanel .offcanvas-body {
        flex: 1 1 auto;
        min-height: 0;
    }

    .chat-composer {
        grid-template-columns: 1fr auto;
        align-items: end;
    }
}



/* for Buttons */
/* for gallery - can be reused to remove */
.favorite-remove-btn {
    --bs-btn-close-opacity: 0.7;
    --bs-btn-close-hover-opacity: 1;
    background-color: white;
    border-radius: 999px;
    padding: 0.5rem;
}

/* BUTTONS */
/* favorite button in recipe list */
.favorite-button .favorite-heart {
    fill: none;
    stroke: #E5AEA9;
    stroke-width: 1.5;
    transition: fill 0.2s ease, stroke 0.2s ease, transform 0.2s ease;
}

.favorite-button.is-favorited .favorite-heart {
    fill: #E5AEA9;
    stroke: #E5AEA9;
}

.favorite-button:hover .favorite-heart {
    transform: scale(1.08);
}


/* pinning in recipe list */
.pin-button {
    color: #A6A9D0;
}

.pin-button:hover,
.pin-button:focus,
.pin-button:active {
    color: #A6A9D0;
}

.pin-button .pin-filled {
    display: none;
}

.pin-button.is-pinned .pin-outline {
    display: none;
}

.pin-button.is-pinned .pin-filled {
    display: inline-block;
}

.pin-button svg {
    transition: transform 0.2s ease;
}

.pin-button:hover svg {
    transform: scale(1.08);
}


/* More button */
.more-button {
    border-color: #35627A;
    color: #35627A;
}

.more-button:hover,
.more-button:focus,
.more-button:active {
    color: #35627A;
}


/* Update Button */
.update-button {
    border-color: #A1C3E7;
    color: white;
    background-color: #A1C3E7;
}

.update-button:hover,
.update-button:focus,
.update-button:active {
    border-color: #A1C3E7;
    color: white;
    background-color: #A1C3E7;
    transform: scale(1.08);
    transition: transform 0.2s ease;
}


/* Recipe tag pills: filter bar on the recipes list, tag links on the detail
   page. Colors ride the semantic tokens so light/dark parity is automatic. */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.65rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--app-color-text);
    font-size: 0.875rem;
    line-height: 1.4;
    text-decoration: none;
}

.tag-pill:hover,
.tag-pill:focus-visible {
    background: var(--app-color-hover-bg);
    color: var(--app-color-text);
}

.tag-pill.active {
    border-color: var(--app-color-active);
    background: var(--app-color-active-bg);
    color: var(--app-color-active);
}

/* remove affordance on selected filter pills */
.tag-pill.active::after {
    content: "\00d7";
    font-weight: 700;
    line-height: 1;
}

.tag-pill-count {
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.tag-pill.active .tag-pill-count {
    color: inherit;
}

/* Classes replacing the last inline style= attributes — the CSP style-src no
   longer allows 'unsafe-inline' (Talisman config in app.py), so an inline
   style attribute would be silently dropped by the browser. */
.input-group-narrow {
    max-width: 32rem;
}

.min-w-0 {
    min-width: 0;
}

.text-pre-wrap {
    white-space: pre-wrap;
}

.photo-grid-square {
    aspect-ratio: 1 / 1;
}

.recipe-thumb {
    width: 96px;
    height: 96px;
    cursor: zoom-in;
}

.content-narrow {
    max-width: 720px;
}
