/* App shell */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Skip link — off-screen until focused, for keyboard navigation */
.skip-link {
    position: absolute;
    left: var(--space-3);
    top: -3.5rem;
    z-index: 200;
    background: var(--color-bg-surface);
    color: var(--color-brand);
    border: 1px solid var(--color-gold-line);
    border-radius: 6px;
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: var(--space-3);
}

/* Top navigation bar */
.nav {
    background-color: var(--color-bg-nav);
    border-bottom: 1px solid var(--color-gold-line);
    padding: 0 var(--space-6);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-brand);
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: nowrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    transition: background-color var(--transition), color var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Mobile hamburger button — hidden on desktop */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}
.nav-toggle:hover { background-color: var(--color-bg-subtle); }

/* ── Mobile nav: hamburger + slide-down panel ─────────────────────── */
@media (max-width: 900px) {
    .nav {
        padding: 0 var(--space-4);
    }
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .nav-links {
        position: absolute;
        top: 3.5rem;
        left: 0;
        right: 0;
        background: var(--color-bg-surface);
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: var(--space-2);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        display: none;
    }
    .nav-links.nav-links--open {
        display: flex;
    }
    .nav-link {
        width: 100%;
        padding: var(--space-3) var(--space-3);
    }
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--color-bg-subtle);
    color: var(--color-text);
}

/* Nav badges — small count chip sitting on a nav link */
.nav-notif-badge,
.nav-brew-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    margin-left: var(--space-1);
    vertical-align: middle;
}

/* Hub badge — unread notifications, kept live by _notifications.js */
.nav-notif-badge {
    background: var(--color-error);
}

/* Brewhouse badge — counts sessions mid-brew; warning hue, matching the
   "brewing" status pill in the sessions list (not an alert like Hub's).
   Deliberately NOT a .nav-notif-badge: that class is harvested by the
   notification poller, which would overwrite or remove this static badge.
   Gently pulses a ring so an active brew catches the eye. */
.nav-brew-badge {
    background: var(--color-warning);
    color: #12161f;  /* dark text — readable on the amber fill in both themes */
    animation: nav-brew-pulse 2.4s ease-in-out infinite;
}
@keyframes nav-brew-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 156, 26, 0.55); }
    50%      { box-shadow: 0 0 0 5px rgba(232, 156, 26, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .nav-brew-badge { animation: none; }
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Main content area */
.main {
    flex: 1;
    padding: var(--space-8) var(--space-6);
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* Page label/title — used by recipe hero card and dashboard, not by a page header any more. */
.page-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-1);
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

/* Generic modal overlay — used by transfer, export, quick-add, pre-flight, etc.
   Any interactive popover that should fill the viewport with a dimmed backdrop.
   Pair with .modal-card for the content surface. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    overflow: auto;
}
.modal-overlay[hidden] { display: none; }
.modal-overlay--center { align-items: center; }

.modal-card {
    max-width: 480px;
    width: 100%;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0;
    max-height: 90vh;
    overflow: auto;
}
.modal-card--wide { max-width: 640px; }
.modal-card--narrow { max-width: 420px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-md);
}
.modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--color-text); }

.modal-body {
    padding: var(--space-4);
}

/* Breadcrumbs — replaces the old page-label/page-title header on listing pages.
   Rendered via templates/_breadcrumbs.php. */
.breadcrumbs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}
.breadcrumbs-trail {
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.breadcrumbs-trail a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.breadcrumbs-trail a:hover {
    color: var(--color-text);
}
.breadcrumbs-trail .breadcrumbs-sep {
    opacity: 0.5;
}
.breadcrumbs-trail .breadcrumbs-current {
    color: var(--color-text);
}
.breadcrumbs-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Two-column layout with sidebar */
.layout-with-sidebar {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--space-6);
    align-items: start;
}

.sidebar {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* Stack utility */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.stack-sm { gap: var(--space-2); }
.stack-lg { gap: var(--space-8); }

/* Inline cluster */
.cluster {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* Footer */
.footer {
    background-color: var(--color-bg-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-4) var(--space-6);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .nav {
        padding: 0 var(--space-4);
    }

    .main {
        padding: var(--space-4);
    }

    .layout-with-sidebar {
        grid-template-columns: 1fr;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

}
