/* === DESIGN TOKENS — CRT / RETRO TERMINAL === */
:root {
    --c-bg: #0000FF;
    --c-surface: #000000;
    --c-ink: #FFFFFF;
    --c-sub: #888888;
    --c-accent: #00FF00;
    --c-danger: #FF0000;
    --c-success: #00FF00;

    --border-width: 2px;
    --shadow-depth: 6px;

    --font-ui: 'Courier New', Courier, monospace;

    --space-xs: 4px;
    --space-s: 8px;
    --space-m: 16px;
    --space-l: 24px;

    --header-pattern: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAIklEQVQIW2NkQAKrVq36zwjjgzjwqgABJBNIMkGYXBwGAgAJEwkO99ywWAAAAABJRU5ErkJggg==');
    --scanline-color: rgba(0, 0, 0, 0.1);
}

/* === RESET === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    cursor: crosshair;
}

/* === UTILITIES === */
.u-bold {
    font-weight: 700;
}

.u-caps {
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.u-mono {
    font-family: monospace;
}

.flex-grow {
    flex: 1;
    min-height: 0;
}

/* === BODY === */
body {
    font-family: var(--font-ui);
    background-color: var(--c-bg);
    color: var(--c-ink);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-font-smoothing: none;
    image-rendering: pixelated;
    font-size: 14px;
}

/* === CRT OVERLAY === */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 2px, 3px 100%;
    animation: flicker 0.15s infinite;
}

.crt-scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.4;
    animation: scanline 6s linear infinite;
    pointer-events: none;
    z-index: 9998;
}

@keyframes scanline {
    0% {
        top: -10%;
    }

    100% {
        top: 110%;
    }
}

@keyframes flicker {
    0% {
        opacity: 0.97;
    }

    5% {
        opacity: 0.95;
    }

    10% {
        opacity: 0.9;
    }

    15% {
        opacity: 0.95;
    }

    20% {
        opacity: 0.99;
    }

    25% {
        opacity: 0.95;
    }

    30% {
        opacity: 0.9;
    }

    35% {
        opacity: 0.96;
    }

    40% {
        opacity: 0.98;
    }

    45% {
        opacity: 0.95;
    }

    50% {
        opacity: 0.99;
    }

    55% {
        opacity: 0.93;
    }

    60% {
        opacity: 0.9;
    }

    65% {
        opacity: 0.96;
    }

    70% {
        opacity: 1;
    }

    75% {
        opacity: 0.97;
    }

    80% {
        opacity: 0.95;
    }

    85% {
        opacity: 0.92;
    }

    90% {
        opacity: 0.98;
    }

    95% {
        opacity: 0.99;
    }

    100% {
        opacity: 0.96;
    }
}

/* === LAYOUT === */
.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: var(--space-m);
    gap: var(--space-m);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.content-grid {
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    gap: var(--space-m);
    flex: 1;
    min-height: 0;
}

/* === SYSTEM BAR (Taskbar) === */
.system-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--c-surface);
    border: var(--border-width) solid var(--c-ink);
    padding: var(--space-s) var(--space-m);
    box-shadow: var(--shadow-depth) var(--shadow-depth) 0px rgba(0, 0, 0, 0.5);
}

.sys-left {
    display: flex;
    align-items: center;
    gap: var(--space-s);
    color: var(--c-accent);
}

.sys-icon {
    width: 12px;
    height: 12px;
    background: var(--c-accent);
    box-shadow: 0 0 6px var(--c-accent);
}

.footer-bar {
    font-size: 0.75rem;
    color: var(--c-sub);
    box-shadow: var(--shadow-depth) var(--shadow-depth) 0px rgba(0, 0, 0, 0.5);
}

/* === PANEL (Window) === */
.panel {
    background: var(--c-surface);
    border: var(--border-width) solid var(--c-ink);
    box-shadow: var(--shadow-depth) var(--shadow-depth) 0px rgba(0, 0, 0, 0.5);
    padding: var(--space-m);
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel-header {
    height: 28px;
    background-color: var(--c-ink);
    background-image: var(--header-pattern);
    background-size: 4px 4px;
    color: var(--c-surface);
    padding: var(--space-xs) var(--space-s);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    margin: calc(var(--space-m) * -1) calc(var(--space-m) * -1) var(--space-m) calc(var(--space-m) * -1);
    border-bottom: var(--border-width) solid var(--c-ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === SIDEBARS === */
.sidebar-left,
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
    overflow-y: auto;
}

/* Sidebar scrollbar */
.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar,
.viewport::-webkit-scrollbar,
.log-container::-webkit-scrollbar {
    width: 14px;
    background: var(--c-surface);
    border-left: 2px solid var(--c-ink);
}

.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb,
.viewport::-webkit-scrollbar-thumb,
.log-container::-webkit-scrollbar-thumb {
    background: var(--c-ink);
    border: 2px solid var(--c-surface);
}

.sidebar-left::-webkit-scrollbar-button,
.sidebar-right::-webkit-scrollbar-button,
.viewport::-webkit-scrollbar-button,
.log-container::-webkit-scrollbar-button {
    background: var(--c-ink);
    height: 14px;
}

/* === PROFILE BLOCK === */
.profile-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-m);
    gap: var(--space-s);
}

