/* ===================================
   Global Styles
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #4d4d4d;
    color: #cbcbcb;
    overflow-x: hidden;
}

/* ===================================
   Layout Structure
   =================================== */
#gameOfLife {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: #434343;
}

.container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.page {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 40px 20px;
    pointer-events: auto;
}

.page.active {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    align-content: center;
}

.content-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    align-content: center;
    min-height: 80vh;
    pointer-events: auto;
}

/* ===================================
   Typography
   =================================== */

.large-text {
    font-size: 2.5rem;
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.subtext {
    font-size: 1.2rem;
    color: #b0b0b0;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.subtext:hover {
    color: #d0d0d0;
    transform: scale(1.02);
}

.subtitle {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 40px;
    color: #d0d0d0;
    animation: fadeIn 0.8s ease-out 0.3s both;
}

/* ===================================
   Home & Welcome Page
   =================================== */
#home .content-wrapper {
    grid-template-rows: auto auto auto;
    gap: 60px;
}

.hero-text {
    grid-row: 1;
}

.welcome-text {
    text-align: left;
    transition: opacity 0.5s ease;
    display: grid;
    gap: 10px;
}

.welcome-text p {
    transition: opacity 0.3s ease;
    animation: fadeIn 0.8s ease-out;
}

.welcome-text p:nth-child(1) { animation-delay: 0.2s; opacity: 0; animation-fill-mode: forwards; }
.welcome-text p:nth-child(2) { animation-delay: 0.4s; opacity: 0; animation-fill-mode: forwards; }
.welcome-text p:nth-child(3) { animation-delay: 0.6s; opacity: 0; animation-fill-mode: forwards; }
.welcome-text p:nth-child(6) { animation-delay: 0.8s; opacity: 0; animation-fill-mode: forwards; }

/* ===================================
   Terminal
   =================================== */
.terminal {
    width: 100%;
    max-width: 900px;
    background: rgba(60, 60, 60, 0.8);
    border-radius: 8px;
    padding: 20px 30px;
    margin: 40px 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    text-align: left;
    pointer-events: auto;
    transition: all 0.3s ease;
    animation: slideInUp 0.8s ease-out;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.terminal:hover {
    background: rgba(60, 60, 60, 0.9);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
    border-color: rgba(74, 222, 128, 0.4);
    transform: translateY(-2px);
}

.terminal-content {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: #e0e0e0;
    text-align: left;
}

.prompt-user {
    color: #4ade80;
}

.prompt-colon,
.prompt-dollar {
    color: #e0e0e0;
}

.prompt-path {
    color: #60a5fa;
}

.cursor-blink {
    color: #e0e0e0;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ===================================
   Keyframe Animations
   =================================== */
@keyframes fadeIn { /* for welcome text */
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp { /* for portfolio page */
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow { /* for portfolio link */
    0%, 100% {
        box-shadow: 0 0 10px rgba(74, 222, 128, 0.4),
                    0 0 20px rgba(74, 222, 128, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.6),
                    0 0 30px rgba(74, 222, 128, 0.3),
                    0 0 40px rgba(74, 222, 128, 0.1);
    }
}

/* ===================================
   Navigation
   =================================== */
.main-nav,
.bottom-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    align-items: center;
    pointer-events: auto;
    animation: fadeIn 1s ease-out 1s both;
}

/* Wrapper injected by JS — display:contents makes it invisible to the flex/grid parent */
.nav-links-wrapper {
    display: contents;
}

.bottom-nav {
    margin-top: 40px;
    animation: fadeIn 0.8s ease-out 0.6s both;
}

.nav-link {
    color: #b0b0b0;
    text-decoration: underline;
    font-size: 1.1rem;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: #4ade80;
    transition: width 0.3s ease;
}

.nav-link:hover {
    color: #4ade80;
    transform: translateX(4px);
}

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

.nav-link.current {
    color: #4ade80;
}

/* ===================================
   Breadcrumb
   =================================== */
.breadcrumb {
    position: absolute;
    top: 40px;
    left: 40px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: auto;
    z-index: 100;
    transition: all 0.3s ease;
    animation: slideInUp 0.5s ease-out;
}

.breadcrumb a {
    color: #2a2a2a;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    transition: all 0.3s ease;
}

.breadcrumb a:hover {
    color: #60a5fa;
    transform: scale(1.05);
}

/* ===================================
   Blog Content
   =================================== */
.blog-content {
    padding-top: 80px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.blog-content h2 {
    font-size: 3.5rem;
    font-weight: 700;
    color: #ffffff;
    animation: slideInUp 0.6s ease-out;
}

.blog-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #e0e0e0;
    display: grid;
    gap: 24px;
    animation: fadeIn 0.8s ease-out 0.5s both;
}

.blog-text p {
    margin: 0;
    transition: all 0.3s ease;
}

.blog-text p:hover {
    color: #f5f5f5;
    transform: translateX(4px);
}

.book-reference {
    font-style: italic;
    color: #b0b0b0;
    margin-top: 40px;
}

.book-reference a {
    color: #60a5fa;
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: inline-block;
}

.book-reference a:hover {
    color: #4ade80;
    /* transform: translateX(4px); */
}

/* ===================================
   Poems
   =================================== */
.poems {
    display: grid;
    grid-template-columns: 1fr;
    gap: 50px;
    animation: fadeIn 0.8s ease-out 0.5s both;
}

.poem-section {
    display: grid;
    gap: 8px;
    padding: 20px;
    border-left: 3px solid transparent;
    transition: all 0.4s ease;
}

.poem-section:hover {
    border-left-color: #4ade80;
    padding-left: 30px;
    background: rgba(74, 222, 128, 0.05);
    border-radius: 4px;
}

.poem-line {
    line-height: 1.8;
}

.poem-attribution {
    font-style: italic;
    color: #b0b0b0;
    margin-top: 20px;
}

.spacing-top {
    margin-top: 24px;
}

/* ===================================
   Book Lists
   =================================== */
.disclaimer {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #b0b0b0;
    font-style: italic;
    animation: fadeIn 0.8s ease-out 0.4s both;
    transition: all 0.3s ease;
}

.book-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    width: 100%;
    animation: fadeIn 0.8s ease-out 0.5s both;
}

.book-column {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 30px;
    transition: all 0.3s ease;
}

.book-column:hover {
    transform: translateY(-4px);
}

.book-column h3 {
    font-size: 1.5rem;
    color: #ffffff;
    transition: all 0.3s ease;
    position: relative;
    padding-bottom: 10px;
}

.book-column h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #4ade80, #60a5fa);
    transition: width 0.4s ease;
}

.book-column:hover h3::after {
    width: 100%;
}

.book-list {
    list-style: none;
    padding-left: 0;
    display: grid;
    gap: 16px;
}

.book-list li {
    line-height: 1.6;
    color: #e0e0e0;
    transition: all 0.3s ease;
    padding-left: 0;
    position: relative;
}

/* ===================================
   Portfolio Link
   =================================== */
.portfolio-link-wrapper {
    margin-top: 40px;
    text-align: center;
}

.portfolio-link {
    color: #4ade80;
    text-decoration: none;
    font-size: 1.3rem;
    padding: 12px 24px;
    border: 2px solid #4ade80;
    border-radius: 8px;
    display: inline-block;
    transition: all 0.3s ease;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    animation: pulseGlow 2s ease-in-out infinite;
}

.portfolio-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(74, 222, 128, 0.3),
        transparent
    );
    transition: left 0.5s ease;
}

