/* ============================================
   PPUZZL.WIN — Styles
   Glitch Art × Scholarly Archive
   ============================================ */

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

:root {
    --bg-primary: #0b1628;
    --bg-secondary: #0e1a2e;
    --bg-tertiary: #142438;
    --text-primary: #c5d5e8;
    --text-secondary: #6b8aad;
    --accent-primary: #4fc3f7;
    --accent-secondary: #26c6da;
    --accent-flash: #e0f7fa;
    --glitch-magenta: #e040fb;
    --elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1vw + 0.5rem, 1.1rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* Scan line overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(11, 22, 40, 0.15) 2px,
        rgba(11, 22, 40, 0.15) 4px
    );
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
}

/* --- The Aperture (Hero) --- */
#aperture {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

#aperture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(79, 195, 247, 0.04) 2px,
        rgba(79, 195, 247, 0.04) 3px
    );
    opacity: 0;
    animation: scanFadeIn 1s 0.5s forwards;
}

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

#hero-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

#logotype {
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--accent-primary);
    font-weight: 500;
    cursor: pointer;
    display: inline-block;
    user-select: none;
}

#logotype .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(var(--jitter, 0));
    animation: charAppear 0.15s forwards, charSnap 0.4s 2s var(--elastic) forwards;
}

#logotype .char:nth-child(1),
#logotype .char:nth-child(2) {
    font-weight: 700;
}

#logotype .char:nth-child(1) { animation-delay: 1s, 2s; }
#logotype .char:nth-child(2) { animation-delay: 1.1s, 2s; }
#logotype .char:nth-child(3) { animation-delay: 1.2s, 2s; }
#logotype .char:nth-child(4) { animation-delay: 1.3s, 2s; }
#logotype .char:nth-child(5) { animation-delay: 1.4s, 2s; }
#logotype .char:nth-child(6) { animation-delay: 1.5s, 2s; }

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

@keyframes charSnap {
    to { transform: translateY(0); }
}

/* Glitch burst on click */
#logotype.glitch-active {
    animation: glitchBurst 0.3s;
}

@keyframes glitchBurst {
    0% { transform: translateX(0); filter: none; }
    15% { transform: translateX(3px); }
    30% { transform: translateX(-2px); text-shadow: -2px 0 #ff0000, 2px 0 #00ff00; }
    45% { transform: translateX(1px); text-shadow: 2px 0 #0000ff, -2px 0 #ff0000; }
    50% { transform: translateX(0); color: var(--glitch-magenta); }
    65% { transform: translateX(-1px); text-shadow: -1px 0 #00ff00, 1px 0 #0000ff; }
    100% { transform: translateX(0); text-shadow: none; filter: none; }
}

#bisect-rule {
    width: 100vw;
    height: 1px;
    background: var(--accent-primary);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    animation: ruleExtend 0.6s 2.5s var(--elastic) forwards;
}

@keyframes ruleExtend {
    to { transform: translateX(-50%) scaleX(1); }
}

#scroll-indicator {
    width: 2px;
    height: 12px;
    background: var(--accent-primary);
    opacity: 0;
    margin: 3rem auto 0;
    animation: scrollPulse 1.5s 3s infinite, fadeInIndicator 0.3s 3s forwards;
}

@keyframes scrollPulse {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(8px); opacity: 0.2; }
}

@keyframes fadeInIndicator {
    to { opacity: 0.5; }
}

/* --- The Index (Portfolio Grid) --- */
#index {
    padding: 2rem 24px;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 2px;
}

.grid-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(79, 195, 247, 0.08);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.grid-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.grid-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--accent-primary);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.3s ease;
}

.grid-card:hover {
    transform: scale(1.02);
    transition: transform 0.6s var(--elastic);
}

.grid-card:hover::before {
    transform: scaleY(1);
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }

.card-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 500;
    color: var(--accent-flash);
    margin-bottom: 0.5rem;
}

.card-desc {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.card-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Photo cards */
.card-photo,
.codex-photo {
    position: relative;
    width: 100%;
    height: 160px;
    margin-bottom: 1rem;
    overflow: hidden;
    background: var(--bg-tertiary);
    filter: contrast(1.1) brightness(0.9);
}

.photo-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--accent-primary) 50%, var(--bg-secondary) 100%);
    mix-blend-mode: luminosity;
    opacity: 0.6;
}

.layer-r {
    mix-blend-mode: screen;
    background: linear-gradient(135deg, #1a2a4a 0%, #2a4a6a 40%, #1a3050 100%);
    opacity: 0.8;
}

.layer-g {
    mix-blend-mode: screen;
    background: linear-gradient(225deg, #0a2030 0%, #1a4a5a 50%, #0a3040 100%);
    opacity: 0.6;
    transition: transform 0.3s ease;
}

.layer-b {
    mix-blend-mode: screen;
    background: linear-gradient(45deg, #0a1828 0%, #1a3050 60%, #0a2040 100%);
    opacity: 0.5;
    transition: transform 0.3s ease;
}

.card-photo:hover .layer-r,
.codex-photo:hover .layer-r {
    transform: translateX(-2px);
}

.card-photo:hover .layer-g,
.codex-photo:hover .layer-g {
    transform: translateX(0);
}

.card-photo:hover .layer-b,
.codex-photo:hover .layer-b {
    transform: translateX(2px);
}

/* --- The Codex --- */
#codex {
    padding: 6rem 24px;
}

.codex-inner {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

.codex-image {
    position: relative;
}

.codex-photo {
    height: 400px;
}

.codex-text {
    max-width: 38em;
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M0 30h20v0h10v-10h0v-10h10' fill='none' stroke='%234fc3f7' stroke-width='1' opacity='0.05'/%3E%3Ccircle cx='20' cy='30' r='2' fill='%234fc3f7' opacity='0.05'/%3E%3Ccircle cx='30' cy='20' r='2' fill='%234fc3f7' opacity='0.05'/%3E%3Cpath d='M50 60v-20h-10' fill='none' stroke='%234fc3f7' stroke-width='1' opacity='0.05'/%3E%3Ccircle cx='50' cy='40' r='2' fill='%234fc3f7' opacity='0.05'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 60px 60px;
    padding: 2rem;
}

.codex-text h2 {
    font-size: clamp(2rem, 4vw + 0.5rem, 4.5rem);
    font-weight: 700;
    color: var(--accent-flash);
    margin-bottom: 2rem;
}

.codex-text p {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.codex-annotation {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-left: 2px solid var(--accent-primary);
    padding-left: 1rem;
    margin-top: 2rem;
}

/* --- Signal Rule --- */
.signal-rule {
    height: 1px;
    margin: 0 24px;
    background: linear-gradient(to right, var(--accent-primary), transparent 50%, var(--accent-primary));
}

/* --- The Register (Footer) --- */
#register {
    padding: 4rem 24px 3rem;
}

.register-inner {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.register-name {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.register-contact {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.register-rules {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.rule {
    width: 100%;
    max-width: 300px;
    background: var(--accent-primary);
}

.rule-1 {
    height: 1px;
    opacity: 0.6;
}

.rule-2 {
    height: 2px;
    opacity: 0.3;
}

.rule-3 {
    height: 1px;
    opacity: 0.1;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .span-2, .span-3, .span-4, .span-6 {
        grid-column: span 4;
    }

    .codex-inner {
        grid-template-columns: 1fr;
    }

    .codex-photo {
        height: 250px;
    }
}

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

    .span-2, .span-3, .span-4, .span-6 {
        grid-column: span 1;
    }
}
