/* ========================================
   Mono Theme — Elena Matyushenko Portfolio
   Strict black & white, IBM Plex Mono/Sans,
   ultra-minimal, high contrast, technical
   ======================================== */

:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --text: #111111;
    --text-muted: #666666;
    --text-warm: #333333;
    --accent: #111111;
    --accent-light: #444444;
    --accent-rgb: 17, 17, 17;
    --accent-glow: rgba(0, 0, 0, 0.08);
    --accent-gradient: linear-gradient(135deg, #111, #555, #111);
    --accent-title-gradient: linear-gradient(135deg, #000, #444, #999, #444, #111);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.2);
    --font-display: 'IBM Plex Mono', 'Courier New', monospace;
    --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
    --radius: 4px;
    --radius-sm: 2px;
    --transition: 0.2s ease;
    --canvas-opacity: 1;
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    font-size: 16px;
    scrollbar-width: thin;
    scrollbar-color: #aaa #f0f0f0;
    background: var(--bg);
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.7;
    font-weight: 400;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #aaa; border-radius: 2px; }

::selection { background: #111; color: #fff; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ========== Canvas Background ========== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: var(--canvas-opacity);
    pointer-events: none;
}

/* ========== Theme Switcher ========== */
.theme-switcher {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 8px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border);
}

.theme-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-decoration: none;
}

.theme-dot .dot-inner {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
    transition: transform 0.2s ease;
}

.theme-dot:hover .dot-inner { transform: scale(1.2); }

.theme-dot.active {
    border-color: var(--accent);
}

/* ========== Navigation ========== */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(250, 250, 250, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    transform: translateY(-100%);
    animation: slideDown 0.6s 0.3s forwards;
}

@keyframes slideDown { to { transform: translateY(0); } }

.nav-logo {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.nav-links { display: flex; gap: 2.5rem; }

.nav-links a {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color var(--transition);
    font-family: var(--font-display);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width var(--transition);
}

.nav-links a { position: relative; }
.nav-links a:hover { color: var(--accent); }
.nav-links a:hover::after { width: 100%; }

/* ========== Hero Section ========== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    padding: 6rem 2.5rem 4rem;
}

.hero-content {
    max-width: 800px;
    text-align: center;
}

.hero-badge {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    border: 1px solid var(--accent);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeUp 0.6s 0.8s forwards;
    font-family: var(--font-display);
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, 5.5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.hero-title .line {
    display: block;
    opacity: 0;
    animation: fadeUp 0.6s forwards;
}

.hero-title .line:nth-child(1) { animation-delay: 1s; }
.hero-title .line:nth-child(2) { animation-delay: 1.15s; }

.hero-title .accent {
    background: var(--accent-title-gradient);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeUp 0.6s 1.15s forwards, accentShift 12s 2s ease-in-out infinite;
}

@keyframes accentShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 3rem;
    line-height: 1.8;
    opacity: 0;
    animation: fadeUp 0.6s 1.3s forwards;
    font-weight: 300;
}

/* Stats */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-bottom: 3rem;
    opacity: 0;
    animation: fadeUp 0.6s 1.5s forwards;
    border: 1px solid var(--border);
}

.stat {
    text-align: center;
    padding: 1.2rem 0.5rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
}

.stat:hover {
    background: #f0f0f0;
}

.stat-number {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    display: inline;
}

.stat-suffix {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-light);
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 0.3rem;
    font-family: var(--font-display);
}

/* CTA Buttons */
.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    opacity: 0;
    animation: fadeUp 0.6s 1.7s forwards;
}

.btn {
    padding: 0.8rem 2rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all var(--transition);
    font-family: var(--font-display);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.btn-primary:hover {
    background: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Sections ========== */
.section {
    position: relative;
    z-index: 2;
    padding: 6rem 2.5rem;
}

.section-alt {
    background: #f0f0f0;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 3.5rem;
    text-align: center;
    color: var(--text);
    text-transform: uppercase;
}

.section-title::after {
    content: '';
    display: block;
    width: 40px;
    height: 1px;
    background: var(--accent);
    margin: 1rem auto 0;
}

/* ========== About ========== */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: start;
}

.about-text {
    opacity: 0;
    transform: translateX(-20px);
}

.about-text.visible { animation: slideIn 0.6s forwards; }

@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }

