/* ==========================================================================
   Džiugas Valančauskas — minimal portfolio
   One typeface, two greys, lots of air. Palette follows Apple's system tones.
   Type scale is calibrated against the references: a ~68px light (300) hero
   (karoliskosas.com uses 72px light) and quiet 13–20px supporting text
   (lukasmisevicius.com uses 12–19px). Images run wide with tight gutters.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #86868b;
  --line: #e3e3e8;
  --soft: #f5f5f7;
  --pad: clamp(20px, 2.4vw, 40px);
  --max: 1800px;
  --gap: clamp(8px, .7vw, 12px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --header: 52px;
}

[data-theme="dark"] {
  --bg: #000000;
  --fg: #f5f5f7;
  --muted: #86868b;
  --line: #2a2a2d;
  --soft: #141416;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header) + 12px); }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: Geist, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .45s var(--ease), color .45s var(--ease);
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--pad); }
.muted { color: var(--muted); }

.skip {
  position: absolute; left: var(--pad); top: -40px; z-index: 100;
  background: var(--fg); color: var(--bg); padding: 8px 12px; font-size: 14px;
}
.skip:focus { top: 8px; }

/* -------------------------------------------------------------- Header */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background-color .45s var(--ease);
}
.site-header.scrolled { border-bottom-color: var(--line); }
.site-header .wrap {
  height: var(--header);
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 15px; font-weight: 500; letter-spacing: -0.015em; }
.nav { display: flex; align-items: center; gap: clamp(18px, 2.2vw, 32px); font-size: 14px; }
.nav a { color: var(--muted); transition: color .2s; }
.nav a:hover, .nav a.active { color: var(--fg); }

.theme-btn {
  width: 30px; height: 30px; margin-right: -7px;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--muted); transition: color .2s, background-color .2s;
}
.theme-btn:hover { color: var(--fg); background: var(--soft); }
.theme-btn .i-moon { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: block; }

/* -------------------------------------------------------------- Shared type */

.display {
  font-size: clamp(2rem, 3.9vw, 4.25rem);
  font-weight: 300;
  line-height: 1.06;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.display .dim { color: var(--muted); }

.label { font-size: 13px; color: var(--muted); }

.sec { padding-block: clamp(72px, 8vw, 128px); }
.sec + .sec { padding-block-start: 0; }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  margin-bottom: clamp(20px, 2.4vw, 32px);
}
.sec-head h2 { font-size: clamp(1.25rem, 1.7vw, 1.75rem); font-weight: 300; letter-spacing: -0.022em; line-height: 1.2; }
.sec-head .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- Hero */

.hero { padding-block: clamp(64px, 11vh, 128px) 0; }
.hero .display { max-width: 20em; }
.hero .display .dim { display: block; }

.hero .intro {
  margin-top: clamp(20px, 2.2vw, 32px);
  max-width: 31em;
  font-size: clamp(1.0625rem, 1.2vw, 1.25rem);
  line-height: 1.5;
  letter-spacing: -0.012em;
  color: var(--muted);
  text-wrap: pretty;
}

.meta {
  margin-top: clamp(48px, 6vw, 88px);
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px;
  font-size: 13px;
}
.meta dt { color: var(--muted); }
.meta dd { margin-top: 3px; }
.status { display: inline-flex; align-items: center; gap: 8px; }
.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #30d158; box-shadow: 0 0 0 0 rgba(48, 209, 88, .5);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(48, 209, 88, .45); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(48, 209, 88, 0); }
}

/* -------------------------------------------------------------- Work mosaic */

.mosaic { display: flex; flex-direction: column; gap: clamp(32px, 3.6vw, 56px); }
.mrow { display: flex; gap: var(--gap); align-items: flex-start; }
.tile { flex: var(--a) 1 0; min-width: 0; display: block; }
.tile .ph { aspect-ratio: var(--a); overflow: hidden; background: var(--soft); }
.tile img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 1.4s var(--ease), opacity .5s var(--ease);
}
.tile:hover img { transform: scale(1.025); }
.tile .cap {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin-top: 10px; font-size: 14px;
}
.tile .cap .t { font-weight: 400; }
.tile .cap .c { color: var(--muted); text-align: right; }

/* -------------------------------------------------------------- Index list */

.index { border-top: 1px solid var(--line); }
.irow {
  display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.5fr) 48px; gap: 16px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.45;
  transition: color .25s var(--ease);
}
.irow .c, .irow .y { color: var(--muted); transition: color .25s var(--ease); }
.irow .y { text-align: right; font-variant-numeric: tabular-nums; }
.irow .t::after { content: " →"; opacity: 0; transition: opacity .25s var(--ease); }
@media (hover: hover) {
  .index:hover .irow, .index:hover .irow .c, .index:hover .irow .y { color: var(--muted); }
  .index .irow:hover, .index .irow:hover .c, .index .irow:hover .y { color: var(--fg); }
  .index .irow:hover .t::after { opacity: 1; }
}

.preview {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  width: clamp(160px, 14vw, 240px); aspect-ratio: 4 / 3; object-fit: cover;
  opacity: 0; transform: translate(-50%, -50%) scale(.94);
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.preview.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* -------------------------------------------------------------- About */

.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(28px, 5vw, 96px); }
.about-h {
  font-size: clamp(1.375rem, 2.2vw, 2.25rem); font-weight: 300;
  line-height: 1.2; letter-spacing: -0.022em; max-width: 22em; text-wrap: balance;
}
.about-p { margin-top: clamp(24px, 2.4vw, 32px); max-width: 38em; }
.about-p p + p { margin-top: 1em; }
.portrait { width: 100%; max-width: 340px; aspect-ratio: 4 / 5; object-fit: cover; background: var(--soft); }

