/* ========================================
   MOBILE-ONLY OVERRIDES FOR STATUS BAR
   ======================================== */

@media (max-width: 768px) {
    /* Compact horizontal-scroll status bar on mobile */
    #community-status-bar {
        min-height: 36px;
        padding: 0 !important;
        margin: 0 !important;
    }

    #community-status-bar .container {
        min-height: 36px;
        overflow: hidden;
    }

    #community-status-content {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.5rem !important;
        font-size: 0.68rem;
        min-height: 36px;
        padding: 0 0.75rem !important;
        align-items: center;
    }

    #community-status-content::-webkit-scrollbar {
        display: none;
    }

    /* Hide "your status" on mobile — saves space */
    #header-your-status {
        display: none !important;
    }

    /* Online section stays horizontal */
    #header-online-section {
        flex-shrink: 0;
        gap: 0.4rem !important;
        flex-wrap: nowrap;
        align-items: center;
        width: auto;
    }

    #header-online-section > div:first-child {
        gap: 0.2rem !important;
        min-width: auto;
        flex-shrink: 0;
    }

    #header-online-section > div:first-child .text-xs {
        font-size: 0.62rem !important;
        font-weight: 700;
        white-space: nowrap;
        opacity: 1;
    }

    #header-online-users-list {
        gap: 0.25rem !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: auto;
        min-width: 0;
        flex-shrink: 0;
    }

    #header-online-users-list::-webkit-scrollbar {
        display: none;
    }

    /* Concurrency label hidden on mobile (too wide) */
    #header-online-concurrency {
        display: none !important;
    }

    /* Compact horizontal pills on mobile */
    #header-online-users-list .status-badge {
        gap: 0.22rem;
        padding: 0.22rem 0.55rem;
        border-radius: 999px;
        font-size: 0.65rem;
        font-weight: 500;
        line-height: 1.2;
        box-shadow: none;
        border-color: rgba(148, 163, 184, 0.22);
        background: rgba(255, 255, 255, 0.88);
        flex: 0 0 auto;
        min-width: auto;
        max-width: none;
        width: auto;
        align-items: center;
        justify-content: flex-start;
        white-space: nowrap;
        min-height: auto;
    }

    /* Status dots - compact on mobile */
    #header-online-users-list .status-dot {
        width: 0.34rem;
        height: 0.34rem;
        flex-shrink: 0;
        margin-top: 0;
    }

    #header-online-users-list .status-badge--presence {
        padding: 0.22rem 0.55rem;
        backdrop-filter: blur(4px);
    }

    /* Name and time inline on one line */
    #header-online-users-list .status-badge__info {
        display: flex;
        flex-direction: row;
        gap: 0.18rem;
        align-items: baseline;
        width: auto;
        min-width: 0;
        white-space: nowrap;
    }

    #header-online-users-list .status-name--presence {
        font-size: 0.67rem;
        letter-spacing: 0;
        white-space: nowrap;
    }

    #header-online-users-list .status-time--detail {
        font-size: 0.58rem;
        line-height: 1.2;
        white-space: nowrap;
        opacity: 0.72;
    }

    .weekly-holiday-box {
        border-radius: 16px;
        margin-bottom: 1.4rem;
    }

    .weekly-holiday-box__content {
        padding: 1.2rem 1rem 1.1rem;
        gap: 0.65rem;
    }

    .weekly-holiday-box__title {
        font-size: 1.25rem;
    }

    .weekly-holiday-box__text {
        font-size: 0.95rem;
        line-height: 1.62;
    }

    .weekly-holiday-box__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .weekly-holiday-box__button {
        width: 100%;
        text-align: center;
    }

    .weekly-holiday-box__link {
        text-align: center;
        width: fit-content;
        align-self: center;
    }

    .mitzvah-card {
        padding: 1.5rem;
        gap: 1.5rem;
    }

    .mitzvah-card__body {
        grid-template-columns: 1fr;
        gap: 1.1rem;
    }

    .mitzvah-card__section {
        padding: 1rem 1.1rem;
    }

    .mitzvah-card__title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .mitzvah-card__countdown {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

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

    .mitzvah-card__subheading {
        text-align: center;
    }

    .mitzvah-checklist {
        align-items: center;
        text-align: center;
    }

    .mitzvah-checklist__label {
        justify-content: center;
        text-align: center;
    }

    .mitzvah-checklist__input {
        margin-top: 0;
    }

    .mitzvah-chat {
        padding: 1.25rem;
    }

    .mitzvah-chat__header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .mitzvah-chat__messages {
        max-height: 220px;
    }

    .mitzvah-chat__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .mitzvah-chat__submit {
        width: 100%;
    }

    .mitzvah-chat__hint {
        text-align: center;
    }

    .mitzvah-locked__card {
        padding: 1.35rem;
    }

    #header-online-users-list .status-dot--compact {
        width: 0.34rem;
        height: 0.34rem;
        margin-top: 0.04rem;
    }

    #header-online-users-list .status-badge--active {
        background: rgba(240, 253, 244, 0.78);
    }

    /* Mobile tooltip styling - centered bubble */
    .status-tooltip[data-tooltip] {
        position: relative;
    }

    .status-tooltip[data-tooltip]::after {
        top: calc(100% + 0.4rem) !important;
        bottom: auto !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, 0) !important;
        width: min(72vw, 260px) !important;
        min-width: 180px !important;
        max-width: calc(100vw - 3rem) !important;
        padding: 0.55rem 0.85rem !important;
        font-size: 0.66rem !important;
        line-height: 1.45 !important;
        border-radius: 0.65rem !important;
        text-align: left !important;
        white-space: normal !important;
        background: rgba(15, 23, 42, 0.95) !important;
        color: #f8fafc !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.35) !important;
        border: 1px solid rgba(148, 163, 184, 0.25) !important;
        z-index: 50 !important;
        opacity: 0;
        pointer-events: none;
    }

    .status-tooltip[data-tooltip]::before {
        display: none !important;
    }

    .status-tooltip[data-tooltip]:hover::after,
    .status-tooltip[data-tooltip]:focus-visible::after,
    .status-tooltip[data-tooltip]:active::after {
        opacity: 1 !important;
        transform: translate(-50%, 0) !important;
    }

    /* Ensure reaction button tooltips never show on mobile */
    .reaction-btn.status-tooltip[data-tooltip]::after,
    .reaction-btn.status-tooltip[data-tooltip]::before {
        display: none !important;
        opacity: 0 !important;
    }

    /* Hover effects - more subtle on mobile */
    #header-online-users-list .status-badge:hover {
        transform: translateY(-0.4px);
        box-shadow: 0 2px 5px rgba(15, 23, 42, 0.06);
    }

    /* Status leading dot - smaller on mobile */
    .status-leading-dot {
        width: 0.3rem !important;
        height: 0.3rem !important;
        flex-shrink: 0;
    }
}

