/* Section shell — transparent, continues the global .site-bg canvas.
   Every piece is positioned absolutely against this fixed-height frame
   (same approach as hero/assembly) so the orbit's safe vertical band is
   exact, instead of fighting flexbox for space against the HUD text. */
.portfolio {
  position: relative;
  height: 118vh;
  overflow: hidden;
  background: transparent;
  font-family: var(--font-body);
}

/* Huge, near-invisible background typographic label — our own mark,
   not the orbit's content. Pure texture, sits behind the cards. */
.portfolio__label {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.portfolio__label-main {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(120px, 16vw, 260px);
  letter-spacing: .05em;
  line-height: 1;
  color: rgba(255, 255, 255, .035);
  white-space: nowrap;
}

.portfolio__label-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: .5em;
  padding-left: .5em;
  color: rgba(200, 255, 46, .14);
  white-space: nowrap;
}

/* Top-left HUD — compact, out of the orbit's way. Horizontal edge comes
   from .section-edge-left (set in HTML) so it lines up with hero/assembly. */
.portfolio__hud {
  position: absolute;
  top: calc(var(--header-height) + 40px);
  z-index: 5;
  max-width: 400px;
}

.portfolio__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-h2);
  line-height: 1.12;
  letter-spacing: var(--ls-heading);
  margin: 18px 0 0;
  color: var(--color-text-primary-strong);
  text-wrap: balance;
}

.portfolio__title span {
  color: var(--color-accent);
}

.portfolio__subtitle {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--color-text-muted);
  margin: 14px 0 0;
}

/* Orbit stage — centered in the safe vertical band between the HUD and
   the bottom caption/hints, well clear of both. */
.portfolio__stage {
  position: absolute;
  left: 0;
  right: 0;
  top: 60%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portfolio__orbit {
  position: relative;
  width: 100%;
  max-width: 1500px;
  height: 360px;
  perspective: 2800px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.portfolio__orbit.is-dragging {
  cursor: grabbing;
}

.portfolio__ring {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* Cards — static 3D placement is set inline once by JS (rotateY + translateZ);
   only the inner wrapper's scale/opacity/blur changes every frame. */
.portfolio-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 340px;
  height: 224px;
  display: block;
  color: inherit;
  will-change: transform;
}

.portfolio-card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  will-change: transform, opacity, filter;
}

.portfolio-card__frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-mockup);
  overflow: hidden;
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-soft);
  box-shadow: var(--shadow-deep), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: border-color .3s ease, box-shadow .3s ease;
}

.portfolio-card.is-active .portfolio-card__frame {
  border-color: var(--color-accent-border-strong);
  box-shadow: var(--shadow-deep), 0 0 50px rgba(200, 255, 46, .25), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.portfolio-card__bar {
  position: relative;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-bottom: 1px solid var(--color-border-faint);
  background: var(--color-surface-2);
}

.portfolio-card__bar .browser-bar__dot {
  width: 7px;
  height: 7px;
}

.portfolio-card__url {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--color-text-dim-2);
}

.portfolio-card__preview {
  position: relative;
  height: calc(100% - 30px);
  overflow: hidden;
  background: var(--color-surface-1);
}

.portfolio-card__preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.portfolio-card__preview-mock {
  position: relative;
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.portfolio-card__preview-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.portfolio-card__tag {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--color-accent-on-accent);
  background: var(--color-accent);
  padding: 4px 8px;
  border-radius: 4px;
}

.portfolio-card__meta {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.portfolio-card__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-primary);
}

.portfolio-card__type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: var(--color-text-dim-3);
  white-space: nowrap;
  text-align: right;
}

/* Placeholder cards ("здесь может быть ваш сайт") — visually distinct
   from real screenshots: dashed frame, faint grid, no image. */
.portfolio-card--placeholder .portfolio-card__frame {
  border-style: dashed;
  border-color: var(--color-border-strong);
}

.portfolio-card--placeholder .portfolio-card__tag {
  background: transparent;
  border: 1px solid var(--color-accent-border);
  color: var(--color-accent);
}

.portfolio-card__placeholder {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 18px;
}

.portfolio-card__placeholder-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(70% 75% at 50% 50%, #000, transparent 90%);
  mask-image: radial-gradient(70% 75% at 50% 50%, #000, transparent 90%);
}

.portfolio-card__placeholder-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--color-accent-border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.portfolio-card__placeholder-text {
  position: relative;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-dim-4);
  max-width: 250px;
}

.portfolio-card__placeholder-cta {
  position: relative;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-accent-on-accent);
  background: var(--color-accent);
  padding: 6px 13px;
  border-radius: 5px;
}

/* Bottom-left — active project caption. Horizontal edge from
   .section-edge-left (set in HTML). */
.portfolio__caption {
  position: absolute;
  bottom: 60px;
  z-index: 5;
  max-width: 400px;
}

.portfolio__caption-index {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--color-text-dim-3);
  margin-bottom: 10px;
}

.portfolio__caption-type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 6px;
}

.portfolio__caption-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--color-text-primary-strong);
}

.portfolio__caption-desc {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text-dim-5);
  margin: 10px 0 14px;
  min-height: 44px;
}

/* Compact proof line — one verified fact per real project. Distinct from
   the descriptive copy above it (mono, dot marker) so it reads as a
   status/proof signal, not more marketing text. Hidden entirely for
   placeholder cards, which have no shipped project to report on. */
.portfolio__caption-fact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.4;
  letter-spacing: .01em;
  color: var(--color-text-dim-2);
  margin: 0 0 14px;
}

.portfolio__caption-fact::before {
  content: '';
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 6px rgba(200, 255, 46, .7);
}

