/**
 * STORIES TIMELINE COMPONENT (/stories)
 *
 * Design: Vertical timeline with two card types (log-books & story-books)
 * Reference: web-design\3.0-timeline\timeline-v2.css
 *
 * Dependencies:
 * - /assets/css/tokens/stories-tokens.css (imported in HTML)
 * - /assets/css/tokens/global-tokens.css (auto-imported by stories-tokens.css)
 *
 * Layout provided by: StoriesLayout.astro
 * - .page-container (1200px max-width, background texture)
 * - .content-wrapper (900px max-width, padding)
 * - Breadcrumbs navigation
 *
 * This file contains ONLY timeline-specific styles.
 */


/* ============================================
   PAGE BASE (Override for timeline page)
   ============================================ */

body {
    background-color: var(--color-background-page);
    font-family: var(--font-family-system);
    color: var(--color-text-primary);
}


/* ============================================
   TIMELINE HEADER
   ============================================ */

.timeline-header {
    margin-bottom: 3rem;
}

.timeline-header__title {
    font-size: 2rem; /* 24pt */
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text-header);
    margin-bottom: 1rem;
    font-family: var(--font-family-system);
}

.timeline-header__description {
    font-size: 1.125rem; /* 14pt */
    line-height: 1.6;
    color: var(--color-text-primary);
    opacity: 0.9;
    margin-bottom: 2rem;
    font-family: var(--font-family-system);
}

.timeline-header__helper {
    display: inline-block;
}

/* .helper-link uses shared .stories-link from shared-stories-components.css */
/* .helper-link-text replaced by .stories-link-text */

.helper-link {
    padding: var(--nav-button-padding);
    background: var(--nav-button-background);
}

/* Helper link specific: down arrow indicator */
.helper-link .stories-link-text::after {
    content: ' ⇣';
    font-size: 1.2em;
}


/* ============================================
   TIMELINE CONTENT (Vertical timeline)
   ============================================ */

.timeline-content {
    position: relative;
    padding-left: 2rem; /* Space for vertical line */
    padding-bottom: var(--margin-bottom); /* Space inside timeline, not outside */
}

/* Vertical timeline line */
.timeline-content::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom,
            transparent 0%,
            var(--color-ui-primary) 10%,
            var(--color-ui-primary) 90%,
            transparent 100%);
    opacity: 0.3;
}

/* Empty state */
.timeline-empty {
    font-family: var(--font-family-system);
    font-size: var(--font-size-navigation);
    color: var(--color-text-meta);
    text-align: center;
    padding: 3em 0;
}


/* ============================================
   TIMELINE CARDS - BASE STYLES
   ============================================ */

.timeline-card {
    position: relative;
    margin-bottom: 4rem;
    padding: 2rem;
    background: rgba(18, 18, 18, 0.5);
    transition: background 0.2s ease;

    /* Flex column layout: sub-panel 1 (header) | sub-panel 2 (specific content) */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-card:hover {
    background: rgba(18, 18, 18, 0.7);
}

/* Timeline marker dot */
.timeline-card::before {
    content: '';
    position: absolute;
    left: -2.5rem;
    top: 2rem;
    width: 0.75rem;
    height: 0.75rem;
    background: var(--color-ui-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--color-background-page);
}

/* NEW badge marker (optional - for future use) */
.timeline-card--new::before {
    background: var(--color-light-green);
}


/* ============================================
   SUB-PANEL 1: CARD HEADER (Shared)
   ============================================ */

.card-header {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: start;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}


/* ============================================
   CARD COVER (200x200 square)
   ============================================ */

.card-cover {
    width: 200px;
    height: auto; /* Dynamic height for images */
    overflow: hidden;
    margin-top: 2rem; /* Align with card-info content below title */
}

.card-cover img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* Placeholder for log-books without cover image */
.card-cover--placeholder {
    height: 200px; /* Square placeholder */
    background: linear-gradient(135deg,
            rgba(204, 204, 255, 0.08) 0%,
            rgba(166, 166, 166, 0.08) 100%);
    border: 1px solid rgba(166, 166, 166, 0.2);
    position: relative;
}

.card-cover--placeholder::after {
    content: 'LOG\ABOOK';
    white-space: pre;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-family-system);
    font-size: 1.25rem;
    color: rgba(166, 166, 166, 0.25);
    text-align: center;
    line-height: 1.5;
    letter-spacing: 0.2em;
    font-weight: 700;
}


