/**
 * W.A.Y. — Mobile & responsive enhancements (all pages)
 */

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

img, svg, video { max-width: 100%; height: auto; }

/* Touch-friendly controls */
.way-btn,
.way-app-nav .hamburger,
.way-public-nav__toggle,
button:not(.way-story-carousel__dot):not(.way-calling-slideshow__dot):not(.way-calling-slideshow__arrow):not(.way-dash-tab-btn):not(.way-mission-chip):not(.way-mission-step-btn):not(.way-career-flip-btn):not(.way-career-flip-open):not(.way-career-flip-back):not(.way-journey-wheel__dot):not(.way-journey-wheel__center-hit):not(.way-admin-wizard__dot),
input[type="submit"],
.btn,
.option-btn {
    min-height: 44px;
}

.way-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Public nav: one aligned row on desktop */
.way-public-nav__item {
    min-height: 40px;
    height: 40px;
}

/* App nav: fixed 40px row on desktop — don't stretch with global min-height */
.way-app-nav .nav-link,
.way-app-nav .dropdown-trigger,
.way-app-nav .logout-link {
    min-height: 40px;
    height: 40px;
}

/* ——— Public pages ——— */
@media (max-width: 768px) {
    .way-public-nav {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 0;
    }

    .way-public-nav__brand {
        order: 1;
    }

    .way-public-nav__toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        order: 2;
    }

    .way-public-nav__panel {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        margin: 12px 0 0;
        padding: 20px 0 8px;
        border-top: 1px solid var(--way-border);
        gap: 20px;
    }

    .way-public-nav--open .way-public-nav__panel {
        display: flex;
    }

    .way-public-nav__menu {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }

    .way-public-nav__item {
        width: 100%;
        height: 48px;
        min-height: 48px;
        font-size: 0.9rem;
        justify-content: center;
        margin-left: 0 !important;
    }

    .way-public-nav__item--cta {
        border-width: 2px;
    }

    .way-hero {
        min-height: auto;
        padding: 36px 20px 48px;
    }

    .way-hero__headline {
        font-size: 1.1rem;
    }

    .way-pillars {
        padding: 40px 20px;
    }

    .way-section {
        padding: 48px 0;
    }

    .way-container {
        padding: 0 20px;
    }

    .way-card-grid {
        grid-template-columns: 1fr;
    }

    .way-cta-band .way-btn {
        display: block;
        width: 100%;
        max-width: 320px;
        margin: 8px auto !important;
    }

    .way-auth-page {
        padding: 88px 16px 32px;
    }

    .way-auth-card {
        padding: 28px 22px;
        max-width: 100%;
    }

    .way-back-home {
        top: 12px;
        left: 12px;
    }
}

@media (max-width: 480px) {
    .way-logo--lg svg { width: 160px; height: 160px; }
    .way-logo--hero svg { width: min(220px, 82vw); height: auto; }
    .way-hero__verse { font-size: 0.85rem; }
}

