/* ============================================
   13 HOMES — Portfolio Page
   ============================================
   Scroll-morph hero where 20 project photos animate
   from scatter → line → circle → 13 HOMES logo shape.
   Below: traditional project grid for browsing.
   ============================================ */

:root {
    --pf-bg: #fafaf7;
    --pf-bg-deep: #ede4d4;
    --pf-text: #1c1c1c;
    --pf-muted: rgba(28, 28, 28, 0.55);
    --pf-accent: #c9a84c;
    --pf-navy: #1a1a2e;
}

/* =========================================================
   HERO (sticky, scroll-pinned)
   ========================================================= */
.portfolio-hero {
    position: relative;
    width: 100%;
    height: 320vh; /* settle → 1.5 rotations → graceful exit */
    background: var(--pf-bg);
}

.portfolio-morph {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(ellipse at top, rgba(201, 168, 76, 0.06), transparent 60%),
        var(--pf-bg);
}

/* Stage that holds all photos — centered */
.portfolio-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Logo background — anchors the circle of photos to the 13 Homes mark.
   The PNG contains the "13 HOMES" wordmark in the bottom ~27%, clipped off
   so only the icon mark is shown. Shifted UP so the icon center aligns with
   the circle's centre. Stays visible at low opacity throughout. */
.pm-logo-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(340px, 60vw, 580px);
    height: auto;
    transform: translate(-50%, -50%) translateY(-13%);
    -webkit-clip-path: inset(0 0 27% 0);
    clip-path: inset(0 0 27% 0);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    user-select: none;
    -webkit-user-drag: none;
}

/* Scroll indicator — rail down the right side of viewport */
.pm-scroll-indicator {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    pointer-events: none;
}

.pm-scroll-rail {
    width: 2px;
    height: 120px;
    background: rgba(28, 28, 28, 0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.pm-scroll-fill {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(180deg, var(--pf-accent), rgba(201,168,76,0.4));
    transition: height 0.15s linear;
}

/* =========================================================
   PHOTO CARDS (.pm-card)
   ========================================================= */
.pm-card {
    position: absolute;
    will-change: transform, opacity;
    cursor: pointer;
    transform-style: preserve-3d;
    perspective: 1000px;
    z-index: 5;
    transition: z-index 0s 0.6s;
}

.pm-card:hover {
    z-index: 50;
}

/* Flipper — rotates on hover */
.pm-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.pm-card:hover .pm-flipper {
    transform: rotateY(180deg);
}

/* Front + back faces share a base */
.pm-face {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18),
                0 2px 6px rgba(0, 0, 0, 0.08);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pm-front {
    background: var(--pf-bg-deep);
}

.pm-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.pm-front-tint {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.25));
    transition: opacity 0.4s ease;
}

.pm-card:hover .pm-front img {
    transform: scale(1.08);
}

/* Back face — project info */
.pm-back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, var(--pf-navy) 0%, #0f3460 100%);
    color: #fff;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid rgba(201, 168, 76, 0.3);
}

.pm-back-eyebrow {
    font-family: 'Inter', sans-serif;
    font-size: 0.52rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 4px;
    line-height: 1;
}

.pm-back-name {
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.pm-back-cta {
    font-family: 'Inter', sans-serif;
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    padding-top: 4px;
    border-top: 1px solid rgba(201, 168, 76, 0.25);
    width: 100%;
}

/* =========================================================
   INTRO OVERLAY (visible early, fades as morph starts)
   ========================================================= */
.pm-intro-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.pm-intro-eyebrow {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.pm-intro-eyebrow::before,
.pm-intro-eyebrow::after {
    content: '';
    width: 36px;
    height: 1px;
    background: var(--pf-accent);
    opacity: 0.5;
}

.pm-intro-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 3.6rem);
    font-weight: 400;
    color: var(--pf-text);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 18px;
    max-width: 22ch;
}

.pm-intro-title em {
    font-style: italic;
    color: var(--pf-accent);
}

