:root {
    /* Base Colors */
    --bg-dark: #020804;
    --brand: #389DC6;
    --brand-soft: rgba(56, 157, 198, 0.15);
    --brand-strong: #2A7A9B;

    /* Text Colors */
    --text-heading: #F5F3EF;
    --text-body: #9C968E;
    --text-brand: #389DC6;
    --text-brand-strong: #88C5E0;

    /* Borders */
    --border-subtle: #163E4F;
    --border-default: #389DC6;

    /* Status */
    --danger: #C70036;
    --success: #007A55;
    --warning: #F97316;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-body);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Terminal Scanline Overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(rgba(56, 157, 198, 0.03) 50%, transparent 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
}

body h1,
body h2,
body h3,
body h4,
body h5,
body h6 {
    color: var(--text-heading);
    font-weight: 600;
}

/* Typography Scale */
body h1 {
    font-size: clamp(20px, 3.2vw, 30px);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

body h2 {
    font-size: clamp(21px, 3.2vw, 30px);
    line-height: 1.15;
}

body h3 {
    font-size: clamp(16px, 2vw, 20px);
    line-height: 1.2;
}

/* Layout & Dividers */
section {
    padding: 64px 16px;
    max-width: 1152px;
    margin: 0 auto;
    background-color: var(--bg-dark);
}

.matrix-divider {
    width: 100%;
    max-width: 1152px;
    height: 1px;
    border-bottom: 1px dashed var(--brand);
    position: relative;
    margin: 0 auto;
}

.matrix-divider::before,
.matrix-divider::after {
    content: '';
    position: absolute;
    top: -2px;
    width: 5px;
    height: 5px;
    background: var(--brand);
}

.matrix-divider::before {
    left: 0;
}

.matrix-divider::after {
    right: 0;
}

/* Interactive Elements */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--brand-soft);
    border: 1px solid var(--border-default);
    color: var(--brand);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: all 150ms ease-out;
}

.btn:hover {
    background: var(--brand-soft) !important;
    color: var(--text-heading) !important;
    border-color: var(--brand) !important;
    box-shadow: 0 0 10px rgba(56, 157, 198, 0.3);
}

/* ── Card: Tiling WM Focus Effect ── */
.card {
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    transition: border-color 80ms ease-out, box-shadow 80ms ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.card:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand) inset, 0 0 12px rgba(56, 157, 198, 0.15);
}

/* ── Terminal Window Chrome (pseudo-header with dots) ── */
.terminal-chrome {
    position: relative;
}

.terminal-chrome::before {
    content: '';
    display: block;
    width: 100%;
    height: 24px;
    background: rgba(56, 157, 198, 0.06);
    border-bottom: 1px solid var(--border-subtle);
    /* Dots are drawn via box-shadow on ::after */
}

.terminal-chrome::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow:
        14px 0 0 var(--warning),
        28px 0 0 var(--success);
}

/* ── Blinking Cursor Animation ── */
@keyframes blink-cursor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.cursor-blink {
    display: inline-block;
    color: var(--brand);
    animation: blink-cursor 1s step-end infinite;
    font-weight: 400;
    margin-left: 2px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--brand-soft);
    border: 1px solid var(--border-subtle);
    color: var(--brand);
    font-size: 12px;
    font-weight: 500;
}

.inp {
    background: #1C1A16;
    /* neutral-secondary-medium mapping to dark */
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--text-heading);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: all 200ms ease;
}

.inp:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
}

.inp::placeholder {
    color: var(--text-body);
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-body);
    text-decoration: none;
    transition: color 150ms ease;
    text-transform: uppercase;
}

.nav-link:hover,
.nav-link.active {
    color: var(--brand);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-left: 1px solid var(--border-subtle);
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand);
}

/* Projects Horizontal Scroll */
.projects-scroll {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding-bottom: 12px;
}

.projects-scroll>.card {
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
    scroll-snap-align: start;
}

.projects-scroll::-webkit-scrollbar {
    height: 4px;
}

.projects-scroll::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-top: 1px solid var(--border-subtle);
}

.projects-scroll::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

.projects-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--brand);
}

/* Lightbox */
#lightbox {
    z-index: 100;
}

