/* ===== Work rows: theme title on the left, horizontal tile strip on the right ===== */

.work {
  max-width: var(--max);
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 78px;
}

.zone {
  --tile-h: clamp(180px, 16vw, 280px);
  display: grid;
  grid-template-columns: clamp(200px, 17vw, 300px) minmax(0, 1fr);
  border-top: 1px solid var(--line);
  scroll-margin-top: 78px;
}

.zone:first-child {
  border-top: 0;
}

.zone.has-groups {
  --tile-h: clamp(160px, 13vw, 230px);
}

.zone-head {
  border-right: 1px solid var(--line);
  background: rgba(6, 8, 15, .5);
}

.zone-head-inner {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 32px clamp(22px, 2.5vw, 40px) 28px clamp(22px, 4.5vw, 56px);
}

.zone-index {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2em;
}

.zone-head h2 {
  margin: 0;
  font-size: clamp(20px, 1.7vw, 28px);
  line-height: 1.05;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.zone-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.zone-body {
  min-width: 0;
}

/* Second level (sub-rows inside a theme) */
.subzone + .subzone {
  border-top: 1px dashed rgba(165, 121, 255, .16);
}

.subzone-title {
  margin: 0;
  padding: 20px 24px 0;
  color: #dddcec;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.subzone-title::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2px;
  margin: 0 10px 3px 0;
  vertical-align: middle;
  background: linear-gradient(90deg, var(--accent), var(--accent-hot));
}

.subzone .zone-grid {
  padding-top: 14px;
}

/* Grid of narrow columns and 1/8-height rows, packed densely.
   main.js gives every tile a column span from its aspect ratio (--ar):
   normal tiles are 2 rows high (= --tile-h), vertical videos/images (ar < .7) are 4 rows high,
   so they come out twice as big and the other tiles flow around them. */
.zone-grid {
  --gap: 14px;
  --cap-h: 58px; /* text strip under each tile */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  grid-auto-rows: calc((var(--tile-h) - 7 * var(--gap)) / 8); /* 8 rows = one normal tile */
  grid-auto-flow: row dense;
  gap: var(--gap);
  padding: 24px clamp(22px, 4.5vw, 56px) 28px 24px;
}

/* Consecutive grids of one theme (tile with newRow) — joined with a normal tile gap */
.zone-grid:has(+ .zone-grid) { padding-bottom: 0; }
.zone-grid + .zone-grid { padding-top: var(--gap); }

/* Tile: --ar = aspect ratio, --tile-h = row height of a normal tile */
.tile {
  --ar: 1.3333;
  position: relative;
  display: flex;
  flex-direction: column;
  grid-column: span 8;
  grid-row: span 8;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(165, 121, 255, .16);
  background: rgba(10, 12, 22, .7);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}

.tile.size-s { --ar: 1.3333; }
.tile.size-w { --ar: 1.7778; }
.tile.size-x { --ar: 2.3333; }
.tile.size-t { --ar: .75; }
.tile.size-q { --ar: 1; }
.tile.size-auto { --ar: 1.7778; } /* until the file reports its real size */

.tile-media {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: block;
}

.tile img,
.tile video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .4s ease;
}

.tile:hover img,
.tile:hover video {
  transform: scale(1.03);
}

.tile:hover,
.tile:focus-visible {
  border-color: rgba(165, 121, 255, .6);
  outline: none;
}

.tile-ph {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(244, 243, 251, .18);
  color: rgba(244, 243, 251, .3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.tile.is-empty {
  background:
    linear-gradient(135deg, rgba(165, 121, 255, .07), rgba(255, 96, 232, .03)),
    rgba(10, 12, 22, .6);
}

/* Text strip under the media: header + short "what it is" */
.tile-info {
  height: var(--cap-h);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 14px;
  border-top: 1px solid rgba(165, 121, 255, .14);
  background: rgba(8, 9, 18, .92);
  overflow: hidden;
}

.tile-info strong {
  overflow: hidden;
  color: #dddcec;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tile-info small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-line; /* "\n" in desc = new line */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tile-info small:empty { display: none; }

/* Lightbox */
.lightbox {
  width: min(94vw, 1600px);
  max-height: 94vh;
  padding: 0;
  border: 1px solid var(--line);
  background: #06070d;
  color: var(--text);
}

.lightbox::backdrop {
  background: rgba(2, 2, 6, .88);
  backdrop-filter: blur(6px);
}

.lb-media {
  display: grid;
  place-items: center;
  min-height: 40vh;
  background: #000;
}

.lb-media img,
.lb-media video {
  max-width: 100%;
  max-height: 84vh;
  display: block;
}

.lb-media .tile-ph {
  position: static;
  width: 100%;
  min-height: 50vh;
  border: 0;
}

.lb-cap {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.lb-cap small { color: var(--muted); }

.lb-link {
  margin-left: auto;
  color: var(--accent-hot);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  text-decoration: none;
  white-space: nowrap;
}

.lb-link:hover { text-decoration: underline; }

.lb-media .lb-yt {
  width: min(94vw, 1600px);
  max-width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 84vh;
  border: 0;
  display: block;
}

/* YouTube tiles: play badge in the centre */
.tile.is-youtube .tile-media::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 44px;
  margin: -22px 0 0 -32px;
  border-radius: 12px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='white'/%3E%3C/svg%3E") center / 26px no-repeat,
    rgba(4, 5, 10, .72);
  border: 1px solid rgba(255, 96, 232, .55);
  pointer-events: none;
  transition: background-color .2s, transform .2s;
}

.tile.is-youtube:hover .tile-media::after {
  background-color: rgba(255, 96, 232, .85);
  transform: scale(1.06);
}

.lb-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(165, 121, 255, .34);
  background: rgba(4, 5, 10, .7);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

/* Narrow screens: theme title above the strip */
@media (max-width: 980px) {
  .zone {
    grid-template-columns: 1fr;
    scroll-margin-top: 128px;
  }

  .zone-head {
    border-right: 0;
    background: transparent;
  }

  .zone-head-inner {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    padding: 22px 16px 0;
  }

  .zone-head p {
    flex-basis: 100%;
  }

  .subzone-title {
    padding: 18px 16px 0;
  }

  .zone-grid {
    --gap: 10px;
    padding: 16px;
  }
}

@media (max-width: 620px) {
  .zone,
  .zone.has-groups { --tile-h: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile img, .tile video { transition: none; }
}
