/* ============================================================================
   Home page — filter bar, tile grid, avatars band, bookshelf.
   Loaded after base.css.
   ========================================================================== */

/* ── Work column: filter bar ──────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  justify-content: flex-start;
}

.chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chip {
  font-family: inherit;
  border: none;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 400;
  padding: 0 16px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 980px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.chip.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

@media (hover: hover) {
  .chip:hover { box-shadow: inset 0 0 0 999px var(--surface-strong); }
}

.chip:active { box-shadow: inset 0 0 0 999px var(--surface-strong); }

/* Language + theme live in the top bar on mobile, in the filter bar on desktop. */
.filter-controls { display: none; }

.empty-state {
  padding: 48px 0;
  font-size: 15px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
}

/* ── Tile ─────────────────────────────────────────────────────────────────── */

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: none;
  cursor: pointer;
  background: var(--bg-secondary);
  grid-column: 1 / -1;
  min-width: 0;
}

.tile.is-soon {
  cursor: default;
  background: transparent;
}

.tile-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tile-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 4;
}

.tile.is-soon .tile-scrim {
  inset: 1px;
  border-radius: 11px;
}

/* A soon card that carries a real cover is a normal picture card apart from
   not being clickable: no dashed frame, no inset. */
.tile.is-soon.has-cover {
  background: var(--bg-secondary);
}

.tile.is-soon.has-cover .tile-scrim {
  inset: 0;
  border-radius: 12px;
}