/* Project Images */
.project-img {
    filter: grayscale(80%) opacity(70%);
    transition: filter 300ms ease;
}

.card:hover .project-img {
    filter: grayscale(0%) opacity(100%);
}

/* Certificate Images */
.cert-img {
    filter: grayscale(80%) opacity(70%);
    transition: all 0.3s ease;
}

.carousel-card:hover .cert-img {
    filter: grayscale(0%) opacity(100%);
}

/* Verify Button */
.verify-btn {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--brand);
    background: transparent;
    border: 1px solid var(--brand);
    border-radius: 2px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.verify-btn:hover {
    background: var(--brand);
    color: #020804;
}

/* Penguins Section Toggle */
#penguins-arrow-indicator {
    opacity: 0.7;
}

#penguins-card:hover #penguins-arrow-indicator:not(.hidden-arrow) {
    opacity: 1;
}

#penguins-arrow-indicator.hidden-arrow {
    opacity: 0 !important;
    pointer-events: none !important;
}

.discord-icon-btn {
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 150ms ease;
    cursor: pointer;
}

.discord-icon-btn:hover {
    color: var(--text-heading);
}

.expandable-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 300ms ease-out;
}

.expandable-wrapper.expanded {
    grid-template-rows: 1fr;
}

.expandable-inner {
    overflow: hidden;
}

/* ── Terminal Window: Windowed & Fullscreen ── */
.terminal-window {
    width: min(900px, 92vw);
    max-height: 85vh;
    border-radius: 4px;
    transition: width 220ms ease, max-height 220ms ease, height 220ms ease, border-radius 220ms ease;
}

.terminal-window.terminal-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
}

/* ── Terminal Block Logo (voxel/LED-display) ── */
.block-logo-container {
    display: flex;
    justify-content: center;
    gap: clamp(10px, 2vw, 14px);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 8px rgba(56, 157, 198, 0.4));
}

.block-letter {
    display: grid;
    grid-template-columns: repeat(7, clamp(6px, 1.4vw, 11px));
    grid-template-rows: repeat(9, clamp(6px, 1.4vw, 11px));
    gap: 2px;
}

.block-cell {
    border-radius: 1px;
    animation: block-flicker 3s ease-in-out infinite alternate;
}

.block-cell--on {
    background: var(--brand);
    box-shadow: 0 0 5px var(--brand);
}

@keyframes block-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ── Terminal Welcome Line ── */
.terminal-welcome {
    color: var(--brand);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 8px;
}

/* ── Terminal Output Lines ── */
.terminal-line {
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-line--bullet {
    padding-left: 4ch;
    text-indent: -4ch;
}

/* ── Terminal Open/Close Transition (CRT Effect) ── */
/* Terminal window itself starts collapsed to a thin horizontal line */
#terminal-overlay .terminal-window {
    transform: scaleY(0.02);
    opacity: 0;
    transform-origin: center;
}

#terminal-overlay.crt-on .terminal-window {
    animation: crt-power-on 260ms cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes crt-power-on {
    0%   { transform: scaleY(0.02); opacity: 0.4; }
    60%  { transform: scaleY(1.04); opacity: 1; }
    80%  { transform: scaleY(0.98); }
    100% { transform: scaleY(1); opacity: 1; }
}

#terminal-overlay.crt-off .terminal-window {
    animation: crt-power-off 200ms ease-in forwards;
}

@keyframes crt-power-off {
    0%   { transform: scaleY(1); opacity: 1; }
    40%  { transform: scaleY(1.03); }
    100% { transform: scaleY(0.02); opacity: 0; }
}

/* Quick bright flash synced with the collapse/expand, like a CRT electron-beam flicker */
#crt-flash.flash {
    animation: crt-flash 260ms ease-out forwards;
}

@keyframes crt-flash {
    0%   { opacity: 0; }
    15%  { opacity: 0.5; }
    30%  { opacity: 0.05; }
    45%  { opacity: 0.3; }
    100% { opacity: 0; }
}
/* ── Scroll Reveal ── */
.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.reveal-prompt {
    display: inline-block;
    color: var(--brand);
    opacity: 0;
    margin-right: 6px;
}

.reveal.revealed .reveal-prompt {
    opacity: 1;
    animation: blink-cursor 1s step-end 3;
}
