/* ============ Vitalii Panfilov — terminal-inspired CV ============ */
:root {
    color-scheme: dark;
    --bg: #0b0f14;
    --bg-soft: #11161d;
    --border: #1e2936;
    --text: #d5dde8;
    --text-dim: #7d8b9c;
    --accent: #3ddc97;
    --accent-dim: rgba(61, 220, 151, .12);
    --nav-bg: rgba(11, 15, 20, .82);
    --btn-primary-text: #06210f;
    --scanline: rgba(255, 255, 255, .008);
    --nav-links-gap: 40px;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Inter", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8fb;
    --bg-soft: #ffffff;
    --border: #d8e0ea;
    --text: #1c2530;
    --text-dim: #5f6b7a;
    --accent: #0c9d63;
    --accent-dim: rgba(12, 157, 99, .1);
    --nav-bg: rgba(246, 248, 251, .85);
    --btn-primary-text: #ffffff;
    --scanline: rgba(0, 0, 0, .02);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(ellipse 60% 40% at 50% -10%, var(--accent-dim), transparent),
        repeating-linear-gradient(0deg, transparent 0 2px, var(--scanline) 2px 4px);
    transition: background-color .3s, color .3s;
}

.container { max-width: 860px; margin: 0 auto; padding: 0 24px; }

a { color: var(--accent); text-decoration: none; transition: opacity .2s; }
a:hover { opacity: .8; }

.prompt { color: var(--accent); font-family: var(--mono); }
.comment { color: var(--text-dim); }

.caret {
    display: inline-block;
    color: var(--accent);
    margin-left: 4px;
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============ nav ============ */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    padding: 14px 28px;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
}
.nav-logo { color: var(--text); font-weight: 700; font-size: 15px; }
.nav-links { display: flex; gap: 22px; align-items: center; margin-left: auto; margin-right: var(--nav-links-gap); }
.nav-links a { color: var(--text-dim); font-size: 14px; }
.nav-links a:hover { color: var(--accent); opacity: 1; }
.nav-links a.is-active {
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: 6px;
    padding: 3px 8px;
    margin: -3px -8px;
}
.nav-cta { color: var(--accent) !important; }

/* ============ theme toggle (system → dark → light) ============ */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-dim);
    font: inherit;
    transition: color .2s, border-color .2s, background .2s;
    user-select: none;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-icon {
    width: 18px; height: 18px;
    display: block;
    transition: transform .3s ease, opacity .2s ease;
}
/* Only the icon matching the current preference is visible */
.theme-icon--system,
.theme-icon--moon,
.theme-icon--sun { position: absolute; inset: 0; margin: auto; opacity: 0; transform: scale(.5) rotate(-90deg); }
[data-theme-pref="system"] .theme-icon--system,
:root:not([data-theme-pref]) .theme-icon--system,
[data-theme-pref="dark"] .theme-icon--moon,
[data-theme-pref="light"] .theme-icon--sun {
    position: static;
    opacity: 1;
    transform: scale(1) rotate(0);
}

/* ============ hero ============ */
.hero { padding: 110px 0 90px; }
.hero-cmd { font-family: var(--mono); color: var(--text-dim); margin-bottom: 14px; }
.hero-name {
    font-family: var(--mono);
    font-size: clamp(40px, 8vw, 72px);
    font-weight: 700;
    letter-spacing: -2px;
    line-height: 1.05;
}
.hero-role {
    font-family: var(--mono);
    font-size: clamp(18px, 3vw, 26px);
    color: var(--accent);
    margin-top: 10px;
    /* Reserve the height of one line so the typewriter never shifts the layout */
    min-height: 1.4em;
}
.role-text { white-space: nowrap; }

/* Screen-reader-only text (the animated role is aria-hidden) */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
.hero-summary { max-width: 560px; margin-top: 22px; color: var(--text-dim); font-size: 17px; }
.hero-actions { display: flex; gap: 14px; margin-top: 34px; flex-wrap: wrap; }
.hero-meta {
    display: flex;
    gap: 26px;
    list-style: none;
    margin-top: 38px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-dim);
    flex-wrap: wrap;
}
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    margin-right: 6px;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

/* ============ buttons ============ */
.btn {
    display: inline-block;
    font-family: var(--mono);
    font-size: 14px;
    padding: 11px 22px;
    border-radius: 8px;
    border: 1px solid var(--accent);
    transition: background .2s, color .2s, transform .15s;
}
.btn:hover { opacity: 1; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--btn-primary-text); font-weight: 700; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-dim); }

