/* ════════════════════════════════════════════════════════════
   BASE
   ════════════════════════════════════════════════════════════ */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
    font-size: 16px;
}

/* Larger base on desktop so all rem-sized elements scale up together */
@media (min-width: 700px) {
    html { font-size: 20px; }
    body { font-size: 1rem; }
}

/* ════════════════════════════════════════════════════════════
   TAB BAR
   ════════════════════════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.4rem 0.4rem 0;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
    flex: 1 0 auto;
    padding: 0.5rem 0.8rem;
    border: 1px solid #ccc;
    border-bottom: none;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 4px 4px 0 0;
    white-space: nowrap;
}

.tabs button.active {
    background: #007BFF;
    color: white;
    border-color: #007BFF;
}

/* ════════════════════════════════════════════════════════════
   TAB PANELS
   ════════════════════════════════════════════════════════════ */
#tab-content {
    padding: 0.75rem;
}

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

/* ════════════════════════════════════════════════════════════
   WHERE TAB — INTRO
   ════════════════════════════════════════════════════════════ */
.intro-text {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    font-size: 1.1rem;
}

/* ════════════════════════════════════════════════════════════
   WHERE TAB — MAP
   ════════════════════════════════════════════════════════════ */
#map-wrap {
    position: relative;  /* legend positions relative to this */
    width: 100%;
}

#map {
    width: 100%;
    height: 50vh;
    min-height: 250px;
    max-height: 500px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

/* ── Floating legend overlay ─────────────────────────────── */
#map-legend {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    background: rgba(255,255,255,0.92);
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: move;
    user-select: none;
    min-width: 130px;
}

#map-legend h4 {
    margin: 0 0 0.3rem;
    font-size: 0.75rem;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#legend-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #666;
    padding: 0;
    line-height: 1;
}

#legend-toggle:hover { color: #333; }

#legend-items { overflow: hidden; transition: max-height 0.2s ease; max-height: 200px; }
#legend-items.collapsed { max-height: 0; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    white-space: nowrap;
}

.legend-item svg { flex-shrink: 0; }

/* ── Animation status bar ────────────────────────────────── */
#anim-status {
    min-height: 1.4rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.82rem;
    color: #333;
    background: #f0f4ff;
    border-left: 3px solid #007BFF;
    border-radius: 0 0 3px 3px;
    display: none;   /* hidden when empty */
}

#anim-status.visible { display: block; }

/* ════════════════════════════════════════════════════════════
   WHERE TAB — TIMELINE
   ════════════════════════════════════════════════════════════ */
#timeline-container {
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem 0.5rem;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#tl-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.tl-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.tl-btn:hover { background: #f0f0f0; }

.tl-btn-default {
    padding: 0.25rem 0.65rem;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
}

.tl-btn-default:hover { background: #f0f0f0; }

.tl-btn-active {
    background: #0078d4 !important;
    color: white !important;
    border-color: #0078d4 !important;
}

.tl-btn-active:hover { background: #106ebe !important; }

#tl-range-btns {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-left: auto;
}

#tl-speed {
    padding: 0.25rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Track + handles */
#tl-slider-wrap {
    position: relative;
    padding-bottom: 2rem;  /* room for ticks and date labels */
}

#tl-track {
    position: relative;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    margin: 0.6rem 0.75rem 0;
}

#tl-range-fill {
    position: absolute;
    height: 100%;
    background: #007BFF;
    border-radius: 3px;
    pointer-events: none;
}

.tl-handle {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007BFF;
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 2;
    touch-action: none;
}

.tl-handle:active { cursor: grabbing; transform: translate(-50%, -50%) scale(1.2); }
.tl-handle:focus  { outline: 2px solid #0056b3; }

/* Tick marks */
#tl-ticks {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 1.4rem;
    pointer-events: none;
}

.tl-tick {
    position: absolute;
    width: 1px;
    height: 5px;
    background: #aaa;
    top: 2px;
    transform: translateX(-50%);
}

.tl-tick-year {
    height: 9px;
    width: 2px;
    background: #444;
}

.tl-tick-label {
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #666;
    white-space: nowrap;
    user-select: none;
}

.tl-tick-label-year {
    top: 11px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #222;
}

/* Date labels under handles */
#tl-labels {
    position: relative;
    height: 1rem;
    margin: 0 0.75rem;
    margin-top: 1.6rem; /* push below the ticks */
}

.tl-label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.68rem;
    color: #333;
    white-space: nowrap;
    background: #f9f9f9;
    padding: 0 2px;
}

/* ════════════════════════════════════════════════════════════
   WHERE TAB — RANGE STATUS
   ════════════════════════════════════════════════════════════ */
#range-status {
    font-size: 0.8rem;
    color: #555;
    text-align: center;
    padding: 0.3rem 0.5rem;
    font-style: italic;
}

/* ════════════════════════════════════════════════════════════
   WHERE TAB — ITINERARY TABLE
   ════════════════════════════════════════════════════════════ */
#itinerary-container {
    margin-top: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #ccc;
    -webkit-overflow-scrolling: touch;
}

#itinerary-table {
    width: 100%;
    border-collapse: collapse;
}

#itinerary-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#itinerary-table th {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #ddd;
    font-size: 1rem;
    background-color: #f5f5f5;
    font-weight: bold;
    text-align: left;
    white-space: nowrap;
    box-shadow: 0 2px 2px -1px rgba(0,0,0,0.1);
}

#itinerary-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #ddd;
    font-size: 1rem;
}

