:root {
    --crt-red: rgb(218, 49, 49);
    --crt-green: rgb(131, 211, 136);
    --crt-blue: rgb(40, 129, 206);
}

/* Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgb(131, 211, 136) rgb(25, 25, 30);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgb(25, 25, 30); }
::-webkit-scrollbar-thumb {
    background: rgb(131, 211, 136);
    box-shadow: 0 0 4px rgb(131, 211, 136);
}
::-webkit-scrollbar-corner { background: rgb(25, 25, 30); }

/* Global */
body {
    background-color: black;
    overflow: hidden;
}
html {
    font-size: clamp(0.75rem, 1.5vw, 1.5rem);
    font-family: "Courier New", monospace;
    height: 100%;
    overflow: hidden;
}
main {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    color: rgba(131, 211, 136, 0.75);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.green {
    color: rgb(131, 211, 136);
}
.yellow {
    color: rgb(255, 255, 111);
}
.lightblue {
    color: lightblue;
}
.wrapper {
    padding-top: 2rem;
    padding-left: 1rem;
    flex: 1;
    overflow-y: auto;
}
.wrapper div { min-height: 1.2em; }
.code {
    animation: typewriter 1s steps(14) 1s 1 normal both;
    line-height: 1;
    margin: 0;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
}
.code-line {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    line-height: 1.5;
    animation: typewriter 1s steps(14) both;
}
.cursor {
    display: inline-block;
    animation: blinkTextCursor 500ms infinite normal;
}

/* Animation */
@keyframes typewriter {
    from { width: 0; }
    to   { width: 100%; }
}
@keyframes blinkTextCursor {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Status bar */
.statusbar {
    background-color: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.5rem;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.5;
    position: relative;
    z-index: 2;
}
#nav-status {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}
#nav-status.nav-status-error {
    animation: blink 1s step-end infinite;
}

/* Menu — vertical (used on landing/index pages) */
.menu {
    padding-left: 1rem;
    margin-top: 1rem;
}
.menu-spacer {
    line-height: 1.5;
}
.menu-item {
    cursor: pointer;
    line-height: 1.5;
    white-space: nowrap;
    display: block;
    overflow: hidden;
    animation: typewriter 1s steps(14) both;
}
.menu-line {
    display: inline-grid;
    grid-template-columns: 3ch 14ch 1fr;
    align-items: baseline;
}
.menu-item.selected .menu-line {
    background-color: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
}

@media (max-width: 600px) {
    .menu-item {
        white-space: normal;
        height: auto;
    }
    .menu-line {
        grid-template-columns: 3ch 1fr;
        grid-template-rows: auto auto;
    }
    .menu-desc {
        grid-column: 2;
        grid-row: 2;
    }
}

/* Nav bar — horizontal, pinned to bottom of main */
nav.menu {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.25rem 0 0.75em 0;
    margin-top: 0;
}
nav.menu .menu-item {
    flex: 1;
    text-align: left;
    padding-left: 1ch;
    animation: none;
    overflow: visible;
    white-space: nowrap;
    display: block;
}
nav.menu .menu-blank {
    flex: 1;
}
nav.menu .menu-break {
    flex: 0 0 100%;
    height: 0;
}
nav.menu .menu-spacer { display: none; }
nav.menu .menu-line { display: inline-grid; grid-template-columns: auto auto; }
nav.menu .menu-desc { display: none; }
nav.menu .menu-key {
    background-color: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
    text-shadow: none;
}
nav.menu .menu-item:hover,
nav.menu .menu-item:focus {
    background-color: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
    text-shadow: none;
    cursor: pointer;
    outline: none;
}
nav.menu .menu-item:hover .menu-key,
nav.menu .menu-item:focus .menu-key {
    background-color: rgb(25, 25, 30);
    color: rgb(131, 211, 136);
}

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

/* Chat unread badge */
.chat-badge {
    color: rgb(255, 255, 111);
    animation: blink 1s step-end infinite;
}
nav.menu .menu-item:hover .chat-badge,
nav.menu .menu-item:focus .chat-badge {
    color: rgb(255, 255, 111);
}

/* Memo list rows */
.memo-row {
    cursor: pointer;
    outline: none;
}
.memo-row:hover,
.memo-row:focus {
    background-color: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
    text-shadow: none;
}
.memo-row:hover span.green,
.memo-row:focus span.green,
.memo-row:hover span.yellow,
.memo-row:focus span.yellow {
    color: inherit;
}

/* Responsive list rows & headers */
.list-row {
    display: grid;
    gap: 0 1ch;
    align-items: baseline;
}
.list-header {
    display: grid;
    gap: 0 1ch;
    align-items: baseline;
    color: rgb(255, 255, 111);
}
.list-dashes {
    overflow: hidden;
    white-space: nowrap;
    color: rgba(131, 211, 136, 0.5);
    margin-bottom: 0.2em;
}
.list-row > *, .list-header > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
@media (max-width: 600px) {
    .landscape-only { display: none; }
}

/* Inbox: marker | date | from | subject */
.inbox-row, .inbox-header {
    grid-template-columns: 2ch 10ch 16ch 1fr;
}
@media (max-width: 600px) {
    .inbox-row, .inbox-header {
        grid-template-columns: 2ch 1fr;
        grid-template-rows: auto auto;
    }
    .inbox-row .col-date, .inbox-header .col-date { display: none; }
    .inbox-row .col-subject, .inbox-header .col-subject {
        grid-column: 2; grid-row: 2; opacity: 0.8;
    }
}

/* HR: id | name | title */
.hr-row, .hr-header {
    grid-template-columns: 5ch 20ch 1fr;
}
@media (max-width: 600px) {
    .hr-row, .hr-header {
        grid-template-columns: 5ch 1fr;
        grid-template-rows: auto auto;
    }
    .hr-row .col-title, .hr-header .col-title {
        grid-column: 2; grid-row: 2; opacity: 0.65;
    }
}

/* Forum posts: marker | date | from | replies | subject */
.forum-posts-row {
    border-bottom: 1px solid rgba(131, 211, 136, 0.15);
    padding: 0.3em 0;
}
.forum-posts-row, .forum-posts-header {
    grid-template-columns: 2ch 10ch 22ch 4ch 1fr;
}
@media (max-width: 600px) {
    .forum-posts-row, .forum-posts-header {
        grid-template-columns: 2ch 1fr;
        grid-template-rows: auto auto;
    }
    .forum-posts-row .col-date, .forum-posts-header .col-date,
    .forum-posts-row .col-replies, .forum-posts-header .col-replies { display: none; }
    .forum-posts-row .col-subject, .forum-posts-header .col-subject {
        grid-column: 2; grid-row: 2; opacity: 0.8;
    }
}

/* Forum categories: name | date | latest | actions */
.forum-cat-row, .forum-cat-header {
    grid-template-columns: 22ch 11ch 1fr auto;
}
@media (max-width: 600px) {
    .forum-cat-row, .forum-cat-header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    .forum-cat-row .col-latest, .forum-cat-header .col-latest {
        grid-row: 2; opacity: 0.75;
    }
}

/* Memo sent/broadcast: marker | date | from | type | subject */
.memo-sent-row, .memo-sent-header {
    grid-template-columns: 2ch 10ch 16ch 4ch 1fr;
}
@media (max-width: 600px) {
    .memo-sent-row, .memo-sent-header {
        grid-template-columns: 2ch 1fr 4ch;
        grid-template-rows: auto auto;
    }
    .memo-sent-row .col-date, .memo-sent-header .col-date { display: none; }
    .memo-sent-row .col-subject, .memo-sent-header .col-subject {
        grid-column: 2 / -1; grid-row: 2; opacity: 0.8;
    }
}

/* Forum flags (admin): name | description | delete */
.forum-flag-row {
    grid-template-columns: 20ch 1fr auto;
}
@media (max-width: 600px) {
    .forum-flag-row {
        grid-template-columns: 1fr auto;
    }
    .forum-flag-row .col-desc { display: none; }
}

/* CRT effect */
.crt {
    background-color: rgb(25, 25, 30);
    text-shadow:
        0 0 0.1em currentColor,
        0 0 0.4em currentColor,
        0 0 1em currentColor;
    position: relative;
    &:before,
    &:after {
        content: "";
        transform: translateZ(0);
        pointer-events: none;
        opacity: 0.8;
        mix-blend-mode: overlay;
        position: absolute;
        height: 100%;
        width: 100%;
        left: 0;
        top: 0;
        z-index: 1;
    }

    &:before {
        background: repeating-linear-gradient(
            var(--crt-red) 0px,
            var(--crt-green) 2px,
            var(--crt-blue) 4px
        );
    }
    &:after {
        background: repeating-linear-gradient(
            90deg,
            var(--crt-red) 1px,
            var(--crt-green) 2px,
            var(--crt-blue) 3px
        );
    }
}

.linkify-link {
    color: rgb(131, 211, 136);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.linkify-link:hover, .linkify-link:focus {
    background: rgb(131, 211, 136);
    color: rgb(25, 25, 30);
    outline: none;
}
