@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Serif:wght@400;500&display=swap');

/* ===============================
   COLOR PALETTE
   =============================== */

/* LIGHT MODE */
:root {
  /* Core */
  --color-bg: #f9f9fa;
  --color-fg: #1c1e21;
  --color-muted: #6e6e73;
  --color-border: #d3d3d8;
  --color-highlight: #e6e8ec;
  --color-code-bg: #f3f3f6;
  --color-expanded-row: #e0e4f4;

  /* Primary accent (violet) */
  --color-accent: #69759A;
  --color-accent-fg: #f9f9fa;
  --accent-hover: #5C688C;
  --accent-active: #515D80;

  /* Links (teal) */
  --color-link: #567C96;
  --link-hover: #496F88;

  /* Status colors */
  --color-green: #547F67;
  --color-yellow: #986B60;
  --color-red: #946875;

  /* Transparency variants */
  --color-border-alpha: rgba(211, 211, 216, 0.7);
}

a {
  color: var(--color-link);
  text-decoration: underline;
}
a:hover {
  color: var(--color-link);
  opacity: 0.85;
}

/* ===============================
   DARK MODE
   =============================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1c1c1e;
    --color-fg: #e2e2e3;
    --color-muted: #9a9aa0;
    --color-border: #3a3a3c;
    --color-highlight: #2a2c31;
    --color-code-bg: #2e2f36;
    --color-expanded-row: #292b31;

    --color-accent: #8f9cb8;
    --color-accent-fg: #1e1f22;
    --accent-hover: #a0adc9;
    --accent-active: #b0bdda;

    --color-link: #9aaacc;
    --link-hover: #aabbdd;

    --color-green: #88b294;
    --color-yellow: #c4ae7a;
    --color-red: #c98989;

    --color-border-alpha: rgba(60, 61, 66, 0.7);
  }

  :root:not([data-theme="light"]) body {
    background: var(--color-bg);
    color: var(--color-fg);
  }

  :root:not([data-theme="light"]) nav {
    background: #2c2c2e;
    border-bottom-color: var(--color-border);
  }

  :root:not([data-theme="light"]) .highlight {
    background-color: #244058;
  }

  :root:not([data-theme="light"]) .card {
    background: #2a2a2c;
    border-color: var(--color-border);
  }
}

:root[data-theme="dark"] {
  --color-bg: #1c1c1e;
  --color-fg: #e2e2e3;
  --color-muted: #9a9aa0;
  --color-border: #3a3a3c;
  --color-highlight: #2a2c31;
  --color-code-bg: #2e2f36;
  --color-expanded-row: #292b31;

  --color-accent: #8f9cb8;
  --color-accent-fg: #1e1f22;
  --accent-hover: #a0adc9;
  --accent-active: #b0bdda;

  --color-link: #9aaacc;
  --link-hover: #aabbdd;

  --color-green: #88b294;
  --color-yellow: #c4ae7a;
  --color-red: #c98989;

  --color-border-alpha: rgba(60, 61, 66, 0.7);
}

:root[data-theme="dark"] body {
  background: var(--color-bg);
  color: var(--color-fg);
}

:root[data-theme="dark"] nav {
  background: #2c2c2e;
  border-bottom-color: var(--color-border);
}

:root[data-theme="dark"] .highlight {
  background-color: #244058;
}

:root[data-theme="dark"] .card {
  background: #2a2a2c;
  border-color: var(--color-border);
}

/* ===============================
   GLOBAL LAYOUT
   =============================== */
html {
  overflow-y: scroll;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  margin: 0;
  padding: 20px;
  line-height: 1.6;
  background: var(--color-bg);
  color: var(--color-fg);
}

.container {
  max-width: 860px;
  margin: 80px auto 40px;
  padding: 0 1rem;
}

.accent-bold {
  color: var(--color-accent);
  font-weight: bold;
}

/* ===============================
   NAVIGATION
   =============================== */
