/* =====================================================================
   Roman Stadnikov — editorial light design system
   Warm paper ground · Fraunces display serif + Inter · hairline rules ·
   flat surfaces · restrained motion. Shared by every page; page-specific
   rules are scoped with body classes (.home / .page).
   ===================================================================== */

:root {
    /* Ground & surfaces (warm, not cool-blue) */
    --paper:     #f4f1ea;
    --paper-2:   #ece7db;
    --surface:   #faf8f3;
    --ink:       #1b1a17;   /* near-black, warm */
    --ink-2:     #47443c;   /* body copy */
    --muted:     #837d70;   /* secondary */

    /* Hairlines */
    --line:        rgba(27, 26, 23, 0.14);
    --line-strong: rgba(27, 26, 23, 0.28);

    /* One flat accent — a classic cobalt, never a gradient */
    --accent:     #2743c9;
    --accent-ink: #21379e;
    --santeflex:  #0f7a5e;

    /* Type */
    --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Shape & rhythm */
    --r-sm: 4px;
    --r:    8px;
    --maxw: 1080px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    color: var(--ink-2);
    background: var(--paper);
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    color-scheme: light;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

/* Ambient identity canvas (node network / satellites) — behind everything */
.bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    pointer-events: none;
}

/* Keep all real content above the canvas */
header,
.home main.hero,
.page main,
footer,
.home-button { position: relative; z-index: 1; }
header { z-index: 5; }
.home-button { z-index: 1000; }

::selection { background: rgba(39, 67, 201, 0.16); }

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 3px;
}

/* ---------------------------------------------------------------- Header */
header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 26px clamp(20px, 5vw, 48px);
    position: relative;
    z-index: 5;
}

.social {
    display: flex;
    align-items: center;
    gap: 22px;
}

.social a {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    position: relative;
    transition: color 0.2s var(--ease);
}

.social a:not(.lang-toggle)::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -3px;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s var(--ease);
}

.social a:not(.lang-toggle):hover { color: var(--ink); }
.social a:not(.lang-toggle):hover::after { transform: scaleX(1); }

.lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 11px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--accent-ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.lang-toggle:hover { background: var(--paper-2); border-color: var(--ink); }

/* ------------------------------------------------------------ Home button */
.home-button {
    position: absolute;
    top: 26px;
    left: clamp(20px, 5vw, 48px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    z-index: 1000;
    transition: color 0.2s var(--ease), gap 0.2s var(--ease);
}

.home-button::before { content: "\2190"; color: var(--accent); }
.home-button:hover { color: var(--ink); gap: 11px; }

/* -------------------------------------------------------- Content layout */
.page main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: clamp(48px, 8vw, 88px) clamp(20px, 5vw, 48px) 64px;
    position: relative;
    z-index: 1;
}

.page main h1 {
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(2.3rem, 5.5vw, 3.5rem);
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin-bottom: 8px;
}

/* Section headings that follow a first h1 (e.g. "Education") */
.page main h1 ~ h1 {
    margin-top: 56px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
    font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.experience-section { margin: 34px 0 24px; }

/* Standalone section subheading (e.g. "Additional training") */
.section-head {
    font-family: var(--serif);
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.1rem);
    color: var(--ink);
    margin-top: 52px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
}

/* Cross-link to another page (e.g. Education & training) */
.page-more {
    margin-top: 44px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

/* --------------------------------------------------- Experience entries */
/* Editorial rows, separated by hairlines — not floating glow-cards. */
.experience-item {
    display: grid;
    grid-template-columns: 132px 1fr;
    column-gap: 34px;
    row-gap: 7px;
    padding: 30px 0;
    border-top: 1px solid var(--line);
}

.experience-item:last-child { border-bottom: 1px solid var(--line); }

.experience-item > img {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    max-width: 112px;
    max-height: 54px;
    object-fit: contain;
    object-position: left top;
    margin-top: 5px;
}

.experience-item > :not(img) { grid-column: 2; }

.experience-item h3 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.3rem;
    line-height: 1.25;
    color: var(--ink);
}

.experience-item .date-location {
    font-size: 0.9rem;
    color: var(--muted);
}

.experience-item p {
    font-size: 1rem;
    color: var(--ink-2);
    max-width: 62ch;
}

.location { color: var(--accent-ink); text-decoration: none; }
.location:hover { text-decoration: underline; text-underline-offset: 2px; }

.recommendation-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent-ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 2px;
    transition: border-color 0.2s var(--ease);
}

.recommendation-link::after { content: "\2197"; }
.recommendation-link:hover { border-color: var(--accent); }

/* ------------------------------------------------------- Info sections */
.info-section {
    margin-top: 56px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
}

.info-section h2 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--ink);
    margin: 26px 0 8px;
}