.pm-intro-hint {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--pf-muted);
    margin-top: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.pm-intro-hint::after {
    content: '';
    width: 1px;
    height: 50px;
    background: linear-gradient(180deg, var(--pf-accent), transparent);
    animation: pmHintPulse 2.4s ease-in-out infinite;
    transform-origin: top;
}

@keyframes pmHintPulse {
    0%, 100% { transform: scaleY(0.3); opacity: 0.4; }
    50%      { transform: scaleY(1);   opacity: 1; }
}

/* =========================================================
   ARC OVERLAY (visible when circle has settled — stays visible)
   ========================================================= */
.pm-arc-overlay {
    position: absolute;
    bottom: 14%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    text-align: center;
    pointer-events: none;
    max-width: 620px;
    width: 90%;
    opacity: 0;
    /* Match the intro overlay's transition so when one fades out and the
       other fades in, we get a clean cross-fade instead of intro fading
       smoothly then arc popping abruptly. */
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.pm-arc-eyebrow {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 16px;
}

.pm-arc-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 500;
    color: var(--pf-text);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
}

.pm-arc-title em {
    font-style: italic;
    color: var(--pf-accent);
}

.pm-arc-desc {
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    color: var(--pf-muted);
    line-height: 1.6;
    font-weight: 300;
    margin: 0;
}

/* =========================================================
   PORTFOLIO GRID (under the hero)
   ========================================================= */
.portfolio-grid-section {
    background: var(--pf-bg);
    padding: 120px 0 140px;
    position: relative;
    border-top: 1px solid rgba(28, 28, 28, 0.06);
}

.portfolio-grid-header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 80px;
    padding: 0 24px;
}

.portfolio-grid-header .section-tag {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 22px;
}

.portfolio-grid-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
    font-weight: 400;
    color: var(--pf-text);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 18px;
}

.portfolio-grid-header h2 em {
    font-style: italic;
    color: var(--pf-accent);
}

.portfolio-grid-header p {
    font-family: 'Inter', sans-serif;
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--pf-muted);
    margin: 0;
    font-weight: 300;
}

.portfolio-grid {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

.pf-project {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    cursor: pointer;
    background: var(--pf-bg-deep);
    text-decoration: none;
    color: inherit;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.pf-project:hover {
    transform: translateY(-6px);
}

.pf-project img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.pf-project:hover img {
    transform: scale(1.06);
}

.pf-project-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.85));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px 26px 24px;
}

.pf-project-suburb {
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 6px;
}

.pf-project-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 500;
    color: #fff;
    line-height: 1.1;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
}

.pf-project-meta {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 300;
}

.pf-project-cta {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.pf-project:hover .pf-project-cta {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   CTA
   ========================================================= */
.portfolio-cta {
    background: var(--pf-navy);
    color: #fff;
    padding: 120px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.portfolio-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(201, 168, 76, 0.15), transparent 60%);
}

.portfolio-cta .container {
    position: relative;
}

.portfolio-cta h2 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 400;
    line-height: 1.15;
    margin: 0 0 18px;
    color: #fff;
}

.portfolio-cta h2 em {
    font-style: italic;
    color: var(--pf-accent);
}

.portfolio-cta p {
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.72);
    max-width: 560px;
    margin: 0 auto 36px;
    line-height: 1.7;
    font-weight: 300;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
    .portfolio-hero { height: 280vh; }
    .portfolio-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .portfolio-hero { height: 240vh; }

    .pm-intro-title { font-size: clamp(1.6rem, 7vw, 2.4rem); }
    .pm-intro-hint::after { height: 36px; }

    .pm-arc-overlay { bottom: 8%; }

    .portfolio-grid {
        grid-template-columns: 1fr;
        padding: 0 20px;
        gap: 20px;
    }

    .pf-project { aspect-ratio: 5 / 4; }
}

@media (prefers-reduced-motion: reduce) {
    .portfolio-hero { height: 100vh; }
    .portfolio-morph { position: relative; }
    .pm-card { transform: none !important; }
    .pm-flipper { transition: none !important; }
    .pm-intro-hint::after { animation: none; }
}
