/* igor ivanov — personal site. paper, ink, one pen. no lines: structure comes from space and type. */
:root {
  --paper: #F5F2EA;
  --paper-raised: #FBF9F5;
  --paper-sunk: #EBE7DC;
  --ink: #24231F;
  --ink-soft: #4A4841;
  --ink-muted: #6B685F;
  --pen: #1F3FD6;

  --sans: Onest, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 48px; --s6: 96px;
  --rail: 208px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  text-transform: lowercase;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, p, ol, ul, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.skip { position: absolute; left: var(--s3); top: -80px; background: var(--ink); color: var(--paper); padding: var(--s2) var(--s3); z-index: 100; }
.skip:focus { top: var(--s3); }

/* ---------- type ---------- */
.h2 { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; }
.cap { font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--ink-muted); }
.prose { font-size: 18px; line-height: 1.5; color: var(--ink-soft); text-wrap: pretty; }
.tl { color: var(--ink); display: inline-block; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: var(--ink-muted); }

/* ---------- pen layer: traced from the notebook ---------- */
.mark { position: relative; display: inline-block; }
.mark img { position: absolute; left: -16%; top: -30%; width: 132%; height: 165%; max-width: none; pointer-events: none; }
.draw { clip-path: inset(0 100% 0 0); animation: draw 1.2s var(--ease) .6s forwards; }
@keyframes draw { to { clip-path: inset(-10% -10% -10% -10%); } }

/* hover marks: injected by main.js into [data-pen] */
[data-pen] { position: relative; }
.scribble { position: absolute; max-width: none; pointer-events: none; clip-path: inset(-20% 100% -20% 0); transition: clip-path .25s var(--ease); }
.scribble.underline { left: -2%; bottom: -9px; width: 104%; height: 12px; }
.scribble.circle { left: -9%; top: -28%; width: 118%; height: 156%; }
a:hover > .scribble, a:hover [data-pen] > .scribble, a:focus-visible > .scribble, [data-pen]:hover > .scribble { clip-path: inset(-20% -5% -20% 0); transition-duration: .55s; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: var(--s2) var(--s4);
  font: 700 15px/1.2 var(--sans); letter-spacing: -0.01em; text-transform: lowercase;
  border: 1px solid var(--ink); border-radius: 0; cursor: pointer;
  transition: transform .3s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-secondary { background: transparent; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s4); }

