/* General Body Styles */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f4f7fa;
    color: #2c3e50;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    background-image: url('../img/background.png');
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0.2;
}

html {
    font-size: 16px;
}

.main-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Styles */
.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1.25rem;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    border-bottom: 1px solid #d1d9e6;
}

.timeline-header h1.header-title {
    flex-grow: 1;
    text-align: center;
}

.timeline-header h1 {
    font-size: 1.5rem;
    color: #1c1c1c;
    margin: 0;
}

.nav-button {
    background: none;
    border: 1px solid #a3b1c6;
    color: #34495e;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.3125rem 0.625rem;
    border-radius: 0.3125rem;
    transition: background-color 0.3s;
}

#filter-button {
    font-size: 1rem;
    padding: 0.5rem 1rem;
}

#story-viewer-nav-button, #filter-button {
    font-size: 1rem;
    padding: 0.5rem 1rem;
    white-space: nowrap; /* Prevents text wrapping on smaller screens */
}

.nav-button:hover {
    background-color: #e1e8f0;
}


/* Filter Styles */
.filter-container {
    position: relative;
}

.filter-panel {
    position: absolute;
    top: 120%;
    right: 0;
    width: 30rem;
    max-width: 90vw;
    z-index: 1000;
    background-color: rgba(250, 252, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1.5rem rgba(44, 62, 80, 0.2);
    padding: 1rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.filter-panel.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.filter-option {
    display: flex;
    align-items: center;
    flex-basis: calc(25% - 1rem);
}

.filter-option label {
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #2c3e50;
    white-space: nowrap;
}

.filter-option input[type="checkbox"] {
    cursor: pointer;
}

/* Timeline Container Styles */
.timeline-wrapper {
    flex-grow: 1;
    overflow: auto;
    padding: 1.25rem 0;
    position: relative;
    cursor: grab;
    user-select: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.timeline-wrapper::-webkit-scrollbar {
    display: none;
}

.timeline-wrapper.active {
    cursor: grabbing;
}

#timeline-container {
    display: inline-grid;
    grid-auto-flow: column;
    /* CHANGE: Reduced the horizontal gap between cards */
    grid-gap: 3.75rem 9.25rem;
    padding: 3.125rem 2.5rem;
    position: relative;
    white-space: nowrap;
}

#timeline-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Timeline Item (Card) Styles */
.timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* CHANGE: Increased the card width */
    width: 16.3rem;
    height: 12.0rem;
    z-index: 2;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, opacity 0.4s ease, filter 0.4s ease;
    background-color: rgba(44, 62, 80, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(163, 177, 198, 0.2);
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: 0.3rem 0.3rem 1rem rgba(0, 0, 0, 0.3),
        0.2rem 0.2rem 2rem rgba(102, 204, 153, 0.2);
}

.timeline-item:hover {
    transform: translateY(-0.3125rem);
    border-bottom-color: rgba(0, 0, 0, 0.4);
    border-right-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0.4rem 0.4rem 1.5rem rgba(0, 0, 0, 0.4),
        0.3rem 0.3rem 2.5rem rgba(102, 204, 153, 0.4);
}

.timeline-item.dimmed {
    opacity: 0.4;
    filter: saturate(0);
}

.timeline-item.highlighted {
    opacity: 1;
    filter: saturate(1);
}

.item-icon {
    /* CHANGE: Increased icon size to match the larger card */
    width: 17rem;
    height: 11rem; /* Maintained 16:9 aspect ratio */
    background-color: #1c2833;
    border: 1px solid #4a4e69;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
}

.item-name {
    font-size: 1rem;
    font-weight: bold;
    color: #f2e9e4;
    white-space: normal;
}

/* Chapter Navigation & Progress Bar Styles */
.chapter-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5625rem 2.5rem;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    border-top: 1px solid #d1d9e6;
    position: relative;
}

#progress-bar-container {
    width: 100%;
    height: 1.875rem;
    position: relative;
    display: flex;
    align-items: center;
}

#progress-bar {
    width: 100%;
    height: 0.375rem;
    background-color: #d1d9e6;
}

#chapter-markers {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.chapter-marker {
    position: absolute;
    top: 50%;
    transform: translateX(-50%);
    color: #000000;
    font-size: 1.125rem;
    font-weight: bold;
    cursor: pointer;
    padding-bottom: 1.5625rem;
    transition: color 0.2s;
}

.chapter-marker:hover {
    color: #2980b9;
}

.chapter-marker::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 0.75rem;
    background-color: #a3b1c6;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    transition: background-color 0.2s;
}

.chapter-marker:hover::before {
    background-color: #2980b9;
}

#timeline-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    width: 0.25rem;
    height: 1.5rem;
    background-color: #4a90e2;
    border-radius: 0.125rem;
    pointer-events: none;
    box-shadow: 0 0 0.5rem #4a90e2;
    transform: translate(-50%, -50%);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #ffffff;
    margin: 10% auto;
    padding: 1.5625rem;
    border: 1px solid #d1d9e6;
    width: 80%;
    max-width: 37.5rem;
    border-radius: 0.625rem;
    color: #2c3e50;
    position: relative;
    box-shadow: 0 0.3125rem 0.9375rem rgba(44, 62, 80, 0.2);
}

.close-button {
    color: #888888;
    position: absolute;
    top: 0.625rem;
    right: 1.25rem;
    font-size: 1.75rem;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover {
    color: #000000;
}

#modal-title {
    margin-top: 0;
    color: #1c1c1c;
    border-bottom: 2px solid #e1e8f0;
    padding-bottom: 0.625rem;
}

#modal-body h3 {
    border-bottom: 1px solid #e1e8f0;
    padding-bottom: 0.3125rem;
    margin-top: 1.25rem;
}

#modal-bgm {
    width: 100%;
    margin-top: 1.25rem;
}