.avatar-frame {
    width: 64px;
    height: 64px;
    border: var(--border-width) solid var(--c-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    font-family: monospace;
    background: var(--c-surface);
    color: var(--c-accent);
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.3), 2px 2px 0 var(--c-accent);
    text-shadow: 0 0 8px var(--c-accent);
    overflow: hidden;
}

.avatar-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: grayscale(1) brightness(0.85) contrast(1.2);
}

.profile-name {
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.08em;
    color: var(--c-accent);
    text-shadow: 0 0 6px rgba(0, 255, 0, 0.4);
}

.profile-sub {
    font-size: 0.7rem;
    color: var(--c-sub);
    text-align: center;
    line-height: 1.4;
}

/* === META LIST === */
.meta-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: 0.8rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    color: var(--c-sub);
}

.meta-row .u-bold,
.meta-row span:last-child {
    color: var(--c-accent);
}

/* === STAT BARS === */
.stat-row {
    display: grid;
    grid-template-columns: 64px 1fr 36px;
    gap: var(--space-s);
    align-items: center;
    font-size: 0.75rem;
    margin-bottom: var(--space-s);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--c-accent);
}

.meter {
    height: 14px;
    border: var(--border-width) solid var(--c-accent);
    padding: 2px;
    background: var(--c-surface);
}

.meter-fill {
    height: 100%;
    background: var(--c-accent);
    box-shadow: 0 0 6px rgba(0, 255, 0, 0.4);
    transition: width 0.3s steps(10);
}

.meter-fill.danger {
    background: var(--c-danger);
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.4);
}

.meter-fill.warning {
    background: #FFAA00;
    box-shadow: 0 0 6px rgba(255, 170, 0, 0.4);
}

/* === VIEWPORT (Center) === */
.viewport-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.viewport-panel {
    height: 100%;
    padding: 0 !important;
}

.viewport-panel .panel-header {
    margin: 0;
    border-bottom: 2px solid var(--c-ink);
    z-index: 10;
}

.viewport {
    flex: 1;
    background: var(--c-surface);
    border-top: none;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background-image:
        linear-gradient(rgba(0, 255, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 0, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    box-shadow: inset 4px 4px 0px rgba(0, 255, 0, 0.03);
    padding: var(--space-l);
}

/* === LINK STACK (inside viewport) === */
.link-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    z-index: 5;
}

.link-card {
    display: flex;
    align-items: center;
    gap: var(--space-m);
    padding: var(--space-m) var(--space-l);
    background: var(--c-surface);
    border: var(--border-width) solid var(--c-accent);
    box-shadow: var(--shadow-depth) var(--shadow-depth) 0px rgba(0, 255, 0, 0.2);
    text-decoration: none;
    color: var(--c-accent);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
}

.link-card::before {
    content: attr(data-label);
    position: absolute;
    top: -1px;
    right: -1px;
    background: var(--c-accent);
    color: var(--c-surface);
    font-size: 0.6rem;
    padding: 2px 6px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.link-card:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px rgba(0, 255, 0, 0.2);
    background: rgba(0, 255, 0, 0.08);
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
    border-color: #FFFFFF;
    color: #FFFFFF;
}

.link-card:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px rgba(0, 255, 0, 0.2);
}

.link-card-icon {
    font-size: 1.3rem;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.link-card-text {
    flex: 1;
}

.link-card-arrow {
    font-size: 1.2rem;
    opacity: 0.4;
    transition: opacity 0.15s, transform 0.15s;
}

.link-card:hover .link-card-arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* === ENTITY (Mascot) === */
.entity {
    width: 48px;
    height: 48px;
    background: var(--c-accent);
    position: absolute;
    bottom: 20px;
    right: 30px;
    z-index: 4;
    transition: bottom 0.5s ease-out, right 0.5s ease-out, transform 0.2s;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.entity::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--c-surface);
    box-shadow: 22px 0 0 var(--c-surface);
}

.entity::before {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 16px;
    width: 16px;
    height: 3px;
    background: var(--c-surface);
}

.entity.state-happy {
    animation: bounce 0.5s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* === CLOUDS === */
.cloud {
    position: absolute;
    font-size: 32px;
    z-index: 0;
    opacity: 0.15;
    animation: drift 20s infinite linear alternate;
    filter: grayscale(1);
}

.cloud:nth-child(2) {
    animation-delay: -8s;
}

@keyframes drift {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(30px);
    }
}