/* ---------- left rail ---------- */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--rail);
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s5) var(--s4) var(--s5) var(--s5);
  background: var(--paper); z-index: 20;
}
.rail-top { display: flex; flex-direction: column; gap: var(--s3); }
.rail-name { font-weight: 700; font-size: 19px; letter-spacing: -0.03em; line-height: 1.1; }
.lang { font-family: var(--mono); font-size: 13px; color: var(--ink-muted); display: inline-flex; gap: var(--s2); }
.lang a { padding: 2px 0; }
.lang a:hover { color: var(--ink); }
.lang [aria-current] { color: var(--ink); font-weight: 700; }
.rail-nav { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.rail-nav a { font-size: 15px; color: var(--ink-muted); line-height: 1.6; transition: color .3s var(--ease); }
.rail-nav a:hover, .rail-nav a[aria-current="true"] { color: var(--ink); }
.rail-nav a[aria-current="true"] { font-weight: 700; }
.rail-icons { display: flex; flex-wrap: wrap; gap: var(--s1); margin-left: -8px; }
.rail-icons a { width: 36px; height: 36px; display: grid; place-items: center; color: var(--ink-muted); transition: color .3s var(--ease), transform .3s var(--ease); }
.rail-icons a:hover { color: var(--ink); transform: translateY(-2px) rotate(-4deg); }
.rail-icons svg, .award svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.rail-meta { margin-top: calc(var(--s4) * -1); font-size: 12px; line-height: 1.7; }
.rail-cta { margin-top: auto; align-self: flex-start; min-height: 40px; padding: var(--s2) var(--s3); font-size: 14px; }

.topbar, .dock { display: none; }

/* ---------- main ---------- */
main { margin-left: var(--rail); padding: 0 var(--s5) 0 var(--s4); max-width: calc(var(--rail) + 1040px); }
.sec { padding-top: 72px; position: relative; }
.sec-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.doodle { pointer-events: none; }
.d-work { transform: rotate(-82deg); margin: -20px 0 -20px 26px; }

/* hello: two type styles only — the greeting and the text */
.hero { padding-top: 40px; display: grid; grid-template-columns: minmax(0, 640px) 200px; gap: var(--s5); justify-content: space-between; align-items: start; }
.hero-text { display: flex; flex-direction: column; gap: var(--s4); }
.greet img { height: 104px; width: auto; margin-left: -8px; }
.greet-ru img { height: 76px; margin: 14px 0 6px -6px; }
.rail-icons svg.solid { fill: currentColor; stroke: none; }
.greet-type { font-size: clamp(36px, 4vw, 48px); line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; padding: 14px 0 6px; }
.hero .prose { display: flex; flex-direction: column; gap: var(--s3); }
.photo { margin-top: var(--s3); }
.photo-img { width: 100%; height: auto; mix-blend-mode: multiply; }
.photo-note { display: flex; align-items: flex-start; gap: 4px; margin-top: var(--s1); }
.photo-note .note-arrow { transform: rotate(-52deg); }
.photo-note .note-text { margin-top: 18px; transform: rotate(-4deg); }

/* bento */
.bento { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(168px, auto); gap: var(--s2); }
.cell { position: relative; display: flex; flex-direction: column; min-width: 0; }
.cell.raised { background: var(--paper-raised); }
.cell.sunk { background: var(--paper-sunk); }
.cell.ink { background: var(--ink); color: var(--paper); padding: var(--s4); justify-content: flex-end; gap: var(--s1); }
.cell-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); flex: 1; }
.cell-title { font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.cell-title [data-pen] { display: inline; }
.cell-text { font-size: 17px; line-height: 1.4; color: #CFCABD; }
.cell-more { font-size: 15px; position: relative; z-index: 2; }
.stretch::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.cell-img { overflow: hidden; background: var(--paper-sunk); }
.cell-img img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(.95); transition: transform .8s var(--ease); }
.cell:hover .cell-img img { transform: scale(1.03); }
.num { font-size: clamp(44px, 5.4vw, 72px); line-height: 1; font-weight: 700; letter-spacing: -0.04em; white-space: nowrap; }
.award { display: inline-flex; align-items: center; gap: var(--s2); margin-top: auto; padding-top: var(--s3); font-family: var(--mono); font-size: 13px; line-height: 1.3; }
.award svg { flex: none; }

.c-a { grid-column: span 2; grid-row: span 2; }
.c-a .cell-img { aspect-ratio: 1100 / 576; }
.c-a .cell-title { font-size: 26px; letter-spacing: -0.03em; }
.c-b { grid-column: span 2; }
.c-e { grid-column: span 2; }
.cell.side { flex-direction: row; }
.cell.side .cell-img { width: 50%; flex: none; }
.c-f .cell-img, .c-g .cell-img { aspect-ratio: 900 / 472; }

/* talks: quiet */
.talks { display: grid; grid-template-columns: 208px minmax(0, 620px); gap: var(--s4); padding-top: 64px; align-items: start; }
.label { font-weight: 400; padding-top: 4px; }
.list { display: flex; flex-direction: column; gap: var(--s2); }
.item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3); }
.item-title { font-size: 17px; line-height: 1.5; }
.item-title [data-pen] { display: inline-block; }
.d-talks { position: absolute; left: 860px; bottom: -6px; transform: rotate(-6deg); }

/* contact: short */
.contact { padding-top: 104px; padding-bottom: var(--s4); }
.contact .prose { max-width: 640px; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s5); margin-top: var(--s4); }
.note { display: flex; align-items: center; gap: var(--s2); }
.note .note-arrow { transform: rotate(-135deg); }
.note .note-text { transform: rotate(-3deg); }

.foot { display: flex; justify-content: flex-end; align-items: center; padding: var(--s5) 0; }
.foot-meta { display: none; }
.foot-doodle { transform: rotate(10deg); }

