/* ============================================
   ppuzzl.in - Renaissance Technical Drawing Aesthetic
   Palette: Warm marble & sunset tones
   Typography: Josefin Sans / Nunito Sans / Caveat
   ============================================ */

/* CSS Custom Properties */
:root {
    --bg-marble: #F5EDE0;
    --surface-stone: #EDE3D0;
    --text-primary: #2C2418;
    --text-secondary: #6B5E4F;
    --accent-gold: #C4872E;
    --accent-terracotta: #D4764E;
    --accent-rose: #B5646A;
    --line-sepia: #8B6914;
    --highlight-amber: #F0D9A8;
    --vein-color: #D4C4A8;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-marble);
    color: var(--text-primary);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* Hide SVG filter definitions */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================
   PARALLAX LAYERS
   ============================================ */

.parallax-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}

.layer-marble {
    z-index: 1;
}

.layer-geometry {
    z-index: 2;
}

.layer-illustrations {
    z-index: 3;
}

.layer-chips {
    z-index: 10;
    position: fixed;
}

.marble-veins,
.geometry-lines {
    width: 100%;
    height: 300vh;
}

/* Architectural fragments positioned absolutely */
.fragment {
    position: absolute;
    opacity: 0.6;
}

.fragment-column {
    width: 80px;
    top: 25%;
    right: 8%;
}

.fragment-arch {
    width: 120px;
    top: 55%;
    left: 5%;
}

.fragment-entablature {
    width: 160px;
    top: 75%;
    right: 15%;
}

/* ============================================
   LEFT MARGIN RULE
   ============================================ */

.margin-rule {
    position: fixed;
    left: 8.33vw;
    top: 0;
    bottom: 0;
    width: 0.5px;
    background-color: var(--text-primary);
    opacity: 0.12;
    z-index: 5;
    pointer-events: none;
}

/* ============================================
   COMPASS ROSE NAVIGATION
   ============================================ */

.compass-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
    width: 56px;
    height: 56px;
    cursor: pointer;
}

.compass-rose {
    width: 56px;
    height: 56px;
    transition: transform 0.1s linear;
}

.compass-labels {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compass-nav:hover .compass-labels {
    opacity: 1;
    pointer-events: all;
}

.compass-label {
    position: absolute;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease, transform 0.3s ease;
    padding: 4px 8px;
    background: rgba(245, 237, 224, 0.9);
}

.compass-label:hover {
    color: var(--accent-gold);
}

.compass-n {
    top: -20px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
}

.compass-e {
    top: 50%;
    right: -60px;
    transform: translateY(-50%) translateX(10px);
}

.compass-s {
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
}

.compass-w {
    top: 50%;
    left: -70px;
    transform: translateY(-50%) translateX(-10px);
}

.compass-nav:hover .compass-n {
    transform: translateX(-50%) translateY(-20px);
}

.compass-nav:hover .compass-e {
    transform: translateY(-50%) translateX(20px);
}

.compass-nav:hover .compass-s {
    transform: translateX(-50%) translateY(20px);
}

.compass-nav:hover .compass-w {
    transform: translateY(-50%) translateX(-20px);
}

/* ============================================
   CONTENT LAYER
   ============================================ */

.content-layer {
    position: relative;
    z-index: 6;
    padding-left: calc(8.33vw + 48px);
    padding-right: 48px;
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero-construction-lines {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.hero-svg {
    width: 90%;
    max-width: 1200px;
    height: auto;
}

/* SVG path drawing animation */
.draw-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawLine 3s ease-out forwards;
}

.spiral-1 { animation-delay: 0s; }
.circle-1 { animation-delay: 0.3s; stroke-dasharray: 1200; stroke-dashoffset: 1200; }
.circle-2 { animation-delay: 0.6s; stroke-dasharray: 800; stroke-dashoffset: 800; }
.circle-3 { animation-delay: 0.9s; stroke-dasharray: 500; stroke-dashoffset: 500; }
.line-h { animation-delay: 1.2s; stroke-dasharray: 600; stroke-dashoffset: 600; }
.line-v { animation-delay: 1.4s; stroke-dasharray: 600; stroke-dashoffset: 600; }
.line-d1 { animation-delay: 1.6s; stroke-dasharray: 600; stroke-dashoffset: 600; }
.line-d2 { animation-delay: 1.8s; stroke-dasharray: 600; stroke-dashoffset: 600; }

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* Hero title: puzzle piece assembly */
.hero-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 5.5vw, 4.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    position: relative;
    z-index: 2;
    display: flex;
    gap: 0.02em;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translate(var(--tx, 0), var(--ty, 0)) rotate(var(--rot, 0deg));
    animation: assembleLetter 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.letter[data-index="0"] { --tx: -80px; --ty: -60px; --rot: -25deg; animation-delay: 1.5s; }
.letter[data-index="1"] { --tx: 40px; --ty: -90px; --rot: 15deg; animation-delay: 1.7s; }
.letter[data-index="2"] { --tx: -50px; --ty: 70px; --rot: -10deg; animation-delay: 1.9s; }
.letter[data-index="3"] { --tx: 90px; --ty: 40px; --rot: 20deg; animation-delay: 2.1s; }
.letter[data-index="4"] { --tx: -30px; --ty: -80px; --rot: -30deg; animation-delay: 2.3s; }
.letter[data-index="5"] { --tx: 70px; --ty: 50px; --rot: 12deg; animation-delay: 2.5s; }
.letter[data-index="6"] { --tx: -60px; --ty: -40px; --rot: -8deg; animation-delay: 2.7s; }
.letter[data-index="7"] { --tx: 50px; --ty: 80px; --rot: 18deg; animation-delay: 2.9s; }
.letter[data-index="8"] { --tx: -40px; --ty: -70px; --rot: -22deg; animation-delay: 3.1s; }

@keyframes assembleLetter {
    0% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) rotate(var(--rot));
    }
    60% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
}

