/* ===================================== */
/* LAYOUT */
/* ===================================== */

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 0;

    font-family:
        Inter,
        "Segoe UI",
        sans-serif;

    background: var(--trailq-bg);
    color: var(--trailq-text);
}


/* ===================================== */
/* MAP / BUBBLE */
/* ===================================== */

.activeView {
    display: block;
}

.hiddenView {
    display: none !important;
}


/* ===================================== */
/* WORKSPACE */
/* ===================================== */

#workspaceLayout {
    flex: 1;
    min-height: 0;

    display: flex;
    overflow: hidden;
}


/* ===================================== */
/* LEFT PANE */
/* ===================================== */

#leftPane {
    flex: 1;
    min-width: 0;
    min-height: 0;

    position: relative;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}


/* ===================================== */
/* RIGHT PANE */
/* ===================================== */

#rightPane {
    width: 620px;
    flex-shrink: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border-left: 1px solid var(--color-border);
    background: var(--color-surface);
}


/* ===================================== */
/* VIEW AREA */
/* ===================================== */

#viewArea {
    position: relative;
    flex: 1;
    min-height: 0;

    overflow: hidden;
}

#mapView,
#bubbleView {
    position: absolute;
    inset: 0;
}

#map {
    width: 100%;
    height: 100%;
}


/* ===================================== */
/* RIGHT PANE CONTEXTS */
/* ===================================== */

#routeContext,
#activeTripContext {
    width: 100%;
    flex: 1;
    min-height: 0;
}

#routeContext {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#activeTripContext {
    display: none;
    overflow: hidden;
}


/* ===================================== */
/* PHONE: screens per phase (UI-NAV-02)  */
/* ===================================== */

#mobileTabBar,
#trailqIcon,
#mobileSelectedBar {
    display: none;
}

@media (max-width: 700px) and (orientation: portrait) {

    #workspaceLayout {
        display: block;
    }

    #leftPane,
    #rightPane {
        width: 100%;
        height: 100%;
    }

    /* one screen at a time */
    body[data-mobile-screen] #leftPane,
    body[data-mobile-screen] #rightPane {
        display: none;
    }

    body[data-mobile-screen="map"] #leftPane {
        display: flex;
    }

    body[data-mobile-screen="list"] #rightPane,
    body[data-mobile-screen="details"] #rightPane,
    body[data-mobile-screen="more"] #rightPane,
    body[data-mobile-screen="dashboard"] #rightPane,
    body[data-mobile-screen="route"] #rightPane,
    body[data-mobile-screen="photos"] #rightPane {
        display: flex;
    }

    /* list and details are separate screens */
    body[data-mobile-screen="list"] #detailsPane,
    body[data-mobile-screen="list"] #exploreNav {
        display: none;
    }

    body[data-mobile-screen="details"] #routeList,
    body[data-mobile-screen="details"] #exploreFilterRow,
    body[data-mobile-screen="details"] #exploreNav {
        display: none;
    }

    body[data-mobile-screen="details"] #detailsPane {
        flex: 1;
        min-height: 0;
    }

    /* the chosen walk below the list, with Go */
    body[data-mobile-screen="list"] #mobileSelectedBar:not([hidden]) {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        border-top: 1px solid var(--color-border);
        background: var(--color-background);
        font-weight: 600;
    }

    #mobileSelectedBar .selectedName {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #mobileSelectedBar button {
        flex: 0 0 auto;
        font: inherit;
        font-size: 0.85rem;
        border-radius: 6px;
        padding: 4px 10px;
        cursor: pointer;
        border: 1px solid var(--color-primary);
        color: var(--color-primary);
        background: var(--color-surface);
    }

    #mobileSelectedBar .selectedGo {
        background: var(--color-primary);
        color: var(--color-surface);
    }

    /* the header must fit next to the settings button: the workspace
       button takes what is left (with "…"), the phase switch keeps its
       width; before, the switch slid over the button (UI-NAV-02) */
    #applicationHeader {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
    }

    #workspaceMenuWrap {
        min-width: 0;
    }

    #phaseSwitch {
        justify-self: end;
    }

    /* the pane has the screen's height, so it scrolls (UI-NAV-02); in the
       phone's block layout it grew with its content and was cut off */
    body.phase-analyse #analysePane {
        padding: var(--spacing-md);
        height: 100%;
        box-sizing: border-box;
    }

    /* tab bar at the bottom */
    #mobileTabBar:not([hidden]) {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        border-top: 1px solid var(--color-border);
        background: var(--color-tabbar);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    #mobileTabBar button {
        font: inherit;
        font-size: 0.68rem;
        border: 0;
        background: none;
        color: var(--color-text-secondary);
        padding: 6px 0 8px;
        display: grid;
        justify-items: center;
        gap: 2px;
        cursor: pointer;
    }

    #mobileTabBar svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    #mobileTabBar button[aria-selected="true"] {
        color: var(--color-primary);
        font-weight: 600;
        background: var(--color-surface);
    }

    /* compact header and status line */
    #applicationHeader {
        gap: 6px;
        padding: 0 8px;
    }

    #trailqLogo {
        display: none;
    }

    #trailqIcon {
        display: block;
        width: 32px;
        height: 32px;
    }

    #workspaceMenuButton {
        max-width: 100%;
        padding: 3px 7px;
        gap: 3px;
    }

    /* ? and ⚙ narrow, so the workspace name gets more room */
    #headerActions {
        gap: 4px;
    }

    #helpButton {
        min-width: 0;
        width: 28px;
        padding: 0;
    }

    #phaseSwitch button {
        padding: 5px 5px;
        font-size: 0.78rem;
    }

    #phaseStatusBar {
        flex-wrap: nowrap;
        overflow: hidden;
        white-space: nowrap;
        padding: 3px 8px;
    }

    #headerActions {
        display: flex;
        gap: 8px;
        align-items: center;
    }

}

