@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

body.loading {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}
body:not(.loading) {
    visibility: visible;
    opacity: 1;
}

/* ============== THEME VARIABLES ============== */
:root {
    --orange: #ffa500;
    --glow: #ff9511;
    --dark-bg: #0a0a0a;
    --edge-glow-color: #ffa500;
    --body-text: #ffa500;
    --h1-text: #ffa500;
    --h2-text: #ffa500;
    --glow-1: 0.6rem;
    --glow-2: 0.6rem;
    --glow-3: 0.6rem;
    --glow-4: 0.6rem;
    --glow-opacity-1: 0.25;
    --glow-opacity-2: 0.25;
    --glow-opacity-3: 0.35;
    --glow-opacity-4: 0.35;
    --edge-glow-intensity: 0.45;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--dark-bg);
    color: var(--body-text);
    font-family: 'VT323', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono',
                 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace',
                 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono',
                 monospace;
    line-height: 1.45;
    overflow-x: hidden;
    image-rendering: pixelated;
    position: relative;
    min-height: 100vh;
    margin: 0;
}

/* FULL VIEWPORT EDGE GLOW */
.edge-glow-left,
.edge-glow-right {
    position: fixed;
    top: 0;
    width: 0rem;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    background: transparent;
    box-shadow:
        0 0 4px 1px var(--edge-glow-color),
        0 0 20px 2px var(--edge-glow-color);
    opacity: var(--edge-glow-intensity);
    transition: opacity 0.4s ease-out, box-shadow 0.4s ease-out;
}
.edge-glow-left { left: 0; }
.edge-glow-right { right: 0; }

/* SUBTLE STATIC SCANLINES */
.scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        transparent 0px,
        transparent 2px,
        rgba(255, 204, 0, 0.02) 2px,
        rgba(255, 204, 0, 0.02) 4px
    );
    pointer-events: none;
    z-index: 999;
}

/* PIRATE GLITCH */
.pirate-wrapper {
    position: relative;
    width: min(420px, 85vw);
    height: auto;
    margin: 0 auto 0rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.pirate-container {
    width: min(280px, 65vw);
    height: auto;
    max-height: 380px;
    position: relative;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 0 var(--glow-4) rgba(255, 204, 0, var(--glow-opacity-4)));
    overflow: visible;
}

.pirate-container::before,
.pirate-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../assets/pirate-man.png') center/contain no-repeat;
    pointer-events: none;
    opacity: 0.85;
}
.pirate-container::before { animation: glitch-slice 0.85s infinite linear; }
.pirate-container::after {
    animation: glitch-slice 1.35s infinite linear;
    filter: brightness(1.3);
}

@keyframes glitch-slice {
    0% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: translate(0); }
    3% { clip-path: polygon(0 8%, 100% 8%, 100% 14%, 0 14%); transform: translate(-6px, 2px); }
    6% { clip-path: polygon(0 28%, 100% 28%, 100% 34%, 0 34%); transform: translate(5px, -3px); }
    9% { clip-path: polygon(0 47%, 100% 47%, 100% 53%, 0 53%); transform: translate(-4px, 4px); }
    12% { clip-path: polygon(0 71%, 100% 71%, 100% 77%, 0 77%); transform: translate(7px, -1px); }
    15% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: translate(0); }
    100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); transform: translate(0); }
}

.pirate-container.loading {
    animation: bottomUpGlitch 1.4s ease-out forwards;
}

@keyframes bottomUpGlitch {
    0% { clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%); opacity: 0.25; filter: brightness(0.45) contrast(2.4); }
    35% { clip-path: polygon(0 62%, 100% 62%, 100% 100%, 0 100%); opacity: 0.68; filter: brightness(0.95) contrast(1.75) drop-shadow(0 0 var(--glow-4) rgba(255, 204, 0, 0.35)); }
    65% { clip-path: polygon(0 24%, 100% 24%, 100% 100%, 0 100%); opacity: 0.92; filter: brightness(1.22) contrast(1.35) drop-shadow(0 0 var(--glow-4) rgba(255, 204, 0, 0.65)); }
    100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); opacity: 1; filter: drop-shadow(0 0 var(--glow-4) rgba(255, 204, 0, var(--glow-opacity-4))); }
}

/* CLEAN CONTENT */
.crt {
    position: relative;
    max-width: min(92vw, 820px);
    margin: 0vh auto;
    padding: clamp(30px, 6vw, 50px) clamp(20px, 5vw, 40px);
    border: none;
    box-shadow: none;
    overflow: visible;
    z-index: 1;
}