.portfolio-link:hover::before {
    left: 100%;
}

.portfolio-link:hover {
    background: #4ade80;
    color: #2a2a2a;
    transform: translateY(-2px);
    animation: none;
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

/* ===================================
   Portfolio Grid (768px+)
   =================================== */
.portfolio-content {
    padding-top: 80px;
}

.portfolio-content h2 {
    animation: slideInUp 0.6s ease-out;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

.portfolio-item {
    background: rgba(60, 60, 60, 0.6);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    opacity: 0;
    animation: slideInUp 0.6s ease-out forwards;
    position: relative;
}

.portfolio-item:nth-child(1) { animation-delay: 0.1s; }
.portfolio-item:nth-child(2) { animation-delay: 0.2s; }
.portfolio-item:nth-child(3) { animation-delay: 0.3s; }
.portfolio-item:nth-child(4) { animation-delay: 0.4s; }
.portfolio-item:nth-child(5) { animation-delay: 0.5s; }
.portfolio-item:nth-child(6) { animation-delay: 0.6s; }
.portfolio-item:nth-child(7) { animation-delay: 0.7s; }
.portfolio-item:nth-child(8) { animation-delay: 0.8s; }

.portfolio-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(74, 222, 128, 0) 0%,
        rgba(74, 222, 128, 0.1) 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

.portfolio-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 32px rgba(74, 222, 128, 0.4);
}

.portfolio-item:hover::before {
    opacity: 1;
}

.portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease, filter 0.4s ease;
    filter: brightness(0.9);
}

.portfolio-item:hover img {
    transform: scale(1.1);
    filter: brightness(1);
}

.portfolio-caption {
    padding: 20px;
    background: rgba(40, 40, 40, 0.9);
    transition: all 0.4s ease;
    position: relative;
    z-index: 2;
}

.portfolio-item:hover .portfolio-caption {
    background: rgba(40, 40, 40, 0.95);
    transform: translateY(-4px);
}

