/* 04 · Subjects: the range there is to explore, between the path of section 03 and the closing scene. One surface of
   triangles in two rows, every edge shared, wider than the window; atlas.js repeats it to either side and moves it as
   one piece. --b is a facet's base and --h its height, so the strip is 2 × --h tall and repeats every 4 × --b. Every
   image carries the same grade (cation/art/atlas/grade.html), shown dimmed until a facet is pointed at or focused.
   The sets don't form stacking contexts of their own, so a facet that opens over the next set's still covers it. */

.atlas {
  --b: min(35vw, 53svh);
  --h: calc(var(--b) * 0.6);
  position: relative;
  padding-top: var(--space-section);
}

/* ---------- The heading: one quiet line, with the count and how to move the strip ---------- */

.atlas-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: calc(14 * var(--z)) calc(32 * var(--z));
  max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
  margin-bottom: clamp(28 * var(--z), 3vw, 52 * var(--z));
}
@media (min-width: 1080px) and (min-height: 600px) {
  .atlas-head { max-width: none; padding-inline: calc(58 * var(--s)) calc(55 * var(--s)); }
}
.atlas-title { font-size: clamp(30 * var(--z), 2.9vw, 52 * var(--z)); font-weight: 500; line-height: 1.05; letter-spacing: -0.035em; }
.atlas-hint {
  display: flex; align-items: center; gap: calc(12 * var(--z));
  font-size: calc(14 * var(--z)); line-height: 1.4; color: var(--text-3); white-space: nowrap;
}
.atlas-hint-icon { width: calc(28 * var(--z)); height: calc(10 * var(--z)); color: var(--text-4); }
.atlas-hint-swipe { display: none; }
@media (hover: none) {
  .atlas-hint-drag { display: none; }
  .atlas-hint-swipe { display: inline; }
}

/* ---------- The strip ---------- */

.atlas-strip {
  position: relative;
  height: calc(2 * var(--h));
  /* Without the script it simply scrolls; atlas.js takes over and moves the track instead. */
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.atlas-strip.is-live {
  overflow: hidden; overflow: clip;
  touch-action: pan-y;
  cursor: grab;
  -webkit-user-select: none; user-select: none;
}
.atlas-strip.is-dragging { cursor: grabbing; }
.atlas-track { position: absolute; left: 0; top: 0; width: calc(4.5 * var(--b)); height: 100%; }
.atlas-strip.is-live .atlas-track { width: 0; will-change: transform; }
.atlas-set { position: absolute; left: calc(var(--copy, 0) * 4 * var(--b)); top: 0; width: calc(4 * var(--b)); height: 100%; }
.atlas-list { position: absolute; inset: 0; }

/* A facet's box covers every triangle it can grow into, and its picture fills the box at one scale; the clip on its view
   shows the facet. The link over it keeps the resting triangle as its only hit area, even while the view is open, so
   pointing at a triangle the open one covers opens that one instead. A top-row ▲ or bottom-row ▼ grows from its point, so its box is two bases wide; the others grow from a corner,
   towards the middle of the window (atlas.js adds .grows-left), so theirs is three. --rest and --grown are the two
   triangles, as fractions of the box; --lx and --ly place the label at the middle of whichever is showing. */
.facet {
  position: absolute; top: 0; height: calc(2 * var(--h));
  left: calc((var(--j) - 1) * var(--b) / 2); width: calc(2 * var(--b));
  z-index: 0;
  pointer-events: none;
  transition: z-index 0.5s linear;
}
.facet.is-corner { left: calc(var(--j) * var(--b) / 2 - var(--b)); width: calc(3 * var(--b)); }
.facet.is-apex.is-up {
  --rest: polygon(50% 0, 75% 50%, 25% 50%); --grown: polygon(50% 0, 100% 100%, 0 100%);
  --lx: 50%; --ly: 31.5%; --lx-grown: 50%; --ly-grown: 63%;
}
.facet.is-apex.is-down {
  --rest: polygon(25% 50%, 75% 50%, 50% 100%); --grown: polygon(0 0, 100% 0, 50% 100%);
  --lx: 50%; --ly: 68.5%; --lx-grown: 50%; --ly-grown: 37%;
}
.facet.is-corner.is-down {
  --rest: polygon(33.333% 0, 66.667% 0, 50% 50%); --grown: polygon(33.333% 0, 100% 0, 66.667% 100%);
  --lx: 50%; --ly: 18.5%; --lx-grown: 66.667%; --ly-grown: 37%;
}
.facet.is-corner.is-down.grows-left { --grown: polygon(0 0, 66.667% 0, 33.333% 100%); --lx-grown: 33.333%; }
.facet.is-corner.is-up {
  --rest: polygon(50% 50%, 66.667% 100%, 33.333% 100%); --grown: polygon(66.667% 0, 100% 100%, 33.333% 100%);
  --lx: 50%; --ly: 81.5%; --lx-grown: 66.667%; --ly-grown: 63%;
}
.facet.is-corner.is-up.grows-left { --grown: polygon(33.333% 0, 66.667% 100%, 0 100%); --lx-grown: 33.333%; }

.facet-view {
  position: absolute; inset: 0; background: #0a0c18;
  clip-path: var(--rest);
  transition: clip-path 0.5s var(--ease-in-out);
}
.facet-link { position: absolute; inset: 0; display: block; clip-path: var(--rest); pointer-events: auto; -webkit-tap-highlight-color: transparent; }
.facet-link:focus-visible { outline: none; }
.facet img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0.66;
  transition: opacity 0.6s var(--ease-out);
  pointer-events: none;
}

