/* Styles specific to templates/traincatcher.html */


.search-wrapper {
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 0.5em;
    background: var(--card-color);
    border-radius: 12px;
    padding: var(--default-padding);
    box-shadow: 0 10px 40px var(--border-color);
}

@media (max-width: 480px) {
    .search-wrapper.mobile-hidden {
        display: none;
    }
}

.search-header {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
}
.search-header h2 {
    color: var(--accent-color-dark);
    font-size: 1rem;
}

.instruction-button {
    height: max-content;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: var(--theme-color);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    position: relative;
}

.instruction-button:hover {
    text-decoration: underline;
}

.input-wrapper {
    display: flex;
    width: 100%;
    height: max-content;
    column-gap: 8px;
    align-items: stretch;
}

.search-input {
    flex: 1 1 auto;
    font-size: 0.7rem;
    padding: 0 0.5em;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.3s, box-shadow 0.2s;
    background: var(--card-color);
    color: var(--text-color);

    line-height: 1;
    height: calc(1em + 1em);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
@media (max-width: 480px) {
    .search-input {
        font-size: 16px;    /* must be 16px to prevent auto zoom on mobile */
    }
}

.searchInput:focus {
    outline: none;
    border-color: var(--border-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.openInBrowserBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-color);
    color: var(--card-color);
    border: 2px solid transparent;
    border-radius: 6px;
    padding:  0 1em;
    font-size: 0.7rem;
    line-height: 1;
    height: calc(1em + 1em);
    cursor: pointer;
}
.openInBrowserBtn:hover {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.instruction-wrapper {
    position: fixed;
    inset: 0;
    background: rgba(from var(--accent-color) r g b / 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.instruction-content {
    box-sizing: border-box;
    width: 90%;
    max-width: 800px;
    padding: var(--default-padding);
    background: var(--card-color);
    color: var(--text-color);
    border-radius: 12px;
    position: relative;
}
.instruction-content h2 {
    font-size: 1rem;
    margin-bottom: 1em;
}

.instruction-step p {
    font-size: 0.8rem;
    padding-left: 1.2em;
    text-indent: -1.2em;
}
.instruction-step b {
    color: var(--theme-color);
}

.instruction-close {
    position: absolute;
    top: 6px;
    color: var(--theme-color);
    right: 15px;
    border: none;
    background: none;
    font-size: 2rem;
    cursor: pointer;
}

.welcome-wrapper {
    display: flex;
    background: var(--card-color);
    padding: var(--default-padding);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--border-color);
}

.welcome-container h2 {
    color: var(--text-color);
    font-size: 1rem;
}
.welcome-container p {
    font-size: 0.8rem;
}
.welcome-container {
    display: flex;
    flex-direction: column;
}

.results-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    background: var(--card-color);
    padding: var(--default-padding);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--border-color);
}
.results-wrapper h2 {
    color: var(--text-color);
    font-size: 1rem;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#addConnectionBtn {
    background: var(--theme-color);
    color: var(--card-color);
    border: 0;
    padding: 0.5em 1em;
    border-radius: 6px;
    cursor: pointer;
}
#addConnectionBtn.disabled {
    background: var(--border-color);
}
@media (max-width: 768px) {
    .btn-text {
        display: none;
    }
}

#addConnectionBtn:hover {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.results-container {
    display: grid;
    grid-template-columns: 1fr 9fr;
    grid-template-rows: 9fr 2fr;
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    min-height: 0;
}
@media (max-width: 768px) {
    .results-container {
        grid-template-columns: 1fr;
        grid-template-rows: 0.5fr 8fr max-content;
    }
}

.tabs-wrapper {
    display: flex;
    align-items: start;
    grid-column: 1;
    grid-row: 1 / span 2;
    max-width: 180px;
    width: 100%;
    gap: 8px;
    padding: 10px;
    background-color: var(--background-color);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    border-right: 2px solid var(--border-color);
}
@media (max-width: 768px) {
    .tabs-wrapper {
        grid-row: 1;
        max-width: 100%;
        border-top-left-radius: 12px;
        border-top-right-radius: 12px;
        border-bottom-left-radius: 0;
        border-right: 0;
    }
}

/* Tabs for multiple journeys */
.tabs-toggle {
    display: none;    /* hidden on desktop */
}
@media (max-width: 768px) {
    .tabs-toggle {
        display: flex;
        grid-column: 2;
        grid-row: 1;
        align-self: start;
        aspect-ratio: 1;
        justify-content: center;
        align-items: center;
        background: transparent;
        border: 2px solid var(--border-color);
        border-radius: 6px;
        font-weight: 700;
        cursor: pointer;
        padding: 0.25em 0.5em;            /* same as .tab */
        font-size: 0.8rem;
        line-height: 1.5;
        color: var(--accent-color);
    }
}

