/* All colours come from the profiles at the top of general.css. */

/* ---------- Page split ---------- */

body {
    display: grid;
    grid-template-columns: 7fr 3fr;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Large desktop screens show the whole page a bit smaller. Viewport units shrink with the zoom too,
   so the page height is divided by it to still fill the window. */
@supports (zoom: 0.8) {
    @media (min-width: 1600px) {
        html {
            --page-zoom: 0.8;
            zoom: var(--page-zoom);
        }

        body {
            height: calc(100vh / var(--page-zoom));
            height: calc(100dvh / var(--page-zoom));
        }
    }
}

/* ---------- Timeline ---------- */

.timeline-container {
    position: relative;
    overflow: hidden;
    background: var(--bg);
    transition: background-color var(--ease);
}

/* Background scenes (scripts/scenes.js). Fixed behind the scrolling timeline. */
.timeline-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.timeline-scene__canvas {
    display: block;
    width: 100%;
    height: 100%;
    transition: opacity 300ms ease-in-out; /* matches FADE_MS in scripts/scenes.js */
}

.timeline-scene__canvas.is-hidden {
    opacity: 0;
}

.timeline-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* Reserve the scrollbar's space so the layout width never shifts. */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--divider) transparent;
}

.timeline {
    position: relative;
}

.zone {
    position: absolute;
    left: 0;
    right: 0;
}