/* ——— App shell ——— */
@media (max-width: 768px) {
    body.way-app {
        padding-top: 64px;
    }

    .way-app-nav {
        height: 64px;
        padding: 0 12px 0 16px;
        gap: 8px;
        overflow: hidden;
    }

    /* Beat legacy compat rule that forced desktop nav visible on phones */
    body.way-app .way-app-nav .desktop-nav {
        display: none !important;
    }

    body.way-app .way-app-nav .hamburger {
        display: flex !important;
        margin-left: auto;
    }

    .way-app-nav .brand-section {
        flex: 0 1 auto;
        min-width: 0;
        max-width: calc(100% - 48px);
        z-index: 2;
    }

    .way-app-nav .brand-section .way-public-nav__brand {
        display: flex;
        align-items: center;
        line-height: 0;
    }

    .way-app-nav .user-name {
        font-size: 0.85rem;
        max-width: 100px;
    }

    .way-app-nav .brand-section .user-name {
        display: none !important;
    }

    body.way-app .way-app-nav .dropdown-content {
        display: none !important;
    }

    .way-app-main,
    .main-layout,
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .main-layout {
        flex-direction: column !important;
        gap: 20px !important;
        padding: 16px !important;
    }

    .right-panel {
        width: 100% !important;
    }

    .levels-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    .progress-section,
    .quiz-header,
    .question-card,
    .section-card,
    .page-header {
        padding: 20px 16px !important;
    }

    .page-header h1 {
        font-size: 1.5rem !important;
    }

    .dimension-tooltip {
        flex-direction: column;
        text-align: center;
        max-width: calc(100vw - 32px);
        bottom: 12px;
    }

    .tooltip-image {
        width: 64px;
        height: 64px;
    }

    /* Quiz */
    .question-options {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .vs-divider {
        padding: 4px 0 !important;
    }

    .action-buttons {
        flex-direction: column !important;
        width: 100%;
    }

    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    .saving-indicator {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .option-btn {
        width: 100% !important;
        min-height: 48px;
        padding: 14px 16px !important;
        font-size: 0.95rem !important;
    }

    .dimension-intro {
        flex-direction: column !important;
        align-items: center;
        text-align: center;
    }

    .dimension-intro img {
        max-width: 100%;
        height: auto;
    }

    /* Report / careers grids */
    .careers-grid,
    .insights-grid,
    .career-grid,
    .circles-grid,
    .challenges-grid,
    .features-grid,
    .users-header {
        grid-template-columns: 1fr !important;
    }

    .archetype-summary {
        flex-direction: column !important;
        text-align: center;
    }

    /* Connections */
    .connection-card,
    .share-code-box {
        flex-direction: column;
        align-items: stretch !important;
    }

    /* Compare */
    .comparison-row,
    .bar-row {
        flex-wrap: wrap;
    }

    .bar-label {
        min-width: 100% !important;
        margin-bottom: 4px;
    }

    /* Admin */
    .topbar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    .admin-grid,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 400px) {
    .levels-container {
        grid-template-columns: 1fr 1fr !important;
    }

    .circle {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.25rem !important;
    }
}

/* ——— App pages: touch, layout, readable text ——— */
@media (max-width: 768px) {
    body.way-app,
    body.way-public {
        overflow-x: clip;
    }

    .way-dash-main,
    .way-page-main,
    .way-compare-main,
    .container.way-app-main {
        padding-left: 16px !important;
        padding-right: 16px !important;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
        max-width: 100%;
        box-sizing: border-box;
    }

    .way-page-main,
    .way-compare-main {
        padding-top: 20px;
    }

    .way-page-header h1 {
        font-size: 1.5rem;
    }

    .way-card {
        padding: 18px 16px;
    }

    .way-card.way-card--intro {
        padding: 16px;
        font-size: 15px;
        line-height: 1.6;
    }

    .way-cta,
    .way-cta--gold,
    .way-cta--ghost {
        min-height: 48px;
        padding: 12px 20px;
    }

    /* Mission builder — full labels on small screens */
    .way-mission-chip-scroll {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 10px;
    }

    .way-mission-chip {
        flex: 0 1 auto;
        width: auto;
        max-width: 100%;
        min-height: 44px;
        padding: 12px 16px;
        font-size: 14px;
        line-height: 1.35;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .way-mission-search,
    .way-mission-custom-input,
    .way-mission-final,
    #item-search,
    .way-scripture-ref,
    .way-scripture-text {
        font-size: 16px;
    }

    .calling-item,
    #item-list .calling-item {
        min-height: 44px;
        padding: 12px 14px !important;
        font-size: 15px;
        line-height: 1.35;
        align-items: flex-start !important;
    }

    .calling-item input[type="checkbox"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        margin-top: 2px;
    }

    .way-quote-modal-overlay {
        padding: max(12px, env(safe-area-inset-top, 12px)) 12px max(12px, env(safe-area-inset-bottom, 12px));
        align-items: flex-end;
    }

    .way-quote-modal {
        max-height: min(88vh, 100%);
        padding: 20px 18px 18px;
        border-radius: 16px 16px 0 0;
    }

    .way-quote-modal__close {
        width: 44px;
        height: 44px;
    }

    .way-compare-header h1 {
        font-size: 1.45rem;
    }

    .way-compare-section {
        padding: 18px 16px;
    }

    .way-compare-dim__labels {
        font-size: 0.75rem;
        gap: 4px;
    }

    .way-compare-pole-bar {
        height: 28px;
    }

    .way-report-section__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .way-report-section__actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .way-report-calling-pills {
        gap: 8px;
    }

    .way-report-calling-pill {
        font-size: 0.9rem;
        padding: 8px 14px;
        max-width: 100%;
        white-space: normal;
        line-height: 1.3;
        text-align: center;
    }

    .dimension-labels {
        font-size: 0.72rem;
        gap: 4px;
    }

    .dimension-labels span {
        max-width: 48%;
        line-height: 1.25;
    }

    .dimension-bar {
        height: 28px;
    }

    .dimension-bar-seg {
        font-size: 0.7rem;
        min-width: 28px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .way-report-becoming-grid {
        grid-template-columns: 1fr;
    }

    .way-becoming-page .way-card,
    .way-quiz-wizard-page .way-quiz-footer--wizard {
        padding-left: 16px;
        padding-right: 16px;
    }

    .way-app-nav {
        padding-left: max(12px, env(safe-area-inset-left, 12px));
        padding-right: max(12px, env(safe-area-inset-right, 12px));
    }

    .way-mobile-sidebar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

@media (max-width: 480px) {
    .way-mission-chip {
        flex: 1 1 100%;
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .way-mission-steps {
        grid-template-columns: 1fr 1fr;
    }

    .way-compare-users {
        gap: 12px;
    }

    .way-compare-tip-card {
        padding: 14px;
    }

    .section-card {
        padding: 20px 16px !important;
    }

    .page-header h1 {
        font-size: 1.4rem !important;
    }
}

@media (max-width: 360px) {
    .way-dash-tab-btn {
        min-width: 100px;
        padding: 10px 12px;
    }

    .way-mission-step-btn {
        font-size: 11px;
        padding: 10px 8px;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .way-public-nav {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    body.way-app {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .way-admin-wizard__bar {
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    }
}
