/* ==========================================================================
   Nyvorin — Main Stylesheet
   Reset → Custom Properties → Layout → Typography → Sections →
   Components → Scroll Reveal → Responsive → Reduced Motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    background: var(--void);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   Custom Properties (injected by theme.rs, declared here as fallbacks)
   -------------------------------------------------------------------------- */

:root {
    --void: #020204;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --accent: #b366ff;
    --accent-deep: #7722cc;
    --accent-glow: rgba(179, 102, 255, 0.15);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-weight-light: 200;
    --font-weight-book: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 8rem;
    --space-2xl: 12rem;

    --transition-fast: 200ms ease-out;
    --transition-normal: 400ms ease-out;
    --transition-slow: 800ms ease-out;
    --transition-reveal: 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

#nyvorin-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.section {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-md);
}

.section-content {
    max-width: 800px;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

.namemark {
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: var(--font-weight-light);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-align: center;
    line-height: 1;
    text-shadow: 0 0 20px rgba(2,2,4,0.9), 0 0 40px rgba(2,2,4,0.7), 0 2px 8px rgba(2,2,4,1);
}

.tagline {
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    font-weight: var(--font-weight-regular);
    font-style: italic;
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-sm);
    text-shadow: 0 0 16px rgba(2,2,4,0.9), 0 0 32px rgba(2,2,4,0.7);
}

.stanza {
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    font-weight: var(--font-weight-regular);
    color: var(--text-secondary);
    line-height: 1.7;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.stanza--emphasis {
    font-weight: var(--font-weight-medium);
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--text-primary);
}

.manifesto-bold {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.section-label {
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

/* Hero */
.section-hero {
    min-height: 100vh;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    opacity: 0;
    transition: opacity 1.2s ease-out;
}

.hero-content.visible {
    opacity: 1;
}

.scroll-chevron {
    position: absolute;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    opacity: 0.3;
    animation: chevron-bob 2s ease-in-out infinite;
    transition: opacity var(--transition-slow);
}

.scroll-chevron.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-chevron::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border-right: 1px solid var(--text-muted);
    border-bottom: 1px solid var(--text-muted);
    transform: rotate(45deg);
    margin: 0 auto;
}

@keyframes chevron-bob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(8px); }
}

/* Origin */
.section-origin {
    min-height: 300vh;
    background: rgba(2, 2, 4, 0.75);
    padding-top: var(--space-xl);
    padding-bottom: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40vh;
}

/* Philosophy */
.section-philosophy {
    min-height: 250vh;
    background: rgba(2, 2, 4, 0.80);
    padding-top: var(--space-xl);
    padding-bottom: var(--space-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30vh;
}

.manifesto-entry {
    max-width: 600px;
    text-align: center;
}

.manifesto-statement {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.manifesto-elaboration {
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    font-weight: var(--font-weight-regular);
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Creations */
.section-creations {
    min-height: 100vh;
    background: rgba(2, 2, 4, 0.95);
    padding-top: var(--space-xl);
    padding-bottom: var(--space-xl);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: var(--space-md);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}
.projects-grid > .scroll-reveal {
    height: 100%;
}

/* Presence */
.section-presence {
    min-height: 80vh;
    background: rgba(2, 2, 4, 0.70);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-md);
}

.presence-text {
    max-width: 600px;
}

.presence-title {
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
}

.presence-body {
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Fallback sigil in Presence — only on Safari/mobile (no-3d) */
.presence-sigil-fallback {
    display: none;
    margin-top: var(--space-lg);
    width: clamp(200px, 40vw, 400px);
}
.presence-sigil-fallback svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 12px rgba(179,102,255,0.4)) drop-shadow(0 0 30px rgba(179,102,255,0.15));
    animation: sigil-breathe 4s ease-in-out infinite;
}
body.no-3d .presence-sigil-fallback {
    display: block;
}

/* Transmission */
.section-transmission {
    min-height: 60vh;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-md);
}

.transmission-header {
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-shadow: 0 0 16px rgba(2,2,4,0.9), 0 0 32px rgba(2,2,4,0.7);
}

.contact-links {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
    justify-content: center;
}

.contact-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: var(--font-weight-regular);
    position: relative;
    transition: color var(--transition-fast);
    padding: var(--space-xs) 0;
    text-shadow: 0 0 12px rgba(2,2,4,0.9), 0 0 24px rgba(2,2,4,0.7);
}

.contact-link:hover {
    color: var(--accent);
}

.contact-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width var(--transition-normal);
}

.contact-link:hover::after {
    width: 100%;
}

.contact-link:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 4px;
}