nav {
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px 10px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  box-sizing: border-box;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

nav a {
  color: var(--color-fg);
  font-weight: 600;
  font-size: 1.12em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

nav a:hover {
  color: var(--accent-hover);
}

.nav-link.active {
  color: var(--accent-active);
}

.nav-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.theme-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 2.35rem;
  height: 2.35rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-code-bg);
  color: var(--color-fg);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--color-highlight);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-icon {
  position: absolute;
  width: 1.15rem;
  height: 1.15rem;
  opacity: 0;
  transform: scale(0.82) rotate(-14deg);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.theme-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.theme-toggle[data-theme-current="light"] .theme-icon-sun,
.theme-toggle[data-theme-current="dark"] .theme-icon-moon,
.theme-toggle[data-theme-current="auto"] .theme-icon-auto {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ===============================
   HERO SECTION
   =============================== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 20vh;
  text-align: center;
  padding: 100px 1rem 0;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin: 0 0 0.3em;
}

.hero p {
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 0 1.5em;
}

.cta-btn {
  display: inline-block;
  padding: 0.75em 1.5em;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  transition: opacity 0.15s ease;
}

.cta-btn:hover {
  opacity: 0.85;
}

.sections {
  max-width: 960px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.sections h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5em;
}

/* ===============================
   BUTTONS
   =============================== */
.pdf-switch-btn {
  border: none;
  border-radius: 4px;
  padding: 3px 12px;
  font-size: 0.9em;
  font-weight: 400;
  cursor: pointer;
  margin: 5px 0;
  background: var(--color-accent);
  color: var(--color-accent-fg);
  transition: background 0.15s ease, opacity 0.15s ease;
}

.pdf-switch-btn:hover {
  background: var(--accent-hover);
}

.pdf-switch-btn.active {
  opacity: 0.6;
}

.pdf-switch-btn:active {
  opacity: 0.5;
}

/* ===============================
   PDF VIEWER & CONTENT AREA
   =============================== */
.pdf-wrap {
  width: 100%;
  margin-top: 10px;
}

.pdf-wrap:empty {
  margin: 0;
  padding: 0;
}

.pdf-viewer-switch-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;
  z-index: 2;
  background: var(--color-expanded-row);
  position: relative;
}

.content-area {
  margin-top: 0.75rem;
}

.content-area:empty {
  display: none;
}

.content-area iframe {
  width: 100%;
  height: 80vh;
  border: none;
  border-radius: 4px;
}

.abstract-content {
  background: var(--color-code-bg);
  padding: 0.2rem 0.25rem;
  margin: 0 0 0.75rem 0;
  border-radius: 4px;
  line-height: 1.5;
  color: var(--color-fg);
  font-family: 'IBM Plex Sans', sans-serif;
  text-align: justify;
  text-justify: inter-word;
}

.abstract-content p {
  margin: 0.5rem;
}

/* ===============================
   PROJECT TABLE
   =============================== */
#project-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  table-layout: fixed;
}

#project-table th,
#project-table td {
  font-size: 1em;
  vertical-align: top;
  padding: 0.3em 0;
}

#project-table th {
  background: var(--color-accent);
  color: var(--color-accent-fg);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 2px solid var(--color-accent);
}

#project-table th:first-child,
#project-table td:first-child {
  width: auto;
  white-space: normal;
  word-break: break-word;
  padding-left: 0.5em;
}

#project-table .year-column {
  width: 2.6em;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  padding-right: 0.5em;
}

.clickable-project {
  cursor: pointer;
  font-size: 1em;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.clickable-project:hover {
  color: var(--accent-hover);
  opacity: 0.85;
}

.no-break {
  white-space: nowrap;
}

/* Open Row */
#project-table tr.open td {
  font-weight: bold;
  background: var(--color-expanded-row);
}

#project-table tr.open td:first-child,
#project-table .details-row td {
  border-left: 2px solid var(--color-accent);
}

/* Details Row */
#project-table .details-row td {
  background: var(--color-expanded-row);
  padding: 0 0.5em 0.5em 0.5em;
  border-left: 2px solid var(--color-accent);
  animation: fadeIn 0.25s ease-in-out;
}

#project-table .details-row td > ul {
  margin-top: 0.5em;
}

#project-table .details-row td > a:first-of-type {
  margin-top: 0.5em;
  display: inline-block;
}

#project-table .details-row a {
  display: inline-block;
  margin-right: 8px;
  margin-top: 6px;
}