.tile-badge {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #1d1d1f;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 980px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tile-title {
  position: absolute;
  z-index: 5;
  left: 14px;
  right: 14px;
  bottom: 14px;
  margin: 0;
  color: #fff;
  font-size: 17px;
  line-height: 22px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tile.labels-on .tile-scrim { opacity: 1; }
.tile.labels-on .tile-badge { opacity: 1; transform: translateY(0); }
.tile.labels-on .tile-title { opacity: 1; transform: translateY(0); }

/* — Variant: flat SVG cover — */

.tile-svg {
  width: 100%;
  height: 100%;
  display: block;
  transform: scale(1);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.tile.hovered .tile-svg { transform: scale(1.06); }

/* — Variant: video — */

.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Desktop only. On a phone the `hovered` class is what a tile gets when it
   scrolls into view, and a clip that swells as you pass it reads as a glitch
   rather than as a response to anything; see the desktop block below. */

/* — Variants: fanned + stacked screens (shared dark stage) — */

.fan-wrap {
  position: absolute;
  inset: 0;
  background: #2c2c2e;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fan-img {
  position: absolute;
  width: 62%;
  border-radius: 8px;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fan-left {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translate(-22%, -24%) rotate(0deg) scale(0.9);
  z-index: 1;
}

.fan-right {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translate(6%, 0%) rotate(-7deg) scale(0.9);
  z-index: 2;
}

.fan-center {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  transform: translate(22%, 24%) rotate(-21deg) scale(0.9);
  z-index: 3;
}

.tile.hovered .fan-left   { transform: translate(-28%, -26%) rotate(0deg) scale(0.84); }
.tile.hovered .fan-right  { transform: translate(0%, 2%) rotate(0deg) scale(0.84); }
.tile.hovered .fan-center { transform: translate(28%, 30%) rotate(0deg) scale(0.84); }

/* Narrower on phones: at full tile width the screens crowded the card. The
   desktop width is restored in the >= 900px block. */
.stack-img {
  position: absolute;
  width: 70%;
  border-radius: 8px;
  transform: translate(0, 0) scale(1);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.stack-back {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  filter: brightness(0.62);
  z-index: 1;
}

.stack-mid {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  filter: brightness(0.8);
  z-index: 2;
}

.stack-front {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

.tile.hovered .stack-back  { transform: translate(0, -26%) scale(0.82); }
.tile.hovered .stack-mid   { transform: translate(0, -6%) scale(0.91); }
.tile.hovered .stack-front { transform: translate(0, 17%) scale(1); }

/* — Variant: coming soon — */

.soon-wrap {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 1px dashed var(--soon-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.soon-logo {
  width: 52%;
  max-width: 260px;
  /* The wordmark's own ratio, so `contain` fills the box exactly rather than
     letterboxing it. */
  aspect-ratio: 130 / 23;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.tile.hovered .soon-logo { transform: scale(1.08); }

/* — Variant: photographic cover — */

.cover-bg {
  position: absolute;
  inset: 0;
}

.cover {
  position: absolute;
  inset: 0;
  background-image: var(--cover);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* A card may ship a second drawing for the dark theme — a wordmark in black
   ink has nothing to sit on once the tile goes dark. Falls through to the
   single picture when there is only one. */
[data-theme="dark"] .cover { background-image: var(--cover-dark, var(--cover)); }

/* For artwork rather than a photograph: sits inside the tile with the tile's
   own background around it instead of being cropped to fill. */
.cover.is-contain {
  background-size: contain;
  background-position: center;
}

.tile.hovered .cover { transform: scale(1.04); }

/* Reads as a printed flyer lying on the tile: a tight contact shadow where it
   meets the surface, and a wide soft one for the height above it. */
.cover.is-tilt {
  inset: auto;
  top: 50%;
  left: 50%;
  height: 70%;
  aspect-ratio: 166 / 227;
  transform: translate(-50%, -50%) scale(0.92) rotate(-4deg);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.10),
    0 10px 24px rgba(0, 0, 0, 0.16);
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Picked up off the surface: the contact shadow softens, the far one spreads. */
.tile.hovered .cover.is-tilt {
  transform: translate(-50%, -50%) scale(1.06) rotate(0deg);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.10),
    0 20px 40px rgba(0, 0, 0, 0.22);
}

/* On a dark tile the same shadow all but vanishes; deepen it to keep the lift. */
[data-theme="dark"] .cover.is-tilt {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 10px 24px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .tile.hovered .cover.is-tilt {
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.5),
    0 20px 40px rgba(0, 0, 0, 0.65);
}

/* — Variant: certificate — */

.cert-wrap {
  position: absolute;
  inset: 0;
  background: rgba(60, 60, 67, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-img {
  width: 62%;
  aspect-ratio: 750 / 578;
  border-radius: 4px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  transform: scale(1) rotate(0deg);
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.tile.hovered .cert-img { transform: scale(1.07) rotate(-2.5deg); }

/* — Variant: rotating app shots — */

.shots-wrap {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 86%;
  aspect-ratio: 9 / 19.5;
  border-radius: 10px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  opacity: 0;
}

.shot.is-current { opacity: 1; }

/* ── Banner: avatars parallax strip ───────────────────────────────────────── */

.avatars {
  grid-column: 1 / -1;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--bg-secondary);
  border-radius: 12px;
  position: relative;
}

.avatars img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  max-width: none;
  display: block;
}

/* ── Banner: bookshelf ────────────────────────────────────────────────────── */

.books {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 22px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.books::-webkit-scrollbar,
.shelf::-webkit-scrollbar { display: none; }

.shelf {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 14px;
  overflow: visible;
  padding-top: 8px;
  padding-bottom: 4px;
  width: max-content;
}

.book {
  display: block;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  z-index: 1;
}

@media (hover: hover) {
  .book:hover { z-index: 10; }
}

.book.size-s { width: 87px;  height: 132px; }
.book.size-m { width: 110px; height: 166px; }
.book.size-l { width: 133px; height: 202px; }

.book-stage {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  overflow: visible;
}

.book-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 2px 6px 6px 2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 10px 10px 10px 30%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 3px;
  transform: translateX(0);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  z-index: 1;
  box-shadow: none;
}

@media (hover: hover) {
  .book:hover .book-page {
    opacity: 1;
    box-shadow: 4px 6px 18px rgba(0, 0, 0, 0.12);
  }
}

.book-title {
  overflow-wrap: anywhere;
  hyphens: auto;
  font-size: 10px;
  line-height: 13px;
  font-weight: 600;
  letter-spacing: -0.002em;
  color: #1d1d1f;
}

.book-author {
  font-size: 9px;
  line-height: 12px;
  color: #86868b;
}

.book-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 2px 6px 6px 2px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: perspective(700px) rotateY(0deg);
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.08);
  z-index: 2;
  backface-visibility: hidden;
}

@media (hover: hover) {
  .book:hover .book-cover {
    transform: perspective(700px) rotateY(-78deg);
    box-shadow: 14px 8px 26px rgba(0, 0, 0, 0.18);
  }
}

/* ── Desktop (>= 900px) ───────────────────────────────────────────────────── */

@media (min-width: 900px) {
  .tile.hovered .tile-video { transform: scale(1.06); }

  .filter-bar { justify-content: space-between; }

  .filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: 16px;
  }

  .tile {
    aspect-ratio: 4 / 3.2;
    grid-column: span var(--span, 3);
  }

  .cover.is-tilt { height: 84%; }
  .cert-img { width: 74%; }
  .stack-img { width: 82%; }

  .avatars { aspect-ratio: 16 / 5; }

  .books { padding: 24px 20px; }
  .shelf { gap: 18px; }

  .book.size-s { width: 86px;  height: 130px; }
  .book.size-m { width: 109px; height: 165px; }
  .book.size-l { width: 132px; height: 200px; }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

/* With Reduce Motion on, the covers used to snap while the labels still faded
   — half animated, half not, which reads as broken rather than as calm. Either
   everything moves or nothing does. */
@media (prefers-reduced-motion: reduce) {
  .tile-svg,
  .tile-video,
  .fan-img,
  .stack-img,
  .soon-logo,
  .cover,
  .cover.is-tilt,
  .cert-img,
  .shot,
  .tile-scrim,
  .tile-badge,
  .tile-title,
  .book-page,
  .book-cover {
    transition-duration: 0.01ms;
  }
}