/* ============ sections ============ */
.section { padding: 72px 0; border-top: 1px solid var(--border); }
.section-title {
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 38px;
    letter-spacing: -0.5px;
}
.lead { font-size: 18px; color: var(--text-dim); max-width: 640px; }
.lead strong { color: var(--text); }

/* ============ summary stats ============ */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}
.stat {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-num { font-family: var(--mono); font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text-dim); line-height: 1.4; }

/* ============ timeline ============ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 6px; top: 6px; bottom: 6px;
    width: 1px;
    background: var(--border);
}
.tl-item { position: relative; padding-bottom: 42px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
    content: "";
    position: absolute;
    left: -26px; top: 8px;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
}
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.tl-head h3 { font-family: var(--mono); font-size: 18px; }
.tl-date { font-family: var(--mono); font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.tl-company { color: var(--text-dim); font-size: 15px; margin: 2px 0 12px; }
.tl-loc { font-size: 13px; }
.tl-item ul { list-style: none; }
.tl-item ul li { padding-left: 22px; position: relative; margin-bottom: 8px; color: var(--text-dim); font-size: 15px; }
.tl-item ul li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }
.tl-item ul li strong { color: var(--text); }

.edu { margin-top: 48px; }
.edu p { margin-bottom: 6px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.edu-title { font-family: var(--mono); font-size: 18px; margin-bottom: 16px; }

/* ============ skills ============ */
.skill-group { margin-bottom: 26px; }
.skill-group h3 {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-dim);
    text-transform: lowercase;
    margin-bottom: 10px;
}
.skill-group h3::before { content: "> "; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.chips li {
    font-family: var(--mono);
    font-size: 13px;
    padding: 5px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--text);
    transition: border-color .2s, background .2s;
}
.chips li:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ============ awards ============ */
.awards { margin-top: 48px; }
.award-card {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 14px;
}
.award-badge {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
}
.award-card h4 { font-family: var(--mono); font-size: 16px; margin-bottom: 4px; }
.award-card p { color: var(--text-dim); font-size: 14px; }