.hero-subtitle {
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    opacity: 0;
    animation: fadeUp 0.8s ease forwards;
    animation-delay: 3.5s;
    position: relative;
    z-index: 2;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.caveat-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-style: italic;
    color: var(--line-sepia);
}

.section-heading {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
}

.section-annotation {
    font-size: clamp(0.85rem, 1vw, 1.05rem);
    text-align: center;
    display: block;
    margin-bottom: 48px;
}

/* ============================================
   SECTION DIVIDERS - Greek Key / Meander
   ============================================ */

.section-divider {
    width: 100%;
    margin: 64px 0 48px;
    overflow: hidden;
}

.section-divider svg {
    width: 100%;
    height: 24px;
}

/* ============================================
   GALLERY - Portfolio Grid
   ============================================ */

.gallery {
    padding-top: 64px;
    padding-bottom: 64px;
}

.grid-registers {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* Registers: horizontal rows */
.register {
    display: grid;
    gap: 48px;
    align-items: start;
}

.register-1 {
    grid-template-columns: 2fr 3fr 2fr;
}

.register-2 {
    grid-template-columns: 3fr 2fr;
}

.register-3 {
    grid-template-columns: 1.5fr 3fr 1.5fr 2fr;
}

/* ============================================
   PANELS
   ============================================ */

.panel {
    position: relative;
    background: var(--surface-stone);
    padding: 32px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    background: var(--highlight-amber);
    box-shadow: 0 0 24px rgba(196, 135, 46, 0.12);
}

/* Panel border SVG overlay */
.panel-border-svg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.panel-border-svg svg {
    width: 100%;
    height: 100%;
}

.panel-border-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-width 0.3s ease;
    filter: url(#hand-drawn);
}

.panel.is-visible .panel-border-path {
    animation: traceBorder 0.6s ease-out forwards;
}

.panel:hover .panel-border-path {
    stroke-width: 0.8;
}

@keyframes traceBorder {
    to {
        stroke-dashoffset: 0;
    }
}

/* Panel content */
.panel-content {
    position: relative;
    z-index: 1;
}

.panel-illustration {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.panel-illustration svg {
    width: 100%;
    max-width: 300px;
    height: auto;
}

.panel-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 1.5vw, 1.4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.panel-desc {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.88rem, 1vw, 1rem);
    line-height: 1.72;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.panel-annotation {
    font-size: clamp(0.8rem, 0.9vw, 0.95rem);
    display: block;
}

/* Panel sizing */
.panel-tall {
    min-height: 420px;
}

.panel-wide {
    min-height: 300px;
}

.panel-square {
    min-height: 320px;
}

.panel-medium {
    min-height: 360px;
}

.panel-narrow-tall {
    min-height: 480px;
}

.panel-small {
    min-height: 240px;
}

.panel-wide-short {
    min-height: 220px;
}

.panel-medium-tall {
    min-height: 400px;
}

/* Corner ornaments */
.panel-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 3;
    pointer-events: none;
}

.corner-tl {
    top: -2px;
    left: -2px;
}

.corner-br {
    bottom: -2px;
    right: -2px;
}

.corner-ornament {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
}

.panel.is-visible .corner-ornament {
    animation: drawCorner 0.3s ease-out forwards;
    animation-delay: 0.5s;
}

@keyframes drawCorner {
    to {
        stroke-dashoffset: 0;
    }
}

/* Cross-hatch shadow */
.panel-crosshatch-shadow {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(44, 36, 24, 0.06) 2px,
        rgba(44, 36, 24, 0.06) 3px
    );
}

