/* ====================================================================
   The Culinary Codex — Mobile-Responsive Stylesheet
   Comprehensive mobile-first responsive overrides.
   Loaded after all other stylesheets in base.html.
   ==================================================================== */

/* ====================================================================
   MOBILE BOTTOM NAVIGATION BAR
   ==================================================================== */
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(26, 20, 16, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        padding: 0.35rem 0;
        padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        align-items: center;
    }

    .mobile-nav__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        padding: 0.4rem 0.5rem;
        min-width: 56px;
        min-height: 44px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.65rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav__item svg {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .mobile-nav__item--active {
        color: var(--accent-gold);
    }

    .mobile-nav__item:active {
        color: var(--accent-gold);
        transform: scale(0.92);
    }

    /* Light theme support */
    [data-theme="light"] .mobile-nav {
        background: rgba(250, 247, 242, 0.96);
    }

    /* Add bottom padding to body so content isn't hidden behind mobile nav */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* Hide top navbar links on mobile — keep logo + hamburger only */
    .navbar__links {
        display: none !important;
    }

    .navbar__actions {
        display: none !important;
    }

    /* Reduce navbar height on mobile */
    .navbar__inner {
        height: 52px;
    }

    #main-content {
        padding-top: 52px;
    }

    #main-content:has(.cuisine-hero),
    #main-content:has(.dish-hero),
    #main-content:has(.home-hero) {
        padding-top: 0;
    }
}


/* ====================================================================
   GLOBAL TOUCH TARGETS — Minimum 44px
   ==================================================================== */
@media (max-width: 768px) {
    button,
    [role="button"],
    input[type="submit"],
    input[type="button"],
    .btn,
    .navbar__link,
    .navbar__dropdown-link,
    a.cuisine-card,
    a.dish-card,
    .enc-card {
        min-height: 44px;
    }

    /* Checkbox/radio touch targets */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 22px;
        min-height: 22px;
    }

    label:not(.form-label) {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* #75 — Floating labels on login/register must stay positioned */
    .form-label {
        min-height: auto;
        display: block;
    }
}


/* ====================================================================
   TYPOGRAPHY — Readable without zooming
   ==================================================================== */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        -webkit-text-size-adjust: 100%;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    h3 {
        font-size: 1.15rem;
    }

    p, li, td, th, dd, dt {
        font-size: 1rem;
        line-height: 1.6;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.05rem;
    }
}


/* ====================================================================
   IMAGES — Scale properly on all screens
   ==================================================================== */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }

    .cuisine-card__image img,
    .dish-card__image img,
    .cuisine-hero__bg img {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
}


/* ====================================================================
   FORMS — Proper sizes for mobile keyboards
   ==================================================================== */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;  /* prevents iOS zoom on focus */
        min-height: 44px;
        padding: 0.65rem 0.85rem;
        border-radius: var(--radius-sm);
    }

    .search-form__input {
        font-size: 16px !important;
        padding: 0.85rem 1rem;
    }

    .search-form__btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem 1.25rem;
    }

    .search-form__wrap {
        flex-direction: row;
    }

    /* Match ingredients input */
    .match-input {
        font-size: 16px !important;
    }

    .match-input-wrap {
        min-height: 48px;
    }

    /* Encyclopedia search */
    .enc-search__input {
        font-size: 16px !important;
        min-height: 44px;
    }

    /* Submit form */
    .submit-form input,
    .submit-form textarea,
    .submit-form select {
        font-size: 16px !important;
        min-height: 44px;
    }
}


/* ====================================================================
   CUISINE GRID — 2 cols phone, 3 tablet, 4+ desktop
   ==================================================================== */
.cuisine-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 1025px) {
    .cuisine-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .cuisine-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .cuisine-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .cuisine-card {
        aspect-ratio: 1/1;
    }

    .cuisine-card__name {
        font-size: 1.1rem;
    }

    .cuisine-card__flag {
        display: none;
    }

    .cuisine-card__tagline {
        font-size: 0.8rem;
    }

    .cuisines-section {
        padding: 2rem 0.75rem;
    }

    .cuisines-section__title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .cuisine-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .cuisine-card__overlay {
        padding: 0.75rem;
    }

    .cuisine-card__name {
        font-size: 0.95rem;
    }
}

/* #98 — At 360px and below, switch to single column for cuisine grid */
@media (max-width: 374px) {
    .cuisine-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}


/* ====================================================================
   DISH CARDS — Full-width on phone with larger images
   ==================================================================== */