/* ===================================== */
/* PHASES (UI-PHASE-01)                  */
/* ===================================== */

#analysePane {
    display: none;
}

body.phase-analyse #leftPane,
body.phase-analyse #rightPane {
    display: none !important;
}

body.phase-analyse #analysePane {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: auto;
    padding: var(--spacing-lg);
    background: var(--color-background);
}

.analyseSection {
    max-width: 760px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    display: grid;
    gap: var(--spacing-sm);
}

.analyseSection h2,
.analyseSection h3 {
    margin: 0;
}

.analyseSection p {
    margin: 0;
    color: var(--color-text-secondary);
}

.analyseRow {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    flex-wrap: wrap;
}

/* after a crosstrainer session: use it for the calibration? (TRAIN-09) */
.sessionCalibrationAsk {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    padding: 8px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 6px;
}

.sessionCalibrationAsk p {
    margin: 0;
}

.analyseCalibrationChange {
    margin: 6px 0;
}

.detailsGoButton {
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: var(--color-surface);
    border-radius: 6px;
    padding: 2px 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== Sessions in Analyse (UI-SESSION-04) ===== */

.sessionHead {
    gap: var(--spacing-md);
}

.sessionHead label {
    font-size: 0.9rem;
}

.sessionList {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sessionRow {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
}

.sessionRow.open {
    border-color: var(--color-primary);
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.sessionIcon {
    flex: 0 0 auto;
    font-size: 18px;
}

.sessionMain {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sessionMain small {
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sessionFigures {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.sessionDetail {
    display: grid;
    gap: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--color-border);
}

.sessionDetail h3,
.sessionDetail h4 {
    margin: 0;
}

.sessionFiguresGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px 16px;
    margin: 0;
}

.sessionFiguresGrid dt {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.sessionFiguresGrid dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.sessionEvents {
    margin: 0;
    padding-left: 1.2em;
}

.sessionDetail .labelChip button {
    border: none;
    background: none;
    color: inherit;
    padding: 0 4px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

/* phone: two columns of figures, less white space around Analyse */
@media (max-width: 700px) {

    body.phase-analyse #analysePane {
        padding: var(--spacing-sm);
    }

    .analyseSection {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .sessionFiguresGrid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== Goal profiles in Analyse (UI-GOAL-01) ===== */

.goalList {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.goalList li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.goalInfo {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.goalInfo small {
    color: var(--color-text-secondary);
}

.goalForm input[type="number"],
.sessionGoalForm input[type="number"] {
    width: 4em;
}

/* ===== Comparing sessions, monthly totals (UI-ANA-01) ===== */

.compareTableWrap {
    overflow-x: auto;
}

.compareTable {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.compareTable th,
.compareTable td {
    padding: 4px 8px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border);
}

.compareTable th:first-child,
.compareTable td:first-child {
    text-align: left;
}

.compareTable th {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.compareTable tr.best td {
    font-weight: 600;
}

/* race against the opponents with a session (UI-GHOST-05) */
.sessionRace {
    white-space: nowrap;
}

.sessionRaceList {
    margin: 2px 0 0;
    padding-left: 18px;
    font-weight: normal;
}

.sessionRaceList small {
    color: var(--color-text-secondary, #666);
    font-variant-numeric: tabular-nums;
}

/* ===== Experience: rating and words (EXP-04, EXP-05) ===== */

.experienceRating {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--color-background, #f4f5f7);
}

.experienceHead {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
}

.experienceHead small {
    color: var(--color-text-secondary, #666);
}

.experienceStars button {
    border: none;
    background: none;
    padding: 0 2px;
    font-size: 1.4rem;
    line-height: 1;
    color: #c9c9c9;
    cursor: pointer;
}

.experienceStars button.on {
    color: #e0a400;
}

/* the review as suggested stars (EXP-10) */
.experienceStars button.suggested {
    color: #e0a400;
    opacity: 0.4;
}

.experienceWords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.experienceWord {
    padding: 2px 9px;
    border-radius: 12px;
    border: 1px solid var(--color-border, #d7d7d7);
    background: var(--color-surface, #fff);
    font-size: 0.8rem;
    cursor: pointer;
}

.experienceWord.positive.chosen {
    background: #2b6f3e;
    border-color: #2b6f3e;
    color: #fff;
}

.experienceWord.negative.chosen {
    background: #b45309;
    border-color: #b45309;
    color: #fff;
}

/* a suggestion from the note or the events: counts once tapped */
.experienceWord.suggested {
    border-style: dashed;
    border-color: currentColor;
}

.experienceWord.positive.suggested {
    color: #2b6f3e;
}

.experienceWord.negative.suggested {
    color: #b45309;
}

.experienceActions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.experienceMessage {
    color: #b45309;
    font-size: 0.8rem;
}

.sessionRatingAsk {
    margin: 8px 0;
    padding: 8px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 6px;
}

.sessionRatingAsk p {
    margin: 0;
}

.walkEventWords {
    margin: 4px 0;
}

/* ===== Experience profile in Explore · Profiles (EXP-07) ===== */

.experienceProfile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--color-background, #f4f5f7);
}

.experienceProfile.current {
    border-left: 3px solid var(--color-primary);
    border-radius: 0 6px 6px 0;
}

.experienceProfile.notes {
    border: 1px dashed var(--color-border, #d7d7d7);
    background: none;
}

.experienceProfile p {
    margin: 4px 0 0;
}

.experienceProfile small {
    color: var(--color-text-secondary, #666);
}

.experienceProfileWords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* "Lijkt op" in Details (EXP-08) */
.similarWalks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: 0 0 12px;
}

.similarWalks small {
    flex-basis: 100%;
    color: var(--color-text-secondary, #666);
}

.similarWalk {
    padding: 2px 8px;
    border: 1px solid var(--color-border, #d7d7d7);
    border-radius: 12px;
    background: var(--color-surface, #fff);
    cursor: pointer;
    font-size: 0.85rem;
}

.similarRating {
    color: #e0a400;
    white-space: nowrap;
}

