/* Historical Pedway Maps timeline (timeline.html only).
   Everything is scoped under .pw / .pw-viewer so the shared style.css and
   styles.css rules (img widths, .active, h2 colours, etc.) don't leak in. */

:root {
    --pw-purple: #302665;
    --pw-purple-deep: #1c1640;
    --pw-yellow: #FFE385;
    --pw-gold: #BB8C09;
    --pw-steel: #C9CEE1;
    --pw-wall: #302665;
    --pw-tile: #252528;
    --pw-ink: #f4f4f6;
    --pw-ink-dim: #a9abb8;
    --pw-card-w: min(640px, 80cqw);
    --pw-gap: 20px;
}

.pw {
    color: var(--pw-ink);
    font-family: "Roboto", system-ui, sans-serif;
    text-align: center;
    padding: 28px 0 8px;
    /* faint tunnel-tile pattern */
    background-color: var(--pw-wall);
    background-image:
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 48px 24px;
    overflow: hidden;
}

.pw *,
.pw *::before,
.pw *::after {
    box-sizing: border-box;
}

.pw button {
    font: inherit;
    color: inherit;
}

.pw :focus-visible,
.pw-viewer :focus-visible {
    outline: 3px solid var(--pw-yellow);
    outline-offset: 3px;
}

/* ---------- Wayfinding sign title ---------- */

.pw-sign {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 14px;
    max-width: calc(100% - 32px);
    margin: 0 16px 26px;
    padding: 12px 20px;
    background: var(--pw-purple);
    border-bottom: 6px solid var(--pw-yellow);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.pw-sign__badge {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 50%;
    background: var(--pw-yellow);
    color: var(--pw-purple);
    font-weight: 900;
    font-size: 24px;
}

.pw-sign__title {
    margin: 0;
    font-size: clamp(22px, 5vw, 34px);
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.1;
}

.pw-sign__sub {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pw-yellow);
}

/* ---------- Route line (one station per map) ---------- */

.pw-route {
    position: relative;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px;
    margin-bottom: 22px;
    /* fade the ends so it reads as "the line keeps going" */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}

.pw-route::-webkit-scrollbar {
    display: none;
}

.pw-route__stops {
    display: flex;
    width: max-content;
    min-width: 100%;
    max-width: none;
    margin: 0 auto;
    /* bottom padding leaves room for the "You are here" marker */
    padding: 4px 8px 76px;
    list-style: none;
    justify-content: center;
}

.pw-route__stops li {
    position: relative;
    flex: 1 0 68px;
    max-width: 110px;
}

/* line segments to the left and right of each station */
.pw-route__stops li::before,
.pw-route__stops li::after {
    content: "";
    position: absolute;
    /* centred on the dot: year (18px) + gap (6px) + half the dot (10px) - half the line (3px) */
    top: 31px;
    height: 6px;
    width: 50%;
    background: var(--pw-yellow);
    opacity: 0.35;
    transition: opacity 0.3s;
}

.pw-route__stops li::before { left: 0; }
.pw-route__stops li::after { right: 0; }
.pw-route__stops li:first-child::before,
.pw-route__stops li:last-child::after { display: none; }

/* the part of the line you have already walked */
.pw-route__stops li.is-passed::before,
.pw-route__stops li.is-passed::after,
.pw-route__stops li.is-current::before {
    opacity: 1;
}

.pw-stop {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 0 2px;
    background: none;
    border: 0;
    cursor: pointer;
}

.pw-stop__dot {
    width: 20px;
    height: 20px;
    flex: none;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--pw-purple);
    box-shadow: 0 0 0 2px var(--pw-yellow);
    transition: transform 0.25s, background 0.25s;
}

.pw-stop__year {
    order: -1;
    /* above the dot */
    height: 18px;
    line-height: 18px;
    font-size: 13px;
    font-weight: 700;
    color: var(--pw-ink-dim);
    white-space: nowrap;
    transition: color 0.25s;
}

.pw-stop:hover .pw-stop__dot {
    transform: scale(1.15);
}

.pw-stop:hover .pw-stop__year {
    color: #fff;
}

.pw-stop[aria-current="true"] .pw-stop__dot {
    background: var(--pw-yellow);
    transform: scale(1.35);
}

.pw-stop[aria-current="true"] .pw-stop__year {
    color: var(--pw-yellow);
    font-size: 15px;
}

/* "You are here" teardrop marker hanging below the current station,
   based on the symbol from the modern map */
.pw-stop__here {
    position: absolute;
    top: 47px;
    left: 50%;
    width: 52px;
    height: 68px;
    margin-left: -26px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-8px) scale(0.85);
    transform-origin: 50% 0;
    transition: opacity 0.25s, transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.pw-stop__here svg {
    display: block;
    width: 100%;
    height: 100%;
}

.pw-stop[aria-current="true"] .pw-stop__here {
    opacity: 1;
    transform: none;
}

