:root {
--background: #f4f1e8;
--surface: #ffffff;
--text: #1e1e1e;
--muted: #5c5c5c;
--accent: #6f4c1e;
--border: rgba(30, 30, 30, 0.12);
--primary: var(--accent);
--secondary: var(--muted);
--light: var(--background);
--dark: var(--surface);
--darker: var(--surface);
--light-text: var(--text);
--dark-text: var(--muted);
--muted-text: var(--muted);
--shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
--font-serif: 'Source Serif 4', 'Iowan Old Style', 'Palatino', 'Times New Roman', serif;
--font-sans: 'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
--content-width: 68ch;
--content-max: 960px;
--content-gutter: clamp(20px, 3vw, 32px);
--section-gap: clamp(16px, 2.6vw, 24px);
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html {
font-size: 18px;
}

body {
background-color: var(--background);
color: var(--text);
line-height: 1.7;
overflow-x: hidden;
font-size: 1rem;
font-family: var(--font-serif);
text-rendering: optimizeLegibility;
}

.layout {
display: flex;
min-height: 100vh;
}

.sidebar {
width: clamp(220px, 22vw, 280px);
padding: 48px 32px;
border-right: 1px solid var(--border);
}

.sidebar h1 {
font-family: var(--font-sans);
font-size: 1.3rem;
font-weight: 700;
}

.sidebar p {
font-size: 0.95rem;
color: var(--muted);
line-height: 1.6;
margin-top: 12px;
}

.nav {
display: flex;
flex-direction: column;
gap: 12px;
font-family: var(--font-sans);
font-weight: 600;
text-transform: lowercase;
margin-top: 24px;
}

.nav a {
color: var(--accent);
text-decoration: none;
}

.nav a:hover {
text-decoration: underline;
}

.content {
flex: 1;
padding: clamp(32px, 6vw, 80px);
}

.card--wide {
max-width: 960px;
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-sans);
font-weight: 700;
line-height: 1.2;
letter-spacing: 0.01em;
}

h1 {
font-size: 2.6rem;
}

h2 {
font-size: 2rem;
}

h3 {
font-size: 1.5rem;
}

h4 {
font-size: 1.3rem;
}

h5 {
font-size: 1.1rem;
}

h6 {
font-size: 1rem;
}

.container {
max-width: 100%;
margin: 0;
padding: 0;
}

/* Language toggle button styles */
.language-toggle {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
display: flex;
background: rgba(255, 255, 255, 0.92);
border-radius: 30px;
overflow: hidden;
box-shadow: var(--shadow);
transition: all 0.3s ease;
border: 1px solid rgba(0, 0, 0, 0.08);
}

.language-toggle:hover {
background: rgba(255, 255, 255, 0.98);
transform: translateY(-2px);
}

.language-btn {
padding: 8px 15px;
color: var(--light-text);
background: transparent;
border: none;
cursor: pointer;
font-family: var(--font-sans);
font-weight: bold;
font-size: 0.9rem;
letter-spacing: 0.04em;
text-transform: uppercase;
transition: all 0.3s ease;
}

.language-btn.active {
background: var(--primary);
color: white;
}

header {
background: var(--darker);
color: var(--light-text);
padding: 40px 0;
text-align: center;
border-radius: 0 0 20px 20px;
box-shadow: var(--shadow);
position: relative;
overflow: hidden;
margin-top: 10px;
border-bottom: 1px solid var(--border);
}

/* === Header datamosh (fuzzing-like) layer === */
.hero-mosh{
position:absolute;
inset:0;
width:100%;
height:100%;
pointer-events:none;
z-index:0;

opacity:0.18;                 /* overall visibility */
mix-blend-mode:multiply;      /* soft on cream background */
filter:grayscale(1) contrast(1.05);

/* show mainly left/right edges, keep center clean */
-webkit-mask-image: linear-gradient(to right,
#000 0%, #000 22%,
transparent 40%, transparent 60%,
#000 78%, #000 100%
);
mask-image: linear-gradient(to right,
#000 0%, #000 22%,
transparent 40%, transparent 60%,
#000 78%, #000 100%
);
}

/* place header content above the canvas layer */
header > :not(.hero-mosh){
position:relative;
z-index:1;
}

