:root {
    --paste-green: #f3fce9;
    --light-green: #8CC63F;
    --dark-green: #6FA22F;
    --light-gray: #F5F5F5;
    --text-color: #333333;
    --alert-color: #f3b333;
    --strong-color: #FF4B00;
}

* {
    box-sizing: border-box;
    font-family: "Zen Kaku Gothic New", sans-serif;
    font-weight: 400;
    font-style: normal;
}

strong {
    font-weight: 700;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100svh;
}

a {
    color: var(--dark-green);
}

/* 共通CSS */

header {
    display: flex;
    justify-content: space-between;
    background-color: var(--paste-green);
    padding: 5px 20px;
}

header a {
    text-decoration: none;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-left img {
    height: 55px;
}

.header-text {
    text-align: left;
    margin-left: 10px;
    color: var(--text-color);
}

.header-text span {
    font-size: 0.875rem;
    font-weight: 700;
}

.header-text h1 {
    margin: 0;
    font-size: 1.375rem;
    color: var(--dark-green);
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
}

.header-right img {
    height: 40px;
}

.header-right-text {
    font-size: 0.75rem;
    margin-left: 7px;
    color: var(--text-color);
}

.header-right-text a {
    display: block;
    font-size: 0.875rem;
}

/* 運行情報 */

.alert {
    display: flex;
    align-items: center;
    background-color: var(--dark-green);
    padding: 5px;
    height: fit-content;
}

.alert img {
    height: 40px;
}

.alert-text-wrapper {
    background-color: var(--paste-green);
    padding: 7px;
    margin-left: 10px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
}

.alert-text {
    display: none;
    font-weight: bold;
    width: fit-content;
    color: var(--text-color);
    font-size: 1rem;
}

.alert-text.fade-in {
    display: block;
    animation: alert-fade 0.5s ease-out forwards;
}

.alert-text.scroll {
    display: block;
    animation: alert-scroll 4s linear forwards;
}

@keyframes alert-fade {
    0% { opacity: 0; transform: translateY(-100%) scaleY(0.2); }
    70% { transform: translateY(10%); }
    100% { opacity: 1; transform: translateY(0) scaleY(1); }
}

@keyframes alert-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(-100% - 1rem)); }
}

/* 地図 */

.main-content {
    display: flex;
    flex: 1;
    align-items: stretch;
    min-height: 0;
}

nav {
    background-color: #fff;
    width: 30%;
    flex: 0 0 30%;
    overflow-y: auto;
}

.right {
    flex: 1 1 auto;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

.mapboxgl-popup-content {
    background-color: #fff !important;
    color: #333 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
    min-width: 300px !important;
    max-width: 80vw !important;
}
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
    border-top-color: #fff !important;
}
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
    border-bottom-color: #fff !important;
}

.popup-operator {
    font-size: 0.75rem;
    color: #555;
}

.popup-title {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 5px;
}

.popup-subtitle {
    font-size: 0.875rem;
    color: #555;
    margin-bottom: 5px;
}

.route {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 700;
}

.congestion-info {
    font-size: 0.875rem;
}

#route-info-btn {
    margin-top: 10px;
    padding: 8px 12px;
    background-color: var(--dark-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: .3s;
}

#route-info-btn:hover {
    background-color: var(--light-green);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--light-green);
}

.trip-detail-route {
    display: inline-block;
    font-size: 1rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-right: 5px;
}

.stop-info {
    position: relative;
    display: flex;
    flex-direction: row;
    border-bottom: 1px solid #eee;
    padding: 4px 0;
}

.stop-info:last-child, .current-stop {
    border-bottom: none;
}

.time {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 3rem;
    line-height: 1.2;
    color: var(--text-color);
}

.scheduled {
    font-size: 1rem;
    font-weight: 700;
}

.delayed {
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: line-through !important;
}

.updated {
    font-size: 1rem;
    color: var(--strong-color);
    font-weight: 700;
}

.stop-name-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 10px;
    color: var(--text-color);
}

.stop-name {
    font-size: 1rem;
    font-weight: 700;
}

.stop-name-kana {
    font-size: 0.75rem;
    color: #555;
}

.average-congestion {
    display: flex;
    flex-direction: column;
    margin-left: auto;
    align-items: center;
    justify-content: center;
}

.congestion-icon {
    width: 25px;
    height: 25px;
}

.congestion-value {
    font-size: 0.75rem;
    color: #555;
}

.current-bus {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 5px 10px;
}

.current-bus img {
    width: 30px;
    height: 30px;
}

.current-bus-label {
    margin-left: 5px;
    font-size: 1rem;
    color: #555;
}


/* 検索結果 */