.about-lead {
    font-size: 1.05rem;
    font-weight: 300;
    line-height: 1.9;
    margin-bottom: 1.5rem;
    color: var(--text-warm);
}

.about-text p {
    font-size: 0.95rem;
    color: var(--text-warm);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.about-text strong {
    color: var(--accent);
    font-weight: 600;
}

.about-highlights {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    border: 1px solid var(--border);
}

.highlight-card {
    padding: 1.5rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(15px);
}

.highlight-card.visible { animation: fadeUp 0.5s forwards; }
.highlight-card:nth-child(1).visible { animation-delay: 0.1s; }
.highlight-card:nth-child(2).visible { animation-delay: 0.15s; }
.highlight-card:nth-child(3).visible { animation-delay: 0.2s; }
.highlight-card:nth-child(4).visible { animation-delay: 0.25s; }

.highlight-icon {
    font-size: 1.2rem;
    color: var(--accent);
    margin-bottom: 0.6rem;
    display: inline-block;
}

.highlight-card h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
    letter-spacing: 0.03em;
}

.highlight-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ========== Skills ========== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    border: 1px solid var(--border);
}

.skill-category {
    padding: 2rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(15px);
}

.skill-category.visible { animation: fadeUp 0.5s forwards; }

.skill-category:hover {
    background: #f8f8f8;
}

.skill-cat-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.skill-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all var(--transition);
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.tag:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ========== Projects ========== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    border: 1px solid var(--border);
}

.project-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 2rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
    position: relative;
    opacity: 0;
    transform: translateY(15px);
}

.project-card.visible { animation: fadeUp 0.5s forwards; }

.project-card:hover {
    background: #f8f8f8;
}

.project-card:hover .project-link {
    transform: translateX(4px);
}

.project-featured {
    grid-column: span 2;
}

.project-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    font-family: var(--font-display);
}

.badge-live { border-color: #2d8a4e; color: #2d8a4e; }
.badge-oss { border-color: #3a7ad4; color: #3a7ad4; }
.badge-civitai { border-color: var(--accent); color: var(--accent); }

.project-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.project-tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-size: 0.8rem;
}

.project-desc {
    font-size: 0.88rem;
    color: var(--text-warm);
    line-height: 1.7;
    margin-bottom: 1.2rem;
}

.project-metrics { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.2rem; }

.project-metrics span {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.project-link {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    transition: all 0.2s;
    font-family: var(--font-display);
    letter-spacing: 0.05em;
}

/* ========== Gallery ========== */
.gallery-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-top: -2rem;
    margin-bottom: 2.5rem;
    font-size: 0.95rem;
}

.gallery-filters {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 2.5rem;
    border: 1px solid var(--border);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.filter-btn {
    padding: 0.5rem 1.2rem;
    font-size: 0.72rem;
    font-weight: 500;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.filter-btn:last-child { border-right: none; }

.filter-btn:hover {
    background: #f0f0f0;
    color: var(--accent);
}

.filter-btn.active {
    background: var(--accent);
    color: #fff;
}

.gallery-grid {
    columns: 4 260px;
    column-gap: 1px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: var(--bg-card);
    break-inside: avoid;
    margin-bottom: 1px;
}

.gallery-item:hover {
    opacity: 0.85;
    z-index: 2;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    transition: transform 0.4s ease;
    filter: grayscale(0.15);
}

.gallery-item:hover img {
    transform: scale(1.03);
    filter: grayscale(0);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.8rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay { opacity: 1; }

.gallery-tag {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #fff;
    color: #111;
    margin-bottom: 0.2rem;
    font-family: var(--font-display);
}

.gallery-overlay p { font-size: 0.72rem; color: rgba(255, 255, 255, 0.85); line-height: 1.4; }
.gallery-item.hidden { display: none; }

/* ========== Lightbox ========== */
.lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(250, 250, 250, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.lightbox.active { opacity: 1; visibility: visible; }

.lightbox img {
    max-width: 85vw;
    max-height: 85vh;
    object-fit: contain;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
    transition: transform 0.3s;
}

.lightbox.active img { transform: scale(1); }

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-body);
}

.lightbox-close {
    top: 1.5rem; right: 1.5rem;
    width: 40px; height: 40px;
    font-size: 1.4rem;
    display: flex; align-items: center; justify-content: center;
}

.lightbox-prev,
.lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    font-size: 1.6rem;
    display: flex; align-items: center; justify-content: center;
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.lightbox-info {
    position: absolute;
    bottom: 2rem; left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-family: var(--font-display);
}

/* ========== Contact ========== */
.contact-subtitle {
    text-align: center;
    color: var(--text-muted);
    max-width: 600px;
    margin: -2rem auto 3rem;
    font-size: 0.95rem;
    line-height: 1.7;
}

.contact-links {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
    border: 1px solid var(--border);
}

.contact-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    background: var(--bg-card);
    transition: all 0.2s ease;
}

.contact-card:hover {
    background: #f0f0f0;
}

.contact-icon {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
    color: var(--accent);
    transition: all 0.2s;
}

.contact-card:hover .contact-icon { transform: scale(1.05); }

.contact-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-family: var(--font-display);
}

.contact-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

/* ========== Footer ========== */
.footer {
    position: relative;
    z-index: 2;
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-display);
    letter-spacing: 0.05em;
}

