/* Realizacje — L→R category tiles over mouse-reactive WebGL */

body.portfolio-page--tiles {
  --tile-w: min(70vw, 26rem);
  --tile-h: min(56svh, 32rem);
  --tile-page-bg: #070709;
  background: var(--tile-page-bg);
  color: #f5f5f5;
  overflow-x: hidden;
  transition: color 0.45s ease, background-color 0.45s ease;
}
body.portfolio-page--tiles[data-tile-theme="web"] { --tile-page-bg: #040404; }
body.portfolio-page--tiles[data-tile-theme="systems"] { --tile-page-bg: #eef1f6; }
body.portfolio-page--tiles[data-tile-theme="video"] { --tile-page-bg: #050505; }
body.portfolio-page--tiles[data-tile-theme="graphics"] { --tile-page-bg: #f2f2f4; }
body.portfolio-page--tiles.is-tile-bg-light {
  color: #111;
}
body.portfolio-page--tiles.is-tile-bg-light .site-nav__toggle,
body.portfolio-page--tiles.is-tile-bg-light .lang-switch button {
  color: #111;
}
body.portfolio-page--tiles.is-tile-bg-light .site-nav__toggle-bars span {
  background: #111;
}

body.portfolio-page--tiles .subpage-ambient,
body.portfolio-page--tiles .subpage-ambient__blur,
body.portfolio-page--tiles .subpage-ambient__shade,
body.portfolio-page--tiles .portfolio-sand-portal,
body.portfolio-page--tiles .grafiki-bloom,
body.portfolio-page--tiles .portfolio-scene-curtain,
body.portfolio-page--tiles .home-scroll-rail,
body.portfolio-page--tiles .subpage-cube-portal,
body.portfolio-page--tiles .portfolio-end {
  display: none !important;
}
/* Homepage liquid ambient — only on Strony */
body.portfolio-page--tiles .portfolio-home-ambient {
  display: none !important;
}
body.portfolio-page--tiles[data-tile-theme="web"] .portfolio-home-ambient.home-ambient,
body.portfolio-page--tiles[data-tile-theme="web"] .portfolio-home-ambient.home-ambient__blur,
body.portfolio-page--tiles[data-tile-theme="web"] .portfolio-home-ambient.home-ambient__shade {
  display: block !important;
}
body.portfolio-page--tiles .home-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 140% 90% at 50% 38%, #0e0e0e 0%, #040404 42%, #000 100%);
}
body.portfolio-page--tiles .home-ambient__blur {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 80vmax;
  height: 80vmax;
  margin: -40vmax 0 0 -40vmax;
  pointer-events: none;
  background:
    radial-gradient(
      circle closest-side,
      rgba(255, 255, 255, 0.1) 0%,
      rgba(255, 255, 255, 0.055) 22%,
      rgba(255, 255, 255, 0.012) 50%,
      transparent 66%
    );
  opacity: 0.55;
  transform: translate3d(50vw, 50vh, 0);
  will-change: transform;
}
body.portfolio-page--tiles .home-ambient__shade {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(3, 3, 3, 0.28);
}
body.portfolio-page--tiles.subpage::after {
  opacity: 0.04;
}

body.portfolio-page--tiles .site-nav {
  z-index: 40;
}

body.portfolio-page--tiles #main {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0;
  background: transparent;
}

/* Full-bleed WebGL (systems primary; others let media layers show) */
.portfolio-tile-bg {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}
body.portfolio-page--tiles[data-tile-theme="systems"] .portfolio-tile-bg {
  opacity: 1;
}

/* Systems — soft field under WebGL glass */
.portfolio-systems-field {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, rgba(255, 255, 255, 0.95), transparent 42%),
    radial-gradient(circle at 72% 60%, rgba(210, 216, 230, 0.7), transparent 40%),
    linear-gradient(160deg, #f7f7f9, #e8ebf2 55%, #dfe3ec);
}

/* Theme stage sits under tiles */
body.portfolio-page--tiles .portfolio-theme-stage {
  z-index: 1;
}

/* Kill legacy #montaz etc. */
body.portfolio-page--tiles a.portfolio-tile#montaz,
body.portfolio-page--tiles a.portfolio-tile#strony,
body.portfolio-page--tiles a.portfolio-tile#grafiki,
body.portfolio-page--tiles a.portfolio-tile#automatyzacje {
  height: var(--tile-h) !important;
  min-height: var(--tile-h) !important;
  max-height: var(--tile-h) !important;
  width: var(--tile-w) !important;
  min-width: var(--tile-w) !important;
  max-width: var(--tile-w) !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

/* Strip */
.portfolio-tiles {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  padding: clamp(4.8rem, 10vh, 6rem) 0 clamp(1.25rem, 3vh, 2rem);
}
.portfolio-tiles__scroller {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.5rem);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 1.25rem max(var(--gutter, 1.25rem), calc((100vw - var(--tile-w)) / 2));
  scrollbar-width: none;
}
.portfolio-tiles__scroller::-webkit-scrollbar {
  display: none;
}

/* Category tile — website-card feel (chrome + media + body) */
.portfolio-tile {
  position: relative;
  flex: 0 0 var(--tile-w);
  width: var(--tile-w);
  min-width: var(--tile-w);
  max-width: var(--tile-w);
  height: var(--tile-h);
  min-height: var(--tile-h);
  max-height: var(--tile-h);
  box-sizing: border-box;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  border-radius: 0.85rem;
  overflow: hidden;
  text-decoration: none;
  color: #f5f5f5;
  background: rgba(8, 8, 10, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.35);
  opacity: 0.78;
  transform: none;
  transition:
    opacity 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.45s ease,
    background 0.45s ease;
}
.portfolio-tile.is-active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile {
  color: #111;
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.12);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile.is-active {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 0, 0, 0.16);
}

