/* Minimal, fast, GitHub-Pages-friendly. Humans love drama; CSS doesn't. */

:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.7);
  --text: #2d2d2d;
  --muted: rgba(0, 0, 0, 0.58);
  --border: rgba(0, 0, 0, 0.10);
  --shadow: rgba(0, 0, 0, 0.08);
  --link: #0249cd;
  --thumb-bg: #ffffff;
  --strong: #1e1e1e;
  --strong-text: #ffffff;
  --icon: #222222;
  --chip-bg: #f6f7f9;
  --ok-bg: #e8f3ec;
  --ok-text: #2e6b4e;
  --ok-dot: #3a9a6a;
  --select: rgba(2, 73, 205, 0.25);
  --sk-base: #e5e8ed;
  --sk-shine: #f4f5f8;
}

/* Dark theme, used only when the visitor picks it with the toggle. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1318;
  --surface: #171c23;
  --surface-soft: rgba(255, 255, 255, 0.04);
  --text: #e4e7eb;
  --muted: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.45);
  --link: #82abff;
  --strong: #e4e7eb;
  --strong-text: #111418;
  --icon: #e4e7eb;
  --chip-bg: rgba(255, 255, 255, 0.06);
  --ok-bg: rgba(58, 154, 106, 0.16);
  --ok-text: #8fd1ad;
  --ok-dot: #4fbf86;
  --select: rgba(130, 171, 255, 0.35);
  --sk-base: rgba(255, 255, 255, 0.06);
  --sk-shine: rgba(255, 255, 255, 0.13);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  color: var(--text);
}

a { color: var(--link); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
a:hover { text-decoration: underline; }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  flex: 1;
  width: 100%;
  max-width: 980px;
  padding: 24px 0 56px;
}

@media (max-width: 980px) {
  .container { padding: 24px 40px 56px; }
}

@media (max-width: 520px) {
  .container { padding: 16px 16px 40px; }
}

/* ===== Top Tabs ===== */
.topbar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 0 18px;
}

.nav-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.tab:hover {
  background: var(--surface);
  box-shadow: 0 6px 14px var(--shadow);
  text-decoration: none;
}

.tab.is-active {
  background: var(--strong);
  border-color: var(--strong);
  color: var(--strong-text);
}

.tab.is-active:hover { background: var(--strong); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
}

.theme-toggle svg { width: 18px; height: 18px; fill: var(--icon); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme-resolved="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme-resolved="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== Sidebar + main ===== */
.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 28px;
  align-items: start;
}

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Keep the profile in view while browsing long tabs on desktop */
@media (min-width: 901px) {
  .sidebar { position: sticky; top: 24px; }
}

.avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 6px 14px var(--shadow);
  background: var(--surface);
}

