/* loophole.dev - Maximalist Zen Design */
/* Colors: #0d0f12, #1a2a2e, #243b35, #39ff85, #ffb347, #4ecdc4, #e8efe4, #8fa89a, #2e4a42, #ff6b8a */
/* Fonts: Share Tech Mono, Lexend, IBM Plex Mono */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #0d0f12;
    --bg-mid: #1a2a2e;
    --surface: #243b35;
    --accent-green: #39ff85;
    --accent-amber: #ffb347;
    --accent-copper: #4ecdc4;
    --text-primary: #e8efe4;
    --text-secondary: #8fa89a;
    --border: #2e4a42;
    --accent-rose: #ff6b8a;
    --cursor-x: 50%;
    --cursor-y: 50%;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Lexend', sans-serif;
    font-weight: 300;
    font-size: 1.0625rem;
    line-height: 1.7;
    overflow-x: hidden;
    cursor: none;
}

/* Noise overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Custom Cursor */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 10001;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

body:hover #custom-cursor {
    opacity: 1;
}

#cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    pointer-events: none;
    z-index: 9999;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(57, 255, 133, 0.08) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

#cursor-glow.expanded {
    width: 160px;
    height: 160px;
}

/* Leaf trail */
#leaf-trail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

.trail-leaf {
    position: absolute;
    width: 6px;
    height: 6px;
    pointer-events: none;
    opacity: 0.6;
    animation: leafFall 2s ease-out forwards;
}

.trail-leaf svg {
    width: 100%;
    height: 100%;
}

@keyframes leafFall {
    0% {
        opacity: 0.6;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(30px) rotate(45deg);
    }
}

/* Navigation Rail */
#nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 1000;
    background: linear-gradient(to right, rgba(13, 15, 18, 0.9), transparent);
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    text-decoration: none;
    position: relative;
}

.nav-item::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    transition: background-color 0.6s ease, box-shadow 0.6s ease, transform 0.6s ease;
}

.nav-item:hover::before,
.nav-item.active::before {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(57, 255, 133, 0.4);
    transform: scale(1.5);
}

.nav-label {
    position: absolute;
    left: 48px;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    padding-left: 12px;
}

.nav-item:hover .nav-label {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(57, 255, 133, 0.3);
}

/* Hero Section */
#hero {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-bg-fern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cpath d='M50,350 C50,300 80,280 100,250 C120,220 90,200 110,170 C130,140 100,120 120,90 C140,60 120,40 130,20' stroke='%238fa89a' fill='none' stroke-width='0.5'/%3E%3Cpath d='M100,250 C120,240 130,235 125,225' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M110,170 C130,160 140,155 135,145' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M120,90 C140,80 150,75 145,65' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M100,250 C80,240 70,235 75,225' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M110,170 C90,160 80,155 85,145' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M300,380 C300,340 320,320 330,290 C340,260 320,240 340,210 C360,180 340,160 350,130' stroke='%238fa89a' fill='none' stroke-width='0.5'/%3E%3Cpath d='M330,290 C350,280 360,275 355,265' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3Cpath d='M340,210 C360,200 370,195 365,185' stroke='%238fa89a' fill='none' stroke-width='0.4'/%3E%3C/svg%3E");
    background-size: 400px 400px;
}

.hero-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.hero-illustration {
    width: 60vw;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.loophole-svg {
    width: 100%;
    height: auto;
}

.draw-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawLine 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.wall-left .draw-line { animation-delay: 0.2s; }
.portal .draw-line { animation-delay: 0.8s; }
.wall-right .draw-line { animation-delay: 0.5s; }
.vine-path { animation-delay: 1.2s; animation-duration: 2s; }

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

.portal-glow {
    animation: drawLine 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards,
               portalPulse 3s ease-in-out 2s infinite;
}

@keyframes portalPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.hero-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeIn 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 1.5s forwards;
}

.hero-subtitle {
    font-family: 'Lexend', sans-serif;
    font-weight: 300;
    font-size: 1.125rem;
    color: var(--text-secondary);
    opacity: 0;
    animation: fadeIn 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 2s forwards;
}

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

