/* ==========================================================================
   Career Reality — Mobile UI Layer
   All rules gated to mobile viewports. Desktop unchanged.
   ========================================================================== */

.cp-sticky-cta {
    display: none;
}

.dock-desktop-hide {
    display: none;
}

.more-sheet-overlay,
.more-sheet {
    display: none;
}

@media (max-width: 768px) {
    .more-sheet-overlay.is-open {
        display: block;
    }

    .dock-mobile-hide {
        display: none !important;
    }

    .dock-desktop-hide {
        display: flex;
    }

    .dock-item--more.dock-desktop-hide {
        display: flex;
    }
    :root {
        --bp-mobile: 768px;
        --bp-phone: 480px;
        --bp-xs: 375px;
        --touch-min: 44px;
        --mobile-gap: 12px;
        --mobile-section-pad: 32px 0;
        --mobile-card-radius: 14px;
        --dock-height: 64px;
        --header-height: 56px;
    }

    /* ── Utility classes ── */
    .mobile-stack {
        display: flex !important;
        flex-direction: column !important;
    }

    .mobile-full-width {
        width: 100% !important;
    }

    .mobile-section {
        padding: var(--mobile-section-pad);
    }

    .mobile-card {
        background: var(--cr-surface-2, var(--c-white));
        border: 1px solid var(--cr-border, var(--c-divider));
        border-radius: var(--mobile-card-radius);
        padding: 16px;
    }

    .mobile-sticky-cta {
        position: sticky;
        bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px) + 8px);
        z-index: 50;
        padding: 12px 0;
        background: linear-gradient(to top, var(--cr-page, var(--c-page)) 70%, transparent);
    }

    .mobile-sticky-cta .btn,
    .mobile-sticky-cta .btn-analyzer,
    .mobile-sticky-cta .btn-submit {
        width: 100%;
        min-height: var(--touch-min);
    }

    /* ── Touch feedback ── */
    .dock-item,
    .mobile-nav-link,
    .mobile-nav-accordion-trigger,
    .more-sheet-link,
    .hp-tool-card,
    .company-card,
    .btn,
    .hp-btn,
    .option-card {
        -webkit-tap-highlight-color: transparent;
    }

    .dock-item:active,
    .mobile-nav-link:active,
    .more-sheet-link:active,
    .hp-tool-card:active,
    .company-card:active,
    .btn:active,
    .hp-btn:active {
        transform: scale(0.97);
    }

    /* ── Header touch targets ── */
    .mobile-actions {
        gap: 4px;
    }

    .mobile-menu-toggle,
    .nav-search-toggle--mobile,
    .mobile-actions .theme-toggle {
        width: var(--touch-min);
        height: var(--touch-min);
        min-width: var(--touch-min);
        min-height: var(--touch-min);
    }

    /* ── Mobile search panel ── */
    .mobile-search-panel {
        padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
    }

    .mobile-search-panel form {
        gap: 0;
    }

    .mobile-search-panel input {
        flex: 1;
        padding: 14px 16px;
        border: 1px solid var(--cr-border, var(--c-divider));
        border-radius: 12px 0 0 12px;
        font-size: 16px;
        background: var(--cr-surface-3, #f5f5f5);
        color: var(--cr-text, var(--c-black));
    }

    .mobile-search-panel button {
        min-width: var(--touch-min);
        min-height: var(--touch-min);
        border-radius: 0 12px 12px 0;
    }

    /* ── Mobile drawer ── */
    .mobile-nav {
        background: var(--cr-surface, var(--c-white));
        border-left: 1px solid var(--cr-border, var(--c-divider));
    }

    .mobile-nav-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid var(--cr-border, var(--c-divider));
        position: sticky;
        top: 0;
        background: var(--cr-surface, var(--c-white));
        z-index: 2;
    }

    .mobile-nav-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--cr-text, var(--c-black));
    }

    .mobile-nav-close {
        width: var(--touch-min);
        height: var(--touch-min);
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--cr-text-secondary, var(--c-grey-mid));
        border-radius: 10px;
    }

    .mobile-nav-close:active {
        background: var(--cr-surface-3, #f0f0f0);
    }

    .mobile-nav-inner {
        display: flex;
        flex-direction: column;
        min-height: calc(100dvh - 57px);
        padding: 0 12px 12px;
    }

    .mobile-nav-section {
        border-bottom: 1px solid var(--cr-border, var(--c-divider));
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .mobile-nav-accordion-trigger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: var(--touch-min);
        padding: 14px 12px;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        color: var(--cr-text-muted, var(--c-grey-light));
        text-align: left;
    }

    .mobile-nav-accordion-trigger .accordion-chevron {
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    .mobile-nav-accordion-trigger[aria-expanded="true"] .accordion-chevron {
        transform: rotate(180deg);
    }

    .mobile-nav-accordion-panel {
        display: none;
        padding-bottom: 8px;
    }

    .mobile-nav-accordion-panel.is-open {
        display: block;
    }

    .mobile-nav-link {
        min-height: 48px;
        padding: 12px 14px;
        font-size: 15px;
        font-weight: 500;
        color: var(--cr-text-secondary, #333);
        border-radius: 10px;
    }

    .mobile-nav-link:hover,
    .mobile-nav-link:active {
        background: var(--cr-surface-3, #f5f5f5);
        color: var(--cr-text, var(--c-black));
    }

    .mobile-nav-link--highlight {
        color: #d93025;
        font-weight: 600;
    }

    .mobile-nav-cta {
        position: sticky;
        bottom: 0;
        margin-top: auto;
        padding: 16px 8px calc(16px + env(safe-area-inset-bottom, 0px));
        background: var(--cr-surface, var(--c-white));
        border-top: 1px solid var(--cr-border, var(--c-divider));
        z-index: 3;
    }

    .mobile-pro-btn {
        min-height: var(--touch-min);
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, var(--cr-text, #111) 0%, #333 100%);
        color: var(--cr-page, #fff);
        border-radius: 12px;
    }

    /* ── Bottom tab bar ── */
    .utility-dock {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        padding: 0;
        background: var(--cr-surface, var(--c-white));
        border-top: 1px solid var(--cr-border, var(--c-divider));
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
        z-index: 900;
    }

    .dock-container {
        flex-direction: row;
        justify-content: space-around;
        align-items: stretch;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        width: 100%;
        gap: 0;
    }

    .dock-item {
        flex: 1;
        min-width: 0;
        min-height: var(--dock-height);
        padding: 6px 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border-radius: 10px;
        position: relative;
        color: var(--cr-text-muted, var(--c-grey-mid));
        transition: color 0.15s ease, background 0.15s ease;
    }

    .dock-item.is-active {
        color: var(--c-blue-accent, #38bdf8);
    }

    .dock-item.is-active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--c-blue-accent, #38bdf8);
        border-radius: 0 0 3px 3px;
    }

    .dock-item--more {
        background: none;
        border: none;
        cursor: pointer;
        font-family: inherit;
    }

    .dock-icon {
        width: 22px;
        height: 22px;
        margin-bottom: 0;
    }

    .dock-icon svg {
        width: 22px;
        height: 22px;
    }

    .dock-label {
        position: static;
        opacity: 1;
        background: transparent;
        color: inherit;
        transform: none;
        font-size: 10px;
        font-weight: 600;
        margin-top: 2px;
        padding: 0;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        pointer-events: none;
        letter-spacing: 0.02em;
        text-transform: none;
    }

    .dock-item[data-dock-path="/layoff-radar/"] .dock-label,
    .dock-item[data-dock-path="/resignation-risk/"] .dock-label {
        font-size: 9px;
    }

    .utility-dock.is-hidden {
        display: none;
    }

    /* ── More bottom sheet ── */
    .more-sheet-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1100;
        opacity: 0;
        transition: opacity 0.25s ease;
        backdrop-filter: blur(2px);
    }

    .more-sheet-overlay.is-open {
        display: block;
        opacity: 1;
    }

    .more-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1101;
        display: none;
        background: var(--cr-surface, var(--c-white));
        border-radius: 20px 20px 0 0;
        padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        max-height: 70vh;
        overflow-y: auto;
    }

    .more-sheet.is-open {
        display: block;
        transform: translateY(0);
    }

    .more-sheet-handle {
        width: 36px;
        height: 4px;
        background: var(--cr-border, var(--c-divider));
        border-radius: 2px;
        margin: 0 auto 16px;
    }

    .more-sheet-title {
        font-size: 13px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--cr-text-muted, var(--c-grey-light));
        margin: 0 0 12px;
    }

    .more-sheet-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .more-sheet-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 16px 12px;
        background: var(--cr-surface-2, #f8f8f8);
        border: 1px solid var(--cr-border, var(--c-divider));
        border-radius: var(--mobile-card-radius);
        text-decoration: none;
        color: var(--cr-text, var(--c-black));
        font-size: 13px;
        font-weight: 600;
        text-align: center;
        min-height: 80px;
        justify-content: center;
    }

    .more-sheet-link .ms-icon {
        font-size: 22px;
        line-height: 1;
    }

    .more-sheet-link--pro {
        grid-column: 1 / -1;
        background: linear-gradient(135deg, #111 0%, #333 100%);
        color: #fff;
        border-color: transparent;
    }

    /* ── Toasts ── */
    .cr-toast-stack {
        top: auto;
        bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px) + 12px);
        left: 12px;
        right: 12px;
        max-width: none;
    }

    .cr-toast {
        width: 100%;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }

    /* ── Table → card layout ── */
    .table-scroll {
        overflow: visible;
    }

    table.editorial-table,
    table.salary-table {
        display: block;
        min-width: 0 !important;
        border: none;
    }

    table.editorial-table thead,
    table.salary-table thead {
        display: none;
    }

    table.editorial-table tbody,
    table.salary-table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--mobile-gap);
    }

    table.editorial-table tr,
    table.salary-table tr {
        display: block;
        background: var(--cr-surface-2, var(--c-white));
        border: 1px solid var(--cr-border, var(--c-divider));
        border-radius: var(--mobile-card-radius);
        padding: 14px 16px;
    }

    table.editorial-table td,
    table.salary-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        padding: 6px 0;
        border: none;
        font-size: 14px;
    }

    table.editorial-table td::before,
    table.salary-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--cr-text-muted, var(--c-grey-light));
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
    }

    table.editorial-table td:first-child,
    table.salary-table td:first-child {
        font-weight: 700;
        font-size: 15px;
        color: var(--cr-text, var(--c-black));
        padding-bottom: 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--cr-border, var(--c-divider));
    }

    table.editorial-table td:first-child::before,
    table.salary-table td:first-child::before {
        display: none;
    }

    /* ── Forms ── */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    .option-card {
        min-height: 52px;
        display: flex;
        align-items: center;
        padding: 14px 16px;
        border-radius: 12px;
    }

    .option-card:has(input:checked) {
        border-color: var(--c-blue-accent, #38bdf8);
        background: rgba(56, 189, 248, 0.08);
    }

    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="search"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px;
        min-height: var(--touch-min);
    }

    /* ── Company detail reorder ── */
    .cp-grid {
        display: flex;
        flex-direction: column;
    }

    .cp-main {
        order: 1;
    }

    .cp-sidebar {
        order: 2;
    }

    .cp-sticky-cta {
        display: block;
        position: fixed;
        bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px) + 8px);
        left: max(16px, env(safe-area-inset-left, 16px));
        right: max(16px, env(safe-area-inset-right, 16px));
        z-index: 50;
        padding: 0;
    }

    .cp-sticky-cta .btn-submit,
    .cp-sticky-cta a {
        display: block;
        width: 100%;
        text-align: center;
        min-height: var(--touch-min);
        line-height: 1.2;
        padding: 12px 16px;
        box-sizing: border-box;
    }

    body.sheet-open {
        overflow: hidden;
    }

    body.menu-open .utility-dock {
        z-index: 800;
    }

    .progress-bar {
        display: flex;
        gap: 6px;
        margin-bottom: 1.5rem;
        height: 4px;
    }

    .progress-bar-segment {
        flex: 1;
        height: 4px;
        border-radius: 2px;
        background: var(--cr-surface-3, #eee);
        transition: background 0.2s;
    }

    .progress-bar-segment.active {
        background: var(--c-blue-accent, #38bdf8);
    }

    /* ── Analyzer wizard ── */
    .analyzer-container {
        max-width: 100%;
        margin: 24px auto;
        padding: 16px max(16px, env(safe-area-inset-left)) 24px max(16px, env(safe-area-inset-right));
        padding-bottom: calc(24px + var(--dock-height) + env(safe-area-inset-bottom, 0px));
    }

    .analyzer-h1 {
        font-size: 1.35rem;
    }

    .progress-dots {
        display: none;
    }

    .cp-sticky-cta.is-hidden {
        opacity: 0;
        pointer-events: none;
        transform: translateY(12px);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .analyzer-form-actions {
        position: sticky;
        bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px) + 8px);
        padding-top: 12px;
        background: linear-gradient(to top, var(--cr-page, var(--c-page)) 80%, transparent);
        z-index: 10;
    }

    .btn-analyzer {
        min-height: var(--touch-min);
        border-radius: 12px;
        font-size: 16px;
    }

    /* ── Layoff radar ── */
    .az-radar-title {
        font-size: clamp(24px, 6vw, 32px) !important;
    }

    /* ── Homepage + tool hub ── */
    .hp-hero { padding: 32px 0 28px; }
    .hp-section { padding: 32px 0; }
    .hp-section-header { margin-bottom: 24px; }
    .hp-tools-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .hp-tool-card {
        align-items: center;
        border-radius: var(--mobile-card-radius);
        padding: 16px;
        text-decoration: none;
    }
    .hp-tool-card:hover {
        transform: none;
    }
    .hp-tool-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 20px;
    }
    .hp-tool-body h3 {
        text-decoration: none;
    }
    .hp-tool-arrow {
        display: block;
        opacity: 0.5;
        font-size: 16px;
    }

    /* ── CTC calculator ── */
    .az-calc-hero {
        text-align: left;
        margin-bottom: 24px;
    }
    .az-calc-title {
        font-size: clamp(24px, 6vw, 32px);
        line-height: 1.15;
    }
    .az-calc-subtitle {
        margin: 12px 0 0;
        font-size: 15px;
        line-height: 1.55;
    }
    .az-calc-card {
        padding: 20px 16px;
        border-radius: var(--mobile-card-radius);
        margin-bottom: 24px;
    }
    .az-calc-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 16px;
    }
    .az-calc-label {
        font-size: 12px;
        margin-bottom: 6px;
    }
    .az-calc-input,
    .az-calc-card select {
        min-height: 48px;
        font-size: 16px;
        border-radius: 10px;
        padding: 12px 14px;
    }
    .az-calc-input--light {
        font-size: 16px;
    }
    .az-calc-divider {
        margin-bottom: 16px;
        padding-top: 12px;
    }
    .az-calc-btn {
        min-height: 52px;
        border-radius: 12px;
        font-size: 15px;
        letter-spacing: 0.02em;
        text-transform: none;
    }

    /* ── Company directory ── */
    .dir-search-wrap {
        position: sticky;
        top: var(--header-height);
        z-index: 40;
        background: var(--cr-page, var(--c-page));
        padding: 8px 0;
    }

    .dir-controls {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .dir-controls::-webkit-scrollbar {
        display: none;
    }

    .dir-controls select {
        min-height: var(--touch-min);
        flex-shrink: 0;
    }

    /* ── Pro dashboard ── */
    .dash-grid {
        grid-template-columns: 1fr !important;
    }

    .quick-links {
        flex-direction: column;
    }

    .quick-link {
        min-height: var(--touch-min);
        display: flex;
        align-items: center;
    }

    /* ── Static pages ── */
    .static-page-content {
        padding: 24px 0 40px;
    }

    .static-page-content h1 {
        font-size: clamp(28px, 7vw, 36px);
        margin-bottom: 16px;
    }

    .static-page-content h2 {
        font-size: 1.25rem;
        margin-top: 28px;
    }

    .static-page-content p,
    .static-page-content li {
        font-size: 16px;
        line-height: 1.65;
    }

    /* ── Article reading ── */
    .art-related-grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
    }

    .art-related-grid > * {
        flex: 0 0 80%;
        max-width: 280px;
        scroll-snap-align: start;
    }

    /* ── Search results ── */
    .sr-item {
        padding: 14px 0;
    }

    /* ── Escape plan progress ── */
    .quiz-progress-bar {
        display: flex;
        gap: 4px;
        margin-bottom: 1.5rem;
    }

    .quiz-btn {
        min-height: 52px;
        width: 100%;
        text-align: left;
        padding: 14px 16px;
        border-radius: 12px;
    }

    .rating-group label {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .disc-filter-select {
        min-width: 0;
        flex: 1;
    }

    .disc-filter-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    body {
        padding-bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px) + 8px);
    }

    main {
        padding-bottom: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px));
    }
}

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

    .dock-label {
        font-size: 9px;
    }
}

@media (max-width: 375px) {
    .brand-wordmark {
        font-size: 13px;
    }

    .dock-label {
        font-size: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav,
    .more-sheet,
    .more-sheet-overlay,
    .dock-item,
    .cp-sticky-cta {
        transition: none !important;
    }
}