/* ============ projects ============ */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
}
.card {
    display: block;
    color: var(--text);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transform-style: preserve-3d;
    transition: border-color .25s, box-shadow .25s;
    will-change: transform;
}
.card:hover {
    opacity: 1;
    border-color: var(--accent);
    box-shadow: 0 14px 40px rgba(61, 220, 151, .12);
}
.card-media {
    height: 180px;
    background-size: cover;
    background-position: top center;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-media--lapa {
    background: linear-gradient(135deg, #0f2c1e, #123a4a 60%, #1a2340);
}
.card-lapa-logo {
    font-size: 48px;
    color: var(--accent);
    text-shadow: 0 0 24px var(--accent);
}
.card-body { padding: 18px 20px 22px; }
.card-body h3 { font-family: var(--mono); font-size: 16px; margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card-flag {
    font-size: 10px;
    font-family: var(--mono);
    color: var(--btn-primary-text);
    background: var(--accent);
    border-radius: 999px;
    padding: 2px 9px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.card-flag--muted { background: var(--text-dim); color: var(--bg); }
.card-body p { color: var(--text-dim); font-size: 14px; margin-bottom: 14px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.card-tags li {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: 5px;
    padding: 2px 8px;
}
.card--soon { opacity: .75; }

/* Clickable project cards (open the case-study modal) */
.card--clickable { cursor: pointer; }
.card--clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-cta {
    display: inline-block;
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    opacity: .75;
    transition: opacity .2s, transform .2s;
}
.card--clickable:hover .card-cta { opacity: 1; transform: translateX(3px); }

/* ============ project case-study gallery (Swiper) ============ */
.project-dialog {
    /* Swiper accent colour via its CSS custom properties */
    --swiper-theme-color: var(--accent);
    --swiper-navigation-size: 0;

    position: fixed;
    inset: 0;
    margin: auto;               /* reliable centering, independent of scroll */
    display: none;
    flex-direction: column;
    width: min(900px, calc(100% - 40px));
    height: min(88vh, 820px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-soft);
    color: var(--text);
    overflow: hidden;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .5);
}
.project-dialog[open] { display: flex; animation: dialog-pop .22s ease; }
.project-dialog::backdrop { background: rgba(3, 6, 10, .68); backdrop-filter: blur(4px); }
[data-theme="light"] .project-dialog::backdrop { background: rgba(30, 41, 54, .38); }
@keyframes dialog-pop {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .project-dialog[open] { animation: none; } }

.dialog-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.dialog-title { font-family: var(--mono); font-size: 15px; color: var(--accent); }
.dialog-head-right { display: flex; align-items: center; gap: 12px; }
.dialog-counter { font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.dialog-close {
    flex-shrink: 0;
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text-dim);
    font-size: 15px; cursor: pointer;
    transition: color .2s, border-color .2s;
}
.dialog-close:hover { color: var(--accent); border-color: var(--accent); }
.dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Outer swiper fills the space between head and foot */
.project-swiper { flex: 1 1 auto; min-width: 0; width: 100%; min-height: 0; }
.project-slide { height: 100%; overflow-y: auto; min-width: 0; }
.slide-inner { display: grid; grid-template-columns: 1fr; }
.slide-inner > * { min-width: 0; } /* stop grid/flex children from feeding Swiper's width back and running away */

/* Nested media gallery */
.media-swiper { height: 220px; min-width: 0; width: 100%; }
.media-swiper .swiper-slide { height: 100%; }
.dialog-media { height: 100%; border-bottom: 0; }
.media-placeholder {
    height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 13px; letter-spacing: .5px;
    color: var(--text-dim);
    background: repeating-linear-gradient(135deg, var(--bg-soft), var(--bg-soft) 12px, var(--bg) 12px, var(--bg) 24px);
    border-bottom: 1px solid var(--border);
}
.media-swiper .media-pagination {
    bottom: 8px;
}
.media-swiper .media-pagination .swiper-pagination-bullet { background: var(--bg); opacity: .6; }
.media-swiper .media-pagination .swiper-pagination-bullet-active { background: var(--accent); opacity: 1; }

.dialog-content { padding: 20px 22px 26px; }
.dialog-flag { display: inline-block; margin-bottom: 12px; }
.dialog-summary { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.dialog-sub {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    margin: 20px 0 10px;
    letter-spacing: .5px;
}
.dialog-points { display: grid; gap: 9px; list-style: none; }
.dialog-points li {
    position: relative;
    padding-left: 20px;
    color: var(--text-dim);
    font-size: 14px;
}
.dialog-points li::before {
    content: "\25B8";
    position: absolute; left: 0; top: 0;
    color: var(--accent);
    font-family: var(--mono);
}
.dialog-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* Footer: prev / dots / next */
.dialog-foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}
.swiper-nav {
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text);
    font-size: 16px; cursor: pointer;
    transition: color .2s, border-color .2s, opacity .2s;
}
.swiper-nav:hover { color: var(--accent); border-color: var(--accent); }
.swiper-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.swiper-nav.swiper-button-disabled { opacity: .35; cursor: default; }
.dialog-foot .project-pagination {
    /* Swiper forces .swiper-pagination to position:absolute + width:100% (two-class specificity).
       Match that specificity and pin it back into the footer's flex flow so it centers between the arrows. */
    position: static !important;
    width: auto !important;
    left: auto;
    right: auto;
    display: flex;
    justify-content: center;
    gap: 8px;
}
.project-pagination .swiper-pagination-bullet {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-dim); opacity: .4; margin: 0 !important;
    transition: opacity .2s, background .2s, transform .2s;
}
.project-pagination .swiper-pagination-bullet-active { background: var(--accent); opacity: 1; transform: scale(1.25); }

body.dialog-open { overflow: hidden; }
html.dialog-open { overflow: hidden; } /* lock the real viewport scroller */

/* Desktop: media on the left, write-up on the right */
@media (min-width: 760px) {
    .project-dialog { width: min(900px, calc(100% - 48px)); }
    .slide-inner { grid-template-columns: 50% 1fr; }
    .media-swiper { height: 100%; min-height: 380px; }
    .dialog-content { padding: 26px 30px 30px; }
}

/* ============ contact ============ */
.contact-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

/* ============ footer ============ */
.footer { border-top: 1px solid var(--border); padding: 34px 0; font-family: var(--mono); font-size: 14px; color: var(--text-dim); }
.footer-copy { margin-top: 8px; font-size: 12px; }

/* ============ reveal animation ============ */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .caret, .status-dot { animation: none; }
}

@media (max-width: 640px) {
    .nav { padding: 12px 18px; flex-wrap: wrap; row-gap: 10px; }
    /* Logo takes the whole first row, so the links always start on a new line */
    .nav-logo { width: 100%; flex-grow: 1; }
    /* Second row: links flush left, theme toggle pinned right */
    .nav-links { gap: 14px; flex-wrap: wrap; align-items: center; margin-left: 0; margin-right: 0; }
    .nav-links a { font-size: 12px; }
    .theme-toggle { margin-left: auto; margin-right: 0; }
    .hero { padding: 70px 0 60px; }
    .section { padding: 54px 0; }
}

/* Very narrow screens: keep links + toggle on one row (they overflow at ≈337px) */
@media (max-width: 360px) {
    .nav-links { gap: 10px; }
    .nav-links a { letter-spacing: -.4px; }
}