/* ============================================
   CARD CONTENT AREA
   ============================================ */

.card-title {
    font-size: 1.5rem; /* 18pt */
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text-header);
    font-family: var(--font-family-system);
}

.card-description {
    font-size: 1.125rem; /* 14pt */
    line-height: 1.6;
    color: var(--color-text-primary);
    opacity: 0.9;
    font-family: var(--font-family-system);
}

.card-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 1rem; /* 12pt */
    color: var(--color-text-meta);
    font-family: var(--font-family-system);
}

.meta-label {
    color: var(--color-text-meta);
}

.meta-value {
    color: var(--color-text-primary);
    font-weight: 700;
}


/* ============================================
   SUB-PANEL 2: SPECIFIC CONTENT
   ============================================ */

/* Log Book specific: Entry list container */
.card-entries {
    width: 100%;
}

/* Story Book specific: Chapters section */
.card-chapters {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Chapters row: chapter numbers + published date */
.chapters-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* Published date styling within chapters-row */
.chapters-row .card-published {
    margin-left: auto;
    white-space: nowrap;
    position: relative;
}

/* NEW badge - floating next to published date */
.chapters-row .card-published [data-new-badge] {
    position: absolute;
    right: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    line-height: 1;
}


/* ============================================
   ENTRY LIST (Log Book only - always visible)
   ============================================ */

.entry-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0 0;
}

.entry-list__item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.5rem 0;
    font-family: var(--font-family-system);
    font-size: 0.875rem; /* 14px */
    border-bottom: 1px solid rgba(166, 166, 166, 0.15);
}

.entry-list__item:last-child {
    border-bottom: none;
}

.entry-day,
.entry-location {
    color: var(--color-text-primary);
}

.entry-published {
    color: var(--color-text-meta);
    font-size: 0.75rem; /* 12px */
    justify-self: end;
    margin-right: 2em;
}

.entry-link {
    font-family: var(--font-family-system);
    font-size: 0.875rem;
    color: var(--color-ui-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

/* Ellipsis for "read/more entries" indicators
 * Uses visibility:hidden (not display:none) so elements always
 * occupy layout space, ensuring stable spacing to the button below */
.entry-ellipsis {
    font-family: var(--font-family-system);
    font-size: 0.75rem;
    color: var(--color-text-meta);
    opacity: 0.7;
    font-style: italic;
    padding: 0.125rem 0;
    visibility: hidden;
}

.entry-ellipsis--visible {
    visibility: visible;
}

/* Entry navigation - Start/Continue Reading button (LogBook) */
.entry-navigation {
    display: flex;
    justify-content: flex-end;
    margin-top: -1rem;
}

/* Chapter navigation - Start/Continue Reading button (StoryBook) */
.chapter-navigation-timeline {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}


/* ============================================
   CHAPTER NUMBERS (Story Book only - clickable)
   ============================================ */

.chapter-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 0;  /* Remove gap, use padding instead */
    align-items: center;
}

/* .chapter-number uses shared .stories-link from shared-stories-components.css */
/* .chapter-number-text uses .stories-link-short for underline effect */

.chapter-number {
    padding-right: 3rem;  /* Space before divider (doubled) */
    position: relative;
}

/* Vertical divider after each chapter number (except last) */
.chapter-number::after {
    content: '';
    position: absolute;
    right: 1.5rem;  /* Center divider in the .chapter-number padding */
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 1em;  /* Match text height */
    background: rgba(166, 166, 166, 0.15);  /* Same as LogBook dividers */
}

/* No divider after last chapter number */
.chapter-number:last-of-type::after {
    display: none;
}

/* Bookmark indicator - floating bookmark emoji */
.chapter-number--bookmark::before {
    content: '🔖';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-30%) rotate(-90deg);
    font-size: 1.25rem;
    pointer-events: none;
}

