/* Homepage stylesheet (self-contained).
   The homepage no longer loads index.css — that file is kept as-is for the
   course pages under course/**, which still link it. */

/* ---------- Tokens ---------- */

:root {
  --grad-a: #00b0f0;
  --grad-b: #b338ff;
  --gradient: linear-gradient(90deg, var(--grad-a), var(--grad-b));

  --bg: #f2f2f4;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --border: rgba(24, 24, 40, 0.08);
  --border-strong: rgba(24, 24, 40, 0.16);
  --text: #3d3d48;
  --text-strong: #1c1c24;
  --text-muted: #74747f;
  --link: #5a5cf0;
  --shadow: 0 1px 2px rgba(24, 24, 40, 0.04), 0 4px 16px rgba(24, 24, 40, 0.04);
  --shadow-hover: 0 2px 4px rgba(24, 24, 40, 0.05), 0 12px 32px rgba(24, 24, 40, 0.08);
  --chip-mix: 12%;
  --chip-text-mix: 100%;

  --radius: 14px;
  --font: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Dark tokens: for the OS preference unless the visitor picked light, and for an explicit dark choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101015;
    --surface: #18181f;
    --surface-2: #1f1f28;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #c9c9d4;
    --text-strong: #f2f2f7;
    --text-muted: #8c8c9a;
    --link: #9ea4ff;
    --shadow: none;
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.4);
    --chip-mix: 20%;
    --chip-text-mix: 55%;
  }
}

:root[data-theme="dark"] {
  --bg: #101015;
  --surface: #18181f;
  --surface-2: #1f1f28;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #c9c9d4;
  --text-strong: #f2f2f7;
  --text-muted: #8c8c9a;
  --link: #9ea4ff;
  --shadow: none;
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.4);
  --chip-mix: 20%;
  --chip-text-mix: 55%;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

b,
strong {
  color: var(--text-strong);
  font-weight: 700;
}

::selection {
  background: color-mix(in srgb, var(--grad-b) 25%, transparent);
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 6px;
}

.muted {
  color: var(--text-muted);
}

.at {
  color: var(--text-muted);
  font-weight: 400;
}

.noscript {
  max-width: 640px;
  margin: 64px auto;
  padding: 0 16px;
}

/* ---------- Layout ---------- */

.layout {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 72px 40px 48px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 72px;
}

.sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 32px;
}

.container {
  min-width: 0;
  max-width: 760px;
}

/* ---------- Sidebar ---------- */

.avatar {
  display: block;
  padding: 4px;
  border-radius: 50%;
  background: var(--gradient);
  transition: transform 0.3s ease;
}

.avatar:hover {
  transform: rotate(-3deg) scale(1.03);
}

img.profile {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg);
  background: var(--surface-2);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

a.nav {
  position: relative;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}

a.nav::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 3px;
  background: var(--gradient);
  transform: translateY(-50%);
  transition: height 0.2s ease;
}

a.nav:hover {
  color: var(--text-strong);
  background: var(--surface);
}

a.nav.active {
  color: var(--text-strong);
}

a.nav.active::before {
  height: 60%;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 8px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text-strong);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you'd switch to. */
.icon-sun { display: none; }

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Header ---------- */

.header {
  padding-bottom: 8px;
}

.header-text {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4.4vw, 2.9rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-a));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  width: fit-content;
  transition: background-position 0.8s ease;
}

.header-text:hover {
  background-position: 100% 0;
}

.header p {
  margin: 0;
}

.header .headline {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 4px;
}

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

a.cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

a.cta::after {
  content: '↗';
  font-weight: 400;
  opacity: 0.5;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

a.cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

a.cta:hover::after {
  opacity: 1;
  transform: translate(2px, -2px);
}

a.cta.linkedin:hover { border-color: #0077b5; }

a.cta.cv {
  border-color: transparent;
  background: var(--gradient);
  color: #fff;
}

/* ---------- Sections ---------- */

.section {
  margin-top: 64px;
  scroll-margin-top: 32px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}

.section-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

/* About */

.prose p {
  margin: 0 0 1em;
}

.prose p:first-child {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-strong);
}

.badges {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

a.badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.35rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.badge:hover {
  transform: translateY(-2px) rotate(-4deg);
  box-shadow: var(--shadow-hover);
}

/* Entry cards */

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

.entry {
  position: relative;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.entry::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.entry:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.entry:hover::before {
  opacity: 1;
}

.entry-title {
  font-weight: 700;
  font-size: 1.04rem;
  line-height: 1.45;
  color: var(--text-strong);
}

.entry-subtitle {
  margin-top: 2px;
  font-size: 0.93rem;
  color: var(--text-muted);
}

.detail {
  margin-top: 10px;
  font-size: 0.93rem;
  color: var(--text);
}

.detail ul {
  margin: 0;
  padding-left: 1.2em;
}

.detail li + li {
  margin-top: 2px;
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

/* Abstract disclosure */

details.abstract {
  margin-top: 12px;
}

details.abstract > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  list-style: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--link);
}

details.abstract > summary::-webkit-details-marker {
  display: none;
}

details.abstract > summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}

details.abstract[open] > summary::before {
  transform: rotate(45deg) translate(-2px, -2px);
}

.abstract-body {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.9rem;
  line-height: 1.65;
}

/* Compact list (entries that are just a title + tag, e.g. competitions) */

.row-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  transition: background-color 0.2s ease;
}

