/* --- Global Styles & New Layout --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Arial', sans-serif;
    background: #000000;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- CRT Background Effect --- */
@keyframes crt-scan {
    0% { background-position: 0 0; }
    100% { background-position: 0 100%; }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        rgba(0, 0, 0, 0.4) 50%,
        transparent 100%
    );
    background-size: 100% 3px; /* Harder Scanlines */
    animation: crt-scan 0.1s linear infinite;
    opacity: 0.4; /* Increased visibility */
    z-index: 2; /* Position above floating assets */
    pointer-events: none;
    box-shadow: inset 0 0 10em rgba(0, 0, 0, 0.5); /* Vignette Effect */
}


/* --- Background & Effects --- */
.bg-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -2; /* Lower z-index */ }
.bg-container::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: url('https://raw.githubusercontent.com/glickko/glickko.github.io/main/background.jpg'); background-size: cover; background-position: center center; background-repeat: no-repeat; opacity: 0.3; animation: ringRotation 30s ease-in-out infinite; }
.pulse-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.pulse { position: absolute; width: 50vw; height: 50vw; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%); animation: pulse-corner 6s ease-in-out infinite alternate; }
.pulse.top-left { top: -25vw; left: -25vw; } .pulse.top-right { top: -25vw; right: -25vw; animation-delay: 1.5s; } .pulse.bottom-left { bottom: -25vw; left: -25vw; animation-delay: 2.5s; } .pulse.bottom-right { bottom: -25vw; right: -25vw; animation-delay: 4s; }
.dimensional-bg::after { content: ''; position: absolute; top: 50%; left: 50%; width: 500px; height: 500px; border: 2px solid rgba(255, 255, 255, 0.15); border-radius: 50%; transform: translate(-50%, -50%) scale(0); animation: dimensionalRing 4s ease-in-out infinite 0.5s; }
.glitch-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.glitch-overlay::before, .glitch-overlay::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: inherit; background-image: url('https://raw.githubusercontent.com/glickko/glickko.github.io/main/background.jpg'); background-size: cover; background-position: center center; opacity: 0.5; }
.glitch-overlay::before { animation: glitch-anim-1 5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite; }
.glitch-overlay::after { animation: glitch-anim-2 4.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite; }

/* --- Floating Asset Styles --- */
.floating-asset-container { position: fixed; top: 20vh; left: 0; width: 100%; height: 80vh; z-index: 1; pointer-events: none; }

.floating-asset-wrapper {
    position: absolute;
    opacity: 0;
    animation-name: ambient-bobbing;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}
.floating-asset-image {
    width: 100%;
    height: auto;
    --glow-color: #fff;
    animation: pulse-glow 5s ease-in-out infinite;
}
.asset-label {
    position: absolute;
    bottom: -15px; 
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    opacity: 0.9;
    white-space: nowrap; 
}

@keyframes ambient-bobbing {
    0%   { transform: translate(0, 0) rotate(-5deg); opacity: 0; }
    10%  { opacity: 0.9; }
    25%  { transform: translate(2vw, 2vh) rotate(5deg); }
    50%  { transform: translate(-2vw, -2vh) rotate(-8deg); opacity: 0.9; }
    75%  { transform: translate(1vw, -1vh) rotate(3deg); }
    90%  { opacity: 0; }
    100% { transform: translate(0, 0) rotate(-5deg); opacity: 0; }
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 12px var(--glow-color)); }
    50%      { filter: drop-shadow(0 0 20px var(--glow-color)); }
}

