/* ============================================================
   Maxim Gorlanov — Portfolio
   Clean / editorial. No gradients.
   ============================================================ */

:root {
  --bg:       #ffffff;
  --bg-soft:  #fafafa;
  --ink:      #18181b;
  --ink-soft: #52525b;
  --ink-mute: #a1a1aa;
  --line:     #e4e4e7;
  --line-2:   #d4d4d8;
  --accent:   #1f2937;   /* near-black, used for primary actions */
  --link:     #2156c2;   /* restrained blue, links only */
  --radius:   14px;
  --radius-s: 9px;
  --maxw:     960px;
  --serif:    "Newsreader", Georgia, "Times New Roman", serif;
  --sans:     "Inter", system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg:       #0e0e10;
  --bg-soft:  #161618;
  --ink:      #f4f4f5;
  --ink-soft: #a1a1aa;
  --ink-mute: #71717a;
  --line:     #27272a;
  --line-2:   #3f3f46;
  --accent:   #e4e4e7;
  --link:     #7aa2f7;
}

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

html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.62;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;                 /* each tab fits one screen */
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

h1, h2, h3, .hero__name, .d-title { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }

/* ===================== NAV ===================== */
.nav {
  flex: 0 0 auto; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }

.tabs { margin-left: auto; display: flex; gap: 4px; position: relative; }
.tab-ind {
  position: absolute; bottom: -1px; left: 0; height: 2px; width: 0;
  background: var(--ink); border-radius: 2px;
  transform: translateX(0);
  transition: transform .42s cubic-bezier(.5,0,.15,1), width .42s cubic-bezier(.5,0,.15,1);
  pointer-events: none;
}
.tab {
  border: 0; background: transparent;
  font: 500 14px/1 var(--sans);
  color: var(--ink-soft);
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer; position: relative;
  transition: color .18s, background .18s;
}
.tab:hover { color: var(--ink); background: var(--bg-soft); }
.tab.is-active { color: var(--ink); }

.theme-toggle {
  width: 36px; height: 36px;
  border: 1px solid var(--line); background: var(--bg);
  border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-soft);
  transition: color .18s, border-color .18s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-2); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===================== PANELS / FULL-HEIGHT LAYOUT ===================== */
main {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
}
.panel { display: none; width: 100%; padding: 28px 0; }
.panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* safety valve for very short screens */
@media (max-height: 620px) { main { overflow-y: auto; justify-content: flex-start; } }

/* ===================== HERO / ABOUT ===================== */
.hero {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 56px; align-items: start;
}
.eyebrow {
  display: block; font-size: 13px; font-weight: 500;
  letter-spacing: .02em; color: var(--ink-mute);
  text-transform: uppercase; margin-bottom: 18px;
}
.hero__name { font-size: clamp(40px, 6vw, 60px); line-height: 1.04; }
.hero__tagline { font-size: 19px; color: var(--ink-soft); margin-top: 10px; }
.hero__bio { color: var(--ink-soft); margin-top: 26px; max-width: 54ch; font-size: 16.5px; }
.hero__focus {
  margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: 16px; color: var(--ink);
}
.hero__focus span {
  display: block; font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-mute); margin-bottom: 4px;
}
.hero__links { display: flex; gap: 22px; margin-top: 26px; }
.hero__links a { font-size: 14.5px; font-weight: 500; color: var(--ink-soft); border-bottom: 1px solid transparent; transition: color .18s, border-color .18s; }
.hero__links a:hover { color: var(--ink); border-color: var(--line-2); }

.photo {
  position: relative; aspect-ratio: 4/5; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__placeholder {
  position: absolute; inset: 0; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-mute);
}
.photo__placeholder span { font-family: var(--serif); font-size: 52px; color: var(--ink-soft); }
.photo__placeholder small { font-size: 11.5px; }

.figures {
  margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px;
}
.fig b { font-family: var(--serif); font-size: 26px; font-weight: 500; display: block; }
.fig span { color: var(--ink-mute); font-size: 13px; }

/* ===================== SECTION HEAD ===================== */
.section-head { margin-bottom: 28px; max-width: 62ch; }
.section-head h2 { font-size: clamp(26px, 4vw, 38px); }
.section-head p { color: var(--ink-soft); margin-top: 12px; font-size: 16px; }

/* ===================== PROJECT CARDS ===================== */
.proj-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.proj {
  text-align: left; font-family: var(--sans); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 22px 18px;
  cursor: pointer; display: flex; flex-direction: column;
  transition: border-color .25s ease, background .25s ease, transform .25s ease, box-shadow .25s ease;
}
.proj:hover { border-color: var(--line-2); background: var(--bg-soft); transform: translateY(-3px); box-shadow: 0 18px 40px -24px rgba(0,0,0,.5); }
.proj--ghost { cursor: default; border-style: dashed; }
.proj--ghost:hover { transform: none; background: var(--bg); border-color: var(--line); }

.proj__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-soft);
}
.meta { font-size: 12.5px; color: var(--ink-mute); }
.proj__title { font-size: 20px; margin-top: 12px; line-height: 1.18; }
.proj__summary {
  color: var(--ink-soft); font-size: 14px; margin-top: 9px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.proj__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.types { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--ink-mute); font-size: 13px; }