.name {
  margin: 14px 0 6px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.role {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.95rem;
}

/* Keep the headline title on a single line */
.nowrap { white-space: nowrap; }

/* Social icons */
.socials {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.social-link {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.social-link:hover {
  background: var(--surface);
  box-shadow: 0 6px 14px var(--shadow);
  text-decoration: none;
}

.social-link svg {
  width: 20px;
  height: 20px;
  fill: var(--icon);
}

.main {
  font-size: 0.95rem;
  min-width: 0;
}

.subtitle {
  margin: 6px 0 36px;
  line-height: 1.45;
}

.subtitle p { margin: 0 0 12px; }
.subtitle p:last-child { margin-bottom: 0; }
.subtitle a { font-size: inherit; }

/* Availability + contact buttons under the intro */
.about-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.availability {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.availability-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok-dot);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
}

.button:hover {
  background: var(--surface);
  box-shadow: 0 6px 14px var(--shadow);
  text-decoration: none;
}

.button--primary {
  background: var(--strong);
  border-color: var(--strong);
  color: var(--strong-text);
}

.button--primary:hover { background: var(--strong); }

.section-title {
  margin: 36px 0 14px;
  font-size: 1.12rem;
}

.section-title--first,
.subtitle + .section-title,
.subtitle + #featured .section-title { margin-top: 6px; }

/* Responsive: stack columns */
@media (max-width: 900px) {
  .topbar { justify-content: center; }

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

  .subtitle { margin-top: 18px; }
}

/* On very small phones, let the headline wrap rather than overflow */
@media (max-width: 420px) {
  .nowrap { white-space: normal; }
}

/* ===== Experience / education timeline ===== */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.timeline li:last-child { border-bottom: 1px solid var(--border); }

.tl-date {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.tl-role { margin: 0; font-size: 0.97rem; line-height: 1.3; }
.tl-org { color: var(--muted); font-weight: 600; }
.tl-desc { margin: 4px 0 0; line-height: 1.45; }

@media (max-width: 520px) {
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* ===== Project carousels ===== */
.group-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.carousel-controls {
  display: flex;
  gap: 6px;
  flex: none;
  margin-bottom: 10px;
}

.carousel-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.carousel-btn:hover:not(:disabled) { background: var(--surface); box-shadow: 0 6px 14px var(--shadow); }
.carousel-btn:disabled { opacity: 0.35; cursor: default; }

.carousel-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  /* Room for card hover shadows inside the scroll area. */
  margin: -8px -4px;
  padding: 8px 4px;
  scroll-padding: 0 4px;
}

.carousel-track::-webkit-scrollbar { display: none; }

/* Two cards per view with a peek at the next one; one card on phones. */
.carousel-track > .card {
  flex: 0 0 calc((100% - 32px) / 2.15);
  scroll-snap-align: start;
}

@media (max-width: 520px) {
  .carousel-track > .card { flex-basis: 86%; }
}

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

/* ===== Card grids (projects + awards) ===== */
.card-grid {
  display: grid;
  gap: 16px;
}

.card-grid--wide    { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card-grid--compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

@media (max-width: 520px) {
  .card-grid--wide,
  .card-grid--compact { grid-template-columns: 1fr; }
}

.card {
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
  background: transparent;
  transition: background 0.25s ease, box-shadow 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.card:hover, .card:focus-visible {
  background: var(--surface);
  box-shadow: 0 0 10px var(--shadow), inset 0 0 0 1px var(--border);
  transform: translateY(-1px);
  outline: none;
}

.card:focus-visible { box-shadow: 0 0 0 2px var(--link); }

.card-media {
  position: relative;
  margin-bottom: 4px;
}

.card-img {
  display: block;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--thumb-bg);
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* Award images are usually certificates or photos: show them whole. */
.card--award .card-img {
  aspect-ratio: 4 / 3;
  object-fit: contain;
  padding: 6px;
}

/* Award photos (rather than certificates) fill the frame. */
.card--photo .card-img { object-fit: cover; padding: 0; }

/* Missing-image placeholder tiles fill the frame. */
.card-img.is-placeholder { padding: 0; object-fit: cover; }

/* Shimmer behind card and gallery thumbnails while they load; the image fades in on top. */
.card-media.is-loading, .modal-thumb.is-loading {
  background: linear-gradient(90deg, var(--sk-base) 25%, var(--sk-shine) 45%, var(--sk-base) 65%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.card-media.is-loading { border-radius: 8px; }
.card-img, .modal-thumb img { transition: opacity 0.2s ease; }
.is-loading > img { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .card-media.is-loading, .modal-thumb.is-loading { animation: none; }
  .card-img, .modal-thumb img { transition: none; }
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: rgba(20, 20, 20, 0.82);
}

/* Award photos often have a ribbon in the top corner; keep the label clear of it. */
.card--award .card-badge { top: auto; bottom: 8px; }

.card-source {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.card-source--open   { color: #2e6b4e; }
.card-source--closed { color: #5a5f66; }

.card-title { margin: 0; font-size: 1.0rem; line-height: 1.25; }
.card-desc  { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.35; }
.card-meta  { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.3; }

/* Notes under grids */
.panel-note {
  margin: 22px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.dot { margin: 0 8px; color: var(--muted); }

/* ===== CV ===== */
.cv-toolbar {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 14px;
}

.cv-pages { display: flex; flex-direction: column; gap: 16px; }

.cv-page {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 14px var(--shadow);
}

.cv-page canvas { display: block; width: 100%; height: auto; }

/* Selectable text over the rendered page (PDF.js text layer). */
.cv-text {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
}

.cv-text :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.cv-text span.markedContent { top: 0; height: 0; }
.cv-text ::selection { background: rgba(2, 73, 205, 0.25); }
.cv-text br::selection { background: transparent; }

.cv-link { position: absolute; display: block; border-radius: 2px; z-index: 3; }
.cv-link:hover, .cv-link:focus-visible { background: rgba(2, 73, 205, 0.12); outline: none; }

.cv-status { margin: 40px 0; text-align: center; color: var(--muted); }

/* Placeholder pages with a shimmer while the CV loads. */
.cv-skeleton {
  aspect-ratio: 612 / 792;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 7% 8%;
}

.sk {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e5e8ed 25%, #f4f5f8 45%, #e5e8ed 65%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.sk-name { align-self: center; width: 38%; height: 22px; margin-bottom: 2px; }
.sk-sub  { align-self: center; width: 66%; margin-bottom: 14px; }
.sk-head { width: 24%; height: 11px; margin-top: 14px; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

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

/* ===== Footer ===== */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 16px 10px;
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ===== Modal ===== */
.modal {
  opacity: 0;
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
}

.modal[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
  z-index: 1000;
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.80);
}

.modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  width: calc(100% - 32px);
  max-width: 620px;
  max-height: 85vh;
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  box-shadow: rgba(0, 0, 0, 0.14) 0 6px 16px;
  overflow: hidden;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.modal[data-open="true"] .modal-card {
  transform: translate(-50%, -50%);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  gap: 12px;
}

.modal-header h2 { margin: 0; font-size: 1.1rem; line-height: 1.25; }

.modal-actions { display: flex; align-items: center; gap: 4px; flex: none; }

.modal-copy {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.modal-copy:hover { color: var(--text); background: var(--chip-bg); }

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  color: var(--text);
  flex: none;
}

.modal-body {
  padding: 0 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  max-height: calc(85vh - 64px);
}

.modal-body img, .modal-body video {
  width: 100%;
  height: auto;
  max-height: 46vh;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--thumb-bg);
}

/* Media viewer with thumbnails */
.modal-media { display: flex; flex-direction: column; gap: 8px; }
.modal-stage img, .modal-stage video { display: block; }
.modal-body .modal-stage video { background: #000; }

/* Fixed stage height so switching items doesn't resize the dialog */
.modal-media.has-thumbs .modal-stage { height: 46vh; }
.modal-body .modal-media.has-thumbs .modal-stage > * { height: 100%; max-height: none; }

@media (max-width: 520px) {
  .modal-media.has-thumbs .modal-stage { height: 32vh; }
}

.modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
}

.modal-thumb {
  position: relative;
  flex: none;
  width: 76px;
  height: 54px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--thumb-bg);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.modal-thumb:hover, .modal-thumb[aria-pressed="true"] { opacity: 1; }
.modal-thumb[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--link); }

.modal-body .modal-thumb img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  border: none;
  border-radius: 0;
}

.modal-thumb.is-video::after {
  content: "\25B6";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.3);
}

.modal-body p { margin: 0; line-height: 1.45; color: var(--text); }
.modal-body .meta { color: var(--muted); font-size: 0.88rem; font-weight: 600; }

.chips {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips li {
  font-size: 0.8rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--chip-bg);
}

.modal-links { margin-top: 2px !important; }

::selection { background: var(--select); }

@media (prefers-reduced-motion: reduce) {
  .card, .modal-card, .modal-thumb { transition: none; }
}