/* Extra small screens - 375px and below */
@media (max-width: 375px) {
    #community-status-bar {
        min-height: 34px;
        padding: 0 !important;
    }

    #community-status-content {
        padding: 0 0.6rem !important;
        min-height: 34px;
    }

    #header-online-users-list .status-badge {
        font-size: 0.62rem;
        padding: 0.18rem 0.45rem;
        flex: 0 0 auto;
        min-width: auto;
        max-width: none;
    }

    #header-online-users-list .status-dot {
        width: 0.3rem;
        height: 0.3rem;
    }

    .status-tooltip[data-tooltip]::after {
        max-width: 220px !important;
        font-size: 0.62rem !important;
        padding: 0.42rem 0.6rem !important;
    }
}

/* ========================================
   COMPREHENSIVE MOBILE PERFECTION
   Hamburger nav + polished mobile UI
   ======================================== */

/* ── Desktop: hide sidebar completely, keep original header ── */
@media (min-width: 961px) {
    /* Override style.css desktop sidebar rules — no sidebar on desktop */
    body.sidebar-nav-enabled {
        padding-left: 0 !important;
    }

    body.sidebar-nav-enabled .site-sidebar {
        display: none !important;
    }

    body.sidebar-nav-enabled .site-sidebar-backdrop {
        display: none !important;
    }

    /* Hamburger already hidden on desktop via style.css, but be safe */
    body.sidebar-nav-enabled .site-header-nav-toggle {
        display: none !important;
    }
}