.portfolio-caption h3 {
    font-size: 1.3rem;
    color: #4ade80;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.portfolio-item:hover .portfolio-caption h3 {
    color: #5ef492;
    transform: translateX(-4px);
}

.portfolio-caption p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #d0d0d0;
    transition: color 0.3s ease;
}

.portfolio-item:hover .portfolio-caption p {
    color: #e8e8e8;
}

/* Grid span classes for different column widths */
.full-width {
    grid-column: span 6;
}

.span-two {
    grid-column: span 2;
}

.span-three {
    grid-column: span 3;
}

.span-four {
    grid-column: span 4;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .large-text {
        font-size: 1.8rem;
    }
    
    .blog-content h2 {
        font-size: 2.5rem;
    }
    
    .main-nav,
    .bottom-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .nav-links-wrapper {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.35s ease, padding 0.35s ease, gap 0.35s ease;
        padding: 0;
        gap: 0;
        width: 100%;
    }

    .nav-links-wrapper.open {
        max-height: 320px;
        padding: 12px 0 6px 0;
        gap: 20px;
    }
    
    .book-lists {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    
    .breadcrumb {
        top: 20px;
        left: 20px;
    }
    
    .terminal {
        padding: 15px 20px;
    }
    
    .terminal-content {
        font-size: 0.9rem;
        word-break: break-all;
    }
    
    .content-wrapper {
        gap: 30px;
    }
    
    .portfolio-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
    
    .full-width {
        grid-column: span 4;
    }
    
    .span-two,
    .span-three {
        grid-column: span 2;
    }
    
    .portfolio-caption h3 {
        font-size: 1.1rem;
    }
    
    .portfolio-caption p {
        font-size: 0.9rem;
    }
}

@media (max-width: 520px) {
    .large-text {
        font-size: 1.4rem;
    }
    
    .blog-content h2 {
        font-size: 2rem;
    }
    
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .full-width,
    .span-two,
    .span-three,
    .span-four {
        grid-column: span 1;
    }
    
    .portfolio-caption {
        padding: 15px;
    }
    
    .portfolio-caption h3 {
        font-size: 1rem;
    }
    
    .portfolio-caption p {
        font-size: 0.85rem;
    }
    
    .portfolio-link {
        font-size: 1.1rem;
        padding: 10px 20px;
    }
}

/* ===================================
   Interaction 1: Hamburger Button
   =================================== */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid rgba(176, 176, 176, 0.25);
    border-radius: 6px;
    cursor: pointer;
    padding: 10px 12px;
    transition: border-color 0.3s ease, background 0.3s ease;
    pointer-events: auto;
}

.hamburger:hover {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.08);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #b0b0b0;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.hamburger:hover span {
    background: #4ade80;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
    background: #4ade80;
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
    background: #4ade80;
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
}

/* ===================================
   Interaction 3: Scroll Progress Bar
   =================================== */
#scrollProgress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #60a5fa, #a78bfa);
    z-index: 9999;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
    pointer-events: none;
}

/* ===================================
   Interaction 4: Portfolio Lightbox
   =================================== */
.portfolio-item img {
    cursor: zoom-in;
}

#lightboxOverlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.93);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(8px);
}

#lightboxOverlay.active {
    opacity: 1;
    pointer-events: auto;
}

#lightboxContent {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transform: scale(0.75) rotate(-3deg);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

#lightboxOverlay.active #lightboxContent {
    transform: scale(1) rotate(0deg);
    opacity: 1;
}

#lightboxImg {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

#lightboxClose {
    position: absolute;
    top: -14px;
    right: -14px;
    background: #4ade80;
    color: #1a1a1a;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 1;
    line-height: 1;
}

#lightboxClose:hover {
    background: #f87171;
    color: #fff;
    transform: scale(1.15) rotate(90deg);
}

#lightboxCaption {
    color: #e0e0e0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#lightboxCaption strong {
    color: #4ade80;
    font-size: 1.1rem;
}

#lightboxCaption span {
    color: #b0b0b0;
    font-size: 0.9rem;
}

.lightbox-open {
    overflow: hidden;
}

/* ===================================
   Interaction 5: Back to Top Button
   =================================== */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: rgba(35, 35, 35, 0.9);
    color: #4ade80;
    border: 2px solid #4ade80;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#backToTop.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#backToTop:hover {
    background: #4ade80;
    color: #1a1a1a;
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 8px 24px rgba(74, 222, 128, 0.45);
}

#backToTop.spinning {
    animation: spinOnce 0.6s ease-in-out;
}

@keyframes spinOnce {
    0%   { transform: translateY(0) scale(1) rotate(0deg); }
    50%  { transform: translateY(-4px) scale(1.1) rotate(180deg); }
    100% { transform: translateY(0) scale(1) rotate(360deg); }
}

@media (max-width: 520px) {
    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
}
