/* ============================================================
   works.css - works list page (works.html) and work detail page
   (work.html): cards, facts, gallery, room filters, back button.
   ============================================================ */

/* ===== Back button (work detail page) =====
   In normal flow right below the hero: an expanded arrow pill. When
   the page is scrolled it sticks under the header and collapses into
   a compact circle arrow (JS toggles .is-compact at the sticky point). */

.back-link {
  position: sticky;
  top: 80px; /* clears the sticky header (64px) */
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  margin-bottom: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  background: var(--dark);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: padding 0.25s ease, gap 0.25s ease, border-radius 0.25s ease,
    background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  /* small entrance slide on page load */
  animation: back-link-in 0.35s ease backwards;
}

@keyframes back-link-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Collapsed state: just the arrow in a circle. */
.back-link.is-compact {
  gap: 0;
  padding: 0;
  width: 44px;
  border-radius: 50%;
}

.back-link__text {
  overflow: hidden;
  white-space: nowrap;
  max-width: 60px;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}

.back-link.is-compact .back-link__text {
  max-width: 0;
  opacity: 0;
}

.back-link__arrow {
  display: inline-block;
  font-size: 18px;
  transition: transform 0.2s;
}

.back-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--dark);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.back-link:hover .back-link__arrow {
  transform: translateX(-3px);
}

.back-link:active {
  transform: scale(0.92);
}

/* Wide screens: the content column is centred, so the button lives
   in the empty left margin instead of overlapping the content. */
@media (min-width: 1276px) {
  .back-link {
    margin-left: -80px;
  }
}

/* ===== Works grid (works.html) ===== */

.works-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* The whole card navigates to the work page (click handler in works.js). */
.work-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.work-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.work-card__img {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.work-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Dashed placeholder box shown when a work has no photos yet. */
.work-card__img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aab2c0;
  font-size: 14px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
}

.work-card__body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.work-card__body h3 {
  color: #fff;
  font-size: 19px;
}

.work-card__body h3 a {
  color: inherit;
  text-decoration: none;
}

.work-card__body h3 a:hover {
  color: var(--accent);
}

.work-card__meta {
  color: #aab2c0;
  font-size: 13px;
}

.work-card__body p {
  color: #aab2c0;
  font-size: 14px;
  /* \n in work.json becomes real line breaks */
  white-space: pre-line;
  /* Card teaser: show only the first 4 lines, then "..." */
  display: -webkit-box;
  line-clamp: 4;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* On the works grid the card body is a flex column, so the vote row
   is pinned to the bottom of the card instead of under the text. */
.work-card .vote-row {
  margin-top: auto;
  padding-top: 26px;
}

/* ===== Fact cards (work detail page) =====
   One per work.json field, with an icon. */

.work-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.work-fact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.work-fact__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

.work-fact__icon img {
  width: 20px;
  height: 20px;
}

.work-fact__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aab2c0;
}

.work-fact__value {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
}

.work-description {
  margin-bottom: 40px;
  color: #dfe3ea;
  font-size: 15px;
}

.work-description__lead {
  font-size: 17px;
  color: #fff;
  margin-bottom: 14px;
  /* \n in work.json becomes real line breaks */
  white-space: pre-line;
}

.work-description p {
  margin-bottom: 8px;
}

.work-description .section__title {
  margin-bottom: 18px;
}

/* ===== Room filters (work detail page) =====
   Chips mirror the sort tabs; every room chip carries its icon from
   icons/rooms/<name>.svg. */

.room-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 26px;
}

.room-filters__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #aab2c0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.room-filters__btn:hover {
  color: #fff;
  border-color: var(--accent);
}

.room-filters__btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--dark);
}

.room-filters__icon {
  width: 16px;
  height: 16px;
}

/* ===== Gallery (work detail page) =====
   Justified rows: photos and videos keep their natural proportions
   (sizes are set inline by js/work.js from the intrinsic aspect
   ratio, read lazily for videos too). */

.work-gallery {
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* fade out/in when a room filter is switched */
  transition: opacity 0.2s ease;
}

.work-gallery--fading {
  opacity: 0;
}

/* Loading progress while media sizes are fetched: a thin accent bar
   with a "NN% (k из m)" caption underneath (js/work.js). */
.gallery-progress {
  padding: 40px 0;
}

.gallery-progress__bar {
  display: block;
  width: min(420px, 80%);
  margin: 0 auto;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.gallery-progress__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.gallery-progress__label {
  margin-top: 12px;
  text-align: center;
  color: #aab2c0;
  font-size: 14px;
}

/* Tiny, barely visible byte/speed detail under the main caption,
   mirroring the landing preloader (js/work.js). */
.gallery-progress__detail {
  margin-top: 6px;
  text-align: center;
  color: rgba(255, 255, 255, 0.32);
  font-size: 11px;
}

.work-gallery__row {
  display: flex;
  gap: 16px;
}

/* A lone very tall photo is shown centred instead of stretched. */
.work-gallery__row--center {
  justify-content: center;
}

.work-gallery__img {
  display: block;
  border-radius: 10px;
  object-fit: cover; /* slight crop when the last photo must fill the row */
  background: rgba(255, 255, 255, 0.06);
  cursor: zoom-in;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Video cells use the first frame as their poster: the <video> fills
   the justified box, a small play badge sits on top, and the native
   controls stay off. Clicking opens the custom lightbox player. */
.work-gallery__item--video {
  position: relative;
  display: block;
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  cursor: zoom-in;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.work-gallery__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.work-gallery__play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(15, 19, 28, 0.5);
  color: #fff;
  font-size: 15px;
  pointer-events: none;
  /* neutral, not accent: the badge must stay quiet */
}

/* A slight lift on hover (desktop only, so it doesn't stick on touch). */
@media (hover: hover) {
  .work-gallery__img:hover,
  .work-gallery__item--video:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  }

  .work-fact:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  }
}

/* ===== Votes + view counter (work detail page) ===== */

.work-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
}

.work-actions .vote-row {
  margin-top: 0;
  padding-top: 0;
}

.work-views {
  color: #aab2c0;
  font-size: 13px;
}