:root {
    --color-brand--1: #ffb545;
    --color-brand--2: #00c46a;

    --color-dark--1: #2d3439;
    --color-dark--2: #42484d;
    --color-light--1: #aaa;
    --color-light--2: #ececec;
    --color-light--3: rgb(214, 222, 224);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: inherit;
}

html {
    font-size: 62.5%;
    box-sizing: border-box;
}

body {
    font-family: 'Manrope', sans-serif;
    color: var(--color-light--2);
    font-weight: 400;
    line-height: 1.6;
    height: 100vh;
    overscroll-behavior-y: none;

    background-color: #fff;
    padding: 2.5rem;

    display: flex;
}

a:link,
a:visited {
    color: var(--color-brand--1);
}

/* SIDEBAR */
.sidebar {
    flex-basis: 50rem;
    background-color: var(--color-dark--1);
    padding: 3rem 5rem 4rem 5rem;
    display: flex;
    flex-direction: column;
}

.logo {
    height: 5.2rem;
    align-self: center;
    margin-bottom: 4rem;
}

.workouts {
    list-style: none;
    height: 77vh;
    overflow-y: scroll;
    overflow-x: hidden;
}

.workouts::-webkit-scrollbar {
    width: 0;
}

.workout {
    background-color: var(--color-dark--2);
    border-radius: 5px;
    padding: 1.5rem 2.25rem;
    margin-bottom: 1.75rem;
    cursor: pointer;

    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.75rem 1.5rem;
}
.workout--running {
    border-left: 5px solid var(--color-brand--2);
}
.workout--cycling {
    border-left: 5px solid var(--color-brand--1);
}

.workout__title {
    font-size: 1.7rem;
    font-weight: 600;
    grid-column: 1 / -1;
}

.workout__details {
    display: flex;
    align-items: baseline;
}

.workout__icon {
    font-size: 1.8rem;
    margin-right: 0.2rem;
    height: 0.28rem;
}

.workout__value {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.workout__unit {
    font-size: 1.1rem;
    color: var(--color-light--1);
    text-transform: uppercase;
    font-weight: 800;
}

.form {
    background-color: var(--color-dark--2);
    border-radius: 5px;
    padding: 1.5rem 2.75rem;
    margin-bottom: 1.75rem;

    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2.5rem;

    height: 9.25rem;
    transition: all 0.5s, transform 1ms;
}

.form.hidden {
    transform: translateY(-30rem);
    height: 0;
    padding: 0 2.25rem;
    margin-bottom: 0;
    opacity: 0;
}

.form__row {
    display: flex;
    align-items: center;
}

.form__row--hidden {
    display: none;
}

.form__label {
    flex: 0 0 50%;
    font-size: 1.5rem;
    font-weight: 600;
}

.form__input {
    width: 100%;
    padding: 0.3rem 1.1rem;
    font-family: inherit;
    font-size: 1.4rem;
    border: none;
    border-radius: 3px;
    background-color: var(--color-light--3);
    transition: all 0.2s;
}

.form__input:focus {
    outline: none;
    background-color: #fff;
}

.form__btn {
    display: none;
}

.copyright {
    margin-top: auto;
    font-size: 1.3rem;
    text-align: center;
    color: var(--color-light--1);
}

.twitter-link:link,
.twitter-link:visited {
    color: var(--color-light--1);
    transition: all 0.2s;
}

.twitter-link:hover,
.twitter-link:active {
    color: var(--color-light--2);
}

/* MAP */
#map {
    flex: 1;
    height: 100%;
    background-color: var(--color-light--1);
}

.leaflet-popup .leaflet-popup-content-wrapper {
    background-color: var(--color-dark--1);
    color: var(--color-light--2);
    border-radius: 5px;
    padding-right: 0.6rem;
}

.leaflet-popup .leaflet-popup-content {
    font-size: 1.5rem;
}

.leaflet-popup .leaflet-popup-tip {
    background-color: var(--color-dark--1);
}