/* Accessibility: honor reduced motion */
@media (prefers-reduced-motion: reduce){
.hero-mosh{ display:none; }
}


.avatar {
width: 150px;
height: 150px;
border-radius: 50%;
border: 5px solid rgba(0, 0, 0, 0.08);
object-fit: cover;
margin-bottom: 20px;
box-shadow: var(--shadow);
transition: transform 0.3s ease;
background-color: #f0ece3;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 60px;
color: var(--primary);
}

.avatar-img {
width: 100%;
height: 100%;
border-radius: 50%;
object-fit: cover;
}

h1 {
margin-bottom: 10px;
letter-spacing: 0.02em;
animation: fadeIn 1s ease;
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.tagline {
font-size: 1.35rem;
line-height: 1.6;
opacity: 0.9;
margin: 0 auto 20px;
max-width: 50ch;
animation: fadeIn 1.5s ease;
color: var(--muted-text);
}

.contact-info {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 20px;
flex-wrap: wrap;
}

.contact-item {
display: flex;
align-items: center;
gap: 8px;
background: rgba(255, 255, 255, 0.92);
padding: 8px 15px;
border-radius: 20px;
transition: all 0.3s ease;
color: var(--light-text);
font-size: 0.95rem;
font-family: var(--font-sans);
cursor: pointer;
position: relative;
border: 1px solid rgba(0, 0, 0, 0.08);
}

.contact-item:hover {
background: rgba(250, 248, 242, 0.98);
transform: translateY(-3px);
}

.contact-item .copy-notification {
position: absolute;
top: -30px;
left: 50%;
transform: translateX(-50%);
background: var(--secondary);
color: white;
padding: 3px 8px;
border-radius: 5px;
font-size: 0.8rem;
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: none;
}

.contact-item.copied .copy-notification {
opacity: 1;
}

.contact-item a {
color: inherit;
text-decoration: none;
}

.contact-item a:hover {
text-decoration: underline;
}

section {
background: var(--dark);
border-radius: 10px;
padding: clamp(26px, 3vw, 36px);
margin: 36px 0;
box-shadow: var(--shadow);
transform: translateY(20px);
opacity: 0;
transition: all 0.6s ease;
border-left: 3px solid var(--primary);
border: 1px solid var(--border);
display: grid;
gap: var(--section-gap);
}

section.visible {
transform: translateY(0);
opacity: 1;
}

h2 {
color: var(--primary);
margin-bottom: 16px;
position: relative;
padding-bottom: 10px;
letter-spacing: 0.01em;
}

h2::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 60px;
height: 3px;
background: var(--secondary);
}

h3 {
color: var(--light-text);
margin: 22px 0 12px;
}

p, li {
color: var(--dark-text);
max-width: var(--content-width);
hyphens: auto;
overflow-wrap: break-word;
}

p {
margin-bottom: 1.2rem;
line-height: 1.8;
}

p + p {
margin-top: 0.75rem;
}

p.lead {
color: var(--light-text);
font-size: 1.05rem;
font-family: var(--font-sans);
letter-spacing: 0.01em;
line-height: 1.7;
}

ul, ol {
margin: 0 0 1.1rem;
padding-left: 1.4rem;
max-width: var(--content-width);
list-style-position: outside;
}

ul {
list-style-type: disc;
}

ol {
list-style-type: decimal;
}

li {
margin: 0.45rem 0;
padding-left: 0.15rem;
}

li::marker {
color: var(--secondary);
}

a {
color: var(--primary);
text-decoration: underline;
text-decoration-color: rgba(179, 27, 27, 0.6);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
color: var(--secondary);
text-decoration-color: rgba(31, 78, 95, 0.8);
}

a:visited {
color: #6b4b8a;
text-decoration-color: rgba(107, 75, 138, 0.6);
}

a:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 3px;
}

blockquote {
margin: 1.2rem 0;
padding: 1rem 1.2rem;
border-left: 4px solid var(--accent);
background: rgba(179, 27, 27, 0.06);
color: var(--light-text);
font-style: italic;
max-width: var(--content-width);
}

blockquote p {
margin: 0;
}

.context-description {
font-family: var(--font-sans);
background-color: rgba(179, 27, 27, 0.06);
padding: 16px 18px;
border-radius: 5px;
border-left: 3px solid var(--accent);
margin: 8px 0 4px;
color: #1f4e5f;
font-size: 0.97rem;
line-height: 1.6;
max-width: var(--content-width);
}