.journey-tabs {
    display: flex;
    flex-direction: column;
    align-items: start;
    width: 100%;
    row-gap: 8px;
}

.journey-tabs .tab {
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
    width: 100%;
    gap: 4px;
    align-items: center;
    background: var(--card-color);
    color: var(--text-color);
    border: 0;
    border-radius: 6px;
    padding: 0.25em 0.5em;
}
@media (max-width: 768px) {
    .journey-tabs .tab {
        display: none;        /* hide all tabs by default on mobile */
    }
    .journey-tabs .tab.active {
        display: flex;
    }
    .journey-tabs .tab:not(.active) {
        display: none;
    }
    .journey-tabs.open .tab {
        display: flex;
    }
    .journey-tabs.open .tab:not(.active) {
        display: flex;
    }
}


.tab-arrow {
    font-size: 2.5rem;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transform: translateY(-4px);
}
@media (max-width: 768px) {
    .tab-arrow {
        display: none;
    }
}

.tab-label {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    background: transparent;
    border: 0;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: inherit;
    line-height: 1.5;
}
.tab-from::after {
    content: '';
    display: block;    /* acts as the \n on desktop */
}
.tab-from,
.tab-to {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
@media (max-width: 768px) {
    .tab-label {
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }

    .tab-from::after {
        content: ' →';
        display: inline;   /* becomes the arrow on mobile */
    }
}

.tab-close {
    align-items: center;
    background: transparent;
    border: 0;
    margin-left: auto;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}

.tab.active {
    background: var(--theme-color);
}
.tab.active * {
    color: var(--card-color);
}
.tab:not(.active) * {
    color: var(--text-color);
}

/* Journey layout */
.journey-wrapper {
    grid-column: 2;
    grid-row: 1;
    flex: 1;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    min-height: 0;
    position: relative;
}
@media (max-width: 768px) {
    .journey-wrapper {
        grid-column: 1;
        grid-row: 2;
    }
}

.analytics-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: color-mix(in srgb, var(--background-color) 80%, transparent);
    border-radius: inherit;
    font-size: 0.85rem;
    color: var(--text-color);
    z-index: 10;
}

.analytics-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--theme-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.journey-container {
    grid-template-columns: max-content max-content minmax(0, 0.1fr) minmax(0, 1fr);
    grid-auto-rows: max-content;
    column-gap: var(--default-padding);
    align-content: start;
    display: none;
    max-width: 100%;
    padding: 10px;
}

.journey-container.active {
    display: grid;
}

.journey-path {
    grid-column: 1;
    grid-row: span 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: stretch;
    height: 100%;
    width: max-content;
    z-index: 2;
    justify-self: end;
}
@media (max-width: 480px) {
    .journey-path {
        position: relative;
        margin-left: 20px;
    }
}

.train-label {
    background: rgba(from var(--theme-color) r g b / 0.1);
    color: var(--theme-color);
    padding: 4px 8px;
    margin-left: var(--default-padding);
    border-radius: 999px;
    font-size: 0.8rem;
    width: max-content;
    z-index: 3;
}
@media (max-width: 480px) {
    .train-label {
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 4px;
    }
}

.path-sketch {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: stretch;
    height: 100%;
    width: max-content;
}
.dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--theme-color);
    border-radius: 50%;
    background: var(--card-color);
    flex-shrink: 0;
}
.leg-line {
    position: relative;
    width: 2px;
    background: var(--theme-color);
    height: 74px;
    margin: 10px 0;
}

.station-name {
    position: relative;
    align-self: start;
    grid-column: 1 / 4;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    padding: var(--default-padding) 0px var(--default-padding) var(--default-padding);
    z-index: 2;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-all;
    /* overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis; */
}
.station-name.station-last {
    grid-column: 1 / 5;
}
.journey-duration {
    font-size: 0.8rem;
}
.journey-duration > span {
    color: var(--theme-color);
}

.leg-row {
    grid-column: 2;
    min-width: max-content;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    z-index: 2;
}

.leg-text-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.leg-text {
    font-size: 0.8rem;
    line-height: 1;
    margin-top: 0;
    color: var(--text-color);
    font-weight: 600;
}

.time-label-short {
    display: none;
}

@media (max-width: 480px) {
    .time-label-full {
        display: none;
    }

    .time-label-short {
        display: inline;
    }
}

.avg-delta {
    font-size: 0.8rem;
    line-height: 1;
    margin-top: 0;
    color: var(--accent-color);
    opacity: 0.8;
}
.delta-pos {
    color: var(--theme-color);
    font-weight: 600;
}
.delta-neg {
    color: var(--contrast-color);
    font-weight: 600;
}
.delta-zero {
    color: var(--accent-color);
    font-weight: 600;
}