/* The grown triangle's edge, which comes up once it has opened. A corner facet carries one for each way it can grow. */
.facet-edge { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: #efe4bd; opacity: 0; transition: opacity 0.15s linear; pointer-events: none; }
.facet-edge polygon { stroke-width: 2; vector-effect: non-scaling-stroke; }
.facet .edge-left, .facet.grows-left .edge-right { display: none; }
.facet.grows-left .edge-left { display: inline; }

/* The name sits at the middle of the facet, a little towards its wide end, with its discipline over it, so the labels
   zigzag along the strip one to a triangle. */
.facet-label {
  position: absolute; left: var(--lx); top: var(--ly); translate: -50% -50%;
  display: flex; flex-direction: column-reverse; align-items: center; gap: calc(var(--b) * 0.009);
  text-align: center; white-space: nowrap; pointer-events: none;
  transition: opacity 0.4s var(--ease-out), left 0.5s var(--ease-in-out), top 0.5s var(--ease-in-out), scale 0.5s var(--ease-in-out);
}
.facet.is-off .facet-label { opacity: 0; }
.facet-name {
  font-size: max(17 * var(--z), var(--b) * 0.042); font-weight: 500; line-height: 1.1; letter-spacing: -0.015em;
  color: var(--text-2); text-shadow: 0 1px 16px rgba(4, 5, 12, 0.7);
  transition: color 0.5s var(--ease-out);
}
.facet-kind {
  font-size: max(10 * var(--z), var(--b) * 0.0195); font-weight: 500; line-height: 1.2; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-4);
  transition: color 0.5s var(--ease-out);
}

/* One facet lit, the rest held back a little further. */
.atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) img,
.facet:has(> .facet-link:focus-visible) img { opacity: 1; }
.atlas-strip:not(.is-dragging):has(.facet-link:hover) .facet:not(:has(> .facet-link:hover)) img,
.atlas-strip:has(.facet-link:focus-visible) .facet:not(:has(> .facet-link:focus-visible)) img { opacity: 0.36; }
.atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) .facet-name,
.facet:has(> .facet-link:focus-visible) .facet-name { color: var(--text); }
.atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) .facet-kind,
.facet:has(> .facet-link:focus-visible) .facet-kind { color: var(--gold); }