.info-section h2:first-of-type { margin-top: 0; }

.info-item {
    font-size: 1rem;
    color: var(--ink-2);
    margin-bottom: 12px;
    max-width: 74ch;
}

.info-item:last-child { margin-bottom: 0; }

/* ------------------------------------------------------ Recent projects */
.recent .content-section { margin-top: 34px; }

.project-item {
    padding: 32px 0;
    border-top: 1px solid var(--line);
}

.recent .content-section .project-item:last-child { border-bottom: 1px solid var(--line); }

.project-title {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.5rem;
    line-height: 1.2;
    color: var(--ink);
    margin-bottom: 6px;
}

.project-title a { color: var(--ink); text-decoration: none; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0% 1px; background-repeat: no-repeat; background-position: left 100%; transition: background-size 0.3s var(--ease), color 0.2s; }
.project-title a:hover { color: var(--accent-ink); background-size: 100% 1px; }

.project-year {
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
    font-style: normal;
}

.project-description {
    font-size: 1.05rem;
    color: var(--ink-2);
    line-height: 1.7;
    max-width: 66ch;
}

.project-highlights { margin-top: 12px; font-weight: 500; color: var(--accent-ink); }

/* --------------------------------------------------------- Tech stack */
.stack .content-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 56px;
    margin-top: 20px;
}

.tech-category {
    padding: 26px 0;
    border-top: 1px solid var(--line);
}

.tech-category h2 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
    margin-bottom: 16px;
}

.tech-items { display: flex; flex-wrap: wrap; gap: 8px; }

.tech-item {
    background: transparent;
    color: var(--ink-2);
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid var(--line-strong);
    transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.tech-item:hover {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

/* ------------------------------------------------------------- Footer */
footer {
    max-width: var(--maxw);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 30px clamp(20px, 5vw, 48px);
    margin-top: 40px;
    border-top: 1px solid var(--line);
    font-size: 0.88rem;
    color: var(--muted);
}

.foot-links { display: flex; gap: 20px; }

footer a {
    color: var(--ink-2);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 1px;
    transition: color 0.2s, border-color 0.2s;
}

footer a:hover { color: var(--ink); border-color: var(--ink); }

/* ======================================================= HOME / HERO */
.home main.hero {
    max-width: 720px;
    margin: 0 auto;
    padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 40px) 80px;
}

.hero-avatar {
    width: 104px;
    height: 104px;
    margin-bottom: 28px;
    border-radius: 50%;
    padding: 4px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
}

.hero-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 22px;
}

.kicker::before {
    content: "";
    width: 28px;
    height: 1px;
    background: var(--accent);
}

.hero-name {
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(2.4rem, 5.5vw, 3.6rem);
    line-height: 1.0;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 24px;
}

.hero-intro {
    font-size: clamp(1.08rem, 2vw, 1.28rem);
    line-height: 1.6;
    color: var(--ink-2);
    max-width: 46ch;
}

/* Domains — three buttons */
.domains { margin-top: 40px; }

.domains-title {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 14px;
}

.domain-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.domain-btn {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    padding: 11px 22px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.domain-btn:hover {
    color: var(--paper);
    background: var(--ink);
    border-color: var(--ink);
    transform: translateY(-2px);
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 26px;
    margin-top: 34px;
}

.text-link {
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-bottom: 1px solid var(--ink);
    padding-bottom: 3px;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease), gap 0.2s var(--ease);
}

.text-link::after { content: "\2192"; color: var(--accent); }
.text-link:hover { color: var(--accent-ink); border-color: var(--accent); gap: 11px; }

/* --------------------------------------------------- Scroll reveal */
/* Visible by default; JS opts into reveal-on only with IntersectionObserver. */
.reveal-on .experience-item,
.reveal-on .project-item,
.reveal-on .tech-category,
.reveal-on .info-section {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.55s var(--ease), transform 0.55s var(--ease);
}

.reveal-on .experience-item.is-visible,
.reveal-on .project-item.is-visible,
.reveal-on .tech-category.is-visible,
.reveal-on .info-section.is-visible {
    opacity: 1;
    transform: none;
}

/* -------------------------------------------------------- Responsive */
@media screen and (max-width: 860px) {
    .stack .content-section { grid-template-columns: 1fr; gap: 0; }
}

@media screen and (max-width: 560px) {
    .experience-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .experience-item img { grid-row: auto; margin-bottom: 2px; }

    .hero-avatar { width: 88px; height: 88px; margin-bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    * , *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    .reveal-on .experience-item,
    .reveal-on .project-item,
    .reveal-on .tech-category,
    .reveal-on .info-section {
        opacity: 1 !important;
        transform: none !important;
    }
}