.running-popup .leaflet-popup-content-wrapper {
    border-left: 5px solid var(--color-brand--2);
}
.cycling-popup .leaflet-popup-content-wrapper {
    border-left: 5px solid var(--color-brand--1);
}

/* ─── TRACKING CONTROLS ─── */
.tracking-controls {
    margin-bottom: 1.2rem;
}

.btn-track {
    width: 100%;
    padding: 1.1rem 1.5rem;
    background-color: var(--color-dark--2);
    color: var(--color-light--2);
    border: 2px solid transparent;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    text-align: left;
}

.btn-track:hover {
    border-color: var(--color-brand--2);
}

.btn-track.tracking--active {
    border-color: var(--color-brand--2);
    background-color: rgba(0, 196, 106, 0.12);
    color: var(--color-brand--2);
}

/* ─── PULSING DOT (live tracking marker) ─── */
.tracking-dot {
    position: relative;
    width: 18px;
    height: 18px;
}

.tracking-dot__core {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-color: #00c46a;
    border: 3px solid white;
    box-shadow: 0 0 0 2px rgba(0,196,106,0.4);
    z-index: 2;
}

.tracking-dot__pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background-color: #00c46a;
    opacity: 0.35;
    animation: trackingPulse 2s ease-out infinite;
    z-index: 1;
}

@keyframes trackingPulse {
    0%   { transform: scale(1);   opacity: 0.35; }
    70%  { transform: scale(2.8); opacity: 0; }
    100% { transform: scale(2.8); opacity: 0; }
}

/* ─── ROUTE CONTROLS ─── */
.route-controls {
    margin-bottom: 1.5rem;
}

.btn-route {
    width: 100%;
    padding: 1.1rem 1.5rem;
    background-color: var(--color-brand--2);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
}

.btn-route:hover {
    background-color: #00a85a;
}

.btn-route:active {
    transform: scale(0.98);
}

.btn-route.hidden {
    display: none;
}

.route-info {
    background-color: var(--color-dark--2);
    border-radius: 5px;
    padding: 1.4rem 1.8rem;
}

.route-info__steps {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.route-info__step {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.3rem;
    color: var(--color-light--1);
    transition: color 0.3s;
}

.route-info__step--done {
    color: var(--color-light--2);
}

.route-info__badge {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    flex-shrink: 0;
}

.route-info__badge--a {
    background-color: var(--color-brand--2);
    color: #fff;
}

.route-info__badge--b {
    background-color: var(--color-brand--1);
    color: #fff;
}

.route-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid #555;
}

.route-result__item {
    background-color: var(--color-dark--1);
    border-radius: 5px;
    padding: 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.route-result__icon {
    font-size: 1.6rem;
}

.route-result__value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-light--2);
}

.route-result__unit {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-light--1);
}

.btn-route-cancel {
    width: 100%;
    padding: 0.8rem;
    background: transparent;
    border: 1px solid #666;
    border-radius: 5px;
    color: var(--color-light--1);
    font-family: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-route-cancel:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.route-marker {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.route-marker--a {
    background-color: var(--color-brand--2);
}

.route-marker--b {
    background-color: var(--color-brand--1);
}

.leaflet-routing-container {
    display: none !important;
}

.hidden {
    display: none !important;
}

/* ─── ACTIVITY MODE SELECTOR ─── */
.route-mode-selector {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.route-mode-btn {
    flex: 1;
    padding: 0.8rem;
    background-color: var(--color-dark--1);
    border: 2px solid transparent;
    border-radius: 5px;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    line-height: 1;
}

.route-mode-btn:hover {
    border-color: var(--color-light--1);
}

.route-mode-btn--active {
    border-color: var(--color-brand--2);
    background-color: rgba(0, 196, 106, 0.12);
}

/* ─── ROUTE LOADING ANIMATION ─── */
.route-loading {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem 0;
    margin-bottom: 0.8rem;
}

.route-loading__spinner {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.route-loading__dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
    background-color: var(--color-brand--2);
    animation: routeDotBounce 1.2s ease-in-out infinite;
}

.route-loading__dot:nth-child(2) {
    animation-delay: 0.2s;
    background-color: color-mix(in srgb, var(--color-brand--2) 70%, var(--color-brand--1));
}

.route-loading__dot:nth-child(3) {
    animation-delay: 0.4s;
    background-color: var(--color-brand--1);
}

@keyframes routeDotBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-0.8rem);
        opacity: 1;
    }
}