.project-desc-list {
  padding-left: 1em;
  margin-top: 0.5em;
  margin-bottom: 0.3em;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.highlight {
  background-color: rgba(76, 91, 119, 0.07);
}

/* ===============================
   CARD GRID
   =============================== */
.card-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background-color: var(--color-code-bg);
  transition: transform 0.15s ease, background-color 0.15s ease;
  height: 120px;
}

.card:link,
.card:visited {
  color: inherit;
  text-decoration: none;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 0 var(--color-border-alpha);
}

.card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.card p {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.card a {
  color: var(--color-link);
  font-weight: 600;
}

.card-link {
  text-decoration: none;
  color: inherit;
}

/* ===============================
   IMAGE SCROLLER
   =============================== */
.image-scroller {
  display: flex;
  flex-direction: row;
  gap: 0.6em;
  overflow-x: auto;
  padding: 0 0 1em 0;
  margin-bottom: 1.4em;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.image-scroller::-webkit-scrollbar {
  display: none;
}

.image-scroller-img {
  max-height: 200px;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.06);
  display: block;
  object-fit: contain;
}

.image-scroller-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ===============================
   MUSIC IFRAME
   =============================== */
.music-iframe {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-top: 0.5em;
  margin-bottom: 0.2em;
  background: var(--color-code-bg);
  display: block;
}

.music-iframe-caption {
  font-size: 0.95em;
  color: var(--color-muted);
  margin-bottom: 1.2em;
  margin-top: 0.2em;
  text-align: left;
  font-family: inherit;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.music-iframe-caption a {
  color: var(--color-link);
  text-decoration: underline;
  font-weight: 500;
  margin-right: 0.5em;
}

.music-iframe-caption a:last-child {
  margin-right: 0;
}

/* ===============================
   PROFILE TIMELINE
   =============================== */
.profile-timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

.profile-timeline li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.4rem 0;
  line-height: 1.4;
}

.profile-timeline .year,
.profile-year-narrow {
  display: inline-block;
  margin-left: auto;
  flex: 0 0 7rem;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===============================
   COMPACT LIST
   =============================== */
.compact-list {
  margin: 0 0 1.2em 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  margin: 0.15em 0;
  line-height: 1.35;
  padding: 0;
}

/* ===============================
   SUBHEADING
   =============================== */
.subheading {
  font-size: 1.08em;
  font-weight: 600;
  margin-top: 0.7em;
  margin-bottom: 0.05em;
  color: var(--color-accent);
  letter-spacing: 0.01em;
}

/* ===============================
   PROJECT IMAGES
   =============================== */
.project-expanded-img-wrap {
  text-align: left;
  margin: 0;
  padding: 0;
  display: inline-block;
  background: transparent;
}

.project-expanded-img-wrap img {
  display: block;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 6px;
  background: #fff;
  max-width: 100%;
  height: auto;
}

.project-plot-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: flex-start;
  line-height: 0;
}

/* ===============================
   IMAGE MODAL
   =============================== */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.image-modal-content {
  position: relative;
  text-align: center;
}

.image-caption {
  font-size: 1rem;
  color: #fff;
  margin-top: 10px;
}

.image-modal .close-btn {
  background: #fff;
  color: #000;
  border: none;
  padding: 0.5em 1em;
  cursor: pointer;
  border-radius: 5px;
  margin: 10px auto 0;
  display: block;
}

/* ===============================
   RESPONSIVE - MOBILE
   =============================== */
@media (max-width: 600px) {
  body {
    font-size: 0.9rem;
  }

  .container {
    padding: 0 0.3rem;
    margin: 60px 0 24px 0;
    max-width: 100vw;
  }

  nav {
    width: 100vw;
    max-width: 100vw;
    justify-content: center;
    padding: 8px 10px;
  }

  .nav-links {
    gap: 8px;
  }

  nav a {
    font-size: 1.05em;
  }

  .theme-toggle {
    display: none;
  }

  .hero h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5em;
  }

  .hero p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 1.2em;
  }

  .sections h2,
  .card h3 {
    font-size: 1.3rem;
  }

  .card p {
    font-size: 0.85rem;
  }

  #project-table,
  #project-table th,
  #project-table td {
    font-size: 0.92em;
  }

  .profile-main {
    font-size: 0.89em;
  }

  .pdf-viewer-switch-row {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.3em 0;
  }

  .pdf-wrap {
    overflow: visible !important;
  }
}