.skills-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
}

.skill-category {
background: rgba(255, 255, 255, 0.92);
padding: 20px;
border-radius: 8px;
border-left: 4px solid var(--secondary);
transition: all 0.3s ease;
border: 1px solid rgba(0, 0, 0, 0.08);
}

.skill-category:hover {
transform: translateY(-5px);
box-shadow: var(--shadow);
}

.skill-list {
list-style-type: none;
}

.skill-item {
margin-bottom: 8px;
position: relative;
padding-left: 25px;
color: var(--dark-text);
}

.skill-item::before {
content: "▹";
position: absolute;
left: 0;
color: var(--accent);
}

.experience-item {
margin-bottom: 32px;
padding-bottom: 22px;
border-bottom: 1px dashed rgba(0, 0, 0, 0.12);
}

.experience-item:last-child {
border-bottom: none;
margin-bottom: 0;
padding-bottom: 0;
}

.experience-header {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
margin-bottom: 10px;
}

.company {
font-weight: bold;
color: var(--light-text);
font-size: 1.05rem;
font-family: var(--font-sans);
}

.date {
color: var(--secondary);
font-style: italic;
font-family: var(--font-sans);
}

.contributions {
margin-top: 20px;
}

.contribution-item {
background: rgba(255, 255, 255, 0.92);
padding: 15px;
border-radius: 8px;
margin-bottom: 10px;
display: flex;
gap: 15px;
align-items: flex-start;
border: 1px solid rgba(0, 0, 0, 0.08);
}

.contribution-icon {
color: var(--accent);
font-size: 1.2rem;
margin-top: 3px;
}

.tag-cloud {
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
justify-content: center;
margin-top: 20px;
max-width: 100%;
padding: 8px 0;
}

.tag-cloud .tag {
color: var(--dark-text);
font-family: var(--font-sans);
font-weight: 600;
letter-spacing: 0.01em;
text-decoration: none;
transition: color 0.2s ease, transform 0.2s ease;
white-space: nowrap;
will-change: transform;
}

.tag-cloud .tag:hover {
color: var(--primary);
transform: translateY(-2px);
}

.tag-cloud .tag.size-xl {
font-size: 2.4rem;
}

.tag-cloud .tag.size-lg {
font-size: 1.9rem;
}

.tag-cloud .tag.size-md {
font-size: 1.4rem;
}

.tag-cloud .tag.size-sm {
font-size: 1.05rem;
}

.tag-cloud .tag.size-xs {
font-size: 0.9rem;
color: var(--muted-text);
font-weight: 500;
}

.tag-cloud.is-interactive {
position: relative;
display: block;
height: clamp(280px, 35vw, 420px);
overflow: hidden;
padding: 12px;
cursor: grab;
touch-action: none;
user-select: none;
}

.tag-cloud.is-interactive .tag {
position: absolute;
left: 50%;
top: 50%;
transform: translate3d(calc(-50% + var(--tag-x, 0)), calc(-50% + var(--tag-y, 0)), 0) scale(var(--tag-scale, 1));
opacity: var(--tag-opacity, 1);
transition: color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
transform-origin: center;
}

.tag-cloud.is-interactive .tag:hover {
transform: translate3d(var(--tag-x, 0), var(--tag-y, 0), 0) scale(calc(var(--tag-scale, 1) * 1.08));
}

.tag-cloud.is-interactive.is-dragging {
cursor: grabbing;
}


.tag-cloud.is-interactive.is-dragging .tag {
transition: none !important;
}


footer {
text-align: center;
padding: 30px 0;
color: var(--dark-text);
opacity: 0.7;
}

footer p {
margin: 0;
font-size: 0.9rem;
/* Override the global paragraph max-width so the copyright can truly center */
max-width: none;
width: 100%;
text-align: center;
}

.availability {
display: inline-block;
background: rgba(31, 78, 95, 0.12);
color: var(--secondary);
padding: 8px 15px;
border-radius: 20px;
margin-top: 10px;
animation: pulse 2s infinite;
font-size: 0.95rem;
max-width: var(--content-width);
font-family: var(--font-sans);
}

@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}

