/* ============================================
   Discover Page — Mobile Overrides (≤768px)
   Sticky ticker, compact cards, carousel,
   creative hierarchy, bonds popup nav
   ============================================ */

@media (max-width: 768px) {

    /* ── Hide page title on mobile ── */
    body.cardboard .cb-page-header h1 {
        display: none;
    }
    body.cardboard .cb-page-header {
        padding-top: 8px;
        margin-bottom: 1rem;
    }

    /* ── Sticky Mobile Ticker (2 rows, 4 items) ── */
    .mobile-ticker-bar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10000;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(20px) saturate(1.4);
        -webkit-backdrop-filter: blur(20px) saturate(1.4);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        display: flex;
        flex-direction: column;
        padding: 6px 12px;
        gap: 2px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: border-color 0.2s ease;
    }

    .mobile-ticker-row {
        display: flex;
        align-items: center;
        gap: 0;
    }

    .mobile-ticker-item {
        display: flex;
        align-items: center;
        gap: 5px;
        flex: 1;
        min-width: 0;
        padding: 2px 6px;
        position: relative;
    }

    .mobile-ticker-item:not(:last-child)::after {
        content: '';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 1px;
        height: 14px;
        background: rgba(255, 255, 255, 0.06);
    }

    .mobile-ticker-name {
        font-size: 0.58rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.3);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        white-space: nowrap;
        min-width: 24px;
    }

    .mobile-ticker-value {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--cb-text-primary);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .mobile-ticker-change {
        font-size: 0.58rem;
        font-weight: 500;
        white-space: nowrap;
        padding: 1px 4px;
        border-radius: 3px;
    }

    .mobile-ticker-change.positive {
        color: #22c55e;
        background: rgba(34, 197, 94, 0.1);
    }

    .mobile-ticker-change.negative {
        color: #ef4444;
        background: rgba(239, 68, 68, 0.1);
    }

    .mobile-ticker-change.neutral {
        color: rgba(255, 255, 255, 0.4);
    }

    /* Expand chevron */
    .mobile-ticker-chevron {
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        font-size: 10px;
        color: rgba(255, 255, 255, 0.2);
        line-height: 1;
        transition: transform 0.3s ease, color 0.2s ease;
    }

    .mobile-ticker-bar.expanded .mobile-ticker-chevron {
        transform: translateX(-50%) rotate(180deg);
        color: rgba(255, 255, 255, 0.4);
    }

    /* ── Expanded Ticker Panel ── */
    .mobile-ticker-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10001;
        background: #0a0a0a;
        padding: 70px 20px 80px;
        overflow-y: auto;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .mobile-ticker-panel.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-ticker-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 24px;
    }

    .mobile-ticker-panel-title {
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--cb-text-primary);
        text-transform: lowercase;
    }

    .mobile-ticker-panel-close {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: rgba(255, 255, 255, 0.5);
        font-size: 1.1rem;
        line-height: 1;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-ticker-panel-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .mobile-ticker-panel-card {
        padding: 16px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mobile-ticker-panel-label {
        font-size: 0.62rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.35);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 8px;
    }

    .mobile-ticker-panel-value {
        font-size: 1.3rem;
        font-weight: 700;
        color: var(--cb-text-primary);
        font-variant-numeric: tabular-nums;
        margin-bottom: 4px;
    }

    .mobile-ticker-panel-change {
        font-size: 0.75rem;
        font-weight: 500;
    }

    .mobile-ticker-panel-change.positive { color: #22c55e; }
    .mobile-ticker-panel-change.negative { color: #ef4444; }
    .mobile-ticker-panel-change.neutral { color: rgba(255, 255, 255, 0.4); }

    .mobile-ticker-panel-market {
        margin-top: 20px;
        text-align: center;
        padding: 16px 14px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mobile-ticker-panel-market-label {
        font-size: 0.62rem;
        color: rgba(255, 255, 255, 0.35);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 10px;
    }

    .mobile-ticker-panel-market-status {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--cb-text-secondary);
        text-transform: lowercase;
    }

    /* Countdown timer pill: "closes in 01:24:36" / "opens in 2d 17h 21m" */
    .mobile-ticker-panel-market-timer {
        margin-top: 8px;
        display: flex;
        justify-content: center;
    }

    .mobile-ticker-panel-market-timer .cb-market-timer {
        display: inline-block;
        padding: 6px 14px;
        font-size: 0.82rem;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
        color: var(--cb-text-secondary, rgba(255, 255, 255, 0.75));
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 20px;
        text-transform: lowercase;
        letter-spacing: 0.01em;
    }

    /* Render MarketStatusPill inline inside the expanded ticker panel
       (override the default fixed-bottom positioning used by floating pill) */
    .mobile-ticker-panel-market-pill-wrap {
        display: flex;
        justify-content: center;
    }

    .mobile-ticker-panel-market-pill-wrap .market-status-pill {
        position: static !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
    }

    /* Hide old ticker bar on discover page */
    .cb-discover-main .ticker-container {
        display: none !important;
    }

    /* ── Discover page top spacing for new ticker ── */
    body.cardboard .cb-discover-main {
        padding-top: 62px;
        padding-bottom: 72px;
    }

    /* ── Search bar full width ── */
    .cb-discover-search {
        margin: 0 auto;
        padding: 0 16px;
    }

    .cb-discover-search .search-box input {
        font-size: 0.82rem;
        padding: 10px 36px 10px 38px;
    }

    /* ── Market Pulse — 2x2 Grid (prominent) ── */
    .cb-discover-pulse {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        margin: 0 16px 1.5rem;
        padding: 14px 16px;
        border-radius: 14px;
    }

    .cb-discover-pulse .cb-pulse-divider {
        display: none;
    }

    .cb-discover-pulse .cb-pulse-item {
        padding: 6px 0;
    }

    .cb-discover-pulse .cb-pulse-label {
        font-size: 0.62rem;
    }

    .cb-discover-pulse .cb-pulse-value {
        font-size: 1.1rem;
        font-weight: 700;
    }

    .cb-discover-pulse .cb-pulse-status {
        font-size: 0.78rem;
    }

    /* ── Category Peek Cards — Simplified ── */
    .cb-bento-grid {
        gap: 10px !important;
        padding: 0 12px !important;
    }

    .cb-peek-card {
        min-height: auto !important;
        padding: 14px 16px !important;
        border-radius: 14px !important;
    }

    /* Hide subtitle on mobile — less clutter */
    .cb-peek-subtitle {
        display: none;
    }

    .cb-peek-header {
        margin-bottom: 6px;
    }

    .cb-peek-card h3 {
        font-size: 0.95rem !important;
        margin: 0 !important;
    }

    .cb-peek-count {
        font-size: 0.58rem;
        padding: 1px 7px;
    }

    .cb-peek-bonds {
        margin: 2px 0;
    }

    .cb-peek-row {
        padding: 5px 4px;
    }

    .cb-peek-bond-name {
        font-size: 0.75rem;
    }

    .cb-peek-bond-tenure {
        display: none;
    }

    .cb-peek-bond-yield {
        font-size: 0.78rem;
    }

    .cb-peek-gold-tag {
        font-size: 0.52rem;
    }

    .cb-peek-footer {
        margin-top: 2px;
    }

    .cb-peek-cta {
        font-size: 0.68rem;
    }

    /* ── Trending — Compact List instead of cards ── */
    .cb-trending-scroll {
        display: flex;
        flex-direction: column !important;
        gap: 0 !important;
        overflow-x: visible !important;
        scroll-snap-type: none !important;
        padding: 0 !important;
    }

    .cb-trending-card {
        width: 100% !important;
        flex: none !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        padding: 10px 4px !important;
        border-radius: 0 !important;
        background: transparent !important;
        border: none !important;
        border-top: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
        scroll-snap-align: none !important;
        gap: 10px;
    }

    .cb-trending-card::before {
        display: none !important;
    }

    .cb-trending-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .cb-trending-card:last-child {
        border-bottom: none !important;
    }

    .cb-trending-type-badge {
        margin-bottom: 0 !important;
        font-size: 0.56rem;
        padding: 1px 6px;
        order: -1;
        flex-shrink: 0;
        min-width: 36px;
        text-align: center;
    }

    .cb-trending-name {
        flex: 1;
        min-width: 0;
        font-size: 0.8rem;
        margin-bottom: 0 !important;
    }

    .cb-trending-yield {
        font-size: 0.85rem !important;
        font-weight: 600;
        margin-bottom: 0 !important;
        flex-shrink: 0;
    }

    .cb-trending-meta {
        display: none !important;
    }

    /* Only show first 5 trending items */
    .cb-trending-card:nth-child(n+6) {
        display: none !important;
    }

    /* ── Section Headers ── */
    .cb-discover-section {
        padding: 0 12px 1.5rem;
    }

    .cb-discover-section-header {
        margin-bottom: 1rem;
        margin-top: 0.5rem;
    }

    /* ── Hide "quick look" section header ── */
    .cb-discover-section:nth-of-type(2) .cb-discover-section-header {
        display: none;
    }

    /* ── Quick Look Carousel ── */
    .cb-curated-grid {
        display: flex !important;
        flex-direction: row !important;
        grid-template-columns: unset !important;
        gap: 0 !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 0 12px 8px;
        scrollbar-width: none;
    }

    .cb-curated-grid::-webkit-scrollbar {
        display: none;
    }

    .cb-curated-grid .cb-curated-list {
        flex: 0 0 85%;
        scroll-snap-align: center;
        min-width: 0;
        margin-right: 10px;
        border-radius: 14px;
        padding: 16px 18px;
    }

    .cb-curated-grid .cb-curated-list:last-child {
        margin-right: 0;
    }

    /* Carousel controls for curated lists */
    .curated-carousel-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        margin-top: 12px;
        padding: 0 16px;
    }

    .curated-carousel-arrow {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .curated-carousel-arrow:active {
        background: rgba(255, 255, 255, 0.12);
    }

    .curated-carousel-arrow svg {
        width: 14px;
        height: 14px;
        stroke: rgba(255, 255, 255, 0.5);
        fill: none;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .curated-carousel-dots {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .curated-carousel-dot {
        width: 6px;
        height: 6px;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.15);
        transition: width 0.3s ease, background 0.3s ease;
        cursor: pointer;
    }

    .curated-carousel-dot.active {
        width: 20px;
        background: rgba(255, 255, 255, 0.6);
    }

    /* ── Rating Chips ── */
    .cb-rating-spectrum {
        padding: 0 4px;
    }

    .cb-rating-chips {
        gap: 6px;
        justify-content: center;
    }

    .cb-rating-chip {
        padding: 7px 12px;
        gap: 6px;
    }

    .cb-rating-chip-label {
        font-size: 0.62rem;
    }

    .cb-rating-chip-count {
        font-size: 0.6rem;
    }

    /* ── Bottom Nav Redesign ── */
    .bottom-nav {
        height: 56px;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(20px) saturate(1.4);
        -webkit-backdrop-filter: blur(20px) saturate(1.4);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .bottom-nav-item {
        flex-direction: column;
        gap: 3px;
        padding: 6px 0;
        font-size: 0.68rem;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.35);
    }

    .bottom-nav-item.active {
        color: #fff;
    }

    .bottom-nav-item .bottom-nav-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .bottom-nav-item .bottom-nav-icon svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        fill: none;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .bottom-nav-separator {
        display: none;
    }

    /* ── Bonds Popup ── */
    .bonds-popup-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 10001;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .bonds-popup-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .bonds-popup {
        position: fixed;
        bottom: 56px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        right: 12px;
        z-index: 10002;
        background: rgba(20, 20, 20, 0.98);
        backdrop-filter: blur(24px) saturate(1.4);
        -webkit-backdrop-filter: blur(24px) saturate(1.4);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 16px;
        padding: 16px;
        transform: translateY(20px);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    }

    .bonds-popup-overlay.visible .bonds-popup {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .bonds-popup-title {
        font-size: 0.65rem;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.35);
        text-transform: lowercase;
        letter-spacing: 0.04em;
        margin-bottom: 12px;
        padding-left: 4px;
    }

    .bonds-popup-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .bonds-popup-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.06);
        text-decoration: none;
        transition: background 0.2s ease, border-color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .bonds-popup-item:active {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.12);
    }

    .bonds-popup-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .bonds-popup-label {
        font-size: 0.78rem;
        font-weight: 500;
        color: var(--cb-text-secondary);
        text-transform: lowercase;
    }

    /* ── Remove pulsating circle on mobile ── */
    .market-status-pill-standalone {
        display: none !important;
    }

    /* ── Creative Visual Hierarchy ── */

    /* Subtle section gradient dividers */
    .cb-discover-section + .cb-discover-section {
        border-top: none;
    }

    .cb-discover-section::before {
        content: '';
        display: block;
        height: 1px;
        margin: 0 -12px 1.5rem;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.06) 70%, transparent);
    }

    /* Subtle category card staggered entrance feel */
    .cb-bento-grid .cb-bento-card:nth-child(1) { --entrance-delay: 0s; }
    .cb-bento-grid .cb-bento-card:nth-child(2) { --entrance-delay: 0.05s; }
    .cb-bento-grid .cb-bento-card:nth-child(3) { --entrance-delay: 0.1s; }
    .cb-bento-grid .cb-bento-card:nth-child(4) { --entrance-delay: 0.15s; }

    .cb-bento-card.cb-visible {
        animation: fadeSlideUp 0.5s ease both;
        animation-delay: var(--entrance-delay, 0s);
    }

    @keyframes fadeSlideUp {
        from {
            opacity: 0;
            transform: translateY(12px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Curated list subtle glow enhancement on mobile */
    .cb-curated-list {
        background: rgba(17, 17, 17, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.06);
    }
}

/* Hide mobile ticker & discover-mobile elements on desktop */
@media (min-width: 769px) {
    .mobile-ticker-bar,
    .mobile-ticker-panel,
    .bonds-popup-overlay,
    .curated-carousel-controls {
        display: none !important;
    }
}