/* ---------- Card track ---------- */

.pw-viewport {
    container-type: inline-size;
}

.pw-track {
    position: relative;
    display: flex;
    gap: var(--pw-gap);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0 16px;
}

.pw-track::-webkit-scrollbar {
    display: none;
}

.pw-track:focus-visible {
    outline-offset: -3px;
}

/* spacers so the first and last card can sit in the centre */
.pw-track::before,
.pw-track::after {
    content: "";
    flex: 0 0 max(0px, calc((100cqw - var(--pw-card-w)) / 2 - var(--pw-gap)));
}

.pw-card {
    flex: 0 0 var(--pw-card-w);
    scroll-snap-align: center;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    background: var(--pw-tile);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 6px solid var(--pw-purple);
    border-radius: 8px;
    overflow: hidden;
    text-align: left;
    opacity: 0.4;
    transform: scale(0.94);
    transition: opacity 0.35s, transform 0.35s, border-color 0.35s;
}

.pw-card.is-current {
    opacity: 1;
    transform: none;
    border-top-color: var(--pw-yellow);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.pw-card:not(.is-current) {
    cursor: pointer;
}

.pw-card__frame {
    position: relative;
    display: block;
    width: 100%;
    height: clamp(220px, 48vh, 460px);
    padding: 0;
    border: 0;
    background: #111;
    cursor: zoom-in;
    overflow: hidden;
}

.pw-card:not(.is-current) .pw-card__frame {
    cursor: pointer;
}

.pw .pw-card__frame img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    float: none;
    object-fit: contain;
    transition: transform 0.4s;
}

.pw-card.is-current .pw-card__frame:hover img {
    transform: scale(1.03);
}

.pw-card__zoom {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(28, 22, 64, 0.85);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 0.3s;
}

.pw-card.is-current .pw-card__zoom {
    opacity: 1;
}

.pw-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px 18px 20px;
    flex: 1;
}

.pw-card__year {
    font-size: clamp(30px, 8cqw, 44px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--pw-yellow);
}

.pw .pw-card__title {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: clamp(16px, 3.6cqw, 20px);
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0;
    color: var(--pw-ink);
}

.pw-card__link {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 4px;
    background: var(--pw-purple);
    border-left: 5px solid var(--pw-yellow);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background 0.2s;
}

.pw-card__link::after {
    content: "\2197";
    /* ↗ */
    font-size: 15px;
}

.pw-card__link:not([target])::after {
    content: "\2192";
    /* → */
}

.pw-card__link:hover {
    background: var(--pw-gold);
}

/* ---------- Controls ---------- */

.pw-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4px 16px 0;
}

.pw-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 48px;
    min-height: 48px;
    padding: 10px 18px;
    border: 2px solid var(--pw-yellow);
    border-radius: 999px;
    background: var(--pw-purple);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.pw-btn:hover:not(:disabled) {
    background: var(--pw-yellow);
    color: var(--pw-purple);
}

.pw-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.pw-counter {
    min-width: 72px;
    margin: 0;
    font-size: 18px;
    font-weight: 900;
    color: #fff;
}

.pw-counter__of {
    font-weight: 400;
    color: var(--pw-ink-dim);
}

.pw-hint {
    margin: 14px 16px 6px;
    font-size: 13px;
    color: var(--pw-ink-dim);
}

@media (max-width: 480px) {
    .pw-btn {
        padding: 10px 14px;
    }

    .pw-btn__label {
        display: none;
    }

    .pw-btn {
        font-size: 20px;
    }
}

/* ---------- Full-size viewer ---------- */

.pw-viewer {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(12, 10, 26, 0.97);
    color: #fff;
    font-family: "Roboto", system-ui, sans-serif;
}

.pw-viewer[open] {
    display: flex;
    flex-direction: column;
}

.pw-viewer::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.pw-viewer__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    background: var(--pw-purple);
    border-bottom: 4px solid var(--pw-yellow);
}

.pw-viewer__title {
    flex: 1;
    text-align: left;
    font-weight: 700;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pw-viewer__close {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--pw-yellow);
    color: var(--pw-purple);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.pw-viewer__stage {
    flex: 1;
    overflow: auto;
    display: grid;
    place-items: center;
    -webkit-overflow-scrolling: touch;
}

.pw-viewer__stage img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    float: none;
    object-fit: contain;
    cursor: zoom-in;
}

.pw-viewer__stage.is-zoomed {
    place-items: start;
}

.pw-viewer__stage.is-zoomed img {
    max-width: none;
    max-height: none;
    width: max(200%, 1400px);
    cursor: zoom-out;
}

.pw-viewer__hint {
    margin: 0;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--pw-ink-dim);
}

@media (prefers-reduced-motion: reduce) {
    .pw-card,
    .pw-card__frame img,
    .pw-stop__dot {
        transition: none;
    }
}