.portfolio__caption-fact[hidden] {
  display: none;
}

/* Bottom-right — small interface hints + counter. Horizontal edge from
   .section-edge-right (set in HTML). */
.portfolio__side {
  position: absolute;
  bottom: 60px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  text-align: right;
}

.portfolio__hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--color-text-dim-2);
}

.portfolio__hint-icon {
  width: 15px;
  height: 15px;
  border: 1px solid var(--color-accent);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 9px;
  flex-shrink: 0;
}

.portfolio__hint--swipe {
  display: none;
}

/* Reduced-motion ONLY — a fully static, non-rotating horizontal row.
   This is the one case with no 3D depth/rotation at all (accessibility
   fallback, not a device-size thing): every other range, including
   touch/mobile, keeps the real orbit below (Pointer Events already
   unify mouse/touch/pen drag, so no separate touch layout is needed —
   see js/portfolio.js). */
@media (prefers-reduced-motion: reduce) {
  .portfolio {
    height: auto;
    padding: calc(var(--header-height) + 44px) 0 56px;
  }

  .portfolio__label {
    display: none;
  }

  .portfolio__hud {
    position: relative;
    left: auto;
    top: auto;
    padding: 0 var(--section-padding);
  }

  .portfolio__stage {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    margin-top: 32px;
  }

  .portfolio__orbit {
    height: auto;
    perspective: none;
    cursor: default;
    max-width: 100%;
    padding: 0 var(--section-padding);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    transform: none;
  }

  .portfolio__ring {
    position: relative;
    inset: auto;
    display: flex;
    gap: 20px;
    padding: 10px calc(50% - 170px) 20px;
    transform: none !important;
  }

  .portfolio-card {
    position: relative;
    left: auto;
    top: auto;
    margin: 0;
    flex: 0 0 auto;
    scroll-snap-align: center;
    transform: rotateY(0deg) !important;
  }

  .portfolio-card__inner {
    transform: scale(.9);
    opacity: .5;
    filter: none !important;
    transition: transform .25s ease, opacity .25s ease;
  }

  .portfolio-card.is-active .portfolio-card__inner {
    transform: scale(1);
    opacity: 1;
  }

  .portfolio__caption {
    position: relative;
    left: auto;
    bottom: auto;
    text-align: center;
    max-width: 560px;
    margin: 32px auto 0;
    padding: 0 var(--section-padding);
  }

  .portfolio__side {
    position: relative;
    right: auto;
    left: auto;
    bottom: auto;
    align-items: center;
    text-align: center;
    padding: 0 var(--section-padding);
    margin-top: 12px;
  }

  .portfolio__hint--orbit,
  .portfolio__hint--swipe {
    display: none;
  }
}

/* ---- Mobile orbit — same 3D carousel, scaled down as one unit ----
   .portfolio__orbit (the viewport/perspective box) is never touched by
   JS — only .portfolio__ring's rotation and each card's inner
   scale/opacity/filter are written per frame — so it's safe to scale
   here, exactly like .hero__mockup-shell/.assembly__scene. Radius,
   card size and rotation all shrink together as one 3D scene, instead
   of trying to resize the 460px JS-side RADIUS constant per
   breakpoint. Neighbor cards are allowed to bleed past the viewport's
   own edges (the signature "carousel continues offscreen" read) —
   .portfolio's overflow:hidden clips that at the section boundary, so
   it never becomes a document-level horizontal scrollbar. */
@media (hover: none) {
  .portfolio__hint--orbit {
    display: none;
  }

  .portfolio__hint--swipe {
    display: flex;
  }
}

/* Below 1024px the caption (bottom-left) and side hints (bottom-right)
   stop being two columns flanking the orbit — there's no longer
   horizontal room for both at once, and since they're both
   position:absolute;bottom:60px, the reported bug (CTA/hint/icon all
   stacked on top of each other) is exactly what you'd expect on a
   narrow viewport: both anchor to the same spot. Converting the whole
   section to a normal-flow column fixes it structurally — .portfolio
   itself becomes auto-height (was a fixed vh, sized only for the
   absolute-positioning scheme) and every child gets an explicit order:
   HUD -> orbit stage -> caption (counter/category/title/desc/fact/CTA,
   already in that DOM order) -> side (touch hint), each its own row
   with real spacing instead of overlapping bottom-anchored blocks. */
@media (max-width: 1023px) {
  .portfolio {
    height: auto;
    display: flex;
    flex-direction: column;
    padding: calc(var(--header-height) + 36px) 0 56px;
  }

  .portfolio__label {
    display: none;
  }

  .portfolio__hud {
    position: relative;
    top: auto;
    left: auto;
    order: 1;
    max-width: 320px;
    padding: 0 var(--section-padding);
  }

  .portfolio__stage {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    order: 2;
    margin-top: 28px;
  }

  .portfolio__caption {
    position: relative;
    left: auto;
    bottom: auto;
    order: 3;
    max-width: none;
    padding: 0 var(--section-padding);
    margin-top: 32px;
  }

  .portfolio__side {
    position: relative;
    right: auto;
    left: auto;
    bottom: auto;
    order: 4;
    align-items: flex-start;
    text-align: left;
    padding: 0 var(--section-padding);
    margin-top: 22px;
  }

  .portfolio__orbit {
    transform: scale(.82);
    touch-action: none;
  }
}

@media (max-width: 767px) {
  .portfolio__orbit {
    transform: scale(.72);
  }
}

@media (max-width: 599px) {
  .portfolio__orbit {
    transform: scale(.64);
  }
}

@media (max-width: 389px) {
  .portfolio__orbit {
    transform: scale(.56);
  }
}
