/* =============================================================
   PORTFOLIO FLY-THROUGH — scroll-driven 3D project showcase
   Scoped entirely under .apf-* — safe to drop into any page.
   Uses the site's own background, cursor, and font everywhere —
   this section should look like part of the site, not a bolted-on
   sci-fi HUD. Default state below is a plain static grid: works
   with no JS, and IS the prefers-reduced-motion fallback.
   portfolio-flythrough.js adds .is-engine to switch on the sticky
   3D camera tunnel.
   ============================================================= */

.apf-root {
    position: relative;
    width: 100%;
    background: var(--bg-color, #03070c);
}

/* ─── STATIC GRID (default / no-JS / reduced-motion) ─── */
.apf-spacer {
    height: auto;
}

.apf-scene {
    position: static;
    height: auto;
    perspective: none;
    overflow: visible;
    padding: 5rem 5%;
}

.apf-cards {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    transform-style: flat;
}

.apf-card {
    position: static !important;
    display: block;
    transform: none;
    opacity: 1;
    filter: none;
    pointer-events: auto;
    will-change: auto;
    text-decoration: none;
    color: inherit;
}

.apf-card__label {
    opacity: 1;
}

/* ─── SHARED CARD VISUALS (apply in both modes) ─── */
.apf-card__img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 0;
    box-shadow: none;
}

.apf-card__label {
    padding-top: 14px;
    transition: opacity 0.2s ease;
    font-family: var(--font-family);
}

.apf-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.apf-card__category,
.apf-card__year {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    opacity: 0.7;
    color: #fff;
}

.apf-card__title {
    margin-top: 8px;
    font-size: 26px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.apf-card__description {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.65);
    max-width: 46ch;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 767px) {
    .apf-card__title { font-size: 19px; }
    .apf-card__description { font-size: 13px; -webkit-line-clamp: 2; }
}

/* =============================================================
   ENGINE MODE — sticky 3D camera tunnel (JS adds .is-engine)
   ============================================================= */
.apf-root.is-engine .apf-scene {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    perspective: 1000px;
    padding: 0;
    touch-action: pan-y;
}

.apf-root.is-engine .apf-cards {
    display: block;
    position: absolute;
    inset: 0;
    max-width: none;
    gap: 0;
    transform-style: preserve-3d;
}

.apf-root.is-engine .apf-card {
    position: absolute !important;
    left: 50%;
    top: 50%;
    width: min(52vw, 760px);
    display: none;
}

/* Labels don't get a separate opacity toggle — they're children of .apf-card,
   so they fade in/out and blur together with it automatically as the JS
   engine updates the card's own opacity/filter every frame. */

/* Card width caps below are chosen relative to the scatter offsets' minimum
   mutual spacing (~999px at scatterScale 1, scaled per breakpoint in JS) —
   each cap leaves a safety margin so two simultaneously-visible cards can
   never touch, at any breakpoint. Don't raise these without checking that
   spacing still holds (see portfolio-flythrough.js breakpoint()). */
@media (max-width: 1023px) {
    .apf-root.is-engine .apf-card { width: min(68vw, 640px); }
}

@media (max-width: 767px) {
    .apf-root.is-engine .apf-scene { perspective: 600px; }
    .apf-root.is-engine .apf-card { width: min(82vw, 480px); }
}

/* ─── "VIEW LIVE" hover cursor (shown only while hovering a card) ─── */
.apf-root.is-engine .apf-card:hover {
    cursor: none;
}

.apf-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    color: #03070c;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-family);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    transform: translate3d(-9999px, -9999px, 0) translate(-50%, -50%);
}

.apf-cursor.is-visible {
    opacity: 1;
}

@media (pointer: coarse) {
    .apf-cursor { display: none; }
}

/* ─── Floating stars (ambient background, both grid and engine mode) ─── */
.apf-starfield {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.apf-star {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    opacity: 0.2;
    animation: apf-twinkle ease-in-out infinite;
}

@keyframes apf-twinkle {
    0%, 100% { opacity: 0.12; transform: scale(0.8); }
    50%      { opacity: 0.85; transform: scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    .apf-star { animation: none; opacity: 0.3; }
}