.row + .row {
  border-top: 1px solid var(--border);
}

.row:hover {
  background: var(--surface-2);
}

.row-title {
  font-weight: 600;
  color: var(--text-strong);
}

.row .entry-tags {
  flex-shrink: 0;
  margin: 0;
}

/* ---------- Chips: tags and inline link buttons ---------- */

/* Each variant sets --c; the chip tints itself from it. */
span.tag,
a.button {
  --c: var(--link);
  display: inline-block;
  padding: 1px 9px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c) var(--chip-mix), transparent);
  color: color-mix(in srgb, var(--c) var(--chip-text-mix), var(--text-strong));
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  text-decoration: none;
}

span.tag {
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

a.button {
  font-size: 0.86em;
  vertical-align: 1px;
  transition: background-color 0.2s ease;
}

a.button:hover {
  background: color-mix(in srgb, var(--c) calc(var(--chip-mix) * 2), transparent);
}

/* Title links (e.g. project names) read as links rather than chips. */
.entry-title a.button:not(.venue):not(.dbdb) {
  padding: 0;
  background: none;
  font-size: inherit;
  vertical-align: baseline;
  white-space: normal;
  color: var(--text-strong);
  background-image: var(--gradient);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;
  transition: background-size 0.3s ease;
}

.entry-title a.button:not(.venue):not(.dbdb)::after {
  content: ' ↗';
  font-weight: 400;
  color: var(--text-muted);
}

.entry-title a.button:not(.venue):not(.dbdb):hover {
  background-size: 100% 2px;
}

/* Tag colour variants (category -> colour) */
.tag.paper { --c: #16a34a; }
.tag.instructor { --c: #2563eb; }
.tag.co-instructor { --c: #0891b2; }
.tag.product { --c: #0d9488; }
.tag.research-project { --c: #db2777; }
.tag.course-project { --c: #c2410c; }
.tag.side-project { --c: #a16207; }
.tag.gold { --c: #ca8a04; }
.tag.silver { --c: #64748b; }
.tag.finalist { --c: #4d7c0f; }
.tag.participant { --c: #0e7490; }
.tag.upcoming { --c: #9333ea; }

/* Button colour variants */
.button.venue { --c: #ea580c; }
.button.dbdb { --c: #3b6e94; }

/* ---------- Footer ---------- */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer a {
  color: inherit;
  text-decoration: none;
}

.footer a:hover {
  color: var(--text-strong);
}

/* ---------- Load-in motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .header,
  .section {
    animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 70ms);
  }

  @keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
  }
}

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

/* ---------- Mobile ---------- */

@media (max-width: 860px) {
  /* Flatten sidebar + main so the nav can sit under the header and stick to the top. */
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 32px 16px 32px;
  }

  .sidebar,
  .container {
    display: contents;
  }

  .avatar { order: 1; justify-self: start; margin-bottom: 20px; }
  .header { order: 2; }
  .nav-list { order: 3; }
  .sections { order: 4; }
  .footer { order: 5; }

  img.profile {
    width: 104px;
    height: 104px;
    border-width: 3px;
  }

  .theme-toggle {
    position: absolute;
    top: 32px;
    right: 16px;
    margin: 0;
  }

  .nav-list {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    gap: 4px;
    width: auto;
    margin: 24px -16px 0;
    padding: 10px 16px;
    overflow-x: auto;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  a.nav {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.88rem;
  }

  a.nav::before {
    display: none;
  }

  a.nav.active {
    background: var(--text-strong);
    color: var(--bg);
  }

  .section {
    margin-top: 48px;
    scroll-margin-top: 72px;
  }

  .entry {
    padding: 18px;
  }

  .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 18px;
  }

  .footer {
    flex-direction: column;
    margin-top: 56px;
  }
}
