/* =====================================================================
   Timeline (js/timeline.js): full-screen view of the Story So Far.
   --c is the colour of the game in the middle of the screen (or the one
   open); the checkerboard, glows and buttons follow it.
   ===================================================================== */
@property --c { syntax: '<color>'; inherits: true; initial-value: #7fe6ff; }
@property --bgc { syntax: '<color>'; inherits: true; initial-value: #070b2b; }

html.tl-open, html.tl-open body { overflow: hidden; }

.tl {
  --c: #7fe6ff; --bgc: #070b2b; --tl-s: 300px; --lw: 290px; --tl-bracket: -380px;   /* set by layout() in js/timeline.js */
  --tl-glass: linear-gradient(180deg, rgba(18, 30, 78, 0.82), rgba(6, 12, 40, 0.9));
  --tl-edge: color-mix(in srgb, var(--c) 45%, rgba(180, 225, 255, 0.5));
  position: fixed; inset: 0; z-index: 1000; overflow: hidden; color: #fff; background: #03041a;
  font-family: var(--font-menu, 'Nunito Sans', sans-serif); user-select: none; -webkit-user-select: none;
  opacity: 0; transition: opacity .28s ease; outline: none;
}
.tl.shown { opacity: 1; }
.tl[hidden] { display: none; }

/* ---------- background: the thumbnails' tint across the whole screen (the game's colour glowing
   over its image background) with a 45° checkerboard ---------- */
.tl-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; transition: --c .7s ease, --bgc .7s ease;   /* the fade runs here only, so the rest of the screen isn't restyled every frame */
  background:
    radial-gradient(ellipse 65% 60% at 50% 55%, color-mix(in srgb, var(--c) 28%, transparent), transparent 70%),
    var(--bgc); }
.tl-grid { position: absolute; inset: -80%; opacity: .055; will-change: transform; transform: rotate(45deg);
  background: repeating-conic-gradient(color-mix(in srgb, var(--c) 75%, #fff) 0 25%, transparent 0 50%); background-size: 64px 64px; }   /* 64px: GRID in js/timeline.js */
/* the checkerboard fades into the solid background towards the bottom, under the edge vignette */
.tl-bg::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 40%, rgba(2, 3, 16, 0.6)), linear-gradient(180deg, transparent 30%, var(--bgc) 88%); }

/* ---------- the line and its games ---------- */
.tl-stage { position: absolute; inset: 0; cursor: grab; touch-action: none; }
.tl.dragging .tl-stage { cursor: grabbing; }
.tl-track { position: absolute; left: 50%; top: 49%; width: 0; height: 0; will-change: transform; }
.tl-line { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; transition: opacity .4s ease; }
.tl-line path { fill: none; stroke-linecap: round; }
.tl-glow { stroke-width: 12; opacity: .7; }
.tl-core { stroke-width: 3; }
.tl-flow { stroke: #fff; stroke-width: 2; stroke-dasharray: 1 26; opacity: .55; animation: tlFlow 1.6s linear infinite; }
/* the drifting dots sit in a separate layer from the blurred glow, so moving them never re-blurs it */
.tl-line.flow { will-change: transform; }
@keyframes tlFlow { to { stroke-dashoffset: -27; } }

.tl-node { position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; outline: none;
  transition: opacity .35s ease; }
.tl.dragging .tl-node { cursor: grabbing; }
.tl-orb { position: absolute; left: 0; top: 0; width: 14px; height: 14px; border-radius: 3px; background: #fff; transform: translate(-50%, -50%) rotate(45deg);
  border: 2px solid var(--nc); box-shadow: 0 0 10px var(--nc), 0 0 26px var(--nc); transition: transform .35s ease; }
.tl-node.active .tl-orb { transform: translate(-50%, -50%) rotate(45deg) scale(1.35); }
/* a short stem from the line to the logo */
.tl-node::before { content: ""; position: absolute; left: -1px; width: 2px; height: 20px; pointer-events: none; }
.tl-node.up::before { bottom: 8px; background: linear-gradient(0deg, var(--nc), transparent); }
.tl-node.down::before { top: 8px; background: linear-gradient(180deg, var(--nc), transparent); }

.tl-card { position: absolute; left: 0; width: var(--lw); display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translateX(-50%) scale(.84); opacity: .5; transition: transform .4s cubic-bezier(.2, .8, .2, 1), opacity .4s ease; }
.tl-node.up .tl-card { bottom: 30px; transform-origin: 50% 100%; }
.tl-node.down .tl-card { top: 30px; transform-origin: 50% 0; }
.tl-node.active .tl-card { transform: translateX(-50%); opacity: 1; }
.tl-node:hover .tl-card { opacity: 1; }
.tl-node:focus-visible .tl-label b { outline: 2px solid var(--nc); outline-offset: 4px; border-radius: 4px; }
.tl-logo { position: relative; width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.tl-logo::before { content: ""; position: absolute; inset: 0 -8%; border-radius: 50%; opacity: .35; transition: opacity .4s ease;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--nc) 55%, transparent), transparent); }
.tl-node.active .tl-logo::before { opacity: 1; }
.tl-logo img, .tl-d-logo img { position: relative; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.tl-logo img { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--nc) 55%, transparent)); transition: transform .4s ease; }
.tl-node:hover .tl-logo img { transform: scale(1.04); }
.tl-emblem { position: relative; width: 42%; color: var(--nc, var(--c)); filter: drop-shadow(0 0 14px var(--nc, var(--c))); }
.tl-emblem svg { width: 100%; height: auto; display: block; }
.tl-label { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2; max-width: 100%; }
.tl-label b { font-weight: 800; font-size: .86rem; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 0 12px color-mix(in srgb, var(--nc) 70%, transparent), 0 1px 3px rgba(0, 0, 0, 0.8); }
.tl-label small { margin-top: 2px; font-size: .72rem; color: #b9c6ec; letter-spacing: .04em; }

/* ---------- chrome: title, ×, arrows, dots ---------- */
.tl-head { position: absolute; left: 28px; top: 22px; z-index: 4; pointer-events: none; }
.tl-eyebrow { display: block; font-size: .66rem; font-weight: 800; letter-spacing: .28em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 65%, #fff); }
.tl-head h2 { position: relative; display: inline-block; overflow: hidden; margin: 6px 0 0; padding: 7px 40px 7px 20px; font-size: 1.35rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 35%, transparent), rgba(42, 99, 216, 0.2) 60%, rgba(12, 24, 70, 0.6));
  border: 1px solid var(--tl-edge); border-radius: 16px 0 16px 0; text-shadow: 0 0 14px color-mix(in srgb, var(--c) 80%, transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.tl-head h2::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #fff, var(--c) 45%, transparent); }
.tl-hint { margin: 10px 0 0; font-size: .74rem; color: #aab8e0; letter-spacing: .05em; transition: opacity .3s ease; }

.tl-close, .tl-arrow, .tl-dots button, .tl-back, .tl-d-nav button, .tl-d-more { font: inherit; }
.tl-close, .tl-arrow { position: absolute; z-index: 6; display: grid; place-items: center; color: #fff; cursor: pointer; padding: 0;
  background: var(--tl-glass); border: 1px solid var(--tl-edge); box-shadow: 0 0 16px color-mix(in srgb, var(--c) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, opacity .25s ease; }
.tl-close:hover, .tl-arrow:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 35%, rgba(36, 60, 130, 0.9)), rgba(12, 24, 70, 0.92)); box-shadow: 0 0 24px color-mix(in srgb, var(--c) 65%, transparent); }
.tl-close:focus-visible, .tl-arrow:focus-visible, .tl-dots button:focus-visible, .tl-back:focus-visible, .tl-d-nav button:focus-visible, .tl-d-more:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.tl-close svg, .tl-arrow svg { width: 22px; height: 22px; }
.tl-close { top: 20px; right: 22px; width: 48px; height: 48px; border-radius: 14px 0 14px 0; }
.tl-close:hover { transform: rotate(90deg); }
.tl-arrow { top: 49%; width: 58px; height: 58px; border-radius: 16px 0 16px 0; transform: translateY(-50%); }
.tl-arrow.prev { left: 24px; }
.tl-arrow.next { right: 24px; }
.tl-arrow.prev:hover { transform: translateY(-50%) translateX(-3px); }
.tl-arrow.next:hover { transform: translateY(-50%) translateX(3px); }
.tl-arrow:disabled { opacity: 0; pointer-events: none; }
.tl-arrow-name { position: absolute; top: calc(100% + 9px); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
  font-size: .64rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #cfe0ff; text-shadow: 0 1px 3px #000; }
.tl-arrow.prev .tl-arrow-name { left: 0; }
.tl-arrow.next .tl-arrow-name { right: 0; text-align: right; }

.tl-modes { position: absolute; left: 50%; top: 24px; z-index: 6; transform: translateX(-50%); display: flex; padding: 4px; gap: 4px;
  background: rgba(4, 8, 30, 0.65); border: 1px solid var(--tl-edge); border-radius: 14px 0 14px 0; box-shadow: 0 0 16px color-mix(in srgb, var(--c) 25%, transparent); }
.tl-modes button { font: inherit; padding: 8px 16px; cursor: pointer; color: #b9c6ec; background: transparent; border: 1px solid transparent; border-radius: 10px 0 10px 0;
  font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; transition: color .2s ease, background .2s ease, box-shadow .2s ease; }
.tl-modes button:hover { color: #fff; }
.tl-modes button.active { color: #fff; border-color: var(--tl-edge); text-shadow: 0 0 10px color-mix(in srgb, var(--c) 80%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 40%, rgba(36, 60, 130, 0.9)), rgba(12, 24, 70, 0.9)); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent); }
.tl-modes button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* each era in timeline order: a bracket under its games, behind the line and the games, with its
   name on the bracket (kept in view by apply() in js/timeline.js) */
.tl-era-band { position: absolute; top: var(--tl-bracket); height: 16px; pointer-events: none; transition: opacity .35s ease;
  border: 1px solid rgba(220, 235, 255, 0.45); border-top: 0; border-radius: 0 0 10px 10px; box-shadow: 0 1px 10px rgba(160, 220, 255, 0.18); }
.tl-era-band span { position: absolute; top: 100%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; padding: 4px 14px;
  font-size: .68rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: #fff;
  background: #070b2b; border: 1px solid rgba(220, 235, 255, 0.45); border-radius: 10px 0 10px 0; text-shadow: 0 0 8px rgba(160, 220, 255, 0.8); }
/* era of the game in the middle, under the order buttons (release order only) */
.tl-era { position: absolute; left: 50%; top: 82px; z-index: 6; transform: translateX(-50%); pointer-events: none; white-space: nowrap; text-align: center;
  font-size: .8rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: #fff; text-shadow: 0 0 12px color-mix(in srgb, var(--c) 80%, transparent), 0 1px 3px #000; transition: opacity .3s ease; }
.tl-era small { display: block; font-size: .58rem; letter-spacing: .3em; color: color-mix(in srgb, var(--c) 60%, #fff); }
.tl.mode-story .tl-era { display: none; }   /* the brackets name the eras instead */
.tl.is-detail .tl-era-band, .tl.is-detail .tl-era { opacity: 0; }
.tl-dots { position: absolute; left: 50%; bottom: 26px; z-index: 6; transform: translateX(-50%); display: flex; gap: 10px; padding: 9px 14px;
  background: rgba(4, 8, 30, 0.6); border: 1px solid rgba(180, 225, 255, 0.18); border-radius: 12px 0 12px 0; }
.tl-dots button { width: 10px; height: 10px; padding: 0; border: 1px solid var(--nc); border-radius: 2px; background: color-mix(in srgb, var(--nc) 30%, transparent); transform: rotate(45deg); cursor: pointer; transition: transform .25s ease, background .25s ease, box-shadow .25s ease; }
.tl-dots button:hover { background: var(--nc); }
.tl-dots button.active { background: #fff; box-shadow: 0 0 10px var(--nc), 0 0 18px var(--nc); transform: rotate(45deg) scale(1.3); }

/* ---------- a game's recap: logo left, text right ---------- */
/* an open game sits over everything; only the ×, the side arrow buttons and the dots stay above it, and the
   arrows drop their game names so nothing overlaps the text */
.tl.is-detail .tl-arrow, .tl.is-detail .tl-dots { z-index: 8; }   /* the dots sit below the text panel, so they stay usable */
.tl.is-detail .tl-arrow-name { display: none; }
.tl-close { z-index: 9; }
.tl-detail { position: absolute; inset: 0; z-index: 7; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 4vw; padding: 100px 120px 84px; }
.tl-detail[hidden] { display: none; }
.tl-d-logo { position: relative; justify-self: center; width: min(100%, 580px); aspect-ratio: 4 / 3; display: grid; place-items: center; transform-origin: 0 0; pointer-events: none;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .45s ease-in; }
.tl-d-logo::before { content: ""; position: absolute; inset: -6% -12%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 50%, transparent), transparent); }
.tl-d-logo img { filter: drop-shadow(0 0 24px color-mix(in srgb, var(--c) 60%, transparent)); }
.tl-d-logo .tl-emblem { width: 40%; }
.tl-d-panel { max-height: 100%; overflow: auto; overscroll-behavior: contain; user-select: text; -webkit-user-select: text; padding: 20px 26px 22px;
  background: var(--tl-glass); border: 1px solid var(--tl-edge); border-radius: 20px 0 20px 0;
  box-shadow: 0 0 30px color-mix(in srgb, var(--c) 25%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 20px 50px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateX(40px); transition: opacity .35s ease, transform .5s cubic-bezier(.2, .8, .2, 1); scrollbar-color: color-mix(in srgb, var(--c) 50%, #334) transparent; }
.tl.is-detail .tl-d-panel { opacity: 1; transform: none; transition-delay: .08s; }
.tl.is-detail .tl-node, .tl.is-detail .tl-line, .tl.is-detail .tl-hint { opacity: 0; pointer-events: none; }
.tl.is-detail .tl-stage { cursor: default; }

.tl-d-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.tl-back { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px 7px 9px; cursor: pointer; color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--tl-edge); border-radius: 10px 0 10px 0; transition: background .2s ease, box-shadow .2s ease; }
.tl-back:hover { background: color-mix(in srgb, var(--c) 25%, rgba(0, 0, 0, 0.3)); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent); }
.tl-back svg { width: 16px; height: 16px; }
.tl-d-count { font-size: .7rem; font-weight: 800; letter-spacing: .2em; color: #aab8e0; }
.tl-d-panel h2 { margin: 4px 0 0; font-size: clamp(1.4rem, 2.6vw, 2.1rem); font-weight: 800; letter-spacing: .06em; line-height: 1.15; text-shadow: 0 0 22px color-mix(in srgb, var(--c) 55%, transparent); }
.tl-d-sub { margin-top: 4px; font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 55%, #fff); }
.tl-d-summary { margin: 14px 0 18px; padding-left: 14px; border-left: 3px solid var(--c); font-size: 1.02rem; font-style: italic; font-weight: 300; color: #e4e8ff; }
.tl-d-body { margin-top: 14px; font-size: .95rem; }
.tl-d-body h4.body-h { color: color-mix(in srgb, var(--c) 60%, #fff); }
.tl-d-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--c) 60%, #fff); }
.tl-d-more:hover { color: #fff; }
.tl-d-more svg { width: 15px; height: 15px; }
.tl-d-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(180, 225, 255, 0.18); }
.tl-d-nav button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 12px; cursor: pointer; color: #fff; text-align: left;
  background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(180, 225, 255, 0.25); border-radius: 12px 0 12px 0; transition: background .2s ease, border-color .2s ease; }
.tl-d-nav button.next { justify-content: flex-end; text-align: right; }
.tl-d-nav button:hover { background: color-mix(in srgb, var(--c) 22%, rgba(0, 0, 0, 0.28)); border-color: var(--tl-edge); }
.tl-d-nav button span { min-width: 0; font-size: .8rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-d-nav small { display: block; font-size: .6rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #aab8e0; }
.tl-d-nav svg { width: 18px; height: 18px; flex: none; }

/* ---------- smaller screens ---------- */
@media (max-width: 760px) {
  .tl-head { left: 16px; top: 14px; }
  .tl-head h2 { font-size: 1rem; padding: 6px 26px 6px 14px; }
  .tl-hint { display: none; }
  .tl-close { top: 14px; right: 16px; width: 42px; height: 42px; }
  .tl-modes { top: 74px; left: 16px; transform: none; }
  .tl-modes button { padding: 6px 10px; font-size: .62rem; letter-spacing: .1em; }
  .tl-detail { padding-top: 118px !important; }
  .tl-arrow { width: 44px; height: 44px; }
  .tl-arrow.prev { left: 10px; }
  .tl-arrow.next { right: 10px; }
  .tl-arrow-name { display: none; }
  .tl-dots { bottom: 16px; gap: 7px; padding: 8px 10px; }
  .tl-era { top: 118px; left: 16px; transform: none; text-align: left; font-size: .7rem; }
  .tl-detail { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: stretch; gap: 10px; padding: 70px 16px 62px; }
  .tl-d-logo { width: min(64vw, 280px); }
  .tl-d-panel { padding: 16px 16px 18px; transform: translateY(30px); }
  .tl.is-detail .tl-arrow { display: none; }   /* the panel's own Previous / Next buttons take over */
}
/* ---------- phones: the line runs down the left, games on its right ---------- */
/* lighter effects to keep dragging smooth: no blur on the glow (a wide faint stroke instead), still
   dots, and no soft shadow behind the logos */
.tl.vert .tl-glow { filter: none; stroke-width: 10; opacity: .3; }
.tl.vert .tl-flow { animation: none; }
.tl.vert .tl-logo img, .tl.vert .tl-emblem { filter: none; }
.tl.vert .tl-track { left: 52px; top: 52%; }
.tl.vert .tl-node::before { left: 8px; top: -1px; bottom: auto; width: calc(12px + var(--off, 0px)); height: 2px; background: linear-gradient(90deg, var(--nc), transparent); }
.tl.vert .tl-node .tl-card { left: calc(22px + var(--off, 0px)); top: 0; bottom: auto; align-items: flex-start; transform: translateY(-50%) scale(.84); transform-origin: 0 50%; }
.tl.vert .tl-node.active .tl-card { transform: translateY(-50%); }
.tl.vert .tl-label { align-items: flex-start; text-align: left; }
.tl.vert .tl-logo img { object-position: left center; }
.tl.vert .tl-logo::before { inset: 0 20% 0 -12%; }
/* the era bracket runs down the left edge, its name turned on its side */
.tl.vert .tl-era-band { left: var(--tl-band-x, -40px); width: 12px; height: auto; border: 1px solid rgba(220, 235, 255, 0.45); border-right: 0; border-radius: 10px 0 0 10px; box-shadow: -1px 0 10px rgba(160, 220, 255, 0.18); }
.tl.vert .tl-era-band span { left: 0; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); }
/* the title, order buttons and dots sit over a fade so the games scroll out of sight under them */
.tl.vert::before, .tl.vert::after { content: ""; position: absolute; left: 0; right: 0; z-index: 2; pointer-events: none; }
.tl.vert::before { top: 0; height: 160px; background: linear-gradient(180deg, color-mix(in srgb, var(--bgc) 92%, #000), transparent); }
.tl.vert::after { bottom: 0; height: 90px; background: linear-gradient(0deg, color-mix(in srgb, var(--bgc) 92%, #000), transparent); }
.tl.vert.is-detail::before, .tl.vert.is-detail::after { opacity: 0; }
/* up / down buttons on the right, above the dots */
.tl.vert .tl-arrow { left: auto; right: 14px; top: auto; transform: none; }
.tl.vert .tl-arrow.prev { bottom: 124px; }
.tl.vert .tl-arrow.next { bottom: 70px; }
.tl.vert .tl-arrow svg { transform: rotate(90deg); }
.tl.vert .tl-arrow:hover { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .tl, .tl *, .tl *::before { transition-duration: .01s !important; animation: none !important; }
}
