/* The archive pages (D133). One column at every width, never a desktop
   layout. Tokens come from style.css, loaded first. */
.archive {
  --archive-col: 520px;
  overflow-x: clip;
}

/* style.css's flex rules would beat the hidden attribute. */
.archive [hidden] {
  display: none !important;
}

.archive-page a {
  color: inherit;
  text-decoration: none;
}

.archive .site-header {
  margin-bottom: 0;
}

.archive .site-header-inner {
  max-width: var(--archive-col);
}

.archive-page {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  gap: var(--space-7);
  width: 100%;
  max-width: var(--archive-col);
  margin: 0 auto;
  padding-bottom: var(--space-7);
}

.archive .site-footer {
  width: 100%;
  max-width: var(--archive-col);
  margin-inline: auto;
}

.archive-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.archive-label {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.archive-empty {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* --- The hero: two posters, with their own colour as light behind. --- */
.archive-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-5);
  text-align: center;
  isolation: isolate;
}

.archive-glow {
  position: absolute;
  z-index: -1;
  top: 0;
  width: 60%;
  height: 300px;
  object-fit: cover;
  filter: blur(64px) saturate(1.5);
  opacity: 0.4;
  pointer-events: none;
}

.archive-glow.is-left {
  left: -8%;
}

.archive-glow.is-right {
  right: -8%;
}