.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px;
  margin-top: clamp(56px, 6vw, 96px); padding-top: 24px; border-top: 1px solid var(--line);
}
.stat .n { font-size: clamp(2rem, 3.2vw, 3.25rem); font-weight: 300; line-height: 1; letter-spacing: -0.035em; }
.stat .l { margin-top: 10px; font-size: 13px; color: var(--muted); }

.lists {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: clamp(28px, 5vw, 96px);
  margin-top: clamp(56px, 6vw, 96px);
}
.lists .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 4vw, 64px); }
.skills li, .rec li { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.skills li:first-child, .rec li:first-child { border-top: 1px solid var(--line); }
.rec li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; }
.rec .yr { color: var(--muted); font-variant-numeric: tabular-nums; }
.lists h3 { font-size: 13px; font-weight: 400; color: var(--muted); margin-bottom: 12px; }

/* -------------------------------------------------------------- Contact */

.contact .display { max-width: 14em; }
.email {
  display: inline-block; margin-top: clamp(28px, 3.2vw, 44px);
  font-size: clamp(1.25rem, 1.8vw, 1.75rem); font-weight: 300; letter-spacing: -0.02em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 3px; transition: background-size .5s var(--ease);
}
.email:hover { background-size: 100% 1px; }
.socials { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-top: 24px; font-size: 14px; }
.socials a { color: var(--muted); transition: color .2s; }
.socials a:hover { color: var(--fg); }

/* -------------------------------------------------------------- Footer */

.site-footer { border-top: 1px solid var(--line); }
.site-footer .wrap {
  display: flex; justify-content: space-between; gap: 20px;
  padding-top: 22px; padding-bottom: 22px; font-size: 13px; color: var(--muted);
}
.site-footer a:hover { color: var(--fg); }

/* -------------------------------------------------------------- Case study */

.case-top { padding-block: clamp(36px, 4.4vw, 64px) clamp(36px, 4vw, 56px); }
.back { font-size: 14px; color: var(--muted); transition: color .2s; }
.back:hover { color: var(--fg); }
.case-top .display { margin-top: clamp(28px, 3.4vw, 48px); }
.case-sub { margin-top: 12px; font-size: 14px; color: var(--muted); }
.case-lead {
  margin-top: clamp(20px, 2.4vw, 32px); max-width: 30em;
  font-size: clamp(1.125rem, 1.5vw, 1.4375rem); font-weight: 300; line-height: 1.4; letter-spacing: -0.016em; text-wrap: pretty;
}

.case-hero { background: var(--soft); }
.case-hero img { width: 100%; height: auto; }

.case-info {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); gap: 24px;
  padding: clamp(32px, 3.6vw, 52px) 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.case-info h3 { font-size: 13px; font-weight: 400; color: var(--muted); margin-bottom: 8px; }
.case-info li + li { margin-top: 3px; }
.credits { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 18px; }
.credits dt { color: var(--muted); }

.case-body {
  padding: clamp(44px, 5vw, 80px) 0; max-width: 38em;
  font-size: clamp(1rem, 1.1vw, 1.0625rem); line-height: 1.65; letter-spacing: -0.008em;
}
.case-body p + p { margin-top: 1em; }

.gallery { display: flex; flex-direction: column; gap: var(--gap); }
.gallery figure { background: var(--soft); }
.gallery img { width: 100%; height: auto; }
.gallery figcaption { background: var(--bg); padding-top: 8px; font-size: 12px; color: var(--muted); }
.gallery.masonry { display: block; columns: 2; column-gap: var(--gap); }
.gallery.masonry figure { break-inside: avoid; margin-bottom: var(--gap); }

.next {
  display: block; margin-top: clamp(72px, 8vw, 128px);
  padding: clamp(48px, 5.6vw, 88px) 0; border-top: 1px solid var(--line);
}
.next .display { margin-top: 12px; font-size: clamp(1.75rem, 3vw, 3rem); transition: color .35s var(--ease); }
.next:hover .display { color: var(--muted); }

/* -------------------------------------------------------------- Motion */

.rv { opacity: 0; transform: translateY(16px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.rv.in { opacity: 1; transform: none; }
#app { transition: opacity .28s var(--ease); }
#app.out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1; transform: none; transition: none; }
  .tile img, .preview, #app { transition: none; }
  .status::before { animation: none; }
}

/* -------------------------------------------------------------- Responsive */

@media (max-width: 900px) {
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
  .about-grid, .lists { grid-template-columns: 1fr; }
  .portrait { max-width: 300px; }
  .case-info { grid-template-columns: 1fr 1fr; }
  .case-info .ci-credits { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .mrow { flex-direction: column; gap: clamp(32px, 8vw, 48px); }
  .tile { width: 100%; }
  .tile .ph { aspect-ratio: 4 / 3; }
  .irow { grid-template-columns: minmax(0, 1fr) auto; }
  .irow .c { display: none; }
  .stats { grid-template-columns: 1fr; gap: 28px; }
  .lists .cols { grid-template-columns: 1fr; }
  .gallery.masonry { columns: 1; }
  .case-info { grid-template-columns: 1fr; }
  .nav { gap: 14px; font-size: 13px; }
  .brand { font-size: 14px; white-space: nowrap; }
}

@media (hover: none), (max-width: 720px) { .preview { display: none; } }