.route-loading__text {
    font-size: 1.3rem;
    color: var(--color-light--1);
    animation: routeTextPulse 1.5s ease-in-out infinite;
}

@keyframes routeTextPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ════════════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 768px) {

    body {
        flex-direction: column;
        padding: 0;
        height: 100dvh;
        overflow: hidden;
    }

    #map {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }

    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        flex-basis: auto;
        width: 100%;
        height: 55vh;
        max-height: 88dvh;
        padding: 0 2rem 2rem 2rem;
        border-radius: 2rem 2rem 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
        overflow: hidden;
        transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar::before {
        content: '';
        display: block;
        width: 4rem;
        height: 0.45rem;
        background-color: rgba(255,255,255,0.25);
        border-radius: 99px;
        margin: 1.2rem auto 1.6rem auto;
        cursor: grab;
        flex-shrink: 0;
    }

    .logo {
        height: 3.6rem;
        margin-bottom: 1.6rem;
    }

    .workouts {
        height: auto;
        max-height: 40dvh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .form {
        padding: 1.2rem 1.6rem;
        gap: 0.4rem 1.5rem;
        height: auto;
        min-height: 9rem;
    }

    .form__label {
        font-size: 1.4rem;
    }

    .form__input {
        font-size: 1.3rem;
        padding: 0.5rem 0.9rem;
    }

    .workout {
        grid-template-columns: 1fr 1fr;
        padding: 1.2rem 1.6rem;
        gap: 0.6rem 1rem;
    }

    .workout__title {
        font-size: 1.5rem;
    }

    .workout__value {
        font-size: 1.4rem;
    }

    .btn-route {
        padding: 1.3rem 1.5rem;
        font-size: 1.5rem;
    }

    .route-info {
        padding: 1.2rem 1.4rem;
    }

    .route-mode-btn {
        padding: 1rem;
        font-size: 2rem;
    }

    .route-info__step {
        font-size: 1.4rem;
    }

    .route-result__value {
        font-size: 2rem;
    }

    .btn-route-cancel {
        padding: 1.1rem;
        font-size: 1.4rem;
    }

    .copyright {
        display: none;
    }

    .leaflet-control-zoom {
        margin-bottom: 15rem !important;
    }

    .leaflet-popup .leaflet-popup-content {
        font-size: 1.4rem;
    }
}

@media (max-width: 380px) {
    .sidebar {
        padding: 0 1.4rem 1.4rem 1.4rem;
    }

    .workout {
        grid-template-columns: 1fr 1fr;
        padding: 1rem 1.2rem;
    }

    .btn-route {
        font-size: 1.4rem;
    }
}

/* ─── WORKOUT DELETE BUTTON ─── */
.workout {
    position: relative;
}

.workout__delete {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-light--1);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s, color 0.2s;
    line-height: 1;
}

.workout:hover .workout__delete {
    opacity: 1;
}

.workout__delete:hover {
    background-color: #ff6b6b22;
    color: #ff6b6b;
}

@media (max-width: 768px) {
    .workout__delete {
        opacity: 1;
        color: var(--color-light--1);
    }
}

/* ─── MOBILE SUBMIT BUTTON ─── */
@media (max-width: 768px) {
    .form__btn {
        display: block;
        grid-column: 1 / -1;
        width: 100%;
        padding: 1.1rem;
        margin-top: 0.4rem;
        background-color: var(--color-brand--2);
        color: #fff;
        border: none;
        border-radius: 5px;
        font-family: inherit;
        font-size: 1.5rem;
        font-weight: 700;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .form__btn:hover {
        background-color: #00a85a;
    }

    .form {
        height: auto;
    }
}