.transition-wrapper {
    grid-column: 1 / span 4;
    display: grid;
    grid-template-columns: subgrid;
    min-width: 0;
    max-width: 100%;
    padding-right: var(--default-padding);
    background-color: var(--background-color);
    border-radius: 12px;
    z-index: 1;
}

.transition-container {
    grid-column: 4;
    display: grid;
    grid-template-columns: max-content minmax(0, max-content);
    grid-template-rows: 22% var(--soft-height, auto) auto 22%;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: start;
    position: relative;
    z-index: 1;
}

.chart {
    position: relative;
    grid-column: 1;
    grid-row: 1 / span 4;
    width: max-content;
    min-width: max-content;
    flex-shrink: 0;
    overflow: visible;
    height: 100%;
    padding: 0 5px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
    z-index: 11;
}
@media (max-width: 768px) {
    .chart {
        gap: 3px;
    }
}

.bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 10px;
    height: 100%;
    position: relative;
}
@media (max-width: 768px) {
    .bar-container {
        width: 8px;
    }
}

.bar {
    width: 100%;
    transition: height 0.5s ease;
    position: relative;
    border-radius: 0 0 6px 6px;
}

.bar-label {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);

    padding: 4px 4px;
    background: var(--card-color);  
    color: var(--accent-color);
    border-radius: 6px;

    font-size: 0.8rem;
    white-space: pre;
    text-align: center;
    box-shadow: 0 2px 6px var(--accent-color);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 30;
}

.bar-label::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--card-color);
}
.bar-label::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-bottom-color: var(--accent-color);    /* shadow color */
    z-index: -1;
}

.bar-container:hover .bar-label {
    opacity: 1;
}

.bar.not-available {
    background-color: var(--accent-color);
    opacity: 1;
}

.bar.cancelled {
    background-color: var(--theme-color);
    opacity: 1;
}
.bar.cancelled::after,
.bar.cancelled::before {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    width: 10px;
    height: 2px;
    background-color: var(--theme-color);
    transform-origin: center;
}
.bar.cancelled::after {
    transform: translateX(-50%) rotate(45deg);
}
.bar.cancelled::before {
    transform: translateX(-50%) rotate(-45deg);
}

.bar.above-threshold {
    background-color: var(--theme-color);
    opacity: 1;
}

.bar.between-threshold {
    background-color: var(--intermediate-color);
    opacity: 1;
}

.bar.below-threshold {
    background-color: var(--contrast-color);
    opacity: 1;
}

.bar.overflow::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid var(--theme-color);
}

.thresholds {
    position: relative;
    grid-column: 1 / span 2;
    grid-row: 1 / span 3;
    max-width: 100%;
    display: grid;
    grid-template-rows: subgrid;
    grid-template-columns: subgrid;
    overflow: hidden;
}
.thresholds>* {
    display: flex;
    justify-content: end;
    align-items: flex-end;
}
.threshold-arrival {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    border-bottom: 2px solid var(--accent-color);
    justify-self: end;
}
.threshold-soft {
    grid-column: 1 / span 2;
    grid-row: 2;
    width: 100%;
    border-bottom: 2px dotted var(--accent-color);
    justify-self: end;
}
.threshold-hard {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    border-bottom: 2px solid var(--accent-color);
    justify-self: end;
}
.threshold-label {
    grid-column: 2;
    grid-row: 2;
    position: static;
    font-size: 0.7rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-right: 0.4em;
    margin-bottom: 0.1em;
    padding-left: 5px;
    align-self: end;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
@media (max-width: 480px) {
    .threshold-label {
        display: none;
    }
}

.summary-wrapper {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
    width: 100%;
    padding: 10px;
    border-top: 2px solid var(--border-color);
}
@media (max-width: 768px) {
    .summary-wrapper {
        grid-column: 1;
        grid-row: 3;
    }
}

.summary-container {
    display: none;
    height: 100%;
}
.summary-container.active {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .summary-container b {
        display: none;
    }
}

.thermometer-chart {
    position: relative;
    width: 100%;
    height: max-content;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.thermometer-colour {
    position: relative;
    flex: 1;
    width: 100%;
    height: 15px;
    background: linear-gradient(to right, var(--theme-color), var(--intermediate-color) 50%, var(--contrast-color));
    opacity: 0.7;
    border-radius: 10px;
}

.thermometer-pointer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 16px;
    height: 16px;
    border: 2px solid var(--card-color);
    box-shadow: 0 2px 4px var(--accent-color);
    z-index: 2;
}

.thermometer-scale {
    position: relative;
    width: max-content;
    height: auto;
    font-size: 0.8rem;
    line-height: 1;
}
.thermometer-scale.left {
    margin-right: 1em;
}
.thermometer-scale.right {
    margin-left: 1em;
}

.summary-text {
    font-size: 0.8rem;
    text-align: justify;
}

.booking-link {
    color: var(--theme-color);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.booking-link:hover {
    text-decoration: underline;
}