.code-snippet {
background: #181818;
color: #d6deeb;
padding: 15px;
border-radius: 8px;
font-family: 'Consolas', monospace;
margin: 15px 0;
overflow-x: auto;
position: relative;
border: 1px solid rgba(0, 0, 0, 0.2);
}

.code-snippet::before {
content: "workflow.py";
position: absolute;
top: 0;
right: 0;
background: rgba(0, 0, 0, 0.45);
padding: 3px 10px;
border-radius: 0 8px 0 8px;
font-size: 0.8rem;
color: #7fdbca;
}

.highlight {
color: #e5c07b;
}

.comment {
color: #5c6370;
font-style: italic;
}

.terminal {
background: #181818;
color: #d6deeb;
padding: 15px;
border-radius: 8px;
font-family: 'Consolas', monospace;
margin: 15px 0;
position: relative;
border: 1px solid rgba(0, 0, 0, 0.2);
}

.terminal::before {
content: "$";
position: absolute;
left: 15px;
color: #7fdbca;
}

.terminal-text {
margin-left: 20px;
}

@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}

/* Language: attribute-driven visibility (no forced display:block) */
html[data-lang="en"] .lang-ru { display: none !important; }
html[data-lang="ru"] .lang-en { display: none !important; }

/* View Transitions: smooth language cross-fade */
@supports (view-transition-name: none) {
::view-transition-old(root) { animation: vt-fade-out 180ms ease both; }
::view-transition-new(root) { animation: vt-fade-in 180ms ease both; }
}
@keyframes vt-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes vt-fade-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 1ms !important; }
}

@media (max-width: 900px) {
.layout {
flex-direction: column;
}

.sidebar {
width: 100%;
border-right: none;
border-bottom: 1px solid var(--border);
padding: 32px 24px;
}
}

@media (max-width: 768px) {
.skills-grid {
grid-template-columns: 1fr;
}

.container {
padding: 0;
}

section {
padding: 24px 20px;
margin: 28px 0;
}

.experience-header {
flex-direction: column;
gap: 5px;
}

h1 {
font-size: 2.1rem;
}

.language-toggle {
top: 10px;
right: 10px;
font-size: 0.9rem;
}
}


/* === PM5544-like PAL test pattern overlay (debug table) === */
.hero-pm5544{
position:absolute;
left:4%;
right:4%;
top:8%;
bottom:18%;
border-radius:18px;
pointer-events:none;
z-index:0;

/* visual */
opacity:0;
mix-blend-mode:multiply;
filter:contrast(1.08) saturate(0.85);
border:1px solid rgba(0,0,0,0.10);
box-shadow: 0 10px 28px rgba(0,0,0,0.06);

/* main pattern (approximation) */
background:
/* center circle */
radial-gradient(circle at 50% 50%,
transparent 0 30%,
rgba(0,0,0,0.22) 30% 30.6%,
transparent 30.6% 100%
),
/* inner circle */
radial-gradient(circle at 50% 50%,
transparent 0 14%,
rgba(0,0,0,0.18) 14% 14.5%,
transparent 14.5% 100%
),
/* crosshair vertical */
linear-gradient(to right,
transparent 0 calc(50% - 0.4%),
rgba(0,0,0,0.18) calc(50% - 0.4%) calc(50% + 0.4%),
transparent calc(50% + 0.4%) 100%
),
/* crosshair horizontal */
linear-gradient(to bottom,
transparent 0 calc(50% - 0.35%),
rgba(0,0,0,0.18) calc(50% - 0.35%) calc(50% + 0.35%),
transparent calc(50% + 0.35%) 100%
),
/* fine grid */
repeating-linear-gradient(to right,
rgba(0,0,0,0.06) 0 1px,
transparent 1px 26px
),
repeating-linear-gradient(to bottom,
rgba(0,0,0,0.06) 0 1px,
transparent 1px 26px
),
/* bottom grayscale steps */
linear-gradient(to right,
#111 0%,
#444 14%,
#777 28%,
#aaa 42%,
#ddd 56%,
#fff 70%,
#bbb 84%,
#000 100%
) bottom / 100% 18% no-repeat,
/* top color bars */
linear-gradient(to right,
#ffffff 0% 12.5%,
#f6f06a 12.5% 25%,
#6de7f3 25% 37.5%,
#6af08b 37.5% 50%,
#e86cf0 50% 62.5%,
#f06767 62.5% 75%,
#6b78ff 75% 87.5%,
#111111 87.5% 100%
) top / 100% 22% no-repeat,
/* base */
linear-gradient(135deg, rgba(255,255,255,0.65), rgba(255,255,255,0.25));
background-color: rgba(255,255,255,0.15);

animation: pm5544Pulse 10s infinite;
transform-origin: 50% 50%;
}

