/* The timeline on /updates, the photo wall on /photos and the viewer they
   share (js/lightbox.js). Tokens come from site-refresh.css.

   The timeline is one line down the page with today on it. Above today the
   line is dashed and the nodes are open: not yet. Below it the line is solid
   and the nodes are filled: done. On a wide screen the line is in the middle
   and the entries take turns on its two sides (js/timeline.js places them). */

/* ── Timeline ───────────────────────────────────────────────────────── */
html:root body .tl-section { padding-top: clamp(1.5rem, 4vw, 2.75rem); }
html:root body .tl { --tl-x: .6875rem; --tl-node: .875rem; position: relative; max-width: 60rem; margin: 0 auto; }
html:root body .tl-part { position: relative; margin: 0; padding: 0; list-style: none; }
html:root body .tl-part[hidden] { display: none; }
html:root body .tl-entry { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem 2.5rem; align-items: start; padding: 0 0 2.5rem 2.75rem; }
html:root body .tl-entry--picture { grid-template-columns: minmax(0, 1fr) minmax(0, 21rem); }
/* Each entry carries its own stretch of the line, so the line starts at the
   first node and stops at the last one. */
html:root body .tl-entry::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--tl-x); border-left: 2px solid var(--brand); }
html:root body .tl-part--future .tl-entry::after { border-left: 2px dashed var(--line-strong); }
html:root body .tl-part--future .tl-entry:first-child::after { top: calc(.3rem + var(--tl-node) / 2); }
html:root body .tl-part--past .tl-entry:last-child::after { bottom: auto; height: calc(.3rem + var(--tl-node) / 2); }
html:root body .tl-part--past .tl-entry:last-child { padding-bottom: 0; }
html:root body .tl-entry::before { content: ""; z-index: 1; position: absolute; top: .3rem; left: calc(var(--tl-x) + 1px - var(--tl-node) / 2); width: var(--tl-node); height: var(--tl-node); box-sizing: border-box; border: 2px solid var(--brand); border-radius: 50%; background: var(--brand); }
html:root body .tl-part--future .tl-entry::before { border-color: var(--line-strong); background: var(--canvas, var(--paper)); }
html:root body .tl-text { max-width: 38rem; min-width: 0; }
html:root body .tl-date { margin: 0 0 .3rem; color: var(--muted); font-size: .9375rem; font-weight: 650; font-variant-numeric: tabular-nums; }
html:root body .tl-part--past .tl-date { color: var(--brand); }
html:root body .tl-title { margin: 0 0 .4rem; color: var(--ink); font-size: clamp(1.2rem, 2.2vw, 1.45rem); font-stretch: 88%; line-height: 1.25; }
html:root body .tl-note { margin: 0; color: var(--ink-soft, var(--ink)); font-size: 1rem; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
html:root body .tl-picture { display: block; width: 100%; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--mist); overflow: hidden; cursor: zoom-in; aspect-ratio: 4 / 3; }
html:root body .tl-picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
html:root body .tl-picture:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (hover: hover) { html:root body .tl-picture:hover { border-color: var(--brand); } }