@media (max-width: 768px) {
    .dish-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .dish-grid--search {
        grid-template-columns: 1fr 1fr;
    }

    .dish-grid--related {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .dish-card {
        border-radius: var(--radius-sm);
    }

    .dish-card__image-wrap {
        aspect-ratio: 1/1;
    }

    .dish-card__body {
        padding: 0.6rem;
    }

    .dish-card__name {
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .dish-card__english {
        font-size: 0.7rem;
    }

    .dish-card__meta {
        font-size: 0.7rem;
        gap: 0.4rem;
    }

    .dish-card__dietary-tags {
        display: none;
    }

    .dish-card__timing-tag {
        display: none;
    }

    .dish-grid-section {
        padding: 1rem 0.5rem 3rem;
    }
}

@media (max-width: 380px) {
    .dish-grid,
    .dish-grid--search,
    .dish-grid--related {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .dish-card__name {
        font-size: 0.8rem;
    }
}


/* ====================================================================
   DISH HERO — Readable text on mobile (#77)
   ==================================================================== */
@media (max-width: 768px) {
    .dish-hero {
        height: auto;
        min-height: 280px;
        max-height: 400px;
    }

    .dish-hero__overlay {
        background: linear-gradient(
            to bottom,
            rgba(26, 20, 16, 0.4) 0%,
            rgba(26, 20, 16, 0.7) 40%,
            rgba(26, 20, 16, 0.95) 80%,
            rgba(26, 20, 16, 1) 100%
        );
    }

    .dish-hero__content {
        padding: 1rem 1rem 1.25rem;
    }

    .dish-hero__title {
        font-size: 1.6rem;
        color: #fff;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    }

    .dish-hero__english {
        color: rgba(255, 255, 255, 0.8);
    }

    .dish-hero__breadcrumb-nav {
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.8rem;
    }

    .dish-hero__breadcrumb-nav a {
        color: var(--accent-gold);
    }

    .dish-hero__actions {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

    .dish-hero__actions .share-btn,
    .dish-hero__actions .cookbook-add-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        min-height: 36px;
    }
}


/* ====================================================================
   DISH DETAIL PAGE — Single column on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .recipe {
        padding: 1rem 0.75rem 3rem;
    }

    .recipe__layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* #79 — Ingredients sidebar must NOT be sticky/fixed on mobile */
    .recipe__sidebar {
        order: -1;
        position: static !important;
    }

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

    .recipe__hero-image {
        border-radius: var(--radius);
        max-height: 300px;
    }

    .recipe__hero-image img {
        border-radius: var(--radius);
    }

    .info-bar__inner {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: center;
    }

    .info-bar__item {
        min-width: auto;
    }

    /* Ingredients grid */
    .ingredients-grid {
        grid-template-columns: 1fr;
    }

    /* #80 — Comment form usable on mobile */
    .comment-form {
        flex-direction: column;
    }

    .comment-form__avatar {
        display: none;
    }

    .comment-form__textarea {
        min-height: 100px;
        font-size: 16px !important;
    }

    .comment-form__submit {
        min-height: 44px;
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }

    .comments-section {
        padding: 0 0.75rem;
    }

    .comments-section__inner {
        padding: 1.25rem;
    }
}


/* ====================================================================
   DASHBOARD — Single column on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .dashboard {
        padding: 1.5rem 0.75rem 3rem;
    }

    .dashboard__grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .dashboard-card {
        padding: 1rem 0.75rem;
    }

    /* Cookbook/rec scroll: bleed past card padding for edge-to-edge scroll */
    .dashboard-card .cookbook-scroll,
    .dashboard-card .recommendations-grid {
        margin-inline: -0.75rem;
        padding-inline: 0.75rem;
    }

    .dashboard__greeting h1 {
        font-size: 1.6rem;
    }

    .dashboard__greeting p {
        font-size: 0.95rem;
    }

    .dashboard__motd {
        padding: 1rem;
    }

    .dashboard__motd blockquote {
        font-size: 1rem;
    }

    .recommendations-grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 0.75rem;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .recommendations-grid::-webkit-scrollbar {
        display: none;
    }

    .recommendations-grid .rec-card {
        flex: 0 0 auto;
        width: 180px;
        scroll-snap-align: start;
    }

    /* Stats bar: tighter on mobile */
    .dashboard__stats-bar {
        gap: 0.5rem;
        padding: 0.75rem 0.75rem;
        -webkit-overflow-scrolling: touch;
    }

    .dashboard__stat {
        min-width: 50px;
    }

    .dashboard__stat-value {
        font-size: 1.1rem;
    }

    .dashboard__stat-label {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .dashboard {
        padding: 1rem 0.5rem 3rem;
    }

    .dashboard__greeting h1 {
        font-size: 1.4rem;
    }

    /* Stats bar: wrap at very small screens */
    .dashboard__stats-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem 0.75rem;
        padding: 0.65rem 0.5rem;
    }

    .dashboard__stat {
        min-width: 55px;
    }
}

/* Dashboard mobile: show tap-to-add, hide drag dropzone text */
@media (max-width: 768px) {
    .shopping-dropzone__text--desktop {
        display: none;
    }
    .shopping-dropzone__text--mobile {
        display: inline;
    }
    .cookbook-card__add-shopping {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: none;
        background: rgba(212, 168, 83, 0.15);
        color: var(--accent-gold, #d4a853);
        font-size: 1rem;
        cursor: pointer;
        flex-shrink: 0;
    }
    .cookbook-card__add-shopping:active {
        transform: scale(0.9);
        background: rgba(212, 168, 83, 0.3);
    }
}
@media (min-width: 769px) {
    .shopping-dropzone__text--mobile {
        display: none;
    }
    .cookbook-card__add-shopping {
        display: none;
    }
}


/* ====================================================================
   SHOPPING LIST — Swipe-friendly checkboxes
   ==================================================================== */
@media (max-width: 768px) {
    .shopping-list-page {
        padding: 1.5rem 0.75rem 5rem;
        min-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .shopping-list-page__inner {
        max-width: 100%;
    }

    .shopping-list-page__header {
        text-align: center;
    }

    .shopping-list-page__title {
        font-size: 1.5rem;
    }

    .shopping-list-page__actions {
        display: flex;
        gap: 0.5rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    .shopping-consolidated__item {
        padding: 0.85rem 0.75rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-height: 52px;
        border-bottom: 1px solid var(--border);
        touch-action: pan-y pan-x;
    }

    .shopping-consolidated__label {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-height: 44px;
        cursor: pointer;
    }

    .shopping-consolidated__checkbox {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        flex-shrink: 0;
        accent-color: var(--accent-gold);
    }

    .shopping-consolidated__text {
        font-size: 1rem;
        line-height: 1.4;
    }

    .shopping-consolidated__remove {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        opacity: 1;
    }

    .shopping-consolidated__badge {
        font-size: 0.8rem;
        flex-shrink: 0;
    }
}


/* ====================================================================
   MEAL PLANNER — Horizontal scroll on mobile instead of grid
   ==================================================================== */
@media (max-width: 768px) {
    .meal-planner {
        padding: 1.5rem 0.75rem 3rem;
    }

    .mp-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mp-header__title {
        font-size: 1.5rem;
    }

    .mp-day-tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 0.5rem;
        padding: 0.5rem 0;
        margin: 0 -0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .mp-day-tabs::-webkit-scrollbar {
        display: none;
    }

    .mp-day-tab {
        flex-shrink: 0;
        scroll-snap-align: start;
        min-width: 64px;
        min-height: 44px;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .mp-slot {
        padding: 1rem;
    }

    .mp-slot__dish-img {
        width: 60px;
        height: 60px;
    }

    .mp-slot__dish-name {
        font-size: 0.95rem;
    }

    .mp-save-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }

    /* Meal type grid */
    .mp-meals-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .mp-header__title {
        font-size: 1.3rem;
    }

    .mp-day-tab {
        min-width: 56px;
        font-size: 0.8rem;
    }
}


/* ====================================================================
   ENCYCLOPEDIA — Single column cards on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .enc-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .enc-hero__title {
        font-size: 1.6rem;
    }

    .enc-hero__subtitle {
        font-size: 0.95rem;
    }

    .enc-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .enc-card {
        padding: 1.15rem;
    }

    .enc-card__name {
        font-size: 1.1rem;
    }

    .enc-search {
        max-width: 100%;
    }

    /* Encyclopedia detail */
    .enc-detail-hero {
        flex-direction: column;
    }

    .enc-detail-hero__image-wrap {
        width: 100%;
        max-width: 100%;
    }

    /* Filter tags horizontal scroll */
    .enc-filters {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 0.5rem;
    }

    .enc-filters::-webkit-scrollbar {
        display: none;
    }

    .enc-filter-btn {
        flex-shrink: 0;
        min-height: 44px;
    }
}


/* ====================================================================
   CUISINE DETAIL PAGE
   ==================================================================== */
@media (max-width: 768px) {
    /* #81 — Prevent title/description from overlapping navbar on mobile */
    .cuisine-hero {
        height: auto;
        min-height: 320px;
        max-height: 480px;
        padding-top: 60px; /* clear mobile navbar */
    }

    .cuisine-hero__content {
        padding: 1rem;
    }

    .cuisine-hero__flag {
        font-size: 3rem;
        margin-bottom: 0.5rem;
    }

    .cuisine-hero__title {
        font-size: 1.75rem;
        color: #fff;
        text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    }

    .cuisine-hero__tagline {
        font-size: 0.95rem;
    }

    .cuisine-hero__stats {
        margin-top: 1rem;
        gap: 1rem;
    }

    .cuisine-hero__scroll-hint {
        display: none;
    }

    .cuisine-hero__location {
        font-size: 0.85rem;
    }

    .cuisine-narrative {
        padding: 1.5rem 0.75rem;
    }

    .cuisine-narrative__text {
        font-size: 1rem;
        line-height: 1.7;
    }

    /* Cultural sections */
    .culture-section {
        padding: 1.5rem 0.75rem;
    }

    .culture-section__title {
        font-size: 1.3rem;
    }

    /* #167 — Stack cultural narrative text/image vertically on mobile */
    .cultural-narrative__body {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .cultural-narrative__gallery {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cultural-narrative__gallery-item {
        min-width: 200px;
    }

    .cultural-narrative__inner {
        padding: 1.5rem 0.75rem;
    }

    .cuisine-intro {
        padding: 2rem 0.75rem 1.5rem;
    }

    .cuisine-intro__text {
        font-size: 1rem;
    }

    /* #82 — Key Flavors: style as plain tags, not buttons */
    .ingredients-strip__tag {
        cursor: default;
        pointer-events: none;
        user-select: none;
        -webkit-user-select: none;
        border-color: rgba(212, 168, 83, 0.1);
        opacity: 0.85;
    }
}


/* ====================================================================
   HERO SECTION — Mobile optimizations
   ==================================================================== */
@media (max-width: 768px) {
    .hero {
        min-height: 400px;
    }

    .hero__content {
        padding: 0 1rem;
    }

    .hero__title {
        font-size: 2rem;
    }

    .hero__subtitle {
        font-size: 1rem;
    }

    .hero__cta-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero__cta-group .btn {
        width: 100%;
        text-align: center;
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    .hero {
        min-height: 350px;
    }

    .hero__title {
        font-size: 1.6rem;
    }
}


/* ====================================================================
   COOKBOOK PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .cookbook-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .cookbook-header {
        flex-direction: column;
        gap: 1rem;
    }

    .cookbook-header__title {
        font-size: 1.5rem;
    }

    .cookbook-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .cookbook-tabs::-webkit-scrollbar {
        display: none;
    }

    .cookbook-tab {
        flex-shrink: 0;
        min-height: 44px;
    }

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


/* ====================================================================
   PROFILE PAGE — Complete mobile redesign
   ==================================================================== */
@media (max-width: 768px) {
    .profile-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    /* Header: stack avatar, info, edit button vertically */
    .profile-header__inner {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem 1rem;
        gap: 1rem;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        margin: 0 auto;
    }

    .profile-info__name {
        font-size: 1.4rem;
    }

    .profile-info__featured-badges {
        justify-content: center;
    }

    .profile-edit-btn {
        width: 100%;
        text-align: center;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Stats bar: wrap on mobile, scrollable if too many */
    .profile-stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem 1rem;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .profile-stat {
        min-width: 65px;
    }

    .profile-stat__number {
        font-size: 1.4rem;
    }

    .profile-stat__label {
        font-size: 0.75rem;
    }

    /* Tabs: horizontal scroll, touch-friendly */
    .profile-tabs {
        padding: 0 0.75rem;
        gap: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        margin-bottom: 1.5rem;
    }

    .profile-tabs::-webkit-scrollbar {
        display: none;
    }

    .profile-tab {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .profile-tab__count {
        font-size: 0.7rem;
    }

    /* Tab content: reduce padding */
    .profile-tab-content {
        padding: 0 0.75rem;
    }

    /* Ratings list */
    .profile-rating-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.85rem 1rem;
    }

    .profile-rating-item__score {
        font-size: 1rem;
    }

    /* Empty states */
    .profile-empty {
        padding: 2rem 0.75rem;
    }

    /* Collections grid */
    .collections-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .create-collection__form {
        flex-direction: column;
        gap: 0.75rem;
    }

    .create-collection__input {
        width: 100%;
    }

    .create-collection__btn {
        width: 100%;
        min-height: 44px;
    }

    /* Badges grid */
    .badges-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .badge-card {
        padding: 1rem;
    }

    .badge-card__icon {
        font-size: 2rem;
    }

    .badges-showcase__slots {
        justify-content: center;
    }

    .badges-header__how {
        font-size: 0.85rem;
    }

    /* Section footers */
    .profile-section__view-all {
        display: block;
        text-align: center;
        padding: 0.75rem;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .profile-stats {
        gap: 0.4rem 0.75rem;
    }

    .profile-stat {
        min-width: 55px;
    }

    .profile-stat__number {
        font-size: 1.2rem;
    }

    .profile-tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }
}


/* ====================================================================
   SEARCH PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .search-page {
        padding: 5rem 0.75rem 3rem;
    }

    .search-page__title {
        font-size: 1.5rem;
    }

    .search-results-grid {
        grid-template-columns: 1fr;
    }
}


/* ====================================================================
   SEARCH MODAL — Fullscreen on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .search-modal__container {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .search-modal__input {
        font-size: 16px !important;
    }

    .search-modal__header {
        padding: 0.75rem;
    }

    .search-modal__close kbd {
        font-size: 0.75rem;
    }
}


/* ====================================================================
   SOCIAL / COMMUNITY PAGES
   ==================================================================== */
@media (max-width: 768px) {
    .social-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .social-card {
        padding: 1rem;
    }

    .community-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .comment-form textarea {
        font-size: 16px !important;
        min-height: 80px;
    }

    .comment__actions button {
        min-height: 44px;
        min-width: 44px;
    }
}


/* ====================================================================
   COMPARE CUISINES PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .compare-page {
        padding: 1.5rem 0.75rem 3rem;
    }

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

    .compare-select {
        min-height: 44px;
        font-size: 16px !important;
    }
}


/* ====================================================================
   COLLECTIONS / BOOKMARKS
   ==================================================================== */
@media (max-width: 768px) {
    .collections-page,
    .bookmarks-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .collections-grid,
    .bookmarks-grid {
        grid-template-columns: 1fr;
    }
}


/* ====================================================================
   COOK-ALONG MODE — Optimized for phone in kitchen (#117)
   Note: cook_along.html is standalone with inline styles.
   These overrides target the inline-styled classes for extra mobile polish.
   ==================================================================== */
@media (max-width: 768px) {
    /* Ensure the mobile bottom nav doesn't cover cook-along nav */
    .mobile-nav ~ .cook-along .ca-nav,
    .cook-along .ca-nav {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .cook-along .ca-step-card__action {
        font-size: 18px;
        line-height: 1.5;
    }

    .cook-along .ca-timer {
        flex-direction: column;
        align-items: stretch;
    }

    .cook-along .ca-timer__display {
        font-size: 28px;
        text-align: center;
    }

    .cook-along .ca-timer__controls {
        justify-content: center;
    }

    .cook-along .ca-nav__btn {
        min-height: 48px;
        font-size: 14px;
        padding: 10px 12px;
    }

    .cook-along .ca-sidebar {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .cook-along .ca-step-card {
        padding: 16px;
    }

    .cook-along .ca-step-card__action {
        font-size: 16px;
    }

    .cook-along .ca-header__title {
        font-size: 14px;
    }

    .cook-along .ca-nav__btn {
        min-width: 80px;
        font-size: 13px;
        padding: 8px 10px;
    }
}


/* ====================================================================
   ONBOARDING PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .onboarding {
        padding: 1.5rem 0.75rem 3rem;
    }

    .onboarding__step-content {
        padding: 1rem;
    }

    .onboarding__options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .onboarding__option {
        min-height: 44px;
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .onboarding__options-grid {
        grid-template-columns: 1fr;
    }
}


/* ====================================================================
   NOTIFICATIONS PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .notifications-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .notification-item {
        padding: 0.85rem 0.75rem;
        min-height: 52px;
    }
}


/* ====================================================================
   FOOTER — Stacked on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 0.75rem;
        /* Hide footer on mobile to avoid clashing with bottom nav */
        margin-bottom: 0;
    }

    .footer__inner {
        flex-direction: column;
        gap: 1.5rem;
    }

    .footer__cuisine-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer__links {
        flex-direction: column;
        gap: 0.5rem;
    }
}


/* ====================================================================
   CHEF & BOOK CARD GRIDS — Responsive columns (Audit Fix)
   ==================================================================== */
@media (max-width: 768px) {
    .chefs-section__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .books-section__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .chefs-section__grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .books-section__grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}


/* ====================================================================
   CULTURAL NARRATIVE — Single column on tablets (Audit Fix)
   ==================================================================== */
@media (max-width: 1024px) {
    .cultural-narrative__body {
        grid-template-columns: 1fr;
    }

    .cultural-narrative__gallery {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 1rem;
        padding-bottom: 0.5rem;
        scrollbar-width: thin;
    }

    .cultural-narrative__gallery-item {
        flex-shrink: 0;
        scroll-snap-align: start;
        width: 200px;
    }
}


/* ====================================================================
   DIETARY FILTER PILLS — Stack on small phones (Audit Fix)
   ==================================================================== */
@media (max-width: 374px) {
    .dietary-filter__pills {
        flex-direction: column;
        align-items: stretch;
    }

    .dietary-filter__pill {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        text-align: center;
    }
}


/* ====================================================================
   COMPARE CUISINES — Fix text overlap (#121)
   ==================================================================== */
@media (max-width: 768px) {
    .compare-hero__title {
        font-size: 1.5rem;
    }

    .compare-hero__subtitle {
        font-size: 0.9rem;
    }

    .compare-selectors__form {
        flex-direction: column;
        gap: 1rem;
    }

    .compare-selectors__vs {
        text-align: center;
    }

    .compare-columns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .compare-overview {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .compare-overview__card {
        padding: 1.25rem;
    }

    .compare-overview__name {
        font-size: 1.4rem;
    }

    .compare-overview__flag {
        font-size: 3rem;
    }

    .compare-overview__stat-value {
        font-size: 2rem;
    }

    .compare-section__title {
        font-size: 1.2rem;
    }

    .compare-column__header {
        font-size: 0.95rem;
    }

    .compare-column {
        padding: 1rem;
    }

    .compare-dish-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .compare-results {
        padding: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .compare-dish-grid {
        grid-template-columns: 1fr;
    }
}


/* ====================================================================
   DIETARY FILTERS PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .dietary-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .dietary-filters {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .dietary-filters::-webkit-scrollbar {
        display: none;
    }

    .dietary-filter-btn {
        flex-shrink: 0;
        min-height: 44px;
    }
}


/* ====================================================================
   REGIONS PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .regions-page {
        padding: 1.5rem 0.75rem 3rem;
    }

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

    .region-card {
        min-height: 44px;
    }
}


/* ====================================================================
   ADMIN PANEL
   ==================================================================== */
@media (max-width: 768px) {
    .admin-panel {
        padding: 1.5rem 0.75rem 3rem;
    }

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

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ====================================================================
   SUBMIT RECIPE PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .submit-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .submit-form {
        padding: 1rem;
    }

    .submit-form__row {
        flex-direction: column;
        gap: 1rem;
    }
}


/* ====================================================================
   EXPLORE PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .explore-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .explore-filters {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .explore-filters::-webkit-scrollbar {
        display: none;
    }

    .explore-filter-btn {
        flex-shrink: 0;
        min-height: 44px;
    }
}


/* ====================================================================
   FEATURED / TICKER SECTIONS
   ==================================================================== */
@media (max-width: 768px) {
    .featured {
        padding: 2rem 0.75rem;
    }

    .featured__title {
        font-size: 1.4rem;
    }

    .ticker {
        font-size: 0.85rem;
    }
}


/* ====================================================================
   BUTTONS — All mobile-optimized
   ==================================================================== */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
    }

    .btn--lg {
        min-height: 52px;
        padding: 0.85rem 1.5rem;
        font-size: 1.05rem;
    }

    .btn--sm {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}


/* ====================================================================
   MODALS — Fullscreen on mobile
   ==================================================================== */
@media (max-width: 768px) {
    .modal__content {
        width: 100%;
        max-width: 100%;
        min-height: auto;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal__header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--warm-surface);
    }

    .modal__close {
        min-width: 44px;
        min-height: 44px;
    }
}


/* ====================================================================
   INGREDIENT MATCH PAGE
   ==================================================================== */
@media (max-width: 768px) {
    .match-page {
        padding: 1.5rem 0.75rem 3rem;
    }

    .match-hero__title {
        font-size: 1.5rem;
    }

    .match-hero__subtitle {
        font-size: 0.9rem;
    }

    .match-input-wrap {
        padding: 0.5rem;
    }

    .match-results-grid {
        grid-template-columns: 1fr;
    }

    .match-chip {
        min-height: 36px;
    }
}


/* ====================================================================
   PWA INSTALL BANNER
   ==================================================================== */
.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 1rem;
    right: 1rem;
    z-index: 1100;
    background: var(--warm-surface);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideUpBanner 0.4s ease-out;
}

.pwa-install-banner--visible {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-install-banner__text {
    flex: 1;
}

.pwa-install-banner__title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 0.15rem;
}

.pwa-install-banner__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pwa-install-banner__btn {
    background: var(--accent-gold);
    color: var(--warm-bg);
    border: none;
    padding: 0.55rem 1.25rem;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
}

.pwa-install-banner__btn:hover {
    background: #e8b95a;
}

.pwa-install-banner__dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideUpBanner {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 769px) {
    .pwa-install-banner {
        bottom: 2rem;
        left: auto;
        right: 2rem;
        max-width: 400px;
    }
}


/* ====================================================================
   SAFE AREA SUPPORT (iPhone notch, rounded corners)
   ==================================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-nav {
        padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}


/* ====================================================================
   RTL SUPPORT & TEXT OVERFLOW — Arabic and other RTL languages (#97)
   ==================================================================== */
/* Prevent text overlap on all screen sizes */
.dish-card__name,
.dish-card__english,
.cuisine-card__name,
.cuisine-card__tagline,
.cookbook-card__name,
.rec-card__name,
.meal-day__dish-name,
.dashboard-card__title,
.discussion-mini__title,
.enc-card__name {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* Global container overflow protection */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .dashboard,
    .cuisines-section,
    .dish-grid-section,
    .explore-page,
    .search-page {
        overflow-x: hidden;
    }
}

/* RTL-aware text containers */
[dir="rtl"] .dish-card__name,
[dir="rtl"] .cuisine-card__name,
[dir="rtl"] .cookbook-card__name,
[dir="rtl"] .rec-card__name,
[dir="rtl"] .meal-day__dish-name {
    text-align: right;
    direction: rtl;
}

/* For Arabic content rendered without explicit dir attribute */
@media (max-width: 768px) {
    p, h1, h2, h3, h4, h5, h6,
    .dish-card__body,
    .cookbook-card__body,
    .rec-card__body,
    .dashboard-card,
    .cuisine-card__overlay {
        word-wrap: break-word;
        overflow-wrap: anywhere;
        line-height: 1.5;
    }
}


/* ====================================================================
   GENESIS MOBILE AUDIT — 2026-03-26
   Comprehensive fixes for text overflow, touch targets, dropdown widths,
   iOS form zoom, and safe-area handling.
   ==================================================================== */

/* --- Navbar dropdown width constraints (360px phones) --- */
@media (max-width: 480px) {
    .navbar__notif-dropdown {
        min-width: 0;
        max-width: calc(100vw - 20px);
        inset-inline-end: -40px;
    }

    .navbar__user-dropdown {
        min-width: 0;
        max-width: calc(100vw - 20px);
        right: -10px;
    }

    .navbar__dropdown-menu {
        min-width: 0;
        max-width: calc(100vw - 20px);
    }

    .navbar__dropdown-menu .navbar__dropdown-link {
        white-space: normal;
        word-wrap: break-word;
    }
}

/* --- Text overflow: add ellipsis to nowrap elements without it --- */
@media (max-width: 768px) {
    /* Cuisine detail page filters and tags */
    .category-filter__btn,
    .dietary-filter__pill,
    .dietary-filter__label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Dish card names — prevent run-in with meta */
    .dish-card__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .dish-card__english {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Cuisine hero title — allow wrapping */
    .cuisine-hero__title {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ingredient chips — allow wrapping on mobile */
    .ingredient-chip {
        white-space: normal;
        word-break: break-word;
    }

    /* Match card names */
    .match-card__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Chef card names */
    .chef-card__name,
    .chef-card__expanded-name {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Book titles */
    .book-card__title {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Encyclopedia card names */
    .enc-card__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Comment text — prevent URL overflow */
    .comment__text {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Discussion titles */
    .discussion-mini__title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Info bar items — prevent text run-in */
    .info-bar__item {
        min-width: 0;
    }

    .info-bar__value {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    /* Historical profile text — ensure wrapping */
    .historical-profile__text {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Breadcrumb nav — allow wrapping */
    .dish-hero__breadcrumb-nav {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    /* Trending card names */
    .trending-card__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* --- iOS form zoom prevention (font-size: 16px) --- */
@media (max-width: 768px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* --- Touch targets: minimum 44px on mobile --- */
@media (max-width: 768px) {
    /* Serving adjuster +/- buttons */
    .serving-adjuster__btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    /* Recipe step number */
    .recipe__step-number {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }

    /* Star rating buttons */
    .star-rating__star {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.6rem;
    }

    /* Comment delete button */
    .comment__delete {
        min-width: 44px;
        min-height: 44px;
    }

    /* Ingredient info button */
    .recipe__ingredient-info {
        min-width: 32px;
        min-height: 32px;
    }
}

/* --- Dev feedback safe-area inset --- */
@media (max-width: 768px) {
    .dev-feedback {
        right: max(8px, env(safe-area-inset-right, 0px));
    }
}

/* --- Search popular grid: single column on tiny screens --- */
@media (max-width: 374px) {
    .search-modal__popular {
        grid-template-columns: 1fr;
    }
}

/* --- Footer cuisine grid: single column on tiny screens --- */
@media (max-width: 374px) {
    .footer__cuisine-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Force single-column on ALL multi-column grids at mobile --- */
/* Fixes pages.css 2-column grids that lack mobile overrides */
@media (max-width: 768px) {
    .nutrition-grid,
    .compare-columns,
    .compare-overview,
    .cultural-narrative__body,
    .chefs-section__grid,
    .books-section__grid,
    .chefs-notes__grid,
    .admin-stats,
    .allergen-grid,
    .equipment-grid {
        grid-template-columns: 1fr !important;
    }

    .compare-dish-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .recipe__inner {
        grid-template-columns: 1fr !important;
    }

    /* Nutrition section: full width, reduced padding */
    .nutrition-section {
        padding: 1.5rem 0.75rem;
    }

    .nutrition-section__inner {
        padding: 1rem;
    }

    .nutrition-card {
        padding: 1rem;
    }

    .nutrition-card__calorie-number {
        font-size: 2rem;
    }

    /* Cultural narrative: stack text + gallery */
    .cultural-narrative__body {
        gap: 1.5rem;
    }

    /* Chefs/books: 2 columns on tablet, 1 on phone */
    .chefs-section__grid,
    .books-section__grid {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .compare-dish-grid {
        grid-template-columns: 1fr !important;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* --- Global text safety net --- */
@media (max-width: 768px) {
    /* Prevent ANY element from causing horizontal scroll */
    .dish-hero__content,
    .info-bar__inner,
    .nutrition-section__inner,
    .recipe__inner,
    .historical-profile__inner,
    .comments-section__inner,
    .chefs-section__inner,
    .books-section__inner {
        max-width: 100%;
        overflow-x: hidden;
    }
}


/* ====================================================================
   LANDSCAPE ORIENTATION — Prevent heroes from consuming entire viewport
   ==================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .dish-hero {
        min-height: 180px;
        max-height: 40vh;
    }

    .cuisine-hero {
        min-height: 200px;
        max-height: 45vh;
    }

    .home-hero {
        min-height: 200px;
        max-height: 50vh;
    }

    .search-modal__container {
        max-height: 90vh;
        max-height: 90dvh;
    }

    /* Cooking mode: compact topbar in landscape */
    .cm-topbar {
        padding: 0.4rem 1rem;
    }

    .cm-main {
        padding-top: 3.5rem;
    }

    .cook-along .ca-step-card__action {
        font-size: 15px;
        line-height: 1.4;
    }

    .cook-along .ca-nav__btn {
        min-height: 40px;
        padding: 6px 10px;
    }

    /* Reduce body padding — mobile nav shorter in landscape */
    body {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}


/* ====================================================================
   FOCUS-VISIBLE — Accessibility indicators for keyboard/assistive nav
   ==================================================================== */
@media (max-width: 768px) {
    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    select:focus-visible,
    [role="button"]:focus-visible {
        outline: 2px solid var(--accent-gold, #d4a853);
        outline-offset: 2px;
    }

    /* Don't show outline on click for touch users */
    a:focus:not(:focus-visible),
    button:focus:not(:focus-visible) {
        outline: none;
    }
}


/* ====================================================================
   SCROLL INDICATORS — Gradient hints for horizontal-scroll containers
   ==================================================================== */
@media (max-width: 768px) {
    .mp-day-tabs,
    .dietary-filters,
    .explore-filters,
    .enc-filters,
    .cookbook-tabs {
        position: relative;
        -webkit-mask-image: linear-gradient(
            to right,
            transparent 0,
            black 8px,
            black calc(100% - 32px),
            transparent 100%
        );
        mask-image: linear-gradient(
            to right,
            transparent 0,
            black 8px,
            black calc(100% - 32px),
            transparent 100%
        );
    }
}


/* ====================================================================
   TOUCH TARGETS — Fix remaining sub-44px elements
   ==================================================================== */
@media (max-width: 768px) {
    /* Serving adjuster: 40px → 44px */
    .serving-adjuster__btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    /* Ingredient info: 32px → 36px (secondary action, 36px acceptable) */
    .recipe__ingredient-info {
        min-width: 36px;
        min-height: 36px;
        font-size: 0.9rem;
    }

    /* Badge feature pin button */
    .badge-card__feature-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }

    /* Match chip close buttons */
    .match-chip__remove {
        min-width: 36px;
        min-height: 36px;
    }

    /* Meal day remove button */
    .meal-day__remove,
    .mp-slot__remove {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Dish hero action buttons — were 36px */
    .dish-hero__actions .share-btn,
    .dish-hero__actions .cookbook-add-btn {
        min-height: 44px;
    }
}


/* ====================================================================
   BADGE TOAST — Responsive on small screens
   ==================================================================== */
@media (max-width: 380px) {
    .badge-toast__content {
        min-width: auto;
        max-width: calc(100vw - 2rem);
        padding: 1rem 1.5rem;
    }
}


/* ====================================================================
   FORM INPUT READABILITY — Better line-height and placeholders
   ==================================================================== */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        line-height: 1.5;
    }

    input::placeholder,
    textarea::placeholder {
        opacity: 0.7;
    }
}


/* ====================================================================
   PRINT STYLES — Full print support
   ==================================================================== */
@media print {
    .mobile-nav,
    .pwa-install-banner,
    .navbar,
    .footer,
    .dev-feedback,
    .pwa-install-banner,
    .badge-toast {
        display: none !important;
    }

    body {
        padding-bottom: 0 !important;
        padding-top: 0 !important;
    }

    #main-content {
        padding-top: 0 !important;
    }

    .recipe {
        max-width: 100%;
        padding: 0;
    }

    .recipe__sidebar {
        position: static !important;
    }

    .dish-hero {
        height: auto;
        min-height: auto;
        max-height: 300px;
        break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }
}
