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

:root {
  --bg:             #FFF8F0;
  --surface:        #FFF1E6;
  --border:         #E8DDD4;
  --text:           #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-dim:       #8a8078;
  --accent:         #5a8a64;
  --link:           #2a7a6a;
  --highlight:      #c47a4a;
  --font:           'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

html { scroll-behavior: smooth; font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
strong { color: var(--text); font-weight: 600; }

/* ─── Accessibility ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* ─── Scrollbar ─── */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.accent { color: var(--accent); }

/* ════════════════════════════════
   LAYOUT — Sidebar + Carousel
════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ════════════════════════════════
   SIDEBAR (left 1/2)
════════════════════════════════ */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.75rem;
}

/* Sidebar header / identity */
.sidebar-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.tagline {
  font-size: 0.82rem;
  color: var(--accent);
  margin-top: 0.2rem;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
}
.profile-links a {
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: color 0.15s;
}
.profile-links a:hover { color: var(--link); text-decoration: none; }

/* Sidebar sections */
.sidebar section {
  margin-bottom: 1.5rem;
}
.sidebar section:last-child {
  margin-bottom: 0;
}

h2 {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

/* About */
.about-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

.contact-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.35rem; }
.contact-links a { font-size: 0.78rem; }

/* Entries */
.entries {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.entry h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.entry h3 a { color: var(--text); transition: color 0.15s; }
.entry h3 a:hover { color: var(--link); text-decoration: none; }

.date {
  font-size: 0.72rem;
  color: var(--highlight);
  white-space: nowrap;
  flex-shrink: 0;
}

.role {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.entry > p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.entry-desc + .entry-desc {
  margin-top: 0.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}
.tags span {
  font-size: 0.68rem;
  color: var(--text-dim);
}
.tags span:not(:last-child)::after { content: ' ·'; }

/* Badges */
.badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.accent { color: var(--accent); }

/* Publication links */
.pub-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.3rem;
}
.pub-links a { font-size: 0.75rem; }

/* Awards */
.award-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.award-row {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  line-height: 1.5;
}
.award-row dt {
  min-width: 2rem;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}
.award-row dd { color: var(--text-secondary); }
.award-text + .award-text {
  margin-top: 0.2rem;
}

/* Skills */
.skill-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.skill-row {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  line-height: 1.5;
}
.skill-row dt {
  min-width: 90px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.skill-row dd { color: var(--text); }

/* Sidebar footer */
.sidebar-footer {
  padding: 0.75rem 1.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ════════════════════════════════
   PROJECTS PANEL (right 1/2)
════════════════════════════════ */
.projects-panel {
  position: relative;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}
.projects-panel:focus,
.projects-panel:focus-visible {
  outline: none;
}

.projects-container {
  padding: 2rem 2.5rem;
}

.projects-container > h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
}

/* ─── Project Grid ─── */
.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

/* Card thumbnail */
.card-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8.5;
  background: var(--border);
  overflow: hidden;
}
.card-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  background-color: var(--surface);
}
.card-video-placeholder svg { opacity: 0.5; }

/* Card info */
.card-info {
  padding: 0.65rem 0.85rem 0.75rem;
}
.card-info h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.card-info p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Project Popup ─── */
body.project-popup-open {
  overflow: hidden;
}

.project-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(26, 26, 26, 0.18);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}
.project-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.project-popup {
  position: fixed;
  z-index: 100;
  width: min(820px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.12), 0 2px 12px rgba(0,0,0,0.06);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  left: 50%;
  top: 50%;

  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-50% + 10px)) scale(0.98);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  pointer-events: none;
}
.project-popup.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* Popup video */
.popup-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.popup-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.popup-replay {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%) scale(0.96);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(26, 26, 26, 0.74);
  color: var(--bg);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s, border-color 0.18s, background 0.18s;
}
.popup-replay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.popup-replay:hover {
  border-color: var(--accent);
  background: rgba(26, 26, 26, 0.84);
}
.popup-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-dim);
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
  background-color: var(--surface);
}
.popup-video-placeholder svg { opacity: 0.35; }
.popup-video-placeholder span {
  font-size: 0.72rem;
  opacity: 0.55;
}


/* Popup body */
.popup-body {
  padding: 1.6rem 1.75rem 1.9rem;
  overflow: visible;
  flex: 0 0 auto;
  min-height: auto;
  display: flex;
  flex-direction: column;
}

.popup-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.9rem;
}
.popup-header h3 {
  flex: 1 1 14rem;
  font-size: 1.22rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.popup-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.popup-link {
  display: inline-block;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--accent);
  transition: color 0.15s;
}
.popup-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.popup-body .tags {
  margin-bottom: 1.05rem;
}

.popup-desc {
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.85;
  margin-bottom: 0;
  max-width: none;
}
.popup-desc p + p {
  margin-top: 0.85rem;
}

@media (min-width: 1180px) {
  .project-popup {
    width: min(860px, calc(100vw - 3rem));
  }

  .popup-body {
    padding: 1.75rem 1.9rem 2.05rem;
  }

  .popup-desc {
    font-size: 0.96rem;
  }
}

/* ════════════════════════════════
   MOBILE / TABLET
════════════════════════════════ */
@media (max-width: 900px) {
  body {
    overflow: auto;
    height: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-scroll {
    overflow: visible;
  }

  .projects-panel {
    height: auto;
    min-height: auto;
  }

  .projects-container {
    padding: 1.5rem 1.25rem;
  }

  .project-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .project-popup {
    width: min(94vw, 820px);
    max-height: calc(100vh - 1.5rem);
  }
}

@media (max-width: 640px) {
  .sidebar-scroll {
    padding: 1.25rem 1rem;
  }

  .projects-container {
    padding: 1.25rem 1rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .project-popup {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    border-radius: 12px;
  }

  .popup-body {
    padding: 1.25rem 1.1rem 1.35rem;
  }

  .popup-desc {
    font-size: 0.88rem;
    line-height: 1.78;
  }

  .entry-header { flex-direction: column; gap: 0.15rem; }
  .skill-row { flex-direction: column; gap: 0.1rem; }
  .skill-row dt { min-width: unset; }
  .award-row { gap: 0.5rem; }
}
