/* === STONE FOREST OS — PURE MONOCHROME CYBER-BRUTALIST === */

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

@font-face {
    font-family: 'Terminus';
    src: local('Courier New'), local('Consolas'), monospace;
}

body {
    background: #000000; 
    color: #FFFFFF;
    font-family: 'Terminus', 'Courier New', Courier, monospace;
    font-size: 1rem; 
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
}

/* Grayscale Scanlines */
.scanlines {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.3) 50%);
    background-size: 100% 4px;
    pointer-events: none; z-index: 1000;
}

/* === NAV === */
#nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; 
    border-bottom: 2px solid #FFFFFF;
    position: sticky; top: 0; background: #000; z-index: 100;
}
.nav-logo {
    font-size: 1.5rem; font-weight: 900; letter-spacing: 4px;
    color: #FFFFFF;
    background: #000000;
    padding: 0 6px;
    white-space: nowrap;
    animation: glitch-skew 2.5s cubic-bezier(0.25,0.46,0.45,0.94) both infinite;
}
@keyframes glitch-skew {
    0%{transform:skew(0)} 
    10%{transform:skew(-4deg)} 
    20%{transform:skew(4deg)} 
    30%{transform:skew(0)} 
    100%{transform:skew(0)}
}
.nav-links { 
    display: flex; gap: 8px; flex-wrap: wrap; 
}
.nav-link {
    color: #000000; background: #FFFFFF;
    text-decoration: none; padding: 6px 14px; font-size: 0.85rem;
    font-weight: bold; border: 1px solid #FFFFFF;
    transition: all 0.1s;
    white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center;
}
.nav-link:hover, .nav-link.active { 
    color: #FFFFFF; background: #000000; 
    border: 1px solid #FFFFFF;
}

/* === MAIN === */
#content { padding: 25px 20px; min-height: calc(100vh - 70px); max-width: 1200px; margin: 0 auto; }