/* Today: a node on the line, a small arrow pointing at it, and the date. */
html:root body .tl-today { position: relative; display: flex; align-items: center; min-height: 2.5rem; margin: 0; padding: 0 0 0 2.75rem; scroll-margin: 40vh 0; }
html:root body .tl-today::before { content: ""; z-index: 1; position: absolute; top: 50%; left: calc(var(--tl-x) + 1px); width: 1.125rem; height: 1.125rem; box-sizing: border-box; border: 3px solid var(--paper); border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 2px var(--brand); transform: translate(-50%, -50%); }
html:root body .tl-today__label { position: relative; display: inline-flex; align-items: baseline; gap: .5rem; padding: .4rem .8rem; border-radius: var(--r-ctl); background: var(--brand); color: var(--on-brand, #fff); font-size: .9375rem; font-weight: 700; line-height: 1.3; }
html:root body .tl-today__label::before { content: ""; position: absolute; top: 50%; right: 100%; border: .4rem solid transparent; border-right-color: var(--brand); border-left: 0; transform: translateY(-50%); }
html:root body .tl-today__date { font-weight: 500; font-variant-numeric: tabular-nums; opacity: .9; }
html:root body .tl-gap { height: 2.5rem; margin-left: var(--tl-x); border-left: 2px solid var(--brand); }
html:root body .tl-gap--future { border-left: 2px dashed var(--line-strong); }
/* Nothing coming up: no dashed line above today; the timeline starts there. */
html:root body .tl-gap[hidden] { display: none; }

html:root body .tl-today:focus { outline: none; }
html:root body .tl-today:focus-visible .tl-today__label { outline: 3px solid var(--focus); outline-offset: 3px; }
html:root body .tl-status { margin: 0 0 1.5rem; color: var(--muted); }

/* A way back to today once it has scrolled out of sight. */
html:root body .tl-jump { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1.25rem, env(safe-area-inset-bottom)); z-index: 30; display: inline-flex; align-items: center; gap: .4rem; min-height: 2.75rem; padding: .5rem .95rem; border: 1px solid var(--brand); border-radius: 999px; background: var(--paper); color: var(--brand); font: inherit; font-size: .9375rem; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(8, 20, 43, .16); }
html:root body .tl-jump[hidden] { display: none; }
html:root body .tl-jump svg { width: .9rem; height: .9rem; }
html:root body .tl-jump[data-direction="up"] svg { transform: rotate(180deg); }
html:root body .tl-jump:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (hover: hover) { html:root body .tl-jump:hover { background: var(--brand); color: var(--on-brand, #fff); } }

html:root body .tl-more { max-width: 60rem; margin: 2rem auto 0; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); }
html:root body .tl-more a { color: var(--brand); text-decoration: underline; text-underline-offset: .2em; }

/* Wide screens: the line in the middle, entries to its left and right.
   js/timeline.js sets .tl--sides, each entry's side and its rows; a row is 4px. */
@media (min-width: 861px) {
  html:root body .tl--sides { --tl-gutter: 3rem; }
  html:root body .tl--sides .tl-part { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: calc(var(--tl-gutter) * 2); grid-auto-rows: 4px; align-items: start; }
  html:root body .tl--sides .tl-part[hidden] { display: none; }
  html:root body .tl--sides .tl-part::before { content: ""; position: absolute; top: var(--tl-line-top, 0px); bottom: var(--tl-line-bottom, 0px); left: calc(50% - 1px); border-left: 2px solid var(--brand); }
  html:root body .tl--sides .tl-part--future::before { border-left: 2px dashed var(--line-strong); }
  html:root body .tl--sides .tl-part .tl-entry.tl-entry { grid-template-columns: minmax(0, 1fr); gap: .9rem; padding: 0; }
  html:root body .tl--sides .tl-entry[data-side="left"] { grid-column: 1; justify-items: end; text-align: right; }
  html:root body .tl--sides .tl-entry[data-side="right"] { grid-column: 2; justify-items: start; }
  /* The node sits on the line; a short arm joins it to its entry. */
  html:root body .tl--sides .tl-entry[data-side="right"]::before { left: calc(-1 * var(--tl-gutter) - var(--tl-node) / 2); }
  html:root body .tl--sides .tl-entry[data-side="left"]::before { left: auto; right: calc(-1 * var(--tl-gutter) - var(--tl-node) / 2); }
  html:root body .tl--sides .tl-part .tl-entry.tl-entry::after { top: calc(.3rem + var(--tl-node) / 2 - 1px); bottom: auto; height: 0; width: calc(var(--tl-gutter) - .75rem); border-left: 0; border-top: 2px solid var(--brand); }
  html:root body .tl--sides .tl-part--future .tl-entry.tl-entry::after { border-left: 0; border-top: 2px dashed var(--line-strong); }
  html:root body .tl--sides .tl-part .tl-entry[data-side="right"]::after { left: calc(-1 * var(--tl-gutter)); }
  html:root body .tl--sides .tl-part .tl-entry[data-side="left"]::after { left: auto; right: calc(-1 * var(--tl-gutter)); }
  html:root body .tl--sides .tl-text { max-width: none; }
  html:root body .tl--sides .tl-picture { max-width: 24rem; }
  /* Today is on the line itself. */
  html:root body .tl--sides .tl-today { justify-content: center; padding-left: 0; }
  html:root body .tl--sides .tl-today::before, html:root body .tl--sides .tl-today__label::before { display: none; }
  html:root body .tl--sides .tl-gap { margin-left: calc(50% - 1px); }
}

@media (max-width: 720px) {
  html:root body .tl { --tl-x: .5rem; --tl-node: .75rem; }
  html:root body .tl-entry, html:root body .tl-entry--picture { grid-template-columns: minmax(0, 1fr); gap: .875rem; padding: 0 0 2rem 1.875rem; }
  html:root body .tl-today { padding-left: 1.875rem; }
  html:root body .tl-picture { max-width: 26rem; }
}

/* ── Photo wall ─────────────────────────────────────────────────────── */
html:root body .wall-section { padding-top: clamp(1.5rem, 4vw, 2.75rem); }
html:root body .wall-status { margin: 0; color: var(--muted); font-size: 1.05rem; }
/* Rows of equal height, each photo as wide as its shape asks for. */
html:root body .wall { --wall-row: 15rem; display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
html:root body .wall::after { content: ""; flex-grow: 1000; }
html:root body .wall-item { position: relative; flex-grow: calc(var(--shape) * 100); flex-basis: calc(var(--shape) * var(--wall-row)); min-width: 0; margin: 0; }
html:root body .wall-photo { position: relative; display: block; width: 100%; margin: 0; padding: 0; border: 0; border-radius: var(--r-ctl); background: var(--mist); overflow: hidden; cursor: zoom-in; aspect-ratio: var(--shape); }
html:root body .wall-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
html:root body .wall-photo:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
html:root body .wall-caption { position: absolute; inset: auto 0 0 0; padding: 1.75rem .7rem .55rem; background: linear-gradient(to top, rgba(6, 16, 38, .78), rgba(6, 16, 38, 0)); color: #fff; font-size: .875rem; font-weight: 600; line-height: 1.35; text-align: left; opacity: 0; transition: opacity .15s ease; pointer-events: none; }
html:root body .wall-photo:focus-visible .wall-caption { opacity: 1; }
@media (hover: hover) { html:root body .wall-photo:hover .wall-caption { opacity: 1; } }
/* Without a pointer there is no hover, so the caption is always there. */
@media (hover: none) { html:root body .wall-caption { opacity: 1; } }
@media (max-width: 720px) { html:root body .wall { --wall-row: 8.5rem; gap: .375rem; } html:root body .wall-caption { padding: 1.25rem .5rem .4rem; font-size: .8125rem; } }
@media (prefers-reduced-motion: reduce) { html:root body .wall-caption { transition: none; } }

/* ── Viewer ─────────────────────────────────────────────────────────── */
html:root body .lightbox { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: rgba(4, 10, 24, .94); color: #fff; }
html:root body .lightbox[hidden] { display: none; }
html:root body .lightbox__stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 3.5rem 1rem .75rem; }
html:root body .lightbox__image { display: block; max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: 4px; }
html:root body .lightbox__text { display: grid; gap: .2rem; justify-items: center; padding: .25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom)); text-align: center; }
html:root body .lightbox__caption { margin: 0; max-width: 46rem; color: #fff; font-size: 1.0625rem; font-weight: 600; line-height: 1.45; }
html:root body .lightbox__meta { margin: 0; color: rgba(255, 255, 255, .72); font-size: .9375rem; font-variant-numeric: tabular-nums; }
html:root body .lightbox__button { position: absolute; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: rgba(4, 10, 24, .55); color: #fff; cursor: pointer; }
html:root body .lightbox__button svg { width: 1.1rem; height: 1.1rem; }
html:root body .lightbox__button[hidden] { display: none; }
html:root body .lightbox__button:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
html:root body .lightbox__close { top: max(.75rem, env(safe-area-inset-top)); right: max(.75rem, env(safe-area-inset-right)); }
html:root body .lightbox__prev { top: 50%; left: max(.75rem, env(safe-area-inset-left)); transform: translateY(-50%); }
html:root body .lightbox__next { top: 50%; right: max(.75rem, env(safe-area-inset-right)); transform: translateY(-50%); }
@media (hover: hover) { html:root body .lightbox__button:hover { background: #fff; color: #061026; } }
@media (max-width: 720px) {
  html:root body .lightbox__stage { padding: 3.5rem .5rem .5rem; }
  html:root body .lightbox__prev, html:root body .lightbox__next { top: auto; bottom: .5rem; transform: none; }
}