.archive-when {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.archive-title {
  margin: 0;
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.archive-lede {
  max-width: 38ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  text-wrap: balance;
}

/* One sentence a line, shrinking on narrow phones so none wraps. */
.archive-lede.is-lines {
  max-width: none;
  font-size: clamp(0.75rem, 3.7vw, 0.95rem);
}

.archive-lede.is-lines span {
  display: block;
}

/* Blue and underlined, so it reads as a link and not as more text. */
.archive-lede a {
  color: var(--accent-bright);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.archive-ends {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: center;
  width: 100%;
  max-width: 400px;
}

.archive-end {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.archive-end img,
.archive-poster-missing {
  display: block;
  width: 100%;
  /* Beats the img's height attribute, or the poster stretches tall. */
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.archive-end img {
  opacity: 0.45;
  transform: scale(0.94);
  transition:
    opacity 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}

.archive-end[aria-selected='true'] img {
  opacity: 1;
  transform: none;
  box-shadow: var(--elevation-4);
}

.archive-arrow {
  color: var(--accent-2);
  font-size: var(--text-xl);
  font-weight: 800;
  text-align: center;
}

/* --- Film details, straight under the posters with no box. --- */
.archive-film {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.archive-film h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.archive-facts {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.archive-synopsis {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
}

.archive-synopsis.is-cut {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Runs to the screen edge on a phone, so a sixth face peeks in. */
.archive-cast {
  display: flex;
  gap: var(--space-3);
  margin: 0 -1rem;
  padding: 2px 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  list-style: none;
}

.archive-cast li {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 76px;
  font-size: var(--text-xs);
  line-height: 1.2;
  text-align: center;
}

.archive-face {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: 700;
}

/* --- The day's card: one box, one switch. --- */
.archive-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.archive-big {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.archive-big small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0;
}

.archive-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg);
}

.archive-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.archive-tabs button[aria-selected='true'] {
  background: var(--surface-2);
  color: var(--text);
}

.archive-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* A swatch before each, matching the bar's two marks. */

/* --- Go-to cards start face down. --- */

/* --- How the day went (D145): one number and one chart a tab. --- */
.archive-pane-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.archive-big.is-gold {
  color: var(--accent-2);
}

.archive-versus {
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.archive-versus.is-up {
  background: rgb(var(--success-rgb) / 0.14);
  color: var(--success);
}

.archive-versus.is-down {
  background: rgb(var(--danger-rgb) / 0.14);
  color: var(--danger);
}

.archive-pane-line {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.archive-pane-line b {
  color: var(--text);
  font-weight: 600;
}

.archive-week {
  display: block;
  width: 100%;
  height: auto;
  margin-top: var(--space-3);
  overflow: visible;
}

.archive-week-col {
  fill: var(--surface-2);
}

.archive-week-col.is-day {
  fill: var(--accent-2);
}

.archive-week-value,
.archive-week-date {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
}

.archive-week-value.is-day,
.archive-week-date.is-day {
  fill: var(--accent-2-bright);
}

.archive-week-typical {
  stroke: rgb(232 236 244 / 0.4);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.archive-key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.archive-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.archive-key span::before {
  content: '';
  display: inline-block;
}

.archive-key .is-day::before {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent-2);
}

.archive-key .is-typical::before {
  width: 14px;
  border-top: 2px dashed rgb(232 236 244 / 0.55);
}

.archive-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.archive-flips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.archive-flip {
  display: grid;
  min-height: 164px;
  perspective: 900px;
}

.archive-flip-front,
.archive-flip-back {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.archive-flip-front {
  border: 1px dashed var(--border);
  background: none;
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 800;
  cursor: pointer;
}

.archive-flip-front span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 400;
}

.archive-flip-back {
  background: var(--surface);
  transform: rotateY(-180deg);
}

.archive-flip.is-open .archive-flip-front {
  transform: rotateY(180deg);
}

.archive-flip.is-open .archive-flip-back {
  transform: none;
}

.archive-flip-back img,
.archive-flip-back .archive-poster-missing {
  width: auto;
  height: 64px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.archive-flip-back .archive-face {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.archive-flip-back b {
  font-size: var(--text-sm);
  line-height: 1.2;
}

.archive-flip-back small {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* --- Best scores (D155): two tiles, like Most picked. --- */
.archive-bests {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.archive-best {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.archive-best h3 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
}

.archive-best-who {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.archive-best-line {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* --- A filmstrip of nearby days, edge to edge on a phone. --- */
.archive-strip {
  display: flex;
  gap: var(--space-3);
  margin: 0 -1rem;
  padding: 4px 1rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.archive-strip a {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 96px;
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: center;
  scroll-snap-align: center;
}

.archive-strip a[aria-current='page'] {
  color: var(--text);
  font-weight: 700;
}

.archive-strip a[aria-current='page'] .archive-mini {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.archive-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.archive-mini img,
.archive-mini .archive-poster-missing {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0;
}

/* On a wide screen the column has room, so the strips stop at its edge. */
@media (min-width: 552px) {
  .archive-cast,
  .archive-strip {
    margin-inline: 0;
    padding-inline: 0;
  }
}

/* --- The calendar. --- */
.archive-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.archive-month h2 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 800;
}

.archive-month a,
.archive-month span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--accent-bright);
  font-size: var(--text-lg);
}

.archive-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.archive-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-md);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s;
}

.archive-cell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
}

.archive-cell span {
  position: relative;
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.9);
}

.archive-cell.is-empty {
  color: var(--muted);
  font-weight: 400;
  opacity: 0.4;
}

.archive-cell.is-selected {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.archive-cell.is-today {
  background: var(--accent);
  color: #fff;
}

.archive-peek {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: center;
}

.archive-peek a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
}

.archive-peek a::after {
  content: '›';
  color: var(--accent-bright);
  font-size: var(--text-lg);
}

.archive-peek h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 800;
  line-height: 1.2;
}

.archive-peek p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

@media (prefers-reduced-motion: reduce) {
  .archive-end img,
  .archive-flip-front,
  .archive-flip-back,
  .archive-cell {
    transition: none;
  }
}

/* --- Plain text for readers and search: notes, the answer, the lists. --- */
.archive-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* One way to link them: the game's own rail (style.css), as a list. */
.archive-chain-wrap ol {
  margin: 0;
  list-style: none;
}

.archive-chain-wrap .chain-node {
  cursor: default;
}

.archive-chain-wrap .node-thumb-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
}

.archive-prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.archive-prevnext a {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

.archive-prevnext a:last-child {
  text-align: right;
}

.archive-prevnext small {
  color: var(--accent-bright);
  font-size: var(--text-xs);
}

.archive-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.archive-list a {
  color: var(--text);
  text-decoration: none;
}

.archive-list b {
  color: var(--accent-bright);
}

.archive-list time {
  flex: none;
  color: var(--muted);
}