.panel.is-visible .panel-crosshatch-shadow {
    animation: fadeInShadow 0.3s ease forwards;
    animation-delay: 0.7s;
}

@keyframes fadeInShadow {
    to {
        opacity: 1;
    }
}

/* Panel entry animation for content */
.panel .panel-content {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel.is-visible .panel-content {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.15s;
}

.panel.is-visible .panel-title {
    transition-delay: 0.2s;
}

.panel.is-visible .panel-desc {
    transition-delay: 0.3s;
}

.panel.is-visible .panel-annotation {
    transition-delay: 0.4s;
}

/* Hover: illustration opacity boost */
.panel:hover .panel-illustration svg {
    opacity: 1;
}

.panel-illustration svg {
    transition: opacity 0.3s ease;
}

/* ============================================
   FRAGMENTS SECTION - Scattered finds
   ============================================ */

.fragments-section {
    padding-top: 32px;
    padding-bottom: 64px;
}

.scattered-fragments {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 48px 64px;
    max-width: 900px;
    margin: 0 auto;
}

.scatter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.scatter-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.scatter-item svg {
    width: 80px;
    height: auto;
    transition: transform 0.3s ease;
}

.scatter-item:hover svg {
    transform: rotate(5deg) scale(1.08);
}

.scatter-label {
    font-size: clamp(0.8rem, 0.9vw, 0.95rem);
}

/* Staggered scatter positions */
.scatter-1 { transition-delay: 0.1s; }
.scatter-2 { transition-delay: 0.2s; }
.scatter-3 { transition-delay: 0.3s; }
.scatter-4 { transition-delay: 0.4s; }
.scatter-5 { transition-delay: 0.5s; }
.scatter-6 { transition-delay: 0.6s; }

/* Individual scatter item offsets for organic feel */
.scatter-1 { transform: translateY(16px) rotate(-3deg); }
.scatter-2 { transform: translateY(16px) translateX(8px); }
.scatter-3 { transform: translateY(16px) rotate(5deg); }
.scatter-4 { transform: translateY(16px) translateX(-5px) rotate(-2deg); }
.scatter-5 { transform: translateY(16px) rotate(4deg); }
.scatter-6 { transform: translateY(16px) translateX(6px) rotate(-4deg); }

.scatter-1.is-visible { transform: translateY(0) rotate(-3deg); }
.scatter-2.is-visible { transform: translateY(0) translateX(8px); }
.scatter-3.is-visible { transform: translateY(0) rotate(5deg); }
.scatter-4.is-visible { transform: translateY(0) translateX(-5px) rotate(-2deg); }
.scatter-5.is-visible { transform: translateY(0) rotate(4deg); }
.scatter-6.is-visible { transform: translateY(0) translateX(6px) rotate(-4deg); }

/* ============================================
   ABOUT SECTION
   ============================================ */

.about-section {
    padding-top: 32px;
    padding-bottom: 64px;
}

.about-panel {
    position: relative;
    background: var(--surface-stone);
    padding: 56px 48px;
    max-width: 1000px;
    margin: 0 auto;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.about-panel:hover {
    background: var(--highlight-amber);
    box-shadow: 0 0 24px rgba(196, 135, 46, 0.12);
}

.about-panel .panel-border-svg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.about-panel .panel-border-svg svg {
    width: 100%;
    height: 100%;
}

.about-panel .panel-border-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    filter: url(#hand-drawn);
}

.about-panel.is-visible .panel-border-path {
    animation: traceBorder 0.6s ease-out forwards;
}

.about-panel .section-heading {
    margin-bottom: 32px;
}

.about-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.about-col p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: clamp(0.92rem, 1.1vw, 1.05rem);
}

.about-annotation {
    font-size: clamp(0.85rem, 1vw, 1.05rem) !important;
    margin-top: 16px;
}

.about-panel .panel-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 3;
    pointer-events: none;
}