.portfolio-tile:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 4px;
}

.portfolio-tile__chrome {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile__chrome {
  background: rgba(0, 0, 0, 0.06);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
.portfolio-tile__chrome span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile__chrome span {
  background: rgba(0, 0, 0, 0.18);
}

.portfolio-tile__media {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0a0a0a;
}
.portfolio-tile__media video,
.portfolio-tile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portfolio-tile__slides {
  position: absolute;
  inset: 0;
}
.portfolio-tile__slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.portfolio-tile__slide.is-on {
  opacity: 1;
}

.portfolio-tile__systems {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 40% 42%, #ffffff 0%, #eceef3 48%, #c8ccd6 100%);
}
.portfolio-tile__systems-cube {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotateX(18deg) rotateY(-28deg);
  background: rgba(8, 8, 10, 0.9);
  border-radius: 18%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 16px 36px rgba(0, 0, 0, 0.22);
  animation: tile-cube 8s ease-in-out infinite;
}
@keyframes tile-cube {
  0%, 100% { transform: translate(-50%, -50%) rotateX(18deg) rotateY(-28deg); }
  50% { transform: translate(-50%, -54%) rotateX(22deg) rotateY(-16deg); }
}

.portfolio-tile__body {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.95rem 1rem 1.05rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55));
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile__body {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.85));
}
/* When body sits under media as flex child, use solid bar */
.portfolio-tile > .portfolio-tile__body {
  background: rgba(0, 0, 0, 0.55);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile > .portfolio-tile__body {
  background: rgba(255, 255, 255, 0.92);
}

.portfolio-tile__title {
  margin: 0;
  font-family: var(--font-display, "Satoshi", sans-serif);
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-transform: none;
}
.portfolio-tile__lead {
  margin: 0;
  max-width: 28ch;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(245, 245, 245, 0.68);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tile__lead {
  color: rgba(17, 17, 17, 0.62);
}
.portfolio-tile__cta {
  margin-top: 0.35rem;
  align-self: flex-start;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.85;
}

.portfolio-tiles__dots {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1rem;
  padding: 0 var(--gutter, 1.25rem);
}
.portfolio-tiles__dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}
.portfolio-tiles__dot.is-active {
  width: 1.35rem;
  background: rgba(255, 255, 255, 0.92);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tiles__dot {
  background: rgba(0, 0, 0, 0.22);
}
body.portfolio-page--tiles.is-tile-bg-light .portfolio-tiles__dot.is-active {
  background: rgba(0, 0, 0, 0.82);
}

@media (min-width: 901px) {
  body.portfolio-page--tiles {
    --tile-w: min(32vw, 26rem);
    --tile-h: min(56svh, 32rem);
  }
}

@media (max-width: 720px) {
  body.portfolio-page--tiles {
    --tile-w: min(82vw, 22rem);
    --tile-h: min(52svh, 28rem);
  }
}

html.reduce-motion .portfolio-tile,
html.reduce-motion .portfolio-tile__slide,
html.reduce-motion .portfolio-tile__systems-cube {
  transition: none !important;
  animation: none !important;
}