/* ── Mobile: hide original header nav, show hamburger + drawer ── */
@media (max-width: 960px) {
    /* Hide the inline header nav buttons — drawer replaces them */
    body.sidebar-nav-enabled .header-actions-wrapper {
        display: none !important;
    }

    body.sidebar-nav-enabled .header-main {
        position: sticky;
        top: 0;
        z-index: 40;
        border-bottom: none !important;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15) !important;
    }

    body.sidebar-nav-enabled .header-container {
        padding: 0.65rem 0.85rem;
        padding-right: 4.2rem; /* room for hamburger */
        gap: 0;
        flex-direction: row;
        align-items: center;
    }

    body.sidebar-nav-enabled .header-title {
        font-size: clamp(1.1rem, 4.8vw, 1.5rem);
        line-height: 1.2;
        white-space: normal;
    }

    body.sidebar-nav-enabled .header-subtitle {
        font-size: 0.7rem;
        opacity: 0.78;
        max-width: 30ch;
        line-height: 1.3;
    }

    /* Show the close button inside drawer */
    body.sidebar-nav-enabled .site-sidebar-close-btn {
        display: inline-flex;
    }
}

/* Hide branding subtitle on very small screens */
@media (max-width: 400px) {
    body.sidebar-nav-enabled .header-subtitle {
        display: none;
    }
}

/* ── Global mobile typography & spacing ── */
@media (max-width: 768px) {
    /* Tighter body spacing */
    body {
        font-size: 0.92rem;
        line-height: 1.6;
    }

    /* Main content container */
    main.container,
    .container {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    /* Page title bars — compact */
    [style*="background:#1a3264"] {
        padding: 7px 0 !important;
    }

    [style*="background:#1a3264"] p {
        font-size: 0.7rem !important;
    }

    /* Smaller headings on mobile */
    h1 {
        font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
    }

    h2 {
        font-size: clamp(1.1rem, 4.5vw, 1.5rem) !important;
    }

    h3 {
        font-size: clamp(1rem, 4vw, 1.25rem) !important;
    }

    /* Cards and sections — tighter on mobile */
    .bg-white.rounded-lg.shadow-lg,
    .bg-white.rounded-lg.shadow-md,
    .bg-white.rounded-xl {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    /* Better spacing between sections */
    .mb-8 {
        margin-bottom: 1.25rem !important;
    }

    .mb-6 {
        margin-bottom: 1rem !important;
    }

    .p-6, .p-8 {
        padding: 1rem !important;
    }

    .md\:p-8 {
        padding: 1rem !important;
    }

    /* Grid layouts — single column on mobile */
    .grid.grid-cols-2,
    .grid.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .grid.md\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    /* Smaller text throughout */
    .text-lg {
        font-size: 1rem !important;
    }

    .text-xl {
        font-size: 1.1rem !important;
    }

    .text-2xl {
        font-size: 1.25rem !important;
    }

    .text-sm {
        font-size: 0.8rem !important;
    }

    .text-xs {
        font-size: 0.68rem !important;
    }

    /* Buttons — touch-friendly but compact */
    .inline-flex.items-center,
    a.inline-flex {
        font-size: 0.82rem;
    }

    /* Better mobile form elements */
    input[type="search"],
    input[type="text"],
    select {
        font-size: 16px; /* prevent iOS zoom */
        padding: 0.6rem 0.8rem;
        border-radius: 10px;
    }
}

/* ── Dashboard mobile improvements ── */
@media (max-width: 768px) {
    .dashboard-body .dashboard-main {
        padding: 0 0.85rem !important;
        margin-top: 0.75rem !important;
        margin-bottom: 1.2rem !important;
        gap: 0.85rem !important;
    }

    .dashboard-body .dashboard-stack {
        gap: 0.85rem !important;
    }

    .dashboard-body .section-card {
        border-radius: 1rem !important;
    }

    .dashboard-body .dash-section-shell {
        padding: 0.85rem !important;
    }

    .dashboard-body .dash-section-title {
        font-size: 0.95rem !important;
    }

    .dashboard-body .dash-welcome {
        padding: 0.85rem !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.65rem;
    }

    .dashboard-body .dash-welcome-name {
        font-size: 0.95rem !important;
    }

    .dashboard-body .dash-welcome-sub {
        font-size: 0.72rem !important;
    }

    .dashboard-body .dash-avatar {
        width: 2.2rem !important;
        height: 2.2rem !important;
        font-size: 0.78rem !important;
    }

    .dashboard-body .dash-btn-primary {
        font-size: 0.72rem !important;
        padding: 0.52rem 0.85rem !important;
    }

    .dashboard-body .dash-btn-icon {
        width: 1.9rem !important;
        height: 1.9rem !important;
    }

    /* Daily inspiration — defer to dashboard inline styles for compact mobile */

    /* Explore cards grid */
    .dashboard-body .dash-explore-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.55rem !important;
    }

    .dashboard-body .dash-explore-card {
        min-height: 92px !important;
        padding: 0.7rem 0.5rem !important;
        border-radius: 0.85rem !important;
    }

    .dashboard-body .dash-explore-icon {
        font-size: 1.5rem !important;
    }

    .dashboard-body .dash-explore-label {
        font-size: 0.68rem !important;
    }

    .dashboard-body .dash-explore-sub {
        font-size: 0.58rem !important;
    }

    /* Chavruta cards */
    .dashboard-body .chavruta-card {
        border-radius: 0.85rem !important;
    }

    /* Community line */
    .dashboard-body .dash-community-line {
        font-size: 0.65rem !important;
    }

    /* Count pills */
    .dashboard-body .dash-count-pill {
        font-size: 0.6rem !important;
        padding: 0.15rem 0.5rem !important;
    }

    /* Chat FAB — slightly smaller */
    .dashboard-body .chat-fab {
        width: 2.8rem !important;
        height: 2.8rem !important;
    }

    .dashboard-body .chat-fab-wrapper {
        bottom: 0.85rem !important;
        right: 0.85rem !important;
    }
}

/* ── Prayers page mobile ── */
@media (max-width: 768px) {
    /* Hide the floating anchor menu on mobile — clutters the view */
    .prayers-anchor-menu {
        display: none !important;
    }

    /* Prayer finder — compact */
    .prayer-finder-sticky {
        position: relative !important;
        top: 0 !important;
        margin-top: 0 !important;
    }

    #prayer-finder {
        padding: 0.85rem !important;
    }

    .finder-header h3 {
        font-size: 1rem !important;
    }

    .finder-header p {
        font-size: 0.78rem !important;
    }

    .finder-grid {
        gap: 0.65rem !important;
    }

    .filter-label {
        font-size: 0.72rem !important;
    }

    .filter-helper {
        font-size: 0.65rem !important;
    }

    /* Category cards — smaller */
    .category-card {
        padding: 1rem !important;
        border-radius: 12px !important;
    }

    .category-title {
        font-size: 1rem !important;
    }

    .category-description {
        font-size: 0.82rem !important;
        line-height: 1.5 !important;
    }

    .category-link {
        font-size: 0.78rem !important;
        padding: 0.38rem 0.72rem !important;
    }

    /* Prayer items */
    .prayer-section-heading {
        font-size: 1.05rem !important;
    }
}