/* The dashed line above each year. Dash length and gap are set in the mask. */
.zone::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--year-line-width, 1px);
    background: var(--year-line);
    -webkit-mask: repeating-linear-gradient(to right, #000 0 10px, transparent 10px 15px);
    mask: repeating-linear-gradient(to right, #000 0 10px, transparent 10px 15px);
    transition: background-color var(--ease);
}

/* The newest year starts at the top of the timeline, with no line above it. */
.zone:first-of-type::before {
    display: none;
}

.zone__year {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bungee', sans-serif;
    font-size: clamp(1.25rem, 2.2vw, 2.6rem);
    line-height: 1;
    color: var(--year);
    text-shadow: 0.1em 0.1em 0 var(--year-shadow);
    transition: color var(--ease), text-shadow var(--ease);
    user-select: none;
}

.timeline__line {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.timeline__line path {
    fill: none;
    stroke: var(--line);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke var(--ease);
}

/* Debug labels, shown when LINE.showBendLabels is on in main.js. */
.bend-number {
    position: absolute;
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 900;
    color: var(--accent);
    pointer-events: none;
}

/* ---------- ET Games header ---------- */

/* Sits in the top-left corner, its background flush with the top and left edges. */
.mark {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 32px 16px 16px;
    border-radius: 0 0 24px 0;
    background: var(--bg-2);
    color: var(--mark-text, var(--panel-text));
    /* Scales from the corner, so it stays flush with the top and left edges. */
    transform-origin: top left;
    transition: background-color var(--ease), color var(--ease), transform 120ms ease;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .mark:hover {
        transform: scale(1.05);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .mark:active {
        transform: scale(0.96);
    }
}

.mark__logo {
    width: auto;
    height: 64px;
}

.mark__name {
    font-weight: 900;
    font-size: 2.1rem;
    letter-spacing: 0.01em;
}

/* ---------- Tiles ---------- */

.tile {
    position: absolute;
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg);
    /* Same colour as the line, so the line looks like it wraps around the tile. */
    border: 3px solid var(--line);
    outline: 3px solid transparent;
    outline-offset: 4px;
    transition: outline-color var(--ease), background-color var(--ease), border-color var(--ease), transform 120ms ease;
}

.tile:hover {
    outline-color: var(--line);
}

.mark:focus-visible,
.tile.is-selected,
.tile:focus-visible {
    outline-color: var(--timeline-outline, var(--accent));
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .tile:hover {
        transform: scale(1.03);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .tile:active {
        transform: scale(0.97);
    }
}

.tile img,
.tile__placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile__placeholder {
    display: flex;
    align-items: flex-end;
    padding: 12px 14px;
    background: var(--tile-bg);
    color: var(--tile-text);
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    text-align: left;
    transition: background-color var(--ease), color var(--ease);
}

/* Game name over tile art. */
.tile__name {
    position: absolute;
    max-width: calc(100% - 20px);
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--tile-name-bg);
    color: var(--tile-name-text);
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
    text-align: left;
}

.tile__name[data-corner^="top"] { top: 10px; }
.tile__name[data-corner^="bottom"] { bottom: 10px; }
.tile__name[data-corner$="left"] { left: 10px; }
.tile__name[data-corner$="right"] { right: 10px; }

.tile.is-soon > img,
.tile.is-soon > .tile__placeholder {
    filter: grayscale(1);
    opacity: 0.5;
}

.tile__soon {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--soon-bg);
    color: var(--soon-text);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Side panel ---------- */

.sidepanel-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    padding: 48px 40px 28px;
    overflow-y: auto;
    background: var(--panel-bg);
    color: var(--panel-text);
    transition: background-color var(--ease), color var(--ease);
}

/* On desktop the wrappers disappear and every piece sits in one column. */
.panel__main,
.panel__drawer,
.panel__drawer-inner {
    display: contents;
}

.panel__head {
    order: 1;
    display: flex;
    align-items: center;
    gap: 18px;
}

/* The accent square is a placeholder until each game's logo exists. */
.panel__logo {
    flex: none;
    width: 68px;
    height: 68px;
    border-radius: 14px;
    background: var(--accent) center / cover no-repeat;
    transition: background-color var(--ease);
}

.panel__logo.has-logo {
    background-color: transparent;
}

.panel__title {
    font-size: clamp(1.8rem, 2.6vw, 2.6rem);
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.panel__meta {
    margin-top: 6px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.8;
}

.panel__teaser {
    order: 2;
    font-size: clamp(1.05rem, 1.2vw, 1.35rem);
    line-height: 1.55;
}

.panel__clip {
    order: 3;
    /* Keeps its shape on short screens; the panel scrolls instead. */
    flex-shrink: 0;
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: color-mix(in srgb, var(--panel-text) 8%, transparent);
    transition: background-color var(--ease);
}

.panel__clip video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.panel__clip-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    opacity: 0.5;
}

.panel__cta {
    order: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 76px;
    padding: 0 12px;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 900;
    font-size: clamp(1.3rem, 1.8vw, 1.8rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
}

.panel__cta.swap {
    box-shadow: 0 5px 0 var(--accent-edge);
    transition: opacity var(--fade), background-color 100ms ease, box-shadow 100ms ease, transform 100ms ease;
}

@media (hover: hover) {
    .panel__cta:hover {
        background: var(--accent-hover);
        box-shadow: 0 7px 0 var(--accent-hover-edge);
        transform: translateY(-2px);
    }
}

.panel__cta:focus-visible {
    background: var(--accent-hover);
    box-shadow: 0 5px 0 var(--accent-hover-edge);
}

/* Pressed: the button drops onto its edge. */
.panel__cta:active {
    background: var(--accent-hover);
    box-shadow: 0 1px 0 var(--accent-hover-edge);
    transform: translateY(4px);
}

@media (prefers-reduced-motion: reduce) {
    .panel__cta:hover,
    .panel__cta:active {
        transform: none;
    }
}

/* Upcoming games without a wishlist link yet. */
.panel__cta.is-disabled.swap {
    box-shadow: none;
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

/* Shown when no game is selected. */
.panel__intro {
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.panel__intro-logo {
    width: auto;
    height: 240px;
}

.has-small-logo .panel__intro-logo {
    height: 120px;
}

.panel__intro-title {
    font-size: clamp(1.6rem, 3.2vw, 3.2rem);
    font-weight: 900;
    line-height: 1.1;
}

/* A centred block whose text lines up on the left. */
.panel__intro-body {
    display: flex;
    flex-direction: column;
    gap: inherit;
    text-align: left;
}

.panel__intro-text {
    font-size: 1.45rem;
    line-height: 1.5;
    padding: 0 50px;
    padding-top: 20px;
    color: color-mix(in srgb, var(--panel-text) 75%, transparent);
}

.panel__intro-hint {
    font-size: 1.45rem;
    line-height: 1.5;
    padding: 0 50px;
    padding-bottom: 20px;
    color: color-mix(in srgb, #8cfcd6 75%, transparent);
}

/* Same style as the play button, but smaller. They stack when the panel is narrow. */
.panel__links {
    display: flex;
    flex-wrap: wrap;
    gap: 26px;
    width: 100%;
    margin-top: 8px;
    padding: 0 50px;
}

@media (max-width: 1500px) {
    .panel__intro-text,
    .panel__intro-hint,
    .panel__links {
        padding-left: 0;
        padding-right: 0;
    }
}

.panel__link {
    flex: 1 1 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0 12px;
    border-radius: 12px;
    background: var(--accent);
    box-shadow: 0 6px 0 var(--accent-edge);
    color: var(--accent-text);
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 100ms ease, box-shadow 100ms ease, transform 100ms ease;
}

@media (hover: hover) {
    .panel__link:hover {
        background: var(--accent-hover);
        box-shadow: 0 6px 0 var(--accent-hover-edge);
        transform: translateY(-4px);
    }
}

.panel__link:focus-visible {
    background: var(--accent-hover);
    box-shadow: 0 6px 0 var(--accent-hover-edge);
}

/* Pressed: the button drops onto its edge. */
.panel__link:active {
    background: var(--accent-hover);
    box-shadow: 0 1px 0 var(--accent-hover-edge);
    transform: translateY(3px);
}

@media (prefers-reduced-motion: reduce) {
    .panel__link:hover,
    .panel__link:active {
        transform: none;
    }
}

/* Desktop uses the heading inside the intro. Phones keep the panel's own, which stays visible when collapsed. */
@media (min-width: 768px) {
    .is-intro .panel__head {
        display: none;
    }
}

.panel__footer {
    order: 5;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--panel-divider);
    font-size: 1.05rem;
    text-align: center;
    color: color-mix(in srgb, var(--panel-text) 90%, transparent);
    transition: border-color var(--ease), color var(--ease);
}

.panel__copyright {
    display: block;
    margin-top: 6px;
}

.panel__footer a {
    text-underline-offset: 3px;
}

.panel__handle {
    display: none;
}

/* Panel content crossfade */
.swap {
    transition: opacity var(--fade);
}

.sidepanel-container.is-swapping .swap {
    opacity: 0;
}

/* ---------- 800px and narrower: half-size ET Games header ---------- */

@media (max-width: 800px) {
    .mark {
        gap: 10px;
        padding: 8px 16px 8px 8px;
        border-radius: 0 0 12px 0;
    }

    .mark__logo {
        height: 32px;
    }

    .mark__name {
        font-size: 1.05rem;
    }
}

/* ---------- 768px to 1000px: tighter side panel ---------- */

@media (min-width: 768px) and (max-width: 1000px) {
    .sidepanel-container {
        gap: 18px;
        padding: 24px 18px 18px;
    }

    /* Logo above the title, so the title gets the panel's full width. */
    .panel__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .panel__logo {
        width: 56px;
        height: 56px;
        border-radius: 12px;
    }

    .panel__cta {
        padding: 0 10px;
        font-size: 1.15rem;
    }

    .panel__intro-logo {
        height: 96px;
    }

    .has-small-logo .panel__intro-logo {
        height: 48px;
    }

    .panel__intro-text {
        font-size: 1.1rem;
    }

    .panel__intro-hint {
        font-size: 1rem;
    }
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .timeline-container {
        grid-row: 2;
    }

    .sidepanel-container {
        grid-row: 1;
        gap: 0;
        padding: 18px 16px 0;
        overflow: visible;
        touch-action: none;
        z-index: 1;
        box-shadow: 0 1px 0 var(--divider);
    }

    .panel__main {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .zone__year {
        font-size: clamp(1.25rem, 2.2vw, 2rem);
    }

    .tile__placeholder {
        font-size: 0.95rem;
    }

    .tile__name {
        font-size: 0.95rem;
    }

    .tile__soon {
        font-size: 0.7rem;
    }

    .panel__clip-placeholder {
        font-size: 0.85rem;
    }

    .panel__head {
        gap: 12px;
    }

    .panel__logo {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .panel__title {
        font-size: 1.45rem;
    }

    .panel__meta {
        margin-top: 3px;
        font-size: 0.72rem;
    }

    .panel__cta {
        min-height: 58px;
        font-size: 1.2rem;
    }

    .panel__drawer {
        display: block;
        height: 0;
        overflow: hidden;
        transition: height 250ms ease-in-out;
    }

    .panel__drawer.is-dragging {
        transition: none;
    }

    .panel__drawer-inner {
        display: flex;
        flex-direction: column;
        gap: 14px;
        padding-top: 16px;
    }

    .panel__teaser {
        font-size: 1rem;
    }

    .panel__intro {
        gap: 10px;
    }

    .panel__intro-logo {
        height: 72px;
    }

    /* The panel's own row already shows the title. */
    .panel__intro-title {
        display: none;
    }

    .panel__intro-text {
        font-size: 1rem;
    }

    .panel__intro-hint {
        font-size: 0.9rem;
    }

    .panel__link {
        min-height: 46px;
        font-size: 1rem;
    }

    .panel__footer {
        margin-top: 0;
        padding-top: 12px;
        font-size: 0.85rem;
    }

    .panel__handle {
        display: flex;
        justify-content: center;
        width: 100%;
        padding: 12px 0 10px;
        border-radius: 6px;
    }

    .panel__handle svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
        opacity: 0.6;
        transition: transform 250ms ease-in-out;
    }

    .panel__handle[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }
}