/* .chapter-number-text replaced by .stories-link-short from shared-stories-components.css */

.chapter-ellipsis {
    font-family: var(--font-family-system);
    font-size: 0.875rem;
    color: var(--color-text-meta);
    opacity: 0.5;
    cursor: default;
    /*padding-left: 0.5rem;  /* Space after last chapter */
}


/* ============================================
   PUBLISHED DATE (before buttons)
   ============================================ */

.card-published {
    font-family: var(--font-family-system);
    font-size: 0.75rem; /* 12px - same as entry-published */
    color: var(--color-text-meta);
    justify-self: end;
    margin-right: 2em;
}


/* ============================================
   CARD ACTION BUTTONS
   Uses shared .stories-link from shared-stories-components.css
   .card-button-text replaced by .stories-link-text
   ============================================ */

.card-button {
    padding: var(--nav-button-padding);
    background: var(--nav-button-background);
    white-space: nowrap;
    align-self: flex-start;
}


/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .timeline-header__title {
        font-size: 1.67rem; /* 20pt */
    }

    .timeline-header__description {
        font-size: 1.08rem; /* 13pt */
    }

    .timeline-content {
        padding-left: 1.5rem;
    }

    /* Card layout */
    .timeline-card {
        padding: 1.5rem;
        margin-bottom: 3rem;
    }

    .timeline-card::before {
        left: -2rem;
        width: 0.6rem;
        height: 0.6rem;
    }

    /* Card header - stack vertically */
    .card-header {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Cover - center on mobile */
    .card-cover {
        margin: 0 auto;
    }

    /* Meta row - stack vertically */
    .card-meta-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .card-title {
        font-size: 1.33rem; /* 16pt */
    }

    /* Entry list - stack items vertically */
    .entry-list__item {
        grid-template-columns: 1fr;
        gap: 0.25rem;
        padding: 0.75rem 0;
    }

    .entry-published {
        justify-self: start; /* Left align on mobile */
        margin-right: 0;
    }

    /* Entry navigation - full width button on mobile */
    .entry-navigation {
        margin-top: 1rem;
    }

    .entry-navigation .card-button {
        width: 100%;
        text-align: center;
    }

    /* Chapter navigation - full width button on mobile */
    .chapter-navigation-timeline {
        margin-top: 1rem;
    }

    .chapter-navigation-timeline .card-button {
        width: 100%;
        text-align: center;
    }

    /* Card chapters - stack vertically on mobile */
    .card-chapters {
        gap: 1rem;
    }

    /* Chapters row - stack vertically on mobile */
    .chapters-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .chapters-row .card-published {
        margin-left: 0;
    }

    /* NEW badge - inline on mobile instead of absolute */
    .chapters-row .card-published [data-new-badge]:not(:empty) {
        position: static;
        transform: none;
        display: inline-block;
        margin-left: 0.5rem;
    }

    /* Chapter numbers - center on mobile */
    .chapter-numbers {
        justify-content: center;
    }

    /* Reduce spacing on mobile for compactness */
    .chapter-number {
        padding-right: 1.5rem;  /* Doubled spacing for mobile */
    }

    .chapter-number::after {
        right: 0.75rem;  /* Adjust divider position */
    }

    /* Bookmark indicator - inline on mobile */
    .chapter-number--bookmark::before {
        position: static;
        transform: none;
        display: inline-block;
        margin-left: 0.5rem;
    }

    /* Published - left align on mobile */
    .card-published {
        justify-self: start;
        margin-right: 0;
    }

    /* Buttons - full width on mobile */
    .card-button {
        text-align: center;
        width: 100%;
    }
}


/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .timeline-header__helper {
        display: none;
    }

    .timeline-content::before {
        display: none;
    }

    .timeline-card::before {
        display: none;
    }

    .timeline-card {
        page-break-inside: avoid;
        background: none;
        border: 1px solid #ccc;
        margin-bottom: 2rem;
    }

    .card-button {
        color: black;
        text-decoration: underline;
    }
}