/* ── Songs page mobile ── */
@media (max-width: 768px) {
    .songs-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .song-card {
        padding: 0.85rem !important;
        border-radius: 12px !important;
    }

    /* Filter tabs — scrollable row */
    .type-filter-tabs {
        gap: 0.4rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.3rem;
    }

    .type-filter-tab {
        font-size: 0.78rem !important;
        padding: 0.4rem 0.85rem !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ── Song detail mobile ── */
@media (max-width: 768px) {
    .song-detail-container {
        padding: 0.85rem !important;
    }

    .song-lyrics {
        font-size: 0.92rem !important;
        line-height: 1.75 !important;
    }

    .song-meta {
        font-size: 0.75rem !important;
    }
}

/* ── Holiday pages mobile ── */
@media (max-width: 768px) {
    /* Holiday hero sections */
    .holiday-hero,
    [class*="hero"] {
        padding: 1.2rem 0.85rem !important;
    }

    .holiday-hero h1,
    [class*="hero"] h1 {
        font-size: clamp(1.4rem, 5.5vw, 2rem) !important;
    }

    /* Holiday sections */
    .holiday-section {
        padding: 1rem 0.85rem !important;
    }

    .holiday-section h2 {
        font-size: 1.15rem !important;
    }

    .holiday-section p {
        font-size: 0.85rem !important;
        line-height: 1.65 !important;
    }

    /* Blessing cards on holiday pages */
    .blessing-card {
        padding: 0.85rem !important;
        border-radius: 12px !important;
    }

    .blessing-card h3 {
        font-size: 0.95rem !important;
    }

    .blessing-card p {
        font-size: 0.82rem !important;
    }

    /* Holiday floating decorations — smaller on mobile */
    .holiday-floating-decoration,
    .floating-decoration {
        transform: scale(0.7);
    }
}

/* ── About page mobile ── */
@media (max-width: 768px) {
    .about-hero {
        padding: 1.5rem 0.85rem !important;
    }

    .about-hero h1 {
        font-size: 1.5rem !important;
    }

    .about-content {
        padding: 0 0.85rem !important;
    }

    .about-section {
        padding: 1rem !important;
        margin-bottom: 0.85rem !important;
    }

    .about-section h2 {
        font-size: 1.1rem !important;
    }

    .about-section p {
        font-size: 0.85rem !important;
    }
}

/* ── Bookmarks page mobile ── */
@media (max-width: 768px) {
    .bookmarks-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }

    .bookmarks-stat-card {
        padding: 0.75rem !important;
        border-radius: 12px !important;
    }

    .bookmark-card {
        padding: 0.85rem !important;
        border-radius: 12px !important;
    }
}

/* ── Settings page mobile ── */
@media (max-width: 768px) {
    .settings-section {
        padding: 0.85rem !important;
        border-radius: 12px !important;
    }

    .settings-section h3 {
        font-size: 1rem !important;
    }
}

/* ── Study page significance modal — keep X always visible ── */
@media (max-width: 768px) {
    /* Align to top so long content doesn't push header above viewport */
    #verse-significance-modal {
        align-items: flex-start !important;
        padding: 0.75rem !important;
        overflow-y: auto !important;
    }
    /* Inner dialog: constrain height, scroll internally */
    #verse-significance-modal > div {
        display: flex !important;
        flex-direction: column !important;
        max-height: calc(100dvh - 1.5rem) !important;
        overflow: hidden !important; /* clip rounded corners */
        margin-top: 0 !important;
    }
    /* Header with X: sticky at top — never scrolls away */
    #verse-significance-modal > div > div:first-child {
        position: sticky !important;
        top: 0 !important;
        z-index: 2 !important;
        flex-shrink: 0 !important;
    }
    /* Body: scrollable */
    #verse-significance-modal > div > div:last-child {
        overflow-y: auto !important;
        flex: 1 !important;
        min-height: 0 !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Study page mobile ── */
