/*
    StoryView (vehicle story page)
    All selectors are scoped under .cs-story. Colors are based on the
    Car Stories brand variables defined in site.css.
*/

/* ===== Story view - scoped tokens, based on the Car Stories brand colors (site.css) ===== */
.cs-story {
    --cs-ink: var(--car-stories-darkblue, #0F1944);
    --cs-muted: rgba(15, 25, 68, .68);                          /* darkblue, softened for secondary text */
    --cs-surface: #FFFFFF;
    --cs-canvas: #EDF2F3;                                        /* lightgreen tint */
    --cs-line: #D3DEE0;                                          /* lightgreen tint */
    --cs-signal: var(--car-stories-ochre, #D1AD5F);              /* ochre: primary action, markers, progress */
    --cs-signal-hover: #BE9A4C;
    --cs-signal-ink: var(--car-stories-darkblue, #0F1944);       /* darkblue on ochre, contrast > 7:1 */
    --cs-signal-glow: rgba(209, 173, 95, .3);
    --cs-petrol: var(--car-stories-darkgreen, #34626E);
    --cs-on-petrol: #FFFFFF;
    --cs-shadow: rgba(15, 25, 68, .35);
    --cs-font-display: "Oswald", "Arial Narrow", system-ui, sans-serif;
    --cs-font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--cs-ink);
    font-family: var(--cs-font-body);
    font-size: 1rem;
    line-height: 1.55;
}

[data-bs-theme="dark"] .cs-story {
    --cs-ink: #F1F4F5;
    --cs-muted: #B5C7CC;
    --cs-surface: #1D3E50;
    --cs-canvas: #152F3D;
    --cs-line: #2F5568;
    --cs-petrol: #9CC3C9;
    --cs-on-petrol: #0F1944;
    --cs-shadow: rgba(0, 0, 0, .5);
}

.cs-story :focus-visible { outline: 3px solid var(--cs-petrol); outline-offset: 2px; }
.cs-story h1, .cs-story h2, .cs-story h3 { color: var(--cs-ink); }

/* ===== Buttons ===== */
.cs-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .6rem 1.1rem; border-radius: 6px; border: 1px solid transparent;
    font: 600 .95rem/1.2 var(--cs-font-body); text-decoration: none;
    background: none; color: var(--cs-ink); cursor: pointer;
}
.cs-btn-primary { background: var(--cs-signal); color: var(--cs-signal-ink); }
.cs-btn-primary:hover { background: var(--cs-signal-hover); color: var(--cs-signal-ink); }
.cs-btn-ghost { background: var(--cs-surface); border-color: var(--cs-line); }
.cs-btn-ghost:hover { border-color: var(--cs-petrol); color: var(--cs-petrol); }
.cs-btn-sm { padding: .4rem .8rem; font-size: .875rem; }
.cs-btn-block { width: 100%; justify-content: center; }

/* ===== Top bar ===== */
.cs-topbar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.cs-topbar .breadcrumb { margin: 0; float: none; }
.cs-topbar-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ===== Hero ===== */
.cs-hero {
    display: grid; grid-template-columns: minmax(0, 1fr);
    background: var(--cs-surface); border: 1px solid var(--cs-line);
    border-radius: 14px; overflow: hidden; margin-bottom: 1.25rem;
}
.cs-hero-media { display: block; background: var(--cs-canvas); aspect-ratio: 16 / 10; }
.cs-hero-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cs-hero-body { padding: clamp(1.25rem, 3vw, 2.5rem); display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.cs-hero-make { margin: 0; font: 500 1.25rem/1.2 var(--cs-font-display); color: var(--cs-muted); }
.cs-hero-title {
    margin: 0; font: 600 clamp(2.4rem, 5.2vw, 4rem)/1 var(--cs-font-display);
    letter-spacing: -.01em; overflow-wrap: anywhere;
}
.cs-hero-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.cs-chip { border: 1px solid var(--cs-line); border-radius: 999px; padding: .2rem .75rem; font-size: .875rem; color: var(--cs-muted); }
.cs-chip a { color: inherit; }
.cs-chip-sale { border-color: var(--cs-signal); color: var(--cs-ink); }
.cs-hero-lead { margin: 0; max-width: 60ch; font-size: 1.075rem; }
.cs-hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .25rem; }
.cs-hero-count { margin-left: .25rem; color: var(--cs-muted); font-size: .95rem; }
.cs-hero-count strong { font: 700 1.35rem/1 var(--cs-font-display); color: var(--cs-ink); }

@media (min-width: 992px) {
    .cs-hero { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
    .cs-hero-media { aspect-ratio: auto; min-height: 440px; }
}

/* ===== Fact strip ===== */
.cs-facts {
    display: flex; flex-wrap: wrap; gap: 1px; margin: 0 0 2.25rem;
    background: var(--cs-line); border: 1px solid var(--cs-line); border-radius: 10px; overflow: hidden;
}
.cs-fact { flex: 1 1 9.5rem; background: var(--cs-surface); padding: .8rem 1rem; }
.cs-fact dt { margin: 0; font-size: .8rem; font-weight: 500; color: var(--cs-muted); }
.cs-fact dd { margin: 0; font: 600 1.35rem/1.25 var(--cs-font-display); font-variant-numeric: tabular-nums; }

.cs-section-title { margin: 0 0 1rem; font: 700 1.75rem/1.1 var(--cs-font-display); }

/* ===== Reader ===== */
.cs-reader {
    background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 10px;
    box-shadow: 0 14px 34px -20px var(--cs-shadow);
    margin-bottom: 2.75rem; scroll-margin-top: 80px; overflow: hidden;
}
.cs-reader-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; padding: 1.25rem 1.5rem 1rem; }
.cs-reader-count { margin: 0 0 .25rem; font-size: .875rem; color: var(--cs-muted); font-variant-numeric: tabular-nums; }
.cs-reader-title { margin: 0; font: 700 clamp(1.6rem, 3vw, 2.25rem)/1.05 var(--cs-font-display); }
.cs-reader-type { margin: .35rem 0 0; font-size: .95rem; font-weight: 600; color: var(--cs-petrol); }
.cs-reader-nav { display: flex; gap: .35rem; }
.cs-icon-btn {
    display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem;
    border: 1px solid var(--cs-line); border-radius: 6px; background: var(--cs-surface); color: var(--cs-ink);
}
.cs-icon-btn:hover:not(:disabled) { border-color: var(--cs-ink); }
.cs-icon-btn:disabled { opacity: .35; cursor: default; }
.cs-progress { height: 4px; background: var(--cs-canvas); }
.cs-progress-bar { height: 100%; width: 0; background: var(--cs-signal); transition: width .35s ease; }
.cs-reader-gallery { padding: 1.25rem 1.5rem 0; }
.cs-reader-gallery[hidden] { display: none; }
/* PartialStoryDetailView renders its own gallery (needed on the story detail page).
   In the reader the gallery is shown above the text, so the inner one is hidden here. */
.cs-reader-body .picture-gallery { display: none; }
.cs-reader-body { padding: 1.5rem; transition: opacity .2s ease; }
.cs-reader-body.is-loading { opacity: .4; }
.cs-reader-foot { border-top: 1px solid var(--cs-line); padding: 1rem 1.5rem; }
.cs-next {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0; border: 0; background: none; color: var(--cs-ink); text-align: left; cursor: pointer;
}
.cs-next-label { display: block; font-size: .875rem; color: var(--cs-muted); }
.cs-next-title { display: block; font: 600 1.35rem/1.2 var(--cs-font-display); }
.cs-next:hover .cs-next-title { text-decoration: underline; text-decoration-color: var(--cs-signal); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.cs-next-icon { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--cs-signal); color: var(--cs-signal-ink); }
.cs-reader-end { margin: 0; color: var(--cs-muted); }

.cs-empty { margin-bottom: 2.75rem; padding: 2.5rem 1.5rem; text-align: center; background: var(--cs-surface); border: 1px dashed var(--cs-line); border-radius: 10px; }
.cs-empty p { color: var(--cs-muted); max-width: 46ch; margin: .5rem auto 1rem; }

/* ===== Mileage timeline (signature element) ===== */
.cs-timeline { list-style: none; margin: 0 0 2.75rem; padding: 0; }
.cs-timeline-year { padding: 1rem 0 .35rem 7.75rem; font: 700 1.1rem/1 var(--cs-font-display); color: var(--cs-muted); }
.cs-timeline-year:first-child { padding-top: 0; }
.cs-timeline-link {
    display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto; gap: 0 1.25rem;
    align-items: start; color: inherit; text-decoration: none;
}
.cs-timeline-link:hover { color: inherit; }
.cs-timeline-km { padding-top: .85rem; text-align: right; font: 600 1.3rem/1.2 var(--cs-font-display); font-variant-numeric: tabular-nums; }
.cs-timeline-km small { font-size: .8rem; font-weight: 500; color: var(--cs-muted); }
.cs-timeline-content { position: relative; padding: .75rem 0 1.4rem 1.25rem; border-left: 2px solid var(--cs-line); }
.cs-timeline-content::before {
    content: ""; position: absolute; left: -7px; top: 1.2rem; width: 12px; height: 12px;
    border-radius: 50%; background: var(--cs-surface); border: 2px solid var(--cs-muted);
}
.cs-timeline-meta { display: flex; flex-wrap: wrap; gap: .2rem .75rem; font-size: .85rem; color: var(--cs-muted); }
.cs-timeline-title { margin: .15rem 0 .3rem; font: 600 1.3rem/1.15 var(--cs-font-display); }
.cs-timeline-teaser { margin: 0; max-width: 60ch; font-size: .95rem; color: var(--cs-muted); }
.cs-timeline-thumb { width: 96px; height: 72px; margin-top: .75rem; object-fit: cover; border-radius: 6px; background: var(--cs-canvas); }
.cs-timeline-link:hover .cs-timeline-title { text-decoration: underline; text-underline-offset: 3px; }
.cs-timeline-link.is-active .cs-timeline-content::before { background: var(--cs-signal); border-color: var(--cs-signal); box-shadow: 0 0 0 4px var(--cs-signal-glow); }
.cs-timeline-link.is-active .cs-timeline-title { color: var(--cs-petrol); }

@media (max-width: 575.98px) {
    .cs-timeline-link { grid-template-columns: 4.5rem minmax(0, 1fr); }
    .cs-timeline-thumb { display: none; }
    .cs-timeline-km { font-size: 1.05rem; }
    .cs-timeline-year { padding-left: 5.75rem; }
}

/* ===== About ===== */
.cs-about { margin-bottom: 2rem; }
.cs-prose { max-width: 68ch; font-size: 1.05rem; line-height: 1.65; }
.cs-prose img { max-width: 100%; height: auto; }

/* ===== Aside cards ===== */
.cs-aside { display: flex; flex-direction: column; gap: 1rem; }
.cs-card { background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: 10px; padding: 1.25rem; }
.cs-card-title { margin: 0 0 .75rem; font-size: .9rem; font-weight: 600; color: var(--cs-muted); }
.cs-card p { margin-bottom: .75rem; }
.cs-garage { border-top: 4px solid var(--cs-petrol); }
.cs-garage-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.cs-garage-mark {
    flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 8px;
    background: var(--cs-petrol); color: var(--cs-on-petrol); object-fit: cover;
    font: 700 1.4rem/1 var(--cs-font-display);
}
.cs-garage-title { margin: 0; font: 700 1.4rem/1.1 var(--cs-font-display); }
.cs-garage-place { display: flex; align-items: center; gap: .3rem; margin: .25rem 0 0 !important; font-size: .9rem; color: var(--cs-muted); }
.cs-stat { font: 700 1.6rem/1.1 var(--cs-font-display); font-variant-numeric: tabular-nums; }

/* ===== Similar vehicles ===== */
.cs-similar-list { display: flex; flex-direction: column; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.cs-similar-item {
    display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: .85rem; align-items: center;
    margin: 0 -.5rem; padding: .5rem; border-radius: 8px; color: inherit; text-decoration: none;
}
.cs-similar-item:hover { background: var(--cs-canvas); color: inherit; }
.cs-similar-item:hover .cs-similar-name { color: var(--cs-petrol); }
.cs-similar-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--cs-canvas); }
.cs-similar-name { display: block; font: 600 1.1rem/1.15 var(--cs-font-display); overflow-wrap: anywhere; }
.cs-similar-meta { display: flex; flex-wrap: wrap; gap: 0 .5rem; font-size: .85rem; color: var(--cs-muted); }
.cs-similar-reason { display: inline-block; margin-top: .2rem; font-size: .75rem; font-weight: 600; color: var(--cs-petrol); }

@media (prefers-reduced-motion: reduce) {
    .cs-story * { transition: none !important; }
}
