@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap");

:root {
  --bg-gradient-start: var(--bg);
  --bg-gradient-end: var(--bg);
  --card-bg-color: var(--surface);
  --card-border-color: var(--border);
  --text-primary-color: var(--text);
  --text-secondary-color: var(--muted);
  --accent-color: var(--primary);
  --timeline-bg-color: rgba(0, 0, 0, 0.05);
  --timeline-night-color: rgba(0, 0, 0, 0.15);
  --map-color: var(--surface-2);
  --map-land-color: var(--border);
  --map-marker-color: var(--primary);
  --map-hover-color: var(--primary);
}

[data-theme="dark"] {
  --timeline-bg-color: rgba(255, 255, 255, 0.08);
  --timeline-night-color: rgba(0, 0, 0, 0.4);
  --map-color: var(--surface-2);
  --map-land-color: var(--border);
}

body {
  font-family: "Inter", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text-primary-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  box-sizing: border-box;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 6vw 60px;
}

/* Map Section */
.featured-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 25px;
  overflow: hidden; /* Important for rounding SVG */
  box-shadow: var(--shadow);
  margin-bottom: 40px;
  position: relative;
}

#world-map-svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--map-color);
}

#world-map-svg .country {
  fill: var(--map-land-color);
  stroke: var(--bg);
  stroke-width: 0.5;
  transition: fill 0.2s ease;
}

#world-map-svg .country:hover,
#world-map-svg .country.marker-hover {
  fill: var(--map-hover-color);
  opacity: 0.8;
}

/* Map Markers */
.map-marker {
  fill: var(--map-marker-color);
  stroke: #fff;
  stroke-width: 1.5;
  cursor: pointer;
  transition: r 0.3s ease;
}

.map-marker:hover {
  r: 8;
}

.map-marker.dst-active {
  fill: #e63946;
}

.map-city-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.map-city-card .name { font-weight: 700; margin-bottom: 2px; }
.map-city-card .time { color: var(--accent-color); font-weight: 600; }

.leader-line {
    stroke: var(--text-secondary-color);
    stroke-width: 1;
    stroke-dasharray: 4;
    opacity: 0.6;
}

/* Control Panel layout (visual style comes from shared .control-panel in styles.css) */
.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Center alignment */
    width: 100%;
    gap: 20px;
    flex-wrap: wrap;
}

.control-timeline {
    width: 100%;
    padding-top: 8px; /* Slight spacing from header */
}

.panel-left, .panel-right {
    flex: 0 0 auto;
}

.reference-time-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ref-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: -0.01em;
}

.ref-header i {
    font-size: 0.8rem;
    color: var(--accent-color);
}

.ref-clock {
    display: flex;
    flex-direction: column;
}

.clock-time {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text) 0%, var(--muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.clock-date {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }
    
    .reference-time-wrapper {
        border-right: none;
        padding-right: 0;
        margin-right: 0;
        align-items: center;
        text-align: center;
    }
    
    .ref-header {
        justify-content: center;
    }
    
    .ref-clock {
        align-items: center;
    }
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pill-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 10px 20px;
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.pill-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 106, 167, 255), 0.1);
}

/* .pill-btn uses shared styles from styles.css */

.pill-btn.live {
    background: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--muted);
    transition: background-color 0.2s;
}

.pill-btn.live .live-dot {
    background-color: #e63946;
    box-shadow: 0 0 8px #e63946;
    animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(230, 57, 70, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(230, 57, 70, 0);
    }
}

/* Timeline Bars */
.timeline-bar {
    position: relative;
    height: 40px;
    background: var(--timeline-bg-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.global-timeline {
    height: 48px; /* Slightly taller for main control */
    border-radius: 16px;
    border: 1px solid var(--border);
}

.timeline-bar::before,
.timeline-bar::after {
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--timeline-night-color);
    pointer-events: none;
}
.timeline-bar::before { width: 25%; left: 0; }
.timeline-bar::after { width: 20.83%; right: 0; }

.time-marker {
    position: absolute;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-color);
    transform: translateX(-50%);
    z-index: 2;
    transition: left 0.3s ease; /* Smoother movement */
}