@media (max-width: 768px) {
    /* Verse containers */
    .verse-row {
        padding: 0.65rem 0.75rem !important;
    }

    .hebrew-text {
        font-size: clamp(1rem, 3.5vw, 1.35rem) !important;
        line-height: 2 !important;
    }

    .english-text {
        font-size: 0.85rem !important;
        line-height: 1.65 !important;
    }

    .commentary-text {
        font-size: 0.82rem !important;
        line-height: 1.6 !important;
    }

    /* Torah nav bar on study page — not the sidebar-nav */
    nav.bg-white.shadow-md {
        padding: 0.5rem 0.75rem !important;
    }

    nav.bg-white.shadow-md label {
        font-size: 0.78rem !important;
    }

    nav.bg-white.shadow-md select {
        font-size: 0.8rem !important;
        padding: 0.35rem 2rem 0.35rem 0.5rem !important;
    }
}

/* ── Extra small screens (≤ 400px) ── */
@media (max-width: 400px) {
    body {
        font-size: 0.88rem;
    }

    main.container,
    .container {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }

    .dashboard-body .dashboard-main {
        padding: 0 0.65rem !important;
    }

    .dashboard-body .dash-explore-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.45rem !important;
    }

    .dashboard-body .dash-explore-card {
        min-height: 82px !important;
        padding: 0.55rem 0.4rem !important;
    }

    .dashboard-body .dash-explore-label {
        font-size: 0.62rem !important;
    }

    /* Hamburger button — slightly smaller */
    body.sidebar-nav-enabled .site-header-nav-toggle {
        width: 38px;
        height: 38px;
        top: 0.5rem;
        right: 0.5rem;
    }

    body.sidebar-nav-enabled .site-header-nav-toggle-icon {
        width: 17px;
        gap: 4px;
    }

    body.sidebar-nav-enabled .site-header-nav-toggle-icon span {
        width: 17px;
    }

    /* Header even more compact */
    body.sidebar-nav-enabled .header-container {
        padding: 0.5rem 0.65rem;
        padding-right: 3.5rem;
    }

    body.sidebar-nav-enabled .header-title {
        font-size: 1rem;
    }
}

/* ── Smooth transitions for polish ── */
@media (max-width: 768px) {
    .section-card,
    .bg-white,
    .category-card,
    .song-card,
    .blessing-card,
    .bookmark-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    /* Remove hover effects on mobile — they stick on touch */
    .dash-explore-card:hover,
    .chavruta-card:hover,
    .song-card:hover,
    .category-card:hover {
        transform: none !important;
    }

    /* Safe area insets for notched phones */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Ensure no horizontal overflow on any page */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
}