/* Grid Chapters */
.grid-chapter {
    padding: 2vh 48px 2vh 60px;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Tiles */
.tile {
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.tile.visible {
    opacity: 1;
    transform: translateY(0);
}

.tile-inner {
    background-color: var(--surface);
    height: 100%;
    min-height: 180px;
    position: relative;
    overflow: hidden;
    padding: 24px;
    display: flex;
    align-items: flex-end;
    transition: box-shadow 0.6s ease, transform 0.4s ease;
    box-shadow: inset 0 0 40px rgba(57, 255, 133, 0.03);
}

.tile-inner:hover {
    box-shadow: inset 0 0 60px rgba(57, 255, 133, 0.08);
}

.tile[data-depth="background"] .tile-inner {
    background-color: #1e332e;
}

.tile[data-depth="foreground"] .tile-inner {
    background-color: #2a4840;
}

.tile-tall .tile-inner {
    min-height: 380px;
}

.tile-square .tile-inner {
    min-height: 340px;
}

/* Tile Content */
.tile-content {
    position: relative;
    z-index: 2;
    width: 100%;
}

.tile-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    transition: transform 0.6s ease;
}

.tile-icon-sm {
    width: 48px;
    height: 48px;
}

.tile:hover .tile-icon {
    transform: scale(1.05);
}

.tile:hover .icon-hover {
    stroke: var(--accent-green);
    transition: stroke 0.6s ease;
}

.icon-hover {
    transition: stroke 0.6s ease;
}

.tile-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tile-hidden-text {
    font-family: 'Lexend', sans-serif;
    font-weight: 300;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-secondary);
    opacity: 0.03;
    transition: opacity 0.6s ease;
    margin-top: 8px;
}

.tile:hover .tile-hidden-text {
    opacity: 0.6;
}

/* Leaf corner decorations */
.tile-leaf-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    opacity: 0.15;
    transition: opacity 0.6s ease;
}

.tile:hover .tile-leaf-corner {
    opacity: 0.4;
}

.tile-leaf-tl {
    top: 8px;
    left: 8px;
    border-top: 1px solid var(--accent-copper);
    border-left: 1px solid var(--accent-copper);
    border-top-left-radius: 2px;
}

.tile-leaf-br {
    bottom: 8px;
    right: 8px;
    border-bottom: 1px solid var(--accent-copper);
    border-right: 1px solid var(--accent-copper);
    border-bottom-right-radius: 2px;
}

/* Interstitials */
.interstitial {
    padding: 12vh 60px 12vh 80px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3rem;
}

.branch-divider {
    width: 100%;
    max-width: 800px;
}

.branch-divider svg {
    width: 100%;
    height: 30px;
}

.interstitial-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(1.5rem, 3.5vw, 3rem);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    line-height: 1.4;
    max-width: 900px;
}

.interstitial-text .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 300ms ease;
}

.interstitial-text .char.visible {
    opacity: 1;
}

.interstitial-text .char-space {
    display: inline;
    width: 0.3em;
}

/* Footer */
.interstitial-final {
    padding-bottom: 6vh;
    align-items: center;
    text-align: center;
}

.footer-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 2rem;
}

.footer-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.5;
}

.footer-divider {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        cursor: auto;
    }

    #custom-cursor,
    #cursor-glow,
    #leaf-trail {
        display: none;
    }

    #nav-rail {
        position: fixed;
        left: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: 48px;
        flex-direction: row;
        background: linear-gradient(to top, rgba(13, 15, 18, 0.95), transparent);
    }

    .nav-label {
        display: none;
    }

    .grid-chapter {
        padding: 4vh 16px;
    }

    .portfolio-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2px;
    }

    .tile {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }

    .tile:nth-child(odd) {
        grid-column: span 2 !important;
    }

    .tile-inner {
        min-height: 160px;
    }

    .tile-tall .tile-inner,
    .tile-square .tile-inner {
        min-height: 200px;
    }

    .interstitial {
        padding: 8vh 24px;
        align-items: flex-start;
    }

    .interstitial-final {
        align-items: center;
    }

    .hero-illustration {
        width: 85vw;
    }

    .footer-meta {
        flex-direction: column;
        gap: 8px;
    }
}