/* === TERMINAL PAGE === */
.terminal-output { flex-grow: 1; overflow-y: auto; padding-bottom: 20px; }
.line { margin: 8px 0; word-wrap: break-word; line-height: 1.5; font-size: 0.95rem; }
.prompt { font-weight: bold; color: #FFFFFF; }
.user-input { color: #FFFFFF; }
.sys { color: #FFFFFF; font-style: italic; opacity: 0.8; }
.highlight {
    color: #000000; font-weight: bold; background: #FFFFFF;
    padding: 3px 8px; cursor: pointer; text-decoration: none;
    display: inline-block; margin: 2px 0;
}
.highlight:hover { background: #000000; color: #FFFFFF; border: 1px solid #FFFFFF; }
.cursor { display: inline-block; width: 10px; height: 1.1em; background: #FFFFFF; animation: blink 1s step-end infinite; vertical-align: bottom; }
@keyframes blink { 50%{opacity:0} }
#input-line {
    display: flex; align-items: center; padding-top: 15px; border-top: 2px solid #FFFFFF;
    flex-wrap: wrap; gap: 8px;
}
#cmd {
    background: transparent; border: none; color: #FFFFFF;
    font-family: inherit; font-size: 1.1rem;
    flex-grow: 1; outline: none; caret-color: #FFFFFF;
    text-transform: uppercase; min-width: 160px;
}

/* === FEED PAGE === */
.feed-item {
    border: 2px solid #FFFFFF; padding: 18px; margin: 16px 0;
    background: #000000;
}
.feed-author { color: #000000; background: #FFFFFF; display: inline-block; padding: 2px 8px; font-weight: bold; font-size: 0.85rem; margin-bottom: 8px; }
.feed-content { margin-top: 8px; color: #FFFFFF; line-height: 1.5; font-size: 0.95rem; word-break: break-word; }
.feed-link { color: #FFFFFF; text-decoration: underline; text-decoration-style: dashed; margin-top: 12px; display: inline-block; font-weight: bold; font-size: 0.85rem; }
.feed-link:hover { color: #000000; background: #FFFFFF; text-decoration: none; padding: 2px 5px;}

/* === LORE PAGE === */
.lore-section { margin: 30px 0; border: 2px solid #FFFFFF; padding: 20px; }
.lore-section h2 { color: #000000; background: #FFFFFF; display: inline-block; padding: 4px 12px; margin-bottom: 15px; font-size: 1.2rem; }
.lore-text { color: #FFFFFF; line-height: 1.6; font-size: 0.95rem; }
.lore-img { width: 100%; max-width: 800px; filter: grayscale(100%) contrast(150%) brightness(80%); margin: 20px 0; border: 3px solid #FFFFFF; display: block; }

/* === PROFILE PAGE === */
.profile-card {
    border: 2px solid #FFFFFF; padding: 25px; max-width: 600px; margin: 20px auto;
}
.profile-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed #FFFFFF; flex-wrap: wrap; gap: 6px; }
.profile-label { color: #FFFFFF; opacity: 0.7; font-size: 0.85rem; }
.profile-value { color: #FFFFFF; font-weight: bold; font-size: 1rem; }
.input-field {
    background: #000000; border: 2px solid #FFFFFF; color: #FFFFFF;
    font-family: inherit; font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 12px 16px;
    width: 100%; margin: 12px 0; outline: none; text-transform: uppercase;
}
.input-field:focus { background: #FFFFFF; color: #000000; }
.btn { 
    background: #FFFFFF; color: #000000; border: 2px solid #FFFFFF; padding: 12px 20px;
    font-family: inherit; font-size: 1rem; cursor: pointer; font-weight: bold;
    display: block; width: 100%; text-align: center; text-decoration: none; text-transform: uppercase;
    min-height: 44px; /* Touch target */
}
.btn:hover { background: #000000; color: #FFFFFF; }
.error-msg { color: #000000; background: #FFFFFF; padding: 10px; margin: 15px 0; font-weight: bold; text-align: center; border: 2px dashed #000000; }

/* === ADMIN PAGE === */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; }
.admin-stat {
    border: 2px solid #FFFFFF; padding: 20px 15px; text-align: center;
}
.admin-stat-num { font-size: 2.5rem; font-weight: 900; color: #FFFFFF; }
.admin-stat-label { color: #000000; background: #FFFFFF; display: inline-block; padding: 3px 10px; font-size: 0.8rem; margin-top: 10px; font-weight: bold; }

/* Responsive Table Container */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 20px;
    border: 2px solid #FFFFFF;
}
.user-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.user-table th, .user-table td { padding: 10px 12px; text-align: left; border: 1px solid #333; font-size: 0.85rem; }
.user-table th { background: #FFFFFF; color: #000000; }

/* Strict Monochrome Filter for all User Uploaded Media */
img, video {
    filter: grayscale(100%) contrast(120%);
    max-width: 100%;
}

/* Quick Action Chips for Mobile */
.quick-chips {
    display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; margin-bottom: 10px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.quick-chips::-webkit-scrollbar { display: none; }
.chip-btn {
    background: #111; color: #FFF; border: 1px solid #FFF; padding: 6px 12px;
    font-size: 0.8rem; font-family: monospace; white-space: nowrap; cursor: pointer;
    text-decoration: none; display: inline-flex; align-items: center;
}
.chip-btn:hover, .chip-btn:active { background: #FFF; color: #000; }


/* === MOBILE & TELEGRAM WEBAPP ADAPTATION (MAX-WIDTH: 768px) === */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        font-size: 0.92rem;
    }
    
    /* Touch target optimizations */
    button, .btn, .nav-link, .chip-btn {
        touch-action: manipulation;
    }
    
    #nav { 
        flex-direction: column; 
        align-items: stretch;
        gap: 8px; 
        padding: 8px 10px;
        position: sticky; top: 0;
    }
    
    .nav-logo {
        font-size: 1.1rem;
        letter-spacing: 2px;
        padding: 0;
    }
    
    /* Horizontal Swipeable Nav Tabs on Mobile */
    .nav-links { 
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
        gap: 5px;
        width: 100%;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    
    .nav-link { 
        flex: 0 0 auto;
        padding: 7px 10px; 
        font-size: 0.75rem;
        letter-spacing: 0.5px;
        min-height: 36px;
    }

    #pirate-radio-bar {
        padding: 8px 10px !important;
        flex-direction: column;
        align-items: stretch !important;
        gap: 6px !important;
    }
    #pirate-radio-bar > div {
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }
    #radio-station {
        max-width: 160px;
        font-size: 11px !important;
        padding: 4px 6px;
    }
    
    #content { 
        padding: 12px 10px; 
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .profile-card { 
        padding: 16px 12px; 
        margin: 10px auto;
        width: 100%;
    }
    
    .lore-section { 
        padding: 14px 10px; 
        margin: 15px 0;
    }
    .lore-section h2 {
        font-size: 1rem;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .admin-stat {
        padding: 12px;
    }
    .admin-stat-num {
        font-size: 1.8rem;
    }

    #input-line {
        padding-top: 8px;
        gap: 6px;
    }
    .prompt {
        font-size: 0.8rem;
    }
    
    /* 16px font-size prevents iOS automatic zoom on focus */
    input, select, textarea, #cmd, .input-field, .ctrl-input {
        font-size: 16px !important;
    }
    
    /* Sticky audio player mobile safe positioning */
    .audio-player-container {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .audio-player-container .now-playing {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #main-audio {
        margin-left: 0;
        width: 100%;
        height: 36px;
    }
    
    /* Tables on mobile */
    .table-wrapper {
        border-width: 1px;
        margin-top: 12px;
        position: relative;
    }
    .user-table th, .user-table td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }
    
    /* Safe Area insets for notch phones (iPhone / Android) */
    body {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
}

/* Extra small mobile screens (max-width: 480px) */
@media (max-width: 480px) {
    #nav {
        padding: 6px 8px;
    }
    .nav-logo {
        font-size: 0.95rem;
    }
    .nav-link {
        padding: 6px 8px;
        font-size: 0.72rem;
    }
    .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
    .feed-item {
        padding: 12px 10px;
        margin: 12px 0;
    }
    .feed-author {
        font-size: 0.75rem;
    }
    .feed-content {
        font-size: 0.88rem;
    }
}