/* ---------- narrower desktop ---------- */
@media (max-width: 1100px) {
  .hero { grid-template-columns: minmax(0, 1fr) 150px; gap: var(--s4); }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .c-a { grid-row: span 1; }
  .talks { grid-template-columns: 1fr; gap: var(--s3); }
  .d-talks { left: auto; right: 0; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  main { margin-left: 0; padding: 0 20px 76px; }
  .sec { padding-top: 56px; }

  .topbar { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) 20px; }
  .topbar-name { font-weight: 700; letter-spacing: -0.03em; font-size: 19px; }
  .lang a { padding: 6px 2px; }

  .dock {
    display: grid; grid-template-columns: auto 1fr; gap: var(--s2);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: var(--s2) var(--s3) calc(var(--s2) + env(safe-area-inset-bottom));
    background: var(--paper);
  }
  .dock-menu {
    display: inline-flex; align-items: center; gap: var(--s2);
    min-height: 44px; padding: 0 var(--s3);
    background: var(--paper-sunk); border: 0; border-radius: 0; color: var(--ink);
    font: 700 15px/1 var(--sans); text-transform: lowercase; cursor: pointer;
  }
  .burger { position: relative; width: 16px; height: 10px; }
  .burger i { position: absolute; left: 0; width: 16px; height: 1.5px; background: var(--ink); transition: transform .5s var(--ease); }
  .burger i:first-child { top: 0; } .burger i:last-child { bottom: 0; }
  .menu-open .burger i:first-child { transform: translateY(4.25px) rotate(45deg); }
  .menu-open .burger i:last-child { transform: translateY(-4.25px) rotate(-45deg); }

  .rail {
    width: 100%; z-index: 30; padding: var(--s3) 20px 96px; gap: var(--s5);
    opacity: 0; visibility: hidden; transform: translateY(24px);
    transition: opacity .5s var(--ease), transform .5s var(--ease), visibility 0s .5s;
  }
  .menu-open .rail { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .menu-open { overflow: hidden; }
  .rail-top { flex-direction: row; justify-content: space-between; align-items: center; }
  .rail-nav { gap: var(--s3); margin-top: var(--s4); }
  .rail-nav a { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--ink); }
  .rail-icons { gap: var(--s3); margin-left: -6px; }
  .rail-icons a { width: 44px; height: 44px; color: var(--ink); }
  .rail-icons svg { width: 26px; height: 26px; }
  .rail-meta { margin-top: calc(var(--s3) * -1); font-size: 13px; }
  .rail-cta { display: none; }
  .rail-nav a, .rail-icons, .rail-meta { opacity: 0; transform: translateY(24px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
  .menu-open .rail-nav a, .menu-open .rail-icons, .menu-open .rail-meta { opacity: 1; transform: none; }
  .menu-open .rail-nav a:nth-child(1) { transition-delay: 60ms; }
  .menu-open .rail-nav a:nth-child(2) { transition-delay: 120ms; }
  .menu-open .rail-nav a:nth-child(3) { transition-delay: 180ms; }
  .menu-open .rail-nav a:nth-child(4) { transition-delay: 240ms; }
  .menu-open .rail-icons { transition-delay: 300ms; }
  .menu-open .rail-meta { transition-delay: 360ms; }

  .hero { padding-top: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
  .photo { order: -1; width: 128px; margin: 0; position: relative; }
  .photo-note { position: absolute; left: 136px; bottom: 10px; margin: 0; width: max-content; align-items: center; }
  .photo-note .note-arrow { transform: rotate(-140deg); }
  .photo-note .note-text { margin-top: 0; width: min(134px, 34vw); height: auto; }
  .photo-note .note-arrow { width: 32px; height: auto; }
  .greet img { height: 84px; }
  .greet-ru img { height: auto; width: min(100%, 330px); margin: 6px 0 0 -4px; }
  .prose { font-size: 17px; }

  .bento { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .c-a, .c-b, .c-e { grid-column: auto; }
  .cell.ink { min-height: 168px; }
  .cell-body { padding: 20px; }
  .cell.side { flex-direction: column; }
  .cell.side .cell-img { width: 100%; aspect-ratio: 16 / 9; }

  .list { gap: var(--s3); }
  .d-talks { display: none; }

  .contact { padding-top: 64px; }
  .cta { flex-direction: column; align-items: stretch; gap: var(--s3); }
  .cta .actions { flex-direction: column; gap: var(--s2); }
  .note { order: -1; justify-content: flex-end; }
  .note .note-arrow { transform: rotate(150deg); }
  .foot { justify-content: space-between; padding: var(--s5) 0 var(--s4); }
  .foot-meta { display: block; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .draw { animation: none; clip-path: none; }
  .scribble, .cell-img img { transition: none; }
  .rail, .rail-nav a, .rail-icons, .rail-meta { transform: none !important; }
}