/* ========== Mobile Nav Toggle ========== */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 110;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 1.5px;
    background: var(--text);
    transition: all 0.3s;
}

.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .skills-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery-grid { columns: 3; }
    .contact-links { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .nav { padding: 1rem 1.5rem; }
    .nav-toggle { display: flex; }
    .theme-switcher { gap: 4px; padding: 3px 6px; }
    .theme-dot { width: 18px; height: 18px; }
    .theme-dot .dot-inner { width: 10px; height: 10px; }

    .nav-links {
        position: fixed;
        top: 0; right: -100%;
        width: 280px; height: 100vh;
        background: rgba(250, 250, 250, 0.98);
        flex-direction: column;
        padding: 5rem 2rem 2rem;
        gap: 0;
        transition: right 0.3s ease;
        border-left: 1px solid var(--border);
        z-index: 105;
    }

    .nav-links.open { right: 0; }
    .nav-links a { font-size: 0.9rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }

    .hero { padding: 5rem 1.5rem 3rem; }
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
    .hero-cta { flex-direction: column; align-items: center; }
    .btn { width: 100%; max-width: 280px; text-align: center; }

    .section { padding: 4rem 1.5rem; }
    .about-grid { grid-template-columns: 1fr; gap: 2rem; }
    .about-highlights { grid-template-columns: 1fr 1fr; }
    .skills-grid { grid-template-columns: 1fr; }
    .projects-grid { grid-template-columns: 1fr; }
    .project-featured { grid-column: span 1; }
    .gallery-grid { columns: 2; }
    .contact-links { grid-template-columns: repeat(2, 1fr); }
    .gallery-filters { flex-wrap: wrap; border: none; gap: 4px; }
    .filter-btn { border: 1px solid var(--border); border-right: 1px solid var(--border); }
}

@media (max-width: 480px) {
    .hero { padding: 4rem 1rem 2.5rem; }
    .hero-title { font-size: clamp(2rem, 10vw, 3rem); }
    .section { padding: 3rem 1rem; }
    .about-highlights { grid-template-columns: 1fr; gap: 1px; }
    .gallery-grid { columns: 2; }
    .contact-links { grid-template-columns: 1fr; }
    .contact-card { flex-direction: row; gap: 1rem; padding: 1rem 1.5rem; text-align: left; }
    .contact-icon { margin-bottom: 0; }
}

@media (hover: none) and (pointer: coarse) {
    .gallery-overlay { opacity: 1; background: linear-gradient(transparent 60%, rgba(0, 0, 0, 0.6)); }
    .gallery-item:hover img { transform: none; filter: grayscale(0.15); }
    .gallery-item:hover { opacity: 1; }
}
