/* =========================================================
   Runstia — Portfolio
   Design system: tokens, layout, components
   ========================================================= */

:root {
  --bg: #f7f6fb;
  --bg-elevated: #ffffff;
  --bg-sunken: #eeecf6;
  --text: #17171c;
  --text-muted: #55555f;
  --border: #e1e0ea;
  --accent: #7c3aed;
  --accent-strong: #6425d0;
  --accent-soft: #efe6ff;
  --accent-contrast: #ffffff;
  --danger: #e34850;
  --shadow: 0 10px 30px rgba(20, 10, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 10, 40, 0.14);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --max-width: 1080px;
  --font-head: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0d0d11;
  --bg-elevated: #17171d;
  --bg-sunken: #0a0a0d;
  --text: #f3f2f7;
  --text-muted: #a3a2ad;
  --border: #29282f;
  --accent: #b98bff;
  --accent-strong: #cba6ff;
  --accent-soft: #241a35;
  --accent-contrast: #1a0d2b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d11;
    --bg-elevated: #17171d;
    --bg-sunken: #0a0a0d;
    --text: #f3f2f7;
    --text-muted: #a3a2ad;
    --border: #29282f;
    --accent: #b98bff;
    --accent-strong: #cba6ff;
    --accent-soft: #241a35;
    --accent-contrast: #1a0d2b;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  transition: background-color .2s ease, color .2s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.2;
  margin: 0 0 .5em;
  letter-spacing: -0.01em;
}
p { margin: 0 0 1em; color: var(--text); }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-brand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand .dot { color: var(--accent); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .95rem;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--bg-sunken); }
.nav-links a.active { color: var(--accent-contrast); background: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s ease, transform .15s ease;
  flex: none;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex: none;
}
.nav-toggle svg { width: 20px; height: 20px; }

@media (max-width: 760px) {
  .nav { flex-wrap: wrap; }
  .nav-toggle { display: flex; }
  .nav-links {
    order: 3;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Hero ---------- */
.hero {
  padding: 72px 0 48px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
}
.eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero h1 { font-size: clamp(2rem, 4vw, 3rem); }
.hero .lead { font-size: 1.1rem; color: var(--text-muted); max-width: 52ch; }
.hero-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--bg-sunken);
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-photo { max-width: 260px; margin: 0 auto; }
}

/* ---------- Sections ---------- */
.section { padding: 56px 0; }
.section-title { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 8px; }
.section-sub { color: var(--text-muted); max-width: 60ch; margin-bottom: 32px; }
.section-head { margin-bottom: 32px; }
.section-head .btn-ghost { margin-top: 6px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ---------- Cards / chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-muted { background: var(--bg-sunken); color: var(--text-muted); }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

/* ---------- Project grid ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.project-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
}
.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.project-card .thumb {
  aspect-ratio: 16 / 10;
  background: var(--bg-sunken);
  overflow: hidden;
}
.project-card .thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s ease;
}
.project-card:hover .thumb img { transform: scale(1.05); }
.project-card .body { padding: 18px 20px 20px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.project-card h3 { font-size: 1.15rem; margin: 0; }
.project-card .meta { font-size: .85rem; color: var(--text-muted); }
.project-card p.desc { font-size: .92rem; color: var(--text-muted); margin: 0; flex: 1; }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.filter-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ---------- Project detail page ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 24px;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 16px; height: 16px; }

.project-cover {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 32px;
  background: var(--bg-sunken);
}
.project-cover img { width: 100%; height: auto; display: block; }

.project-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 12px; }
.project-meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.project-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  align-items: start;
}
.project-sidebar {
  position: sticky;
  top: 90px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sidebar-block h4 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sidebar-block .chip-row { gap: 6px; }

@media (max-width: 900px) {
  .project-layout { grid-template-columns: 1fr; }
  .project-sidebar { position: static; order: -1; }
}

.prose h2 { font-size: 1.3rem; margin-top: 1.6em; }
.prose p { color: var(--text); }
.prose ul { list-style: disc; padding-left: 1.3em; margin-bottom: 1em; }
.prose li { margin-bottom: .4em; }

/* ---------- Gallery / lightbox ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 24px 0;
}
.gallery-grid button {
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/10;
  background: var(--bg-sunken);
}
.gallery-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.gallery-grid button:hover img { transform: scale(1.06); }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(5, 5, 8, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 85vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close svg { width: 20px; height: 20px; }

/* ---------- Prev/next project nav ---------- */
.project-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 40px;
}
.pager-link {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s ease, transform .15s ease;
}
.pager-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.pager-link.next { text-align: right; align-items: flex-end; }
.pager-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.pager-title { font-weight: 700; font-family: var(--font-head); }
@media (max-width: 600px) { .project-pager { grid-template-columns: 1fr; } }

/* ---------- CV page ---------- */
.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}
.cv-title { font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.cv-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
}
.cv-block { margin-bottom: 32px; }
.cv-block h2 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 14px;
}
.cv-item { margin-bottom: 18px; }
.cv-item .when {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.cv-item .role { font-weight: 700; font-family: var(--font-head); margin: 2px 0 4px; }
.cv-item .where { color: var(--text-muted); font-size: .92rem; margin-bottom: 6px; }
.cv-item ul { list-style: disc; padding-left: 1.2em; }
.cv-item li { color: var(--text-muted); font-size: .92rem; margin-bottom: 3px; }
.cv-skills-list li {
  display: flex; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px dashed var(--border);
  font-size: .92rem;
}
.cv-skills-list li:last-child { border-bottom: none; }
.cv-tools { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 820px) {
  .cv-grid { grid-template-columns: 1fr; }
}

/* ---------- Contact page ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.contact-card {
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 14px;
}
.contact-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.contact-card .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.contact-card .icon svg { width: 22px; height: 22px; }
.contact-card .label { font-weight: 700; font-family: var(--font-head); font-size: .98rem; }
.contact-card .value { font-size: .85rem; color: var(--text-muted); word-break: break-word; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 32px 0;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .88rem;
  color: var(--text-muted);
}
.footer-social { display: flex; gap: 10px; }
.footer-social a {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all .15s ease;
}
.footer-social a:hover { color: var(--accent); border-color: var(--accent); }
.footer-social svg { width: 16px; height: 16px; }

/* ---------- Misc ---------- */
.note-card {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
  font-size: .92rem;
}
.note-card strong { color: var(--accent); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
