@charset "UTF-8";

/* ==============================================
   Niigata Run - Base Styles
   ============================================== */

/* --- Reset & Box Model --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
    line-height: 1.7;
    color: #333;
    background-color: #f5f5f5;
}

a {
    color: #337ab7;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

a:hover,
a:focus {
    color: #23527c;
    text-decoration: underline;
    opacity: 0.8;
}

/* メインコンテンツ内のテキストリンクを強調 */
.main-content p a,
.main-content li a,
.race-table-info a:not(.btn) {
    text-decoration: underline;
    text-decoration-color: rgba(51, 122, 183, 0.4);
    text-underline-offset: 2px;
}

.main-content p a:hover,
.main-content li a:hover,
.race-table-info a:not(.btn):hover {
    text-decoration-color: #23527c;
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Container --- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 15px;
}

/* --- Layout --- */
.content-area {
    display: flex;
    gap: 30px;
    padding: 20px 0;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.sidebar {
    width: 300px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .content-area {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }
}

/* --- Site Header --- */
.site-header {
    background-color: #fff;
    border-bottom: 1px solid #e7e7e7;
    padding: 15px 0;
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.site-branding {
    flex-shrink: 0;
}

.site-title-link {
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

.site-title-link:hover {
    text-decoration: none;
    color: #337ab7;
}

.site-description {
    font-size: 0.85em;
    color: #777;
    margin-top: 2px;
}

/* --- Header Search --- */
.header-search-wrap {
    flex: 0 0 280px;
}

.search-input-group {
    display: flex;
}

.search-input {
    flex: 1;
    padding: 8px 15px;
    border: 1px solid #ccc;
    border-radius: 20px 0 0 20px;
    font-size: 0.9em;
    outline: none;
}

.search-input:focus {
    border-color: #337ab7;
}

.search-btn {
    padding: 8px 15px;
    border: 1px solid #337ab7;
    border-left: none;
    border-radius: 0 20px 20px 0;
    background-color: #337ab7;
    color: #fff;
    cursor: pointer;
}

.search-btn:hover {
    background-color: #286090;
}

@media (max-width: 768px) {
    .header-search-wrap {
        flex: 1 1 100%;
        max-width: 400px;
        margin: 0 auto;
    }
}

/* --- Breadcrumb --- */
.breadcrumb-nav {
    background-color: #f8f8f8;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
    font-size: 0.85em;
}

.breadcrumb {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.breadcrumb-item+.breadcrumb-item::before {
    content: ">";
    margin-right: 5px;
    color: #999;
}

.breadcrumb-item.active {
    color: #666;
}

/* --- Global Navigation --- */
.global-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #f8f9fa;
    border-top: 1px solid #e7e7e7;
    display: flex;
    justify-content: space-around;
    padding: 8px 0 12px;
    font-size: 0.8em;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999999;
}

/* WordPress管理バーが表示されている時の位置調整 */
body.admin-bar .global-nav {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .global-nav {
        /* モバイルで上部固定にする場合（現状は下部固定なので予備的） */
        top: 46px;
    }
}

.global-nav a {
    color: #555;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.global-nav a i {
    font-size: 1.5em;
    margin-bottom: 3px;
    color: #337ab7;
}

.global-nav-padder {
    display: block;
    height: 60px;
}

/* PC: 上部固定ナビ */
@media (min-width: 768px) {
    .global-nav {
        position: fixed;
        top: 0;
        bottom: auto;
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 40px;
        padding: 15px 0;
        font-size: 1em;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid #e7e7e7;
        border-top: none;
    }

    .global-nav a {
        flex-direction: row;
        gap: 8px;
    }

    .global-nav a i {
        font-size: 1.2em;
        margin-bottom: 0;
    }

    body {
        padding-top: 60px;
    }

    .global-nav-padder {
        display: none;
    }
}

/* --- Site Footer --- */
.site-footer {
    background-color: #333;
    color: #aaa;
    padding: 20px 0;
    text-align: center;
    font-size: 0.85em;
}

/* --- Article --- */
article {
    background: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.entry-title {
    font-size: 1.3em;
    margin-bottom: 10px;
}

.entry-title a {
    color: #333;
}

.entry-title a:hover {
    color: #337ab7;
}

/* --- Widget --- */
.widget {
    background: #fff;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.widget-title {
    font-size: 1.1em;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #337ab7;
}

/* --- Utility --- */
.text-center {
    text-align: center;
}

.margin-top-20 {
    margin-top: 20px;
}

.margin-bottom-20 {
    margin-bottom: 20px;
}

/* --- Responsive Tables (Mobile) --- */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {

    .table-stacked th,
    .table-stacked td {
        display: block;
        width: 100% !important;
        text-align: left;
    }

    .table-stacked th {
        background-color: #f4f6f8;
        border-bottom: none;
        padding-bottom: 5px;
        padding-top: 15px;
    }

    .table-stacked td {
        border-bottom: 1px solid #dee2e6;
        padding-top: 5px;
        padding-bottom: 15px;
    }

    .table-stacked tbody tr:last-child td {
        border-bottom: 1px solid #dee2e6;
        /* 最後の行も線を入れる */
    }

    .race-course-card .table-stacked th,
    .race-course-card .table-stacked td {
        padding-left: 0;
        padding-right: 0;
    }
}

/* ==============================================
   Phase-based Layout & UI (Flexbox Order)
   ============================================== */
.entry-body {
    display: flex;
    flex-direction: column;
}

/* --- Phase 1: エントリー期間中 --- */
.entry-body.phase-1 .race-intro-section {
    order: 1;
}

.entry-body.phase-1 .race-courses-section {
    order: 2;
}

.entry-body.phase-1 .race-data-section {
    order: 3;
}

.entry-body.phase-1 .race-access-section {
    order: 4;
}

.entry-body.phase-1 .race-details-section {
    order: 5;
}

.entry-body.phase-1 .race-timeline-section {
    order: 6;
}

.entry-body.phase-1 .race-history-section {
    order: 7;
}

/* --- Phase 2: 大会直近 --- */
.entry-body.phase-2 .race-intro-section {
    order: 1;
}

.entry-body.phase-2 .race-timeline-section {
    order: 2;
}

.entry-body.phase-2 .race-access-section {
    order: 3;
}

.entry-body.phase-2 .race-details-section {
    order: 4;
}

.entry-body.phase-2 .race-data-section {
    order: 5;
}

.entry-body.phase-2 .race-courses-section {
    order: 6;
}

.entry-body.phase-2 .race-history-section {
    order: 7;
}

/* フェーズ2のエイド情報強調 */
.entry-body.phase-2 .aid-station-row {
    background-color: #fff3e0 !important;
}

.entry-body.phase-2 .aid-station-row th {
    color: #e65100;
}

.entry-body.phase-2 .aid-features-content {
    font-weight: bold;
    color: #d84315;
}

/* フェーズ2のタイムラインアコーディオン制御（常に開く・トグルアイコン非表示） */
.entry-body.phase-2 .timeline-accordion summary {
    pointer-events: none;
}

.entry-body.phase-2 .timeline-accordion .accordion-icon {
    display: none;
}

/* --- Phase 3: 大会終了後 --- */
.entry-body.phase-3 .race-intro-section {
    order: 1;
}

.entry-body.phase-3 .race-data-section {
    order: 2;
}

.entry-body.phase-3 .race-details-section {
    order: 3;
}

.entry-body.phase-3 .race-courses-section {
    order: 4;
}

.entry-body.phase-3 .race-access-section {
    order: 5;
}

.entry-body.phase-3 .race-timeline-section {
    order: 6;
}

.entry-body.phase-3 .race-history-section {
    order: 7;
}

/* タイムラインアコーディオン基本スタイル */
.timeline-accordion summary::-webkit-details-marker {
    display: none;
}

.timeline-accordion[open] .accordion-icon {
    transform: rotate(180deg);
}

.timeline-accordion .accordion-icon {
    transition: transform 0.3s ease;
}

/* Shuttle map button hover */
.shuttle-map-btn:hover {
    background-color: #28a745 !important;
    color: #fff !important;
}

/* ==============================================
   視認性向上（Typography & Spacing & Tables）
   ============================================== */

/* --- 1. セクション間の余白（Section Spacing） --- */
.main-content section,
.race-section {
    margin-top: 30px !important;
    margin-bottom: 30px !important;
}

@media (min-width: 768px) {

    .main-content section,
    .race-section {
        margin-top: 40px !important;
        margin-bottom: 40px !important;
    }
}

@media (min-width: 992px) {

    .main-content section,
    .race-section {
        margin-top: 50px !important;
        margin-bottom: 50px !important;
    }
}

/* --- 2. 行間・タイポグラフィ --- */
/* 本文の基本行間は既に body で 1.7 に設定されていますが、コンポーネント内でも明示的に当てます */
.entry-body p,
.entry-body li,
.entry-body dd,
.entry-body dt {
    line-height: 1.7;
}

.entry-body h2,
.archive-next-race-date {
    margin-top: 2.5rem;
    margin-bottom: 24px;
}

.entry-body h3,
.race-section h3,
.archive-section-title {
    margin-top: 2rem;
    margin-bottom: 16px;
}

/* --- 3. テーブル（表）と凝集力強化 --- */
.entry-body table,
.race-course-card table,
.archive-history-section table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.entry-body table th,
.entry-body table td,
.race-course-card table th,
.race-course-card table td,
.archive-history-section table th,
.archive-history-section table td {
    padding: 10px 12px !important;
    line-height: 1.7;
    border: 1px solid #e0e0e0 !important;
}

.entry-body table th,
.race-course-card table th,
.archive-history-section table th {
    background-color: #f5f5f5;
    vertical-align: middle;
}

.entry-body table th,
.race-course-card table th {
    text-align: left;
    width: 25%;
    min-width: 100px;
}

/* スマホ閲覧時のはみ出し対策（既存の .table-responsive 以外にも網羅的に適用する） */
@media (max-width: 767px) {

    .entry-body table:not(.table-stacked),
    .race-course-card table:not(.table-stacked) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        /* テキストの折り返しを防ぎ、横スクロールさせる */
    }
}

/* --- 4. 画面端のセーフエリア（Container Padding） --- */
/* 既存の .container に padding: 0 15px; がありますが、さらにスマホ時に確実に保持させます */
@media (max-width: 767px) {
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

/* ==============================================
   インラインスタイルからの移行（外部化）
   ============================================== */

/* --- 汎用アラート系 --- */
.race-alert {
    padding: 10px;
    margin-top: 10px;
    font-weight: bold;
}

.race-alert-past {
    background: #eee;
    border-color: #ddd;
    color: #555;
}

.race-alert-predicted {
    background: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}

.race-label-predicted {
    margin-left: 5px;
    vertical-align: middle;
}

/* --- ヘッダー領域 --- */
.race-header-meta {
    margin-top: 1em;
    padding: 15px;
    background: #f5f8fa;
    border-radius: 5px;
}

.race-date-row {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.race-organizer-row {
    font-size: 0.9em;
    color: #666;
    margin-top: 3px;
}

/* --- エントリー領域 --- */
.race-entry-cta {
    margin: 1.5em 0;
    text-align: center;
}

.race-entry-status {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.race-entry-before {
    background: #e9ecef;
    color: #495057;
}

.race-entry-closed {
    background: #f8d7da;
    color: #721c24;
}

.race-entry-status-text {
    font-weight: bold;
    font-size: 1.1em;
    margin: 0;
}

.btn.race-btn-external {
    background-color: #6c757d;
    border: none;
    padding: 15px;
    font-weight: bold;
    color: #fff;
}

.btn.race-btn-entry {
    background-color: #e03e2d;
    border: none;
    padding: 15px;
    font-weight: bold;
    color: #fff;
}

.race-entry-countdown {
    margin-top: 10px;
    font-size: 1.1em;
    color: #666;
    font-weight: bold;
}

.race-entry-countdown-urgent {
    margin-top: 10px;
    font-size: 1.2em;
    color: #e03e2d;
    font-weight: bold;
    background: #fff0f0;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
    border: 1px solid #e03e2d;
}

.countdown-days {
    font-size: 1.3em;
    color: #e03e2d;
}

.race-entry-countdown-urgent .countdown-days {
    font-size: 1.4em;
}

.race-entry-period {
    margin-top: 15px;
    font-size: 1.1em;
    color: #333;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.race-entry-period-label {
    background: #666;
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    vertical-align: middle;
}

.race-entry-period-dates {
    font-weight: bold;
    margin-left: 8px;
    vertical-align: middle;
}

.race-entry-site {
    font-size: 0.9em;
}

/* --- コンテンツ領域（見出しなど） --- */
.heading-timeline {
    border-left: 5px solid #ff9800;
    padding-left: 10px;
    margin-bottom: 0;
    font-weight: bold;
    font-size: 1.3em;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-accordion-summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    outline: none;
}

.accordion-icon {
    color: #ff9800;
    font-size: 0.8em;
}

.race-timeline-container {
    margin-top: 15px;
}

.timeline-event-block.has-multiple {
    margin-bottom: 8px;
}

.timeline-event-block.is-last {
    margin-bottom: 0;
}

.timeline-critical-icon {
    margin-left: 5px;
    color: #c82333;
}

.heading-data {
    border-left: 5px solid #000;
    padding-left: 10px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1.3em;
}

.trend-box {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.trend-box-note {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    margin-bottom: 0;
}

.past-results-box {
    background: #f0f0f0;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    font-size: 0.95em;
}

.weather-source-note {
    font-size: 0.85em;
    color: #666;
    text-align: right;
    margin-bottom: 5px;
}

.weather-chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    margin-bottom: 15px;
}

.weather-content {
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.heading-access {
    border-left: 5px solid #28a745;
    padding-left: 10px;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.3em;
}

.access-info-box {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 5px;
    padding: 15px;
    font-size: 1.05em;
    color: #2e7d32;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.access-info-item {
    flex: 1 1 100%;
}

.access-icon {
    width: 20px;
}

.access-highlight {
    font-weight: bold;
}

.shuttle-map-btn {
    display: inline-block;
    margin-left: 10px;
    padding: 3px 10px;
    background: #fff;
    border: 1px solid #28a745;
    color: #28a745;
    border-radius: 3px;
    font-size: 0.9em;
    text-decoration: none;
    vertical-align: middle;
}

.heading-memo {
    border-left: 5px solid #e03e2d;
    padding-left: 10px;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.3em;
}

.participant-memo-box {
    background: #fffcf5;
    border: 1px solid #faebcc;
    border-radius: 5px;
    padding: 15px;
    font-size: 0.95em;
}

.participant-memo-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.participant-memo-list li {
    margin-bottom: 8px;
}

.participant-memo-list li:last-child {
    margin-bottom: 0;
}

.memo-icon {
    color: #e03e2d;
    width: 20px;
}

.heading-courses {
    border-left: 5px solid #337ab7;
    padding-left: 10px;
    font-weight: bold;
    font-size: 1.3em;
}

.race-course-card {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    background: #fff;
}

.course-card-title {
    margin-top: 0;
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.course-distance {
    font-size: 0.8em;
    color: #666;
    font-weight: normal;
}

.course-label-wheelchair {
    font-size: 0.6em;
    vertical-align: middle;
    margin-left: 5px;
}

.course-info-table th {
    width: 30%;
    background: #f9f9f9;
}

.course-info-table {
    margin-bottom: 0;
}

/* --- レース履歴テーブル (part-race-history-table) --- */
.history-row-current {
    font-weight: bold;
}

.history-cell-date {
    vertical-align: middle;
    white-space: nowrap;
}

.history-cell-middle {
    vertical-align: middle;
}

.history-label-predicted {
    font-size: 0.8em;
    margin-left: 3px;
}

.table-head-date,
.table-head-action {
    white-space: nowrap;
}

.table-head-weather {
    min-width: 120px;
}

.table-head-note {
    font-size: 0.8em;
    margin-left: 1.5em;
}

/* --- アーカイブ（大会一覧）ページ (taxonomy-race_name.php) --- */
.archive-next-race-panel {
    border: 2px solid #337ab7;
}

.archive-panel-title-bold {
    font-weight: bold;
}

.archive-next-race-date {
    margin-top: 0;
    font-weight: bold;
    font-size: 1.8em;
}

.archive-label-predicted {
    margin-left: 5px;
    vertical-align: middle;
    font-size: 0.8em;
}

.archive-entry-alert {
    margin-bottom: 10px;
}

.archive-section-title {
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.archive-section-title-bold {
    font-weight: bold;
    font-size: 1.3em;
}

.archive-trend-title {
    margin-top: 0;
    font-size: 1em;
    font-weight: bold;
    color: #666;
}

.archive-trend-value {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
}

.archive-excluded-races-alert {
    font-size: 0.9em;
    margin-bottom: 15px;
}

.archive-excluded-races-list {
    margin-bottom: 0;
    padding-left: 20px;
    margin-top: 5px;
}

.archive-weather-chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.archive-history-section {
    margin-top: 2em;
}