.search-bar {
    position: relative;
    width: 100%;
    padding: 10px;
    padding-bottom: 0;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0 8px;
    background-color: #fff;
    max-width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.suggestion {
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.suggestion:last-child {
    border-bottom: none;
}

#background {
    display: none;
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 7;
    animation: fadeIn 0.3s ease-out forwards;
    cursor: pointer;
    height: 100%;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

#modal {
    display: none;
    z-index: 8;
    padding: 10px 20px;
    border-radius: 10px;
    background-color: #fff;
    position: absolute;
    inset: 0;
    width: max(80%, 400px);
    height: 70vh;
    margin: auto;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: popup 0.3s forwards;
}

@keyframes popup {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    80% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.search-result {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.search-result:last-child {
    border-bottom: none;
}

.result-operator {
    font-size: 0.75rem;
    color: #555;
}

.result-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.destination {
    font-size: 0.875rem;
}

/* 事業者選択 */

.operator-selection {
    padding: 10px;
}

#operator-form {
    display: flex;
    flex-direction: column;
    padding: 10px;
}

/* マイ停留所 */

.mystops {
    padding: 10px;
}

nav h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 10px;
    background-color: var(--paste-green);
    border-left: 10px solid var(--light-green);
    padding: 2px 10px;
}

#mystops-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    background-color: #fff;
    min-height: 10rem;
}

.mystop {
    padding: 10px;
    border-right: 1px solid #eee;
    cursor: pointer;
    flex-shrink: 0;
    width: min(60%, 500px);
    max-height: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow-x: hidden;
    overflow-y: auto;
}

.mystop:last-child {
    border-right: none;
}

.mystop-operator {
    font-size: 0.75rem;
    color: #555;
}

.mystop-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.timetable-link {
    color: #fff;
    text-decoration: none;
}

.route-info {
    margin: 3px 0;
}

.bottom-buttons {
    display: none;
}

/* 説明用 */

#description-background {
    display: none;
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 7;
    animation: fadeIn 0.3s ease-out forwards;
    cursor: pointer;
}

#service-description, #simple-mode-description {
    display: none;
    position: absolute;
    inset: 0;
    margin: auto;
    z-index: 9;
    padding: 20px 40px;
    border-radius: 10px;
    background-color: #fff;
    width: max(80%, 400px);
    height: fit-content;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: popup 0.3s forwards;
}

#service-description ul li {
    margin: 4px 0;
    color: var(--text-color);
    font-size: 0.875rem;
}

.service-description-section {
    font-size: 0.875rem;
    background-color: #F5F5F5;
    margin-bottom: 20px;
    padding: 8px 14px;
}

.service-description-section .flex {
    margin: 10px 0;
}

#service-description h2, #simple-mode-description h2 {
    margin-top: 0;
    font-weight: 700;
    background-color: var(--paste-green);
    border-left: 10px solid var(--dark-green);
    padding: 2px 10px;
}

.service-description-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-color);
}

button {
    margin: 8px;
    padding: 8px 12px;
    background-color: var(--dark-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: .3s;
}

button:hover {
    background-color: var(--light-green);
}

.main-content nav .locate-me-btn {
    margin-left: 0;
}

.red {
    color: var(--strong-color);
}

#service-description img {
    max-width: 30%;
    height: auto;
    max-height: 200px;
    margin: 10px 0;
}

#service-description .flex {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bus-icon {
    width: 40px;
    height: 40px;
}

.icon-description {
    color: #555;
    font-size: 0.875rem;
}

.buscom-image {
    display: block;
    margin: 10px auto !important;
    width: 40%;
}

#loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 20px;
    border-radius: 10px;
}

.loading-image {
    display: none;
    width: 200px;
    height: auto;
    animation: loadingAnimation .5s linear;
}

@keyframes loadingAnimation {
    0% { transform: translateY(0); }
    50% { transform: translateY(5px);}
    100% { transform: translateY(0); }
}

.mode-comparison-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* スマホ用CSS */

@media (max-width: 768px) {
    header {
        padding: 5px;
    }

    .header-right {
        display: none;
    }

    .main-content {
        position: relative;
        flex-direction: column;
    }

    nav {
        display: none;
        position: absolute;
        top: 0;
        width: 100%;
        height: 100%;
        padding-bottom: 100px;
        z-index: 5;
        animation: leftToRight 0.3s forwards;
    }

    @keyframes leftToRight {
        0% {
            transform: translateX(-100%);
        }
        100% {
            transform: translateX(0);
        }
    }

    .right {
        width: 100%;
    }

    .bottom-buttons {
        width: 100%;
        display: flex;
        gap: 10px;
        justify-content: center;
        padding: 10px;
        text-align: center;
        background-color: var(--dark-green);
        z-index: 6;
    }

    .bottom-buttons button {
        padding: 10px 20px;
        background-color: var(--light-green);
        color: #fff;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: .3s;
    }

    .bottom-buttons button:hover {
        background-color: var(--paste-green);
        color: var(--dark-green)
    }

    #close-menu-btn {
        display: none;
    }

    #modal {
        width: 92%;
        height: 90%;
    }

    #service-description, #simple-mode-description {
        width: 92%;
        height: 90%;
        padding: 10px 20px;
    }

    #service-description img {
        max-width: 100%;
    }

    .loading-image {
        width: 80vw;
    }
}