.type-pill {
  font-size: 11px; font-weight: 500; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; background: var(--bg);
}
.open-cue { font-size: 13.5px; font-weight: 500; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.open-cue .arrow { transition: transform .18s; }
.proj:hover .open-cue .arrow { transform: translateX(3px); }

/* ===================== EMPTY STATE ===================== */
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 64px 28px; text-align: center;
}
.empty h3 { font-size: 22px; }
.empty p { color: var(--ink-soft); max-width: 46ch; margin: 12px auto 0; }

/* ===================== FOOTER ===================== */
.footer {
  border-top: 1px solid var(--line);
  padding: 28px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; flex-wrap: wrap;
  color: var(--ink-mute); font-size: 13.5px;
}
.footer__links { display: flex; gap: 18px; }
.footer__links a { color: var(--ink-soft); }
.footer__links a:hover { color: var(--ink); }

/* ===================== MODAL ===================== */
.modal { position: fixed; inset: 0; z-index: 90; }
.modal[hidden] { display: none; }
.modal__overlay {
  position: absolute; inset: 0;
  background: rgba(9, 9, 11, .5);
  backdrop-filter: blur(3px);
}
.modal__panel {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  width: min(740px, calc(100vw - 32px));
  max-height: calc(100vh - 56px);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.45);
  will-change: transform, opacity;
}
.modal__close {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--ink-soft); cursor: pointer; font-size: 13px;
  transition: color .18s, border-color .18s;
}
.modal__close:hover { color: var(--ink); border-color: var(--line-2); }
.modal__content { overflow-y: auto; padding: 38px 40px 40px; }

/* modal content (from template) */
.d-head { padding-right: 40px; }
.d-head .label { color: var(--ink-mute); }
.d-title { font-size: 30px; margin-top: 10px; line-height: 1.12; }
.d-meta { color: var(--ink-mute); font-size: 13.5px; margin-top: 10px; }
.d-summary { color: var(--ink-soft); font-size: 16px; margin-top: 20px; }
.d-note {
  margin-top: 16px; font-size: 13.5px; color: var(--ink-soft);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 12px 14px;
}

.d-updates { margin-top: 14px; }
.u { padding: 28px 0; border-top: 1px solid var(--line); }
.u__bar { display: flex; align-items: center; gap: 10px; }
.u__title { font-family: var(--sans); font-size: 16px; font-weight: 600; }
.u__desc { color: var(--ink-soft); font-size: 14.5px; margin-top: 8px; }

.embed { position: relative; width: 100%; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-top: 16px; }
.embed--16x9 { aspect-ratio: 16/9; }
.embed--deck { aspect-ratio: 16/10; }
.embed--site { aspect-ratio: 16/10; }
.embed--pdf { aspect-ratio: 16/11; }
.embed iframe, .embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed video { background: #000; object-fit: contain; }

.u__link { display: inline-block; margin-top: 12px; font-size: 13.5px; font-weight: 500; color: var(--link); }
.u__link:hover { text-decoration: underline; }

.u__cta {
  display: inline-flex; align-items: center; margin-top: 16px;
  font-size: 14px; font-weight: 500;
  color: var(--bg); background: var(--accent);
  padding: 11px 18px; border-radius: var(--radius-s);
  transition: opacity .18s;
}
.u__cta:hover { opacity: .88; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .hero__media { order: -1; max-width: 180px; }
  .figures { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .proj-grid { grid-template-columns: 1fr; }
  .modal__content { padding: 32px 24px 28px; }
  .d-title { font-size: 25px; }
}
@media (max-width: 520px) {
  .brand { font-size: 16px; }
  .tab { padding: 8px 8px; font-size: 13px; }
}

/* ===================== ENTRANCE ANIMATIONS ===================== */
@media (prefers-reduced-motion: no-preference) {
  .panel.is-active .section-head,
  .panel.is-active .hero__body,
  .panel.is-active .hero__media,
  .panel.is-active .empty { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }

  .panel.is-active .proj { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; }
  .panel.is-active .proj-grid .proj:nth-child(1) { animation-delay: .06s; }
  .panel.is-active .proj-grid .proj:nth-child(2) { animation-delay: .12s; }
  .panel.is-active .proj-grid .proj:nth-child(3) { animation-delay: .18s; }
  .panel.is-active .proj-grid .proj:nth-child(4) { animation-delay: .24s; }

  .panel.is-active .hero__media { animation-delay: .08s; }
}

/* ===================== CUSTOM CURSOR (single dot) ================= */
.cursor {
  position: fixed; top: 0; left: 0; z-index: 9999;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;      /* inverts per-pixel against the page ->
                                      always visible; each half of a 2-colour
                                      edge adapts independently */
  pointer-events: none; opacity: 0; will-change: left, top;
  transform: translate(-50%, -50%) scale(1);
  transition: transform .25s cubic-bezier(.34,1.4,.5,1), opacity .3s;
}
.has-cursor .cursor { opacity: 1; }
.cursor.is-hover { transform: translate(-50%, -50%) scale(2.4); }
.cursor.is-down  { transform: translate(-50%, -50%) scale(1.5); }

@media (hover: hover) and (pointer: fine) {
  body.has-cursor, body.has-cursor * { cursor: none !important; }
}

/* ===================== THEME LIQUID SWITCH (View Transitions) ===== */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;                 /* we drive the reveal ourselves */
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }   /* new theme floods in on top */

.theme-toggle { overflow: hidden; }
.theme-toggle svg { transition: transform .5s cubic-bezier(.34,1.4,.5,1); }
.theme-toggle:active svg { transform: scale(.8) rotate(-25deg); }