/* HEADER */
header {
    text-align: center;
    margin-bottom: clamp(40px, 8vh, 70px);
}
h1 {
    font-size: clamp(2.4rem, 8vw, 3.8rem);
    text-transform: uppercase;
    letter-spacing: clamp(3px, 1vw, 8px);
    color: var(--h1-text);
    text-shadow:
        0 0 var(--glow-1) rgba(255, 149, 0, var(--glow-opacity-1)),
        0 0 var(--glow-2) rgba(255, 204, 0, var(--glow-opacity-2)),
        0 0 var(--glow-3) rgba(255, 149, 0, var(--glow-opacity-3));
    line-height: 1.1;
}
.tagline {
    font-size: clamp(1.2rem, 4.5vw, 1.55rem);
    color: var(--orange);
    margin: 1rem 0 2rem;
}
nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(20px, 5vw, 50px);
    margin: 2rem 0 2rem;
    font-size: clamp(1.3rem, 4.5vw, 1.65rem);
}
nav a {
    color: var(--body-text);
    text-decoration: none;
    text-shadow: 0 0 var(--glow-1) rgba(255, 204, 0, var(--glow-opacity-2));
    transition: all 0.2s;
    white-space: nowrap;
}
nav a:hover {
    color: white;
    text-shadow: 0 0 var(--glow-2) rgba(255, 204, 0, 0.95);
    transform: scale(1.08);
}

#about { margin-bottom: 5.5rem; }
#projects { margin-bottom: 6.5rem; }
#links { margin-bottom: 7.5rem; }
#contact { margin-bottom: 4rem; }

h2 {
    font-size: clamp(1.7rem, 6vw, 2.3rem);
    border-bottom: 0.13rem solid var(--orange);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--h2-text);
    text-shadow: 0 0 var(--glow-2) rgba(255, 204, 0, var(--glow-opacity-2));
}

.content {
    font-size: clamp(1.2rem, 4vw, 1.45rem);
}
.content a {
    color: var(--glow);
    text-decoration: underline wavy;
}

.links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 1.8rem;
    margin-top: 2rem;
}

/* UPDATED LINK CARDS - whole card is clickable */
.link-card {
    display: block;
    background: rgba(255,150,0,0.08);
    border: 2px solid var(--orange);
    padding: 1.6rem;
    text-align: center;
    transition: all 0.3s;
    color: var(--orange);
    text-decoration: none;
    cursor: pointer;
}
.link-card:hover {
    background: rgba(255,204,0,0.15);
    transform: translateY(-6px);
    box-shadow: 0 0 var(--glow-3) rgba(255, 204, 0, var(--glow-opacity-3));
}
.link-card strong {
    color: var(--orange);
}
.link-card span {
    color: var(--orange);
    font-size: 1.35rem;
    display: block;
    margin-top: 0.4rem;
}
.link-card:hover strong,
.link-card:hover span {
    color: #fff;
    text-shadow: 0 0 var(--glow-2) rgba(255, 204, 0, 0.9);
}

.submit-btn {
    display: inline-block;
    background: rgba(255,150,0,0.08);
    color: var(--orange);
    border: 2px solid var(--orange);
    padding: 0.9rem 2rem;
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1.5rem;
}
.submit-btn:hover {
    background: rgba(255,204,0,0.15);
    color: #fff;
    transform: translateY(-6px);
    box-shadow: 0 0 var(--glow-3) rgba(255, 204, 0, var(--glow-opacity-3));
    text-shadow: 0 0 var(--glow-2) rgba(255, 204, 0, 0.9);
}

footer {
    text-align: center;
    padding: clamp(40px, 8vh, 70px) 1rem 2rem;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    opacity: 0.75;
}

@media (max-width: 480px) {
    .crt {
        padding: 25px 18px;
    }
    #about, #projects, #links, #contact {
        margin-bottom: 3.2rem;
    }
    .pirate-wrapper {
        height: auto;
    }
}

/* ==================== TYPING REVEAL SYSTEM ==================== */
.terminal-cursor {
    display: inline-block;
    animation: blink 0.6s step-end infinite;
    color: var(--orange);
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Hide until typed */
h1, h2, .content, .phosphor-text, .links, .tagline, #nav-links {
    opacity: 0 !important;
    visibility: hidden !important;
    overflow: hidden !important;
    border-bottom: none !important;
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out !important;
}

/* Reveal */
h1.typing, h2.typing, .content.typing, .phosphor-text.typing, .links.typing,
h1.typed, h2.typed, .content.typed, .phosphor-text.typed, .links.typed,
.tagline.typing, .tagline.typed, #nav-links.typing, #nav-links.typed {
    opacity: 1 !important;
    visibility: visible !important;
}

h2.typed {
    border-bottom: 0.13rem solid var(--orange) !important;
}

/* CONTACT FORM OVERRIDE */
#contact .content,
#contact .content * {
    opacity: 0 !important;
    visibility: hidden !important;
}
#contact .content.typing,
#contact .content.typed,
#contact .content.typing * {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Safety */
.content, .tagline, #name, h1, h2 {
    min-height: 1.2em;
}