.about-panel .corner-tl {
    top: -2px;
    left: -2px;
}

.about-panel .corner-br {
    bottom: -2px;
    right: -2px;
}

.about-panel.is-visible .corner-ornament {
    animation: drawCorner 0.3s ease-out forwards;
    animation-delay: 0.5s;
}

.about-panel .panel-crosshatch-shadow {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
    z-index: -1;
    opacity: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(44, 36, 24, 0.06) 2px,
        rgba(44, 36, 24, 0.06) 3px
    );
}

.about-panel.is-visible .panel-crosshatch-shadow {
    animation: fadeInShadow 0.3s ease forwards;
    animation-delay: 0.7s;
}

.about-panel .panel-content {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.about-panel.is-visible .panel-content {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.15s;
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
    position: relative;
    padding: 80px 0 48px;
    text-align: center;
    overflow: hidden;
}

.footer-constructions {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.6;
}

.footer-svg {
    width: 100%;
    height: 100%;
}

.footer-text {
    position: relative;
    z-index: 2;
    font-size: clamp(1rem, 1.2vw, 1.2rem);
    color: var(--text-secondary);
}

/* ============================================
   FLOATING MARBLE CHIPS (Layer 4)
   ============================================ */

.chip {
    position: absolute;
    background: var(--vein-color);
    opacity: 0.2;
    border-radius: 1px;
}

.chip-1 {
    width: 8px;
    height: 6px;
    top: 15%;
    left: 20%;
    transform: rotate(23deg);
}

.chip-2 {
    width: 5px;
    height: 10px;
    top: 30%;
    right: 18%;
    transform: rotate(-15deg);
}

.chip-3 {
    width: 12px;
    height: 4px;
    top: 45%;
    left: 35%;
    transform: rotate(40deg);
}

.chip-4 {
    width: 6px;
    height: 8px;
    top: 55%;
    right: 30%;
    transform: rotate(-30deg);
}

.chip-5 {
    width: 9px;
    height: 5px;
    top: 70%;
    left: 12%;
    transform: rotate(12deg);
}

.chip-6 {
    width: 7px;
    height: 11px;
    top: 80%;
    right: 22%;
    transform: rotate(-45deg);
}

.chip-7 {
    width: 10px;
    height: 6px;
    top: 40%;
    left: 60%;
    transform: rotate(35deg);
}

.chip-8 {
    width: 5px;
    height: 9px;
    top: 65%;
    right: 45%;
    transform: rotate(-20deg);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .content-layer {
        padding-left: calc(8.33vw + 24px);
        padding-right: 24px;
    }

    .register-1 {
        grid-template-columns: 1fr 1fr;
    }

    .register-2 {
        grid-template-columns: 1fr 1fr;
    }

    .register-3 {
        grid-template-columns: 1fr 1fr;
    }

    .about-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .content-layer {
        padding-left: 24px;
        padding-right: 24px;
    }

    .margin-rule {
        display: none;
    }

    .register-1,
    .register-2,
    .register-3 {
        grid-template-columns: 1fr;
    }

    .scattered-fragments {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }

    .compass-nav {
        top: 16px;
        left: 16px;
    }

    .panel-tall,
    .panel-narrow-tall {
        min-height: 300px;
    }

    .about-panel {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .scattered-fragments {
        grid-template-columns: 1fr;
    }

    .hero-title {
        flex-wrap: wrap;
        justify-content: center;
    }
}
