/* ===== Base ===== */
:root {
  --text: #1a1a1a;
  --muted: #666;
  --link: #1a1a1a;
  --border: #e6e6e6;
  --bg: #ffffff;
  --surface: #f2f2f2;
  --code-bg: #f4f4f4;
  --maxw: 920px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --text: #ececec;
  --muted: #9b9b9b;
  --link: #ececec;
  --border: #2a2a2a;
  --bg: #101010;
  --surface: #1b1b1b;
  --code-bg: #1e1e1e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 24px 96px;
}

p { margin: 0 0 1em; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--muted); }

/* ===== Headings ===== */
h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.2em;
}

section { margin-top: 56px; }

/* ===== Intro ===== */
.intro {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
}

.avatar {
  width: 116px;
  height: 116px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.intro-text { min-width: 0; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 10px;
}

.links a {
  display: inline-flex;
  padding: 4px;
  margin: -4px;   /* larger tap target without shifting the layout */
  transition: color 0.12s ease;
}

.links svg {
  display: block;
  width: 26px;
  height: 26px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ===== Entries (experience / projects) ===== */
.entry {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 40px;
}

/* ===== Image carousel ===== */
.carousel {
  position: relative;
  width: 480px;
  height: 270px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.carousel-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
}
.carousel-track::-webkit-scrollbar { display: none; }

.carousel-track img,
.carousel-track video {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  scroll-snap-align: center;
  display: block;
}
.carousel-track img.img-left { object-position: left center; }
.carousel-track .media-contain { object-fit: contain; }
.carousel-track .media-zoom-mid { object-fit: contain; transform: scale(1.8); }
/* Slides that wrap their image (full-resolution link, reduced-motion still) */
.carousel-track .carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  display: block;
}
.carousel-track a.carousel-slide { cursor: zoom-in; }

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #1a1a1a;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease;
}
.carousel-nav:hover { transform: translateY(-50%) scale(1.1); }
.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }
.carousel-nav[hidden] { display: none; }
.carousel-nav:focus-visible { outline: 3px solid #1a6fd6; outline-offset: 2px; }

/* Slide position, so it's clear there is more to see */
.carousel-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Touch devices: tappable size */
@media (hover: none) {
  .carousel-nav {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .carousel-track { scroll-behavior: auto; }
  .carousel-track .media-zoom-mid { transform: none; }
}

.entry-body { min-width: 0; }

/* Stacked layout: visuals are the focal point — full-width media, text below */
.stacked .entry {
  flex-direction: column;
  gap: 16px;
}
.stacked .carousel {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.entry-title { margin-bottom: 0.15em; }

.entry-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.6em;
}

.entry-authors {
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0.35em 0 0;
}

.entry-description {
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0.35em 0 0;
}
.entry-description:empty { display: none; }

.entry-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.92rem;
  margin: 0.4em 0 0;
}

/* ===== Project detail page ===== */
.back-link { font-size: 0.92rem; margin-bottom: 32px; }

.project h3 { margin-top: 1.6em; }

.project ul,
.project ol { margin: 0 0 1em; padding-left: 1.3em; }
.project li { margin-bottom: 0.5em; }

.project figure { margin: 1.4em 0; }
.project figure img,
.project figure video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.project .pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  margin: 1.8em 0 0;
  padding: 0;
  list-style: none;
}
.project .pipeline li {
  position: relative;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.88rem;
  line-height: 1.35;
}
.pipeline li:not(:last-child)::after {
  content: "\2192";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 24px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.05rem;
  text-align: center;
}
@media (max-width: 760px) {
  .project .pipeline { grid-template-columns: 1fr; gap: 26px; }
  .pipeline li:not(:last-child)::after {
    content: "\2193";
    top: 100%;
    left: 0;
    width: 100%;
    transform: none;
    line-height: 26px;
  }
}

.recon-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 1em 0;
}
.project .recon-steps figure { margin: 0; }
.project .recon-steps figcaption { font-size: 0.8rem; margin-top: 5px; }
.recon-note { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 560px) {
  .recon-steps { grid-template-columns: repeat(3, 1fr); }
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.project .stage-pair figure { margin: 0; }

.clip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 1.4em 0;
}
.project .clip-grid figure { margin: 0; }
@media (max-width: 560px) {
  .clip-grid { grid-template-columns: repeat(2, 1fr); }
}
.project figure a:has(img) { cursor: zoom-in; }
.project figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-top: 8px;
}
.project figcaption a { color: inherit; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ===== Dark-mode toggle (top-right, scrolls with page) ===== */
.theme-toggle {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 10;
  display: inline-flex;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  line-height: 0;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 20px; height: 20px; }
.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; }

/* ===== Mobile ===== */
@media (max-width: 560px) {
  main { padding: 64px 20px 72px; }

  .intro { gap: 20px; }

  .avatar { width: 92px; height: 92px; }

  .entry {
    flex-direction: column;
    gap: 14px;
  }

  .carousel {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