/* === FLOATER (Feedback) === */
.floater {
    position: absolute;
    font-size: 14px;
    font-weight: bold;
    animation: floatUp 1s forwards;
    pointer-events: none;
    z-index: 20;
    color: var(--c-accent);
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.6);
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-40px);
        opacity: 0;
    }
}

/* === BUTTONS === */
.btn {
    background: var(--c-surface);
    border: var(--border-width) solid var(--c-accent);
    padding: var(--space-s) var(--space-m);
    font-family: var(--font-ui);
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0px rgba(0, 255, 0, 0.2);
    transition: all 0.1s;
    text-transform: uppercase;
    font-size: 0.8rem;
    text-align: center;
    color: var(--c-accent);
}

.btn:hover {
    background: rgba(0, 255, 0, 0.1);
    text-shadow: 0 0 6px rgba(0, 255, 0, 0.5);
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px rgba(0, 255, 0, 0.2);
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-s);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-m);
    gap: var(--space-xs);
}

.action-icon {
    font-size: 1.5rem;
}

/* === MEDIA GALLERY === */
.media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-s);
}

.media-item {
    border: var(--border-width) solid var(--c-accent);
    overflow: hidden;
    aspect-ratio: 1;
    position: relative;
    box-shadow: 2px 2px 0px rgba(0, 255, 0, 0.2);
    transition: all 0.15s;
}

.media-item:hover {
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.4);
    border-color: #FFFFFF;
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.6) contrast(1.1);
    transition: filter 0.2s;
}

.media-item:hover img {
    filter: saturate(1) contrast(1.2);
}

.reboot-btn {
    margin-top: var(--space-s);
    background: rgba(255, 0, 0, 0.1);
    border-color: var(--c-danger);
    color: var(--c-danger);
}

.reboot-btn:hover {
    background: rgba(255, 0, 0, 0.2);
    text-shadow: 0 0 6px rgba(255, 0, 0, 0.5);
}

/* === LOG === */
.log-container {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    overflow-y: auto;
    border-top: 2px solid rgba(0, 255, 0, 0.2);
    padding-top: var(--space-s);
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 220px;
    color: var(--c-accent);
}

.log-entry {
    display: flex;
    gap: var(--space-s);
    opacity: 0.8;
    line-height: 1.3;
}

.log-entry::before {
    content: ">";
    color: var(--c-accent);
}

.log-time {
    color: var(--c-sub);
    white-space: nowrap;
}

/* === GLITCH TEXT === */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--c-surface);
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 red;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 blue;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% {
        clip: rect(20px, 9999px, 15px, 0);
    }

    20% {
        clip: rect(60px, 9999px, 80px, 0);
    }

    40% {
        clip: rect(30px, 9999px, 10px, 0);
    }

    60% {
        clip: rect(90px, 9999px, 50px, 0);
    }

    80% {
        clip: rect(10px, 9999px, 40px, 0);
    }

    100% {
        clip: rect(70px, 9999px, 95px, 0);
    }
}

@keyframes glitch-anim-2 {
    0% {
        clip: rect(5px, 9999px, 75px, 0);
    }

    20% {
        clip: rect(95px, 9999px, 15px, 0);
    }

    40% {
        clip: rect(30px, 9999px, 55px, 0);
    }

    60% {
        clip: rect(15px, 9999px, 65px, 0);
    }

    80% {
        clip: rect(80px, 9999px, 10px, 0);
    }

    100% {
        clip: rect(40px, 9999px, 35px, 0);
    }
}

/* === BLINKING CURSOR === */
.cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: var(--c-accent);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* === PROMPT LINE (terminal commands) === */
.prompt-line {
    color: var(--c-accent);
    margin-bottom: 8px;
    display: block;
}

.prompt-line::before {
    content: "root@boredmood:~$ ";
    color: var(--c-ink);
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    body {
        height: auto;
        overflow: auto;
    }

    .layout {
        height: auto;
        min-height: 100vh;
    }

    .content-grid {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .viewport-container {
        order: 1;
        min-height: unset;
        height: auto;
    }

    .sidebar-right {
        order: 2;
    }

    .sidebar-left {
        order: 3;
    }

    .sidebar-left,
    .sidebar-right {
        flex-direction: column;
        width: 100%;
    }

    .sidebar-left .panel,
    .sidebar-right .panel {
        width: 100%;
        min-width: unset;
    }
}

@media (max-width: 600px) {
    .layout {
        padding: var(--space-s);
    }

    .link-card {
        padding: var(--space-s) var(--space-m);
        font-size: 0.8rem;
    }

    .viewport-panel {
        aspect-ratio: auto;
    }
}