.hero-pm5544::after{
content:"PM5544";
position:absolute;
right:14px;
bottom:10px;
font-weight:700;
letter-spacing:0.08em;
font-size:12px;
color:rgba(0,0,0,0.35);
text-transform:uppercase;
}

@keyframes pm5544Pulse{
0%   { opacity:0;    transform:scale(0.988); }
3%   { opacity:0.20; transform:scale(1.000); } /* fade in */
20%  { opacity:0.20; transform:scale(1.000); } /* visible ~2s of 10s */
40%  { opacity:0;    transform:scale(1.006); } /* fade out */
100% { opacity:0;    transform:scale(0.988); }
}

/* Also hide for reduced motion */
@media (prefers-reduced-motion: reduce){
.hero-pm5544{ display:none; }
}

/* === Subtle SVG “glitch” (controlled distortion) === */
.glitch-filters{
position:absolute;
width:0;
height:0;
overflow:hidden;
pointer-events:none;
}

/* Keep avatar circular even with displacement */
.avatar{ overflow:hidden; }

/* Opt-in targets are tagged by JS */
.glitchable{
will-change: filter, transform;
transform: translateZ(0);
}

/* A tiny physical “float” to sell the wobble (no layout shift) */
.glitch-avatar.is-glitching{
transform: translate3d(0, -1px, 0);
}
.glitch-text.is-glitching{
transform: translate3d(0, -0.5px, 0);
}

@media (prefers-reduced-motion: reduce){
.glitchable,
.glitchable.is-glitching{
filter:none !important;
transform:none !important;
}
}



/* === Houdini Paint: procedural “engineering” background (grid/noise/scope) === */
:root{
/* Tweakables (numbers are unitless on purpose; worklet treats them as px / coeffs) */
--eng-bg-grid: 28;              /* minor grid step (px) */
--eng-bg-major: 112;            /* major grid step (px) */
--eng-bg-hatch: 160;            /* diagonal hatch spacing (px) */
--eng-bg-seed: 1337;            /* deterministic seed */
--eng-bg-dpr: 1;                /* set by JS (capped) */
--eng-bg-phase: 0;              /* animated by CSS (optional) */

/* Opacity controls (0..1) — keep these subtle */
--eng-bg-grid-alpha: 0.055;
--eng-bg-major-alpha: 0.080;
--eng-bg-hatch-alpha: 0.035;
--eng-bg-noise-alpha: 0.028;
--eng-bg-scope-alpha: 0.055;
--eng-bg-scope-thickness: 1.15;
--eng-bg-cal-alpha: 0.050;      /* “PM5544-ish” calibration marks */
}

@supports (background-image: paint(engineeringBG)) {
/* Base color is already set on body; paint() is layered on top */
body{
background-image: paint(engineeringBG);
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}

/* Allow smooth animation of a numeric custom property (when supported) */
@property --eng-bg-phase {
syntax: '<number>';
inherits: true;
initial-value: 0;
}

@media (prefers-reduced-motion: no-preference){
body{
animation: engBgPhase 14s linear infinite;
}
}

@keyframes engBgPhase{
from { --eng-bg-phase: 0; }
to   { --eng-bg-phase: 6.28318; } /* 2π */
}
}

/* Fallback for browsers without the Painting API */
@supports not (background-image: paint(engineeringBG)) {
body{
background-image:
repeating-linear-gradient(0deg,  rgba(0,0,0,0.030) 0 1px, transparent 1px 28px),
repeating-linear-gradient(90deg, rgba(0,0,0,0.030) 0 1px, transparent 1px 28px),
repeating-linear-gradient(45deg, rgba(0,0,0,0.020) 0 1px, transparent 1px 160px),
radial-gradient(circle at 50% 32%, rgba(0,0,0,0.055), transparent 60%);
background-attachment: fixed;
}
}