.transmission-seal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: var(--space-lg);
    color: var(--text-muted);
    opacity: 0.4;
}
.sigil-seal {
    width: 48px;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(2,2,4,0.9));
}
.seal-text {
    font-size: 0.7rem;
    font-weight: var(--font-weight-light);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(2,2,4,0.9), 0 0 24px rgba(2,2,4,0.7);
}

.love-section {
    padding: var(--space-lg) 0 var(--space-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 2, 4, 0.80);
}

.love-note {
    margin-top: 0;
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    font-style: italic;
    font-weight: var(--font-weight-book);
    color: rgba(179, 102, 255, 0.0);
    text-align: center;
    letter-spacing: 0.4em;
    text-shadow: 0 0 20px rgba(179, 102, 255, 0), 0 0 40px rgba(179, 102, 255, 0);
}
/* Animation starts when ScrollReveal adds .revealed to the parent */
.scroll-reveal.revealed .love-note {
    animation: love-reveal 6s ease-in-out 0.5s forwards;
}
@keyframes love-reveal {
    0% {
        color: rgba(179, 102, 255, 0);
        letter-spacing: 0.4em;
        text-shadow: 0 0 20px rgba(179,102,255,0), 0 0 40px rgba(179,102,255,0);
    }
    40% {
        color: rgba(255, 255, 255, 0.9);
        letter-spacing: 0.15em;
        text-shadow: 0 0 30px rgba(179,102,255,0.6), 0 0 60px rgba(179,102,255,0.3), 0 0 100px rgba(179,102,255,0.1);
    }
    60% {
        color: rgba(255, 255, 255, 0.95);
        text-shadow: 0 0 25px rgba(179,102,255,0.5), 0 0 50px rgba(179,102,255,0.25);
    }
    100% {
        color: rgba(255, 255, 255, 0.7);
        letter-spacing: 0.15em;
        text-shadow: 0 0 15px rgba(179,102,255,0.3), 0 0 30px rgba(179,102,255,0.15);
    }
}

/* --------------------------------------------------------------------------
   WebGPU Fallback
   -------------------------------------------------------------------------- */

/* Fallback sigil — hidden by default, shown via body.no-3d (set by JS) */
.fallback-sigil {
    display: none;
    width: clamp(150px, 35vw, 320px);
    height: auto;
    margin-bottom: 40px;
    animation: sigil-breathe 4s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(179, 102, 255, 0.4))
            drop-shadow(0 0 30px rgba(179, 102, 255, 0.15));
}
body.no-3d .fallback-sigil {
    display: block;
}
/* Also make hero content visible immediately on no-3d */
body.no-3d .hero-content {
    opacity: 1 !important;
    transform: none !important;
}
@keyframes sigil-breathe {
    0%, 100% { opacity: 0.6; filter: drop-shadow(0 0 8px rgba(179,102,255,0.3)) drop-shadow(0 0 20px rgba(179,102,255,0.1)); }
    50% { opacity: 0.85; filter: drop-shadow(0 0 16px rgba(179,102,255,0.5)) drop-shadow(0 0 40px rgba(179,102,255,0.2)); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

/* --------------------------------------------------------------------------
   Scroll Reveal
   -------------------------------------------------------------------------- */

.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Project Cards
   -------------------------------------------------------------------------- */

.project-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: var(--space-md);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.project-card__title {
    font-size: 1.1rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.project-card__statement {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-sm);
    flex: 1;
}

.project-card__meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.project-card__role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.project-card__stack {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.project-card__tech {
    font-size: 0.7rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 6px;
}

.project-card__status {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-deep);
}

.project-card__link {
    display: inline-block;
    margin-top: var(--space-sm);
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.project-card__link:hover {
    opacity: 0.7;
}

/* -- Project card as link -- */
a.project-card {
    text-decoration: none;
    color: inherit;
    display: block;
}

.project-card__sep {
    color: var(--text-muted);
    margin: 0 0.2em;
}

.project-card__category {
    font-size: 0.75rem;
    color: var(--accent-deep);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* -- Show more button -- */
.show-more-btn {
    display: block;
    margin: var(--space-lg) auto 0;
    padding: 10px 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}
.show-more-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}
.show-more-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.projects-grid--more {
    margin-top: var(--space-md);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .section {
        padding: var(--space-md) var(--space-sm);
    }

    .section-origin {
        gap: 30vh;
    }

    .section-philosophy {
        gap: 20vh;
    }

    .contact-links {
        flex-direction: column;
        align-items: center;
        gap: var(--space-md);
    }

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

    .love-section {
        padding: 20vh 0 40vh;
    }
}

/* --------------------------------------------------------------------------
   Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scroll-reveal {
        transform: none;
        transition: opacity 200ms ease-out;
    }

    .scroll-chevron {
        animation: none;
        opacity: 0.3;
    }

    .void-pulse {
        animation: none;
        opacity: 0.5;
    }
}