/* Held for a beat, or focused, the facet opens: its window widens from one corner into a triangle of its own shape,
   twice the size, over the three it shares that space with. The picture stays put and the window reveals more of it.
   It opens quickly and settles slowly, closes a little faster, and stays open while the pointer is on the triangle it
   opened from; moving onto any other resting triangle, covered or not, opens that one. */
@media (hover: hover) {
  .atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) { z-index: 3; transition: z-index 0s; }
  .atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) .facet-view { clip-path: var(--grown); transition: clip-path 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.14s; }
  .atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) .facet-label {
    left: var(--lx-grown); top: var(--ly-grown); scale: 1.18;
    transition: opacity 0.4s var(--ease-out), left 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.14s, top 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.14s, scale 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.14s;
  }
  .atlas-strip:not(.is-dragging) .facet:has(> .facet-link:hover) .facet-edge { opacity: 0.5; transition: opacity 0.5s var(--ease-out) 0.55s; }
}
.facet:has(> .facet-link:focus-visible) { z-index: 3; transition: z-index 0s; }
.facet:has(> .facet-link:focus-visible) .facet-view { clip-path: var(--grown); transition: clip-path 0.85s cubic-bezier(0.16, 1, 0.3, 1); }
.facet:has(> .facet-link:focus-visible) .facet-label {
  left: var(--lx-grown); top: var(--ly-grown); scale: 1.18;
  transition: opacity 0.4s var(--ease-out), left 0.85s cubic-bezier(0.16, 1, 0.3, 1), top 0.85s cubic-bezier(0.16, 1, 0.3, 1), scale 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}
.facet:has(> .facet-link:focus-visible) .facet-edge { opacity: 0.5; transition: opacity 0.5s var(--ease-out) 0.4s; }

/* The lattice: hairlines along every shared edge, which also cover the seams between neighbouring facets. */
.atlas-lattice { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; z-index: 1; fill: none; stroke: rgba(240, 232, 212, 0.13); pointer-events: none; }
.atlas-lattice path { stroke-width: 1; vector-effect: non-scaling-stroke; }

/* The ends fade into the page, and the lower row darkens towards the closing scene below. */
.atlas-strip::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(9, 11, 13, 0.92) 0, rgba(9, 11, 13, 0.5) 4%, rgba(9, 11, 13, 0) 11%, rgba(9, 11, 13, 0) 89%, rgba(9, 11, 13, 0.5) 96%, rgba(9, 11, 13, 0.92) 100%),
    linear-gradient(180deg, rgba(9, 11, 13, 0) 55%, rgba(9, 11, 13, 0.4) 100%);
}

/* ---------- Arriving: the facets come up from the left, column by column ---------- */

@media (prefers-reduced-motion: no-preference) {
  .atlas-strip.is-live:not(.is-in) :is(.facet, .atlas-lattice) { opacity: 0; }
  .atlas-strip.is-in .facet { animation: atlas-in 1.3s var(--ease-out) both; animation-delay: calc(max(0, var(--copy, 0) * 8 + var(--j)) * 70ms); }
  .atlas-strip.is-in .atlas-lattice { animation: atlas-in 1.6s var(--ease-out) 0.2s both; }
}
@keyframes atlas-in { from { opacity: 0; } }

/* ---------- Tablets and phones: larger facets, fewer at a time ---------- */

@media (max-width: 1079px) { .atlas { --b: min(48vw, 42svh); } }
@media (max-width: 719px) {
  .atlas { --b: min(78vw, 52svh); padding-top: calc(var(--space-section) * 0.75); }
  /* With no pointer to light a facet, the middle of the strip is lit and the sides fall away. */
  .atlas-strip::after {
    background:
      linear-gradient(90deg, rgba(9, 11, 13, 0.72) 0, rgba(9, 11, 13, 0) 24%, rgba(9, 11, 13, 0) 76%, rgba(9, 11, 13, 0.72) 100%),
      linear-gradient(180deg, rgba(9, 11, 13, 0) 55%, rgba(9, 11, 13, 0.4) 100%);
  }
  .facet img { opacity: 0.72; }
}
