/* ── Color tokens ── */
:root {
  --bg:           oklch(95.5% 0.012 240);
  --surface:      oklch(99%   0.004 65 / 0.85);
  --surface-bd:   oklch(88%   0.022 242);
  --sidebar-bg:   oklch(92.5% 0.018 240);
  --sidebar-bd:   oklch(85%   0.022 240);

  --text-1:       oklch(17%   0.009 245);
  --text-2:       oklch(40%   0.016 245);
  --text-3:       oklch(58%   0.014 245);

  --accent:       oklch(50%   0.16  252);
  --accent-hi:    oklch(44%   0.18  252);
  --accent-sub:   oklch(93.5% 0.032 250);
  --accent-bd:    oklch(80%   0.065 250);

  --sep:          oklch(87%   0.020 240);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── Base ── */
body {
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.65;
  color: var(--text-1);
  background: var(--bg);
  position: relative;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 230px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-bd);
  border-top: 3px solid var(--accent);
  overflow-y: auto;
  z-index: 100;
  padding: 26px 0 40px;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sep); border-radius: 99px; }

.sidebar-brand {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-1);
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--sep);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.toc { list-style: none; }
.toc > li { margin-bottom: 1px; }

.toc a {
  display: block;
  padding: 7px 12px;
  margin: 0 8px;
  font-size: 0.875rem;
  color: var(--text-3);
  text-decoration: none;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}

.toc a:hover { color: var(--accent); background: var(--accent-sub); text-decoration: none; }
.toc a.active { color: var(--accent); background: var(--accent-sub); font-weight: 600; }

.sub-toc { list-style: none; margin: 2px 0 6px; }

.sub-toc a {
  padding: 5px 12px 5px 28px;
  font-size: 0.8rem;
}

.toc-group-label {
  display: block;
  padding: 6px 20px 2px 34px;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Main content ── */
.main-content {
  margin-left: 230px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Hero entrance animation ── */
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero ── */
.hero {
  background:
    linear-gradient(
      to top,
      oklch(10% 0.07 252 / 0.92) 0%,
      oklch(15% 0.05 248 / 0.56) 44%,
      oklch(18% 0.04 245 / 0.34) 100%
    ),
    url("assets/banner.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: oklch(97% 0.006 245);
  min-height: 52vh;
  padding: 0 64px 64px;
  display: flex;
  align-items: flex-end;
  text-align: left;
}

.hero-content {
  max-width: 680px;
}

.hero h1 {
  font-size: clamp(3.2rem, 7vw, 5.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.0;
  animation: hero-rise 0.72s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero h1::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: oklch(68% 0.14 252);
  margin-top: 20px;
  margin-bottom: 16px;
}

.hero h2 {
  font-size: 0.85rem;
  font-weight: 300;
  opacity: 0.75;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: hero-rise 0.72s cubic-bezier(0.16, 1, 0.3, 1) 0.14s both;
}

/* ── Content body ── */
.content-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 52px 36px 80px;
}

/* ── Sections ── */
section { margin-bottom: 60px; }

section.will-animate {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
section.will-animate.visible { opacity: 1; transform: translateY(0); }

section h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 22px;
  padding-top: 12px;
  border-top: 2px solid var(--accent);
  width: fit-content;
  letter-spacing: -0.01em;
}

p {
  font-size: 1rem;
  color: var(--text-2);
  margin-bottom: 14px;
}

/* ── Section cards (About, Resume) ── */
.section-body {
  background: var(--surface);
  border-radius: 8px;
  padding: 28px 32px;
  border: 1px solid var(--surface-bd);
}

.section-body p {
  font-size: 1.01rem;
  line-height: 1.78;
  max-width: 65ch;
  margin-bottom: 0;
}

/* ── Project cards ── */
.project {
  background: var(--surface);
  border-radius: 8px;
  padding: 26px 28px;
  margin: 12px 0;
  border: 1px solid var(--surface-bd);
  transition: border-color 0.2s ease;
}

.project:hover { border-color: var(--accent-bd); }

.project h4 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  line-height: 1.35;
}

/* ── Status badge ── */
.status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: oklch(93% 0.08 85);
  color: oklch(42% 0.1 75);
  border-radius: 99px;
  padding: 2px 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Skill tags ── */
.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag {
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--accent-sub);
  color: var(--accent);
  border: 1px solid var(--accent-bd);
  border-radius: 99px;
  padding: 3px 10px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ── Project list ── */
.project ul { margin: 0 0 0 18px; padding: 0; }

.project li {
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.65;
}

/* ── Doc link ── */
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 18px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 14px;
  border: 1px solid var(--accent-bd);
  border-radius: 99px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}

.doc-link:hover {
  background: var(--accent-sub);
  border-color: var(--accent);
  color: var(--accent-hi);
  text-decoration: none;
}

/* ── Project images ── */
img { display: block; max-width: 100%; }

.project img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
  margin-top: 18px;
}

.project video {
  display: block;
  width: 100%;
  border-radius: 6px;
  margin-top: 18px;
}

/* ── Links ── */
a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { color: var(--accent-hi); text-decoration: underline; }

/* ── Project groups ── */
.project-group { margin-bottom: 8px; }

.group-toggle {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--sep);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s;
}
.group-toggle:hover { border-color: var(--accent-bd); }

.group-toggle-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  flex: 1;
}

.group-toggle-count {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-sub);
  color: var(--accent);
  border: 1px solid var(--accent-bd);
  border-radius: 99px;
  padding: 2px 9px;
}

.chevron {
  font-size: 0.9rem;
  color: var(--text-3);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-block;
}
.project-group.collapsed .chevron { transform: rotate(-90deg); }

.group-content-wrapper {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.project-group.collapsed .group-content-wrapper { grid-template-rows: 0fr; }
.group-content { overflow: hidden; }

/* ── Galton board canvas ── */
#bg-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
}

/* ── Image wrapper / hover overlay ── */
.img-wrapper {
  position: relative;
  margin-top: 18px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.img-wrapper img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
  object-position: center;
  border-radius: 0;
  margin-top: 0;
  box-shadow: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.img-wrapper:hover img { transform: scale(1.03); }

.img-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease;
}
.img-overlay span {
  color: oklch(97% 0.006 245);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  border-radius: 99px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.img-wrapper:hover .img-overlay { background: rgba(0, 0, 0, 0.42); }
.img-wrapper:hover .img-overlay span { opacity: 1; transform: translateY(0); }

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: oklch(5% 0.008 245 / 0.93);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lightbox.open { opacity: 1; pointer-events: all; }

.lightbox img {
  max-width: 88vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  margin: 0;
  width: auto;
  height: auto;
}

.lightbox-close {
  position: absolute;
  top: 18px; right: 26px;
  background: none;
  border: none;
  color: oklch(97% 0.006 245);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
  padding: 4px;
}
.lightbox-close:hover { opacity: 1; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .content-body { padding: 28px 20px 56px; }
  .hero { padding: 0 24px 48px; min-height: 44vh; }
  .hero h1 { font-size: 2.4rem; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .hero h1,
  .hero h2 { animation: none; opacity: 1; transform: none; }

  section.will-animate,
  section.will-animate.visible { transition: none; opacity: 1; transform: none; }

  .img-wrapper img { transition: none; }
  .group-content-wrapper { transition: none; }
  .chevron { transition: none; }
}