.global-timeline .time-marker {
    width: 6px;
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.5);
}

/* Ticks */
.timeline-scale {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tick {
    position: absolute;
    bottom: 0;
    border-left: 1px solid var(--text-secondary-color);
    opacity: 0.3;
}
.tick.major { height: 12px; }
.tick.minor { height: 6px; }

.tick .label {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-secondary-color);
}

#timeline-dashboard {
  margin-top: 25px;
}

/* Card List (Matches Flag Viewer Grid Items) */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 25px;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 30px;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.city-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.city-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.city-time {
    font-size: 0.95rem;
    color: var(--muted);
}

.time-diff {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
    background: rgba(var(--primary-rgb, 106, 167, 255), 0.1);
    padding: 4px 10px;
    border-radius: 100px;
    width: fit-content;
    margin-top: 4px;
}

/* Tooltips */
#map-tooltip, #country-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    white-space: nowrap;
}

/* Date Line */
#date-line {
  stroke: #ff4d6d;
  stroke-width: 2;
  filter: drop-shadow(0 0 4px #ff4d6d);
  transition: transform 0.5s ease;
}

.date-label-bg {
    fill: var(--surface);
    stroke: var(--border);
}

.date-line-label {
    fill: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-anchor: middle;
}

@media (max-width: 1024px) {
    .container {
        padding: 0 4vw 40px;
    }
}

@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 24px;
        padding: 16px;
    }
    
    .control-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .panel-left, .panel-right {
        width: 100%;
    }

    .reference-time-wrapper {
        align-items: flex-start;
    flex-wrap: wrap;
    align-content: center;
    }

    .input-group {
        width: 100%;
    }
    
    .timeline-row {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
        border-radius: 20px;
    }
    
    .city-info {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .time-diff {
        margin-top: 0;
    }
    
    .pill-input, .pill-btn {
        flex: 1;
        justify-content: center;
    }
}

/* Date Selectors */
.date-select-group {
    display: flex;
    gap: 8px;
}

.pill-select {
    display: none; /* Hide original pill-selects in favor of custom ones */
}

/* Dropdown options styling - for fallback */
.pill-select option {
    background-color: var(--surface);
    color: var(--text);
    padding: 14px;
    font-weight: 500;
}

.pill-select option:checked {
    background-color: var(--primary);
    color: #fff;
}

/* Live Button & Dot Styling */
.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--muted);
    flex-shrink: 0;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.pill-btn.live .live-dot {
    /* Legacy - kept just in case but overridden by ::before */
    display: none; 
}

/* Use pseudo-element for reliable red dot */
.pill-btn#live-btn {
    position: relative;
    padding-left: 50px; /* Space for dot */
    display: flex;
    align-items: center; /* Ensure vertical center */
}

.pill-btn#live-btn::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 50%;
    margin-top: -3px; /* Precise centering half of 6px height */
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--muted);
    transition: all 0.3s ease;
    opacity: 0.5;
    pointer-events: none;
    transform: none; /* Reset transform to avoid sub-pixel blur */
}

.pill-btn#live-btn.live::before {
    width: 8px;
    height: 8px;
    margin-top: -4px; /* Adjust for larger size */
    background-color: #ff4757;
    opacity: 1;
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.6);
    animation: live-pulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

/* Enhanced Pulse Animation */
@keyframes live-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(255, 71, 87, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

@media (max-width: 768px) {
    .control-header {
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 12px;
    }
    
    .date-select-group {
        flex-wrap: wrap;
        width: 100%;
    justify-content: center;
    }
    .pill-select {
        flex: 1;
        min-width: 80px;
    }
}

/* Custom select uses shared styles from styles.css */


/* Map Zoom/Pan */
#world-map-container {
    overflow: hidden; /* Hide overflow when zoomed */
    cursor: grab; /* Pan cursor */
    touch-action: none; /* Prevent browser pan */
}

#world-map-container:active {
    cursor: grabbing;
}


/* Reset Zoom Button */
.map-reset-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
}

.map-marker title {
    display: none;
}