#itinerary-table tr.highlight-current { background-color: #e6f0ff; font-weight: bold; }
#itinerary-table tr.highlight-travel  { background-color: #fff3cd; font-weight: bold; }
#itinerary-table tr.selected          { background-color: #cce5ff; }

/* ════════════════════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════════════════════ */
.disclaimer {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #666;
}

/* ════════════════════════════════════════════════════════════
   MOBILE  (≤ 600px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

    #tab-content { padding: 0.5rem; }

    #map {
        height: 45vh;
        min-height: 220px;
        max-height: 350px;
    }

    #map-legend {
        font-size: 0.68rem;
        padding: 0.3rem 0.5rem;
    }

    /* Hide City/State and Nights columns */
    #itinerary-table th:nth-child(4),
    #itinerary-table td:nth-child(4),
    #itinerary-table th:nth-child(5),
    #itinerary-table td:nth-child(5) { display: none; }

    #itinerary-table th,
    #itinerary-table td {
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .tl-btn-default { font-size: 0.72rem; padding: 0.2rem 0.45rem; }
    #tl-range-btns { gap: 0.25rem; }
    .tl-tick-label      { font-size: 0.52rem; }
    .tl-tick-label-year { font-size: 0.6rem;  }

    .markdown-body .photo-float {
        float: none;
        display: block;
        margin: 0 auto 1rem;
        max-width: 100%;
    }
}

/* ════════════════════════════════════════════════════════════
   MARKDOWN CONTENT TABS
   ════════════════════════════════════════════════════════════ */
.markdown-body {
    max-width: 720px;
    line-height: 1.7;
    color: #222;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 1.4rem;
    margin-bottom: 0.4rem;
    color: #1a1a1a;
}

.markdown-body p   { margin: 0 0 1rem; }
.markdown-body a   { color: #007BFF; }

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
    margin: 0 0 1rem;
}

@media (min-width: 500px) {
    .markdown-body img {
        float: right;
        margin: 0 0 1rem 1.5rem;
        max-width: 280px;
    }
}

.markdown-body::after {
    content: "";
    display: table;
    clear: both;
}

.tab-error {
    color: #888;
    font-style: italic;
}

/* ════════════════════════════════════════════════════════════
   WHEN TAB — MONTHLY CALENDAR
   ════════════════════════════════════════════════════════════ */
.cal-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.cal-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.cal-share .cal-btn {
    text-decoration: none;
    font-size: 0.82rem;
}

.cal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-left: 0.4rem;
}

.cal-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
}

.cal-btn:hover { background: #f0f0f0; }

.cal-arrow {
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.1rem 0.6rem;
}

.cal-grid {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

/* ════════════════════════════════════════════════════════════
   STATES MAP MODAL
   ════════════════════════════════════════════════════════════ */
#states-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#states-modal-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    width: min(96vw, 900px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#states-modal-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #ddd;
    background: #f7f7f7;
    border-radius: 8px 8px 0 0;
}

#states-modal-title {
    font-weight: 600;
    font-size: 1rem;
}

#states-modal-subtitle {
    font-size: 0.8rem;
    color: #666;
}

#states-modal-close {
    margin-left: auto;
    border: none;
    background: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #555;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

#states-modal-close:hover { background: #e8e8e8; }

#states-modal-body {
    overflow: auto;
    padding: 0.75rem;
    flex: 1;
}

#states-svg {
    width: 100%;
    height: auto;
    display: block;
}

#states-svg .state-visited:hover {
    filter: brightness(0.85);
    cursor: default;
}

.cal-dow-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.cal-dow {
    text-align: center;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

.cal-week { border-bottom: 1px solid #ddd; }
.cal-week:last-child { border-bottom: none; }

.cal-days-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #eee;
}

.cal-day {
    min-height: 36px;
    padding: 4px 6px;
    border-right: 1px solid #eee;
    font-size: 0.85rem;
    color: #333;
}

.cal-day:last-child { border-right: none; }
.cal-day-out { color: #bbb; background: #fafafa; }

.cal-day-today .cal-day-num {
    background: #007BFF;
    color: white;
    border-radius: 50%;
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    line-height: 1.5em;
    text-align: center;
}

.cal-bar-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 22px;
    margin-bottom: 2px;
}

.cal-bar-spacer {}

.cal-bar {
    border-radius: 3px;
    overflow: hidden;
    margin: 1px 0;
    cursor: default;
}

.cal-bar-past    { background: #4CAF50; }
.cal-bar-current { background: #007BFF; }
.cal-bar-future  { background: #e07070; }

.cal-bar-label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.72rem;
    color: white;
    line-height: 20px;
    padding: 0 5px;
    pointer-events: none;
}

@media (max-width: 600px) {
    .cal-title     { font-size: 1rem; }
    .cal-dow       { font-size: 0.65rem; padding: 0.2rem 0; }
    .cal-day       { min-height: 28px; font-size: 0.72rem; padding: 2px 3px; }
    .cal-bar-label { font-size: 0.62rem; }
}

/* ════════════════════════════════════════════════════════════
   CHANGELOG (About tab)
   ════════════════════════════════════════════════════════════ */
#changelog { margin-top: 1.5rem; }

#changelog h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

#changelog-scroll {
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#changelog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#changelog-table thead th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
    padding: 0.4rem 0.6rem;
    text-align: left;
    white-space: nowrap;
}

#changelog-table tbody tr:nth-child(even) { background: #fafafa; }

#changelog-table td {
    padding: 0.4rem 0.6rem;
    vertical-align: top;
    border-bottom: 1px solid #eee;
}

#changelog-table td.cl-date {
    white-space: nowrap;
    color: #555;
    width: 7rem;
}
