:root {
    --primary-color: #2a7ae2;
    --btn-bg: #fff;
    --btn-hover-bg: rgba(42, 122, 226, 0.1);
    --bg-header: #2a7ae2;
    --bg-footer: #333;
    --text-footer: #fff;
    --container-max-width: 1000px;
    --spacing: 1rem;
}

/* can-scroll 用スタイル */
.can-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

header a:link,
a:visited,
a:hover,
a:active {
    text-decoration: none;
    color: black;
}

input {
    font-size: 16px;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
}

.container {
    position: relative;
    width: 100%;
    height: auto !important;
    height: 100%;
    min-height: 100%;
}

header {
    background: var(--bg-header);
    color: white;
    overflow: hidden;
    transition: height 0.3s ease;
    z-index: 1000;

    .header-container {
        background: var(--bg-header);
        color: white;
        max-width: var(--container-max-width);
        margin: 0 auto;
        padding: 10px var(--spacing);
        display: grid;
        grid-template-columns: 1fr 44px;
        grid-row: 1fr;
        align-items: stretch;

        @media (max-width: 650px) {
            flex-direction: column;
            align-items: flex-start;
        }

    }

    .logo-nav {
        grid-column: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }

    h1 {
        min-width: max-content;
        grid-column: 1;
        margin: 0 20px;

        @media (max-width: 650px) {
            width: 100%;
            justify-content: center;
            align-items: center;
        }
    }

    #logo {
        font-size: 1.5rem;
        font-weight: bold;
        color: white;
        text-decoration: none;
        display: flex;
        justify-content: center;
        align-items: center;

    }

    #nav {
        position: relative;
        display: flex;
        align-items: center;

        @media (max-width: 650px) {
            width: 100%;
            display: flex;
            flex-direction: column;
        }

        button {
            margin-right: 0;
            color: white;
            background: var(--bg-header);
            padding: 0.5rem 1rem;
            border: 1px solid var(--primary-color);
            border-radius: 4px;
        }

        button:hover {
            cursor: pointer;
            text-decoration: underline;
        }


        .nav-list {
            list-style: none;
            display: flex;
            padding: 0;
            margin: 0;

            @media(max-width: 650px) {
                flex-direction: row;
                overflow-x: auto;
            }

            li {
                @media (max-width: 650px) {
                    flex: none;
                }

                button {
                    /* 幅を内容に合わせる */
                    width: auto;
                    padding: 0.5rem 1rem;
                    text-align: center;

                    @media (max-width: 650px) {
                        white-space: nowrap;
                    }
                }
            }
        }
    }

    #search-toggle {
        grid-column: 2;
        background: none;
        border: none;
        cursor: pointer;
        display: grid;
        place-items: center;
        align-self: center;
        padding: 0;
    }

    #search-box {
        grid-column: 1/3;
        display: block;
        margin: 0;
        padding: 0;
        border: 1px solid var(--primary-color);
        border-radius: 4px;
        outline: none;
        background: white;
        z-index: 1001;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    }

    #search-box:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(42, 122, 226, 0.2);
    }

    #search-box.visible {
        margin: 0.5rem auto;
        max-height: 100px;
        padding: 0.5rem 1rem;
        opacity: 1;
    }

    #nav button {
        border: none;
    }
}

footer.footer {
    background: var(--bg-footer);
    color: var(--text-footer);
    padding: var(--spacing) 0;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;

    p {
        margin: 0;
        font-size: 0.9rem;
    }

    a {
        color: var(--text-footer)
    }
}


body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    overflow-y: scroll;

    /*収まらない場合に折り返す*/
    overflow-wrap: anywhere;
    /* 単語の分割はデフォルトに依存 */
    word-break: normal;
    /* 禁則処理を厳格に適用 */
    line-break: strict;
}


main {
    position: relative;
    padding: var(--spacing);
    padding-bottom: calc(var(--spacing) * 6);
    max-width: var(--container-max-width);
    margin: 0 auto;
}


/* ローディングオーバーレイ */
#loading-overlay {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 4em auto 1em;
    align-self: center;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