.floating-asset-wrapper { width: clamp(60px, 8vw, 120px); }
.floating-asset-wrapper.asset-1 { top: 10%; left: 15%; animation-duration: 20s; animation-delay: 0s; }
.floating-asset-wrapper.asset-2 { top: 20%; left: 80%; animation-duration: 25s; animation-delay: 3s; }
.floating-asset-wrapper.asset-3 { top: 70%; left: 5%; animation-duration: 18s; animation-delay: 5s; }
.floating-asset-wrapper.asset-4 { top: 80%; left: 90%; animation-duration: 22s; animation-delay: 8s; }
.floating-asset-wrapper.asset-5 { top: 50%; left: 50%; animation-duration: 28s; animation-delay: 1s; }
.floating-asset-wrapper.asset-6 { top: 5%; left: 45%; animation-duration: 16s; animation-delay: 10s; }
.floating-asset-wrapper.asset-7 { top: 85%; left: 25%; animation-duration: 24s; animation-delay: 6s; }
.floating-asset-wrapper.asset-8 { top: 60%; left: 75%; animation-duration: 21s; animation-delay: 4s; }

.floating-asset-image { animation-delay: inherit; }


@keyframes ringRotation { 0%{transform:scale(1.1) translate(-20px,0);opacity:.3}25%{transform:scale(1.2) translate(0,20px);opacity:.4}50%{transform:scale(1.15) translate(20px,0);opacity:.3}75%{transform:scale(1.2) translate(0,-20px);opacity:.4}100%{transform:scale(1.1) translate(-20px,0);opacity:.3} } @keyframes pulse-corner { from{transform:scale(.8);opacity:.3}to{transform:scale(1.2);opacity:.8} } @keyframes dimensionalRing { 0%{transform:translate(-50%,-50%) scale(0);opacity:1}100%{transform:translate(-50%,-50%) scale(5);opacity:0} } @keyframes logoGlow { from{text-shadow:0 0 10px rgba(255,255,255,.4),0 0 5px #000}to{text-shadow:0 0 20px rgba(255,255,255,.7),0 0 10px #000} } @keyframes glitch-anim-1{0%{clip-path:polygon(0 2%,100% 2%,100% 5%,0 5%);transform:translate(-10px,0)}10%{clip-path:polygon(0 75%,100% 75%,100% 75%,0 75%);transform:translate(5px,0)}20%{clip-path:polygon(0 40%,100% 40%,100% 45%,0 45%);transform:translate(-8px,0)}30%,100%{clip-path:inset(50%)}} @keyframes glitch-anim-2{0%{clip-path:polygon(0 60%,100% 60%,100% 62%,0 62%);transform:translate(10px,0)}15%{clip-path:polygon(0 15%,100% 15%,100% 20%,0 20%);transform:translate(-5px,0)}25%{clip-path:polygon(0 90%,100% 90%,100% 95%,0 95%);transform:translate(8px,0)}35%,100%{clip-path:inset(50%)}} @keyframes text-glitch-1{0%{clip-path:inset(40% 0 61% 0);transform:translate(-2px,-1px)}20%{clip-path:inset(10% 0 86% 0);transform:translate(1px,1px)}40%{clip-path:inset(90% 0 1% 0);transform:translate(-2px,2px)}60%{clip-path:inset(50% 0 45% 0);transform:translate(2px,-1px)}80%{clip-path:inset(25% 0 70% 0);transform:translate(-1px,1px)}100%{clip-path:inset(40% 0 61% 0);transform:translate(2px,-1px)}} @keyframes text-glitch-2{0%{clip-path:inset(80% 0 3% 0);transform:translate(2px,1px)}20%{clip-path:inset(20% 0 76% 0);transform:translate(-2px,-1px)}40%{clip-path:inset(50% 0 46% 0);transform:translate(2px,-2px)}60%{clip-path:inset(90% 0 5% 0);transform:translate(-2px,1px)}80%{clip-path:inset(45% 0 50% 0);transform:translate(2px,-1px)}100%{clip-path:inset(80% 0 3% 0);transform:translate(-2px,1px)}}
@keyframes sorted-flicker { 0%, 8%, 16% { box-shadow: 0 0 3px #fff, 0 0 6px #fff, 0 0 9px #fff; border-color: rgba(255, 255, 255, 0.8); } 4%, 12%, 20% { box-shadow: none; border-color: rgba(255, 255, 255, 0.25); } 25%, 100% { box-shadow: none; border-color: rgba(255, 255, 255, 0.25); } }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-content-appear { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes item-fade-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- Per-Character Cyberpunk Glitch Effect --- */
@keyframes char-glitch {
  0%, 100% { transform: translate(0, 0); opacity: 1; }
  25% { transform: translate(2px, -2px); opacity: 0.8; }
  50% { transform: translate(-2px, 2px); opacity: 1; }
  75% { transform: translate(2px, 2px); opacity: 0.8; }
}

@keyframes char-glitch-2 {
  0%, 100% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  10% { clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%); }
  30% { clip-path: polygon(0 0, 100% 0, 100% 30%, 0 30%); }
  50% { clip-path: polygon(0 20%, 100% 20%, 100% 80%, 0 80%); }
  70% { clip-path: polygon(0 70%, 100% 70%, 100% 75%, 0 75%); }
  90% { clip-path: polygon(0 0, 100% 0, 100% 10%, 0 10%); }
}

.menu-item.glitch-button {
    animation: none;
    border: none;
    background: transparent;
    padding: clamp(0.9rem, 2.5vh, 1.2rem) 0;
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.menu-item.glitch-button .text {
    display: inline-flex; /* Changed to allow spans to sit side-by-side */
}

.menu-item.glitch-button .text > span {
    position: relative;
    display: inline-block;
    animation: char-glitch 4s infinite;
    animation-delay: calc(var(--i) * 100ms);
}

.menu-item.glitch-button .text > span::before,
.menu-item.glitch-button .text > span::after {
    content: attr(data-char);
    position: absolute;
    top: 0;
    left: 0;
    animation: char-glitch-2 3s infinite;
    animation-timing-function: steps(1, end);
}

.menu-item.glitch-button .text > span::before {
    color: #ff00ff;
    animation-delay: calc(var(--i) * 120ms);
    text-shadow: -1px 0 #ff00ff;
}

.menu-item.glitch-button .text > span::after {
    color: #00ffff;
    animation-delay: calc(var(--i) * 80ms);
    text-shadow: 1px 0 #00ffff;
}

.menu-item.glitch-button:active .text > span {
    animation: char-glitch 0.2s infinite; /* Faster on click */
}


/* --- Header --- */
header { flex-shrink: 0; z-index: 10; padding: 1.5rem 1rem; text-align: center; position: relative; }
.home-link-icon { position: absolute; top: clamp(1.5rem, 2.5vw, 2rem); right: clamp(1.5rem, 2.5vw, 2rem); display: block; line-height: 0; transition: transform 0.2s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.2s ease; opacity: 0.7; will-change: transform, opacity; }
.home-link-icon img { height: clamp(1.75rem, 2.5vw, 2.5rem); width: auto; }
.home-link-icon:hover { transform: scale(1.1); opacity: 1; }
.home-link-icon:active { transform: scale(0.95); opacity: 0.8; }
nav { display: inline-flex; flex-direction: column; justify-content: center; align-items: center; max-width: 1200px; }
.logo { font-size: clamp(1.3rem, 1.1rem + 1.5vw, 2rem); font-weight: bold; letter-spacing: 3px; color: #ffffff; animation: logoGlow 3s ease-in-out infinite alternate; position: relative; }
.logo::before, .logo::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; color: #fff; overflow: hidden; clip-path: inset(0 0 0 0); background: transparent; }
.logo::before { text-shadow: -2px 0 #00aaff; animation: text-glitch-1 3.2s infinite linear alternate-reverse; }
.logo::after { text-shadow: 2px 0 #ff00ff; animation: text-glitch-2 2.8s infinite linear alternate-reverse; }
.social-links { margin-top: 0.75rem; text-align: center; }
.social-links a { font-size: 1.2rem; color: #ccc; text-decoration: none; transition: all 0.3s ease; margin: 0 10px; }
.social-links a:active { transform: scale(0.95); }
.subheader-text { margin-top: 0.75rem; color: rgba(255, 255, 255, 0.5); font-weight: bold; text-transform: uppercase; white-space: nowrap; letter-spacing: 2px; font-size: clamp(0.6rem, 2.5vw, 0.9rem); }

/* --- Main Content (STABLE & FLEXIBLE LAYOUT) --- */
main { flex-grow: 1; z-index: 10; transition: opacity 0.4s ease-in-out; width: 100%; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 2rem 1rem; position: relative; }
main.main-portfolio-layout { padding: 1rem; align-items: initial; justify-content: initial; }
main.fade-out { opacity: 0; }
main.fade-in { opacity: 1; }
#home { display: flex; flex-direction: column; gap: clamp(1.2rem, 2vh, 2rem); align-items: center; justify-content: center; width: 100%; height: 100%; }

/* --- Menu & Generic Page Styles --- */
.menu-item { display: flex; align-items: center; justify-content: center; font-size: clamp(1rem, 3.5vw, 1.3rem); font-weight: bold; color: #ccc; text-decoration: none; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 10px; background: rgba(10, 10, 10, 0.6); transition: transform 0.2s ease, color 0.3s ease, border-color 0.3s; position: relative; overflow: hidden; cursor: pointer; text-align: center; width: clamp(260px, 65vw, 300px); padding: clamp(0.9rem, 2.5vh, 1.2rem) 1.5rem; animation: sorted-flicker 4.5s ease-in-out infinite; }
#home .menu-item { animation-delay: 0s; }
.menu-item:active { transform: translateY(1px) scale(0.98); }
.menu-item .text { position: relative; z-index: 2; }
.content-box { color: #ccc; text-align: center; background: rgba(10, 10, 10, 0.6); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 15px; padding: clamp(2rem, 5vw, 3rem); width: 100%; max-width: 600px; margin: auto; display: flex; flex-direction: column; align-items: center; }
.content-box h1 { margin-bottom: 1rem; }

/* --- Tools Page Styles (STABLE CENTERED BOX) --- */
.tools-container { width: 100%; max-width: 700px; height: 70vh; background: rgba(10, 10, 10, 0.6); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 15px; backdrop-filter: blur(5px); padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; margin: auto; }
.tool-controls { flex-shrink: 0; padding-bottom: 1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
#tool-search-bar { width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 0.5rem 0.8rem; border-radius: 8px; font-size: 0.8rem; }
#tool-search-bar::placeholder { color: #aaa; }
.tools-list { display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; flex-grow: 1; padding-right: 0.5rem; }
.tool-item { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 1rem; background-color: rgba(255, 255, 255, 0.05); border-radius: 8px; text-decoration: none; color: #ccc; transition: all 0.3s ease; }
.tool-item.hidden { display: none; }
.tool-item:active { transform: translateY(1px); }
.tool-item .tool-name { font-size: 0.9rem; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 1rem; }
.tool-tag, .tool-tags-container { font-size: 0.5rem; background-color: rgba(255, 255, 255, 0.15); color: #fff; padding: 0.1rem 0.3rem; border-radius: 5px; font-weight: bold; letter-spacing: 0.5px; flex-shrink: 0; }
.tool-tags-container { display: flex; gap: 0.5rem; background: none; padding: 0; }
.tools-list::-webkit-scrollbar { width: 8px; } .tools-list::-webkit-scrollbar-track { background: transparent; } .tools-list::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.2); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; } .tools-list::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.4); }

/* --- Portfolio Page Styles --- */
.portfolio-page-container {
    width: 100%;
    height: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}
.portfolio-filters {
    flex-shrink: 0;
    padding: 1rem;
    z-index: 10;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: transparent;
    border: none;
}
.filter-btn { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #ccc; padding: 0.4rem 0.9rem; border-radius: 20px; cursor: pointer; transition: all 0.3s ease; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; font-size: 0.7rem; }
.filter-btn.active { background: rgba(255,255,255,0.1); color: #fff; border-color: #fff; transform: scale(1.05); }
.filter-btn:not(.active):hover { transform: scale(1.05); border-color: rgba(255,255,255,0.7); }
.portfolio-scroll-container { flex-grow: 1; overflow-y: auto; padding: 1rem; }
.portfolio-grid { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; }
.portfolio-item { position: relative; cursor: pointer; overflow: hidden; border-radius: 10px; background: #111; aspect-ratio: 4 / 3; border: 1px solid rgba(255, 255, 255, 0.15); flex: 0 1 320px; z-index: 1; animation: item-fade-in 0.5s ease forwards; }
.portfolio-item.hidden { display: none; }
.portfolio-item img { width: 100%; height: 100%; object-fit: cover; }
.portfolio-item .overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 70%);
    transition: background 0.5s ease;
    display: flex; align-items: flex-end; justify-content: center;
    padding: 1.5rem;
} 
.portfolio-item:hover .overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 70%);
}
.overlay-text { 
    text-align: center;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) 0.1s;
} 
.overlay-text h3 { margin: 0; font-size: 1.2rem; }
.overlay-text span { font-size: 0.9rem; color: #aaa; }

/* --- NEW / UPDATED Modal Styles --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.8); backdrop-filter: blur(5px); animation: modal-fade-in 0.3s ease; align-items: center; justify-content: center; padding: 1rem;}
.modal-content {
    display: flex;
    flex-direction: column;
    position: relative;
    background: #181818;
    margin: auto;
    padding: 2rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 15px;
    max-width: 90vw;
    width: 900px;
    max-height: 90vh;
    animation: modal-content-appear 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.modal-image-container { flex-shrink: 0; margin-bottom: 1.5rem; }
.modal-image-container img { max-width: 100%; height: auto; border-radius: 8px; }
.modal-text-container { display: flex; flex-direction: column; text-align: left; }
.modal-text-container h2 { margin-bottom: 0.5rem; font-size: clamp(1.8rem, 5vw, 2.2rem); }
.modal-category { font-size: 1rem; color: #aaa; margin-bottom: 1.5rem; }
.modal-details { overflow-y: auto; margin-bottom: 1.5rem; }
.modal-details p { color: #ccc; line-height: 1.7; font-size: clamp(0.9rem, 2.5vw, 1rem); }
.project-link-btn {
    display: inline-block;
    margin-top: auto; /* Pushes button to the bottom */
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}
.project-link-btn:hover { background: rgba(255,255,255,0.2); border-color: #fff; }
.modal-close {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
}
.modal-close:hover { color: #fff; transform: scale(1.1); }


/* --- Footer --- */
footer { flex-shrink: 0; z-index: 10; text-align: center; padding: 1rem; background: rgba(10,10,10,0.4); border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.9rem; color: #888; }

/* --- Hover-Specific Styles for Mouse Users --- */
@media (hover: hover) and (pointer: fine) {
    .social-links a:hover { transform: scale(1.2); }
    .menu-item:not(.glitch-button):hover { transform: translateY(-8px) scale(1.05); color: #fff; }
    .menu-item.glitch-button:hover { transform: none; } /* Disable hover transform for glitch button */
    .tool-item:hover { background-color: rgba(255, 255, 255, 0.1); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }

    .overlay-text {
      opacity: 0;
      transform: translateY(15px);
    }
    .portfolio-item:hover .overlay-text {
      opacity: 1;
      transform: translateY(0);
    }
}

/* --- Responsive Design for Desktop --- */
@media (min-width: 768px) {
    .floating-asset-wrapper {
        width: clamp(30px, 5vw, 80px);
    }
    .modal-content {
        flex-direction: row;
        gap: 2rem;
    }
    .modal-image-container {
        flex: 1 1 55%; /* Allow image to take up more space */
        margin-bottom: 0;
    }
    .modal-text-container {
        flex: 1 1 45%;
    }
}

/* --- NEW: Loading State Styles --- */
.loading-text {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
    font-size: 1rem;
    font-style: italic;
    animation: flicker-loading 1.5s ease-in-out infinite alternate;
}

@keyframes flicker-loading {
    from {
        opacity: 0.5;
    }
    to {
        opacity: 1;
    }
}