/* ========================================
   1. reset & base styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    line-height: 1.5;
    -webkit-tap-highlight-color: rgba(0, 255, 0, 0.3);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    background: #000;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5), 0 0 10px rgba(255, 255, 255, 0.3);
    font-family: 'Courier New', monospace;
    overflow-x: hidden;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    padding-top: calc(1rem + env(safe-area-inset-top));
}

/* ========================================
   2. layout containers
   ======================================== */
#terminal {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100dvh;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.content {
    position: relative;
    max-width: 600px;
    margin-left: 150px;
    padding: 2rem 0;
    -webkit-user-select: text;
    user-select: text;
}

.content-section {
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    opacity: 0;
    transform: scale(0.98);
    display: none;
    width: 100%;
}

.content-section.active {
    opacity: 1;
    transform: scale(1);
    display: block;
}

.content-section:last-of-type {
    margin-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.abbr {
    color: #ff0;
    text-shadow: 0 0 5px rgba(255, 255, 0, 0.5), 0 0 10px rgba(255, 255, 0, 0.3);
}

.abbr-short {
    display: inline;
}

.abbr-full {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .abbr {
        position: relative;
        cursor: help;
        border-bottom: 1px dotted #ff0;
    }
    
    .abbr:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: #000;
        color: #fff;
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.5), 0 0 10px rgba(255, 255, 255, 0.3);
        padding: 0.5rem;
        border: 1px solid #ff0;
        border-radius: 3px;
        white-space: nowrap;
        z-index: 1000;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .abbr:hover::before {
        content: '';
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        border: 5px solid transparent;
        border-top-color: #ff0;
        margin-bottom: -1px;
        z-index: 1000;
    }
}

@media (hover: none) and (pointer: coarse) {
    .abbr-short {
        display: none;
    }
    
    .abbr-full {
        display: inline;
    }
}

.mobile-header {
    display: none;
}

/* ========================================
   3. navigation - desktop
   ======================================== */
.sidebar {
    position: fixed;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    transition: 0.3s all;
}

.sidebar a {
    display: block;
    color: #fff !important;
    text-decoration: none;
    margin: 1rem 0;
    font-size: 0.9rem;
    transition: 0.3s;
}

.sidebar a:hover {
    background: #fff;
    color: #000 !important;
    padding: 0.2rem;
}

/* ========================================
   4. navigation - mobile
   ======================================== */
.hamburger {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    cursor: pointer;
    z-index: 1001;
    font-size: 1.2rem;
    background: #000;
    padding: 0.5rem;
    border: 1px solid #fff;
    border-radius: 3px;
}

.hamburger:hover {
    background: #333;
    border-color: #00ff00;
}

.mobile-menu {
    position: fixed;
    top: -100vh;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 2px solid #fff;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    padding-top: calc(2rem + env(safe-area-inset-top));
}

.mobile-menu.active {
    top: 0;
}

.mobile-menu a {
    font-size: 1.5rem;
    margin: 1.5rem 0;
    opacity: 0.8;
    transform: translateY(-20px);
    transition: 0.3s all;
}

.mobile-menu a:last-child {
    margin-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

.mobile-menu.active a {
    color: #fff !important;
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   5. typography
   ======================================== */
h1 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
}

h1::after {
    content: '_';
    animation: blink 1s infinite;
}

/* ========================================
   6. links & interactive elements
   ======================================== */
a:link,
a:visited {
    color: #f00;
    text-decoration: none;
    transition: 0.3s all;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5), 0 0 10px rgba(255, 0, 0, 0.3);
}

a:hover {
    background: rgba(0, 255, 0, 0.7);
    color: #fff;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    margin: 0 -0.4rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6), 0 0 15px rgba(0, 255, 0, 0.4);
}

a:active {
    background: rgba(0, 255, 0, 0.7);
    color: #fff;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    margin: 0 -0.4rem;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6), 0 0 15px rgba(0, 255, 0, 0.4);
    transition: all 0.15s ease-out;
}

/* ========================================
   7. content components
   ======================================== */
.project {
    margin: 1rem 0;
    padding: 1rem;
    border-left: 2px solid #fff;
    padding-left: 1rem;
    transition: 0.3s all;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5), 0 0 10px rgba(255, 255, 255, 0.3);
}

.project:hover {
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid #00ff00;
}

.project:active {
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid #00ff00;
    transition: all 0.15s ease-out;
}

.project p {
    margin: 0.5rem 0;
}

.project p:first-child {
    margin-bottom: 0.5rem;
}

/* ========================================
   8. lists
   ======================================== */
ul {
    list-style: none;
    padding-left: 0;
}

ul li {
    margin: 0.5rem 0;
    padding-left: 1rem;
}

ul li:before {
    content: "• ";
    color: #fff;
    margin-right: 0.5rem;
}

/* ========================================
   9. animations
   ======================================== */
@keyframes blink {
    50% { opacity: 0; }
}

/* ========================================
   10. responsive design
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    a:hover {
        background: none;
        color: #f00;
        padding: 0;
        border-radius: 0;
        margin: 0;
        text-shadow: 0 0 5px rgba(255, 0, 0, 0.5), 0 0 10px rgba(255, 0, 0, 0.3);
    }
    
    .hamburger:hover {
        background: #000;
        border-color: #fff;
    }
    
    .project:hover {
        background: none;
        border-left: 2px solid #fff;
    }
    
    .hamburger:active {
        background: #333;
        border-color: #00ff00;
        transition: background-color 0.3s ease, border-color 0.3s ease;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 0;
    }

    .content .header {
        display: none;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #000;
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 999;
        width: 100%;
        border-bottom: 1px solid #fff;
    }

    .mobile-header .header {
        margin: 0;
        font-size: 1.2rem;
    }

    .mobile-header .hamburger {
        display: block;
        position: static;
        border: none;
        padding: 0;
    }

    .sidebar {
        display: none;
    }
    .hamburger {
        display: none;
    }
    .content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 1rem;
    }
    
    #terminal {
        padding: 0;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        justify-content: flex-start;
    }
}

@supports (padding: max(1rem, env(safe-area-inset-bottom))) {
    #terminal {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
    
    .content-section:last-of-type {
        margin-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

@supports(padding: env(safe-area-inset-bottom)) {
    .mobile-menu a:last-child {
        margin-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}