p.note {
    color: #666;
    font-size: 0.9rem;

    a {
        color: #666 !important;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    -webkit-text-size-adjust: 100%;
    line-break: anywhere;

    th,
    td {
        padding: 0.5em;
        border: 1px solid #ccc;
        text-align: left;
    }
}

table.sessions-table {
    th.name {
        min-width: 11.5em
    }

    td.period {
        word-break: keep-all;
        overflow-wrap: normal;
    }
}

table.bill-info-votes-count-table {
    td.vote {
        min-width: 2em;
        width: 1em;
        white-space: nowrap;
        text-align: right;
    }

    tbody tr:nth-child(odd) {
        background-color: #fCfCfC;
        /* 奇数行の背景色 */
    }
}

table.bill-info-votes-table {
    th.name {
        min-width: 9em
    }

    th.vote {
        width: 2em;
        text-align: center;
    }
}

table.member-info-table th {
    width: 1em;
    white-space: nowrap;
}

table.member-career-table {
    font-size: 0.85em;
    border: 1px solid #ccc;
}

.table-wrapper {
    border: 1px solid #ccc;
    border-radius: 0.375rem;
    overflow: hidden;
}

table.bill-info-votes-table,
table.member-info-votes-table {
    font-size: 0.85em;
    margin: 0;

    th,
    td {
        border-left: none;
        border-right: none;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
    }

    thead th {
        border-top: none;
    }

    tbody td {
        border-bottom: none;
    }

    .decision-date {
        min-width: 6rem;
        text-align: center;

        @media (width < 600px) {
            display: none;
        }
    }

    .vote {
        min-width: 3rem;
        text-align: center;
    }

    div.name {
        display: flex;
        gap: 5px;
        align-items: center;

        img {
            width: 1em;
            height: 1em;
            margin: 5px
        }
    }
}

/* ホバー可能な行にのみ適用 */
.sessions-table tbody tr:hover,
.bills-table tbody tr:hover,
.districts-table tbody tr:hover,
.factions-table tbody tr:hover,
.members-table tbody tr:hover,
.bill-info-votes-table tbody tr:hover,
.member-info-votes-table tbody tr:hover {
    background: #f0f0f0;
}

/* クリック可能行にカーソルを表示 */
tr[data-session]:hover,
tr[data-bill-id]:hover,
tr[data-type]:hover,
tr[data-member]:hover,
tr[data-search-bill-id]:hover,
tr[data-search-member]:hover {
    cursor: pointer;
}

/* 非ホバー行 */
.no-hover:hover {
    background: transparent;
    cursor: default;
}

span.vote-green {
    font-weight: bold;
    color: rgb(109, 153, 109)
}

span.vote-red {
    font-weight: bold;
    color: rgb(214, 95, 95)
}

span.vote-gray {
    font-weight: bold;
    color: gray;
}

h2.bill-title {
    margin-top: 0;
}

div.bill-meta-data {
    font-size: 0.85em;
    margin: 0.3em 0;
    font-weight: bold;
    color: gray;
}

/* アコーディオンスタイル改善 */
details.summary-details {
    margin: 1em 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;

    summary {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        padding: 0.75em 1em;
        list-style: none;
        cursor: pointer;
        background-color: #f9f9f9;
        font-weight: bold;
        transition: background-color 0.3s ease;
    }

    summary::marker,
    summary::-webkit-details-marker {
        display: none;
    }

    div.summary-bg-gray {
        padding: 0.5em 1em;
        background-color: #f5f5f5;
    }

    button {
        padding: 0.25em 0.5em;
        cursor: pointer;
        margin-right: 0.5em;
        background-color: #FFF;
        border: 1px solid #ddd;
        border-radius: 4px;
        transition: background-color 0.3s ease;
    }

    button.active {
        cursor: default;
        background-color: #bbb;
        color: white;
        border: #aaa 1px solid;
    }

    div.summary-container {
        font-size: 0.9em;
        padding: 1em;
        background-color: #fff;

        h4 {
            margin-block-end: 0.8em
        }

        p {
            white-space: pre-wrap;
            word-break: break-word;
        }

        ul {
            margin-block-start: 0.8em
        }

        li {
            margin-block-start: 0.5em;
            margin-block-end: 0.5em;
        }
    }

    table {
        background-color: #fff;

        tr th {
            min-width: 7em;
            width: 30%;
        }
    }
}

details.summary-details[open] summary {
    background-color: #e9e9e9;
}

.sessions-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    padding: 0;

    li {
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        transition: box-shadow 0.2s ease, transform 0.2s ease;
        cursor: pointer;

        .session-name {
            font-weight: bold;
            /* color: #2a7ae2; */
            margin-bottom: 0.5rem;
            font-size: 1rem;
        }

        .session-period {
            font-size: 0.85rem;
            color: #666;
            white-space: nowrap;
            margin-top: 0.25rem;
        }
    }

    li:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: translateY(-2px);
    }
}

.bills-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    padding: 0;

    li {
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        transition: box-shadow 0.2s ease, transform 0.2s ease;
        cursor: pointer;

        .bill-type {
            font-weight: bold;
            color: #2a7ae2;
            margin-bottom: 0.5rem;
            font-size: 0.9rem;
        }

        .bill-title {
            font-size: 1.1rem;
            margin-bottom: 0.5rem;
        }

        .bill-date {
            font-size: 0.85rem;
            color: #666;
        }
    }

    li:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: translateY(-2px);
    }
}


.districts-list,
.factions-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 0;

    li {
        font-weight: bold;
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        padding: 0.75rem 1rem;
        text-align: center;
        transition: box-shadow 0.2s ease, transform 0.2s ease;
        cursor: pointer;
    }

    li:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: translateY(-2px);
    }
}

.members-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 0;

    li {
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        transition: box-shadow 0.2s ease, transform 0.2s ease;
        cursor: pointer;

        .member-name {
            font-weight: bold;
            font-size: 1rem;
        }

        .member-district,
        .member-faction {
            font-size: 0.85rem;
            color: #666;
        }
    }

    li:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: translateY(-2px);
    }
}

/* ヘルプアイコン */
#help-icon {
    width: 1em;
    height: 1em;
    margin-left: 0.5em;
    cursor: pointer;
    vertical-align: middle;
}

/* モーダル共通 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    max-width: calc(var(--container-max-width) * 0.9);
    max-height: 80%;
    overflow: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.modal-content .modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
}

span[data-tooltip] {
    position: relative;
    display: inline-block;
    cursor: pointer;
    text-decoration: underline;
}

.custom-tooltip {
    position: absolute;
    z-index: 9999;
    background-color: rgba(60, 60, 60, 0.9);
    color: #fff;
    padding: 0.5em 0.75em;
    border-radius: 4px;
    font-size: 0.85em;
    max-width: 250px;
    word-break: break-word;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.twitter-share-button-container {
    position: absolute;
    top: var(--spacing);
    right: var(--spacing);
}