/* ============================================================
   Walter Sena — personal site
   Single unified stylesheet. Semantic class names only.
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
  --radius: 0.75rem;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;

  /* Dark is the default palette (also used when JS hasn't set data-theme) */
  --background: oklch(16% 0.012 260);
  --foreground: oklch(96% 0.005 250);
  --surface: oklch(21% 0.014 260);
  --surface-elevated: oklch(25% 0.016 262);
  --hairline: oklch(100% 0 0 / 0.08);
  --primary: oklch(82% 0.14 195);
  --primary-foreground: oklch(16% 0.012 260);
  --glow: oklch(82% 0.14 195 / 0.35);
  --accent: oklch(70% 0.14 295);
  --muted-foreground: oklch(70% 0.018 250);

  --chart-text: #96a0a9;
  --chart-grid: rgba(255, 255, 255, 0.08);
  --chart-tooltip-bg: #1d2229;
  --chart-tooltip-text: #eff2f5;
  --chart-muted-pt: #738292;
}

/* Explicit dark (toggle-selected) — same as default */
:root[data-theme="dark"] {
  --background: oklch(16% 0.012 260);
  --foreground: oklch(96% 0.005 250);
  --surface: oklch(21% 0.014 260);
  --surface-elevated: oklch(25% 0.016 262);
  --hairline: oklch(100% 0 0 / 0.08);
  --primary: oklch(82% 0.14 195);
  --primary-foreground: oklch(16% 0.012 260);
  --glow: oklch(82% 0.14 195 / 0.35);
  --accent: oklch(70% 0.14 295);
  --muted-foreground: oklch(70% 0.018 250);

  --chart-text: #96a0a9;
  --chart-grid: rgba(255, 255, 255, 0.08);
  --chart-tooltip-bg: #1d2229;
  --chart-tooltip-text: #eff2f5;
  --chart-muted-pt: #738292;
}

/* Light mode */
:root[data-theme="light"] {
  --background: oklch(98% 0.004 250);
  --foreground: oklch(22% 0.015 260);
  --surface: oklch(100% 0 0);
  --surface-elevated: oklch(96.5% 0.004 250);
  --hairline: oklch(0% 0 0 / 0.12);
  --primary: oklch(58% 0.12 200);
  --primary-foreground: oklch(99% 0 0);
  --glow: oklch(58% 0.12 200 / 0.18);
  --accent: oklch(52% 0.16 295);
  --muted-foreground: oklch(45% 0.02 260);

  --chart-text: #5a6470;
  --chart-grid: rgba(0, 0, 0, 0.10);
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-text: #1e293b;
  --chart-muted-pt: #9aa6b2;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

svg {
  display: block;
}

/* ---------- Layout primitives ---------- */
.page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 72rem; /* 1152px */
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.main {
  flex: 1;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--hairline);
  background-color: color-mix(in oklab, var(--background) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-header__inner {
  display: flex;
  height: 4rem;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.brand__dot {
  display: inline-block;
  height: 0.5rem;
  width: 0.5rem;
  border-radius: 9999px;
  background-color: var(--primary);
  box-shadow: 0 0 12px var(--glow);
}

.brand__name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.nav__link {
  position: relative;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  color: var(--muted-foreground);
  transition: color 0.2s;
}

.nav__link:hover {
  color: var(--foreground);
}

.nav__link--active {
  color: var(--foreground);
}

.nav__link--active::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: -1px;
  height: 1px;
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--glow);
}

/* Right cluster: nav + contact icons */
.site-header__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-contact {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-left: 0.5rem;
  margin-left: 0.25rem;
  border-left: 1px solid var(--hairline);
}

.header-contact__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  width: 2rem;
  border-radius: 0.375rem;
  color: var(--muted-foreground);
  transition: color 0.2s, background-color 0.2s;
}

.header-contact__link:hover {
  color: var(--primary);
  background-color: color-mix(in oklab, var(--surface) 60%, transparent);
}

.header-contact__link svg {
  height: 1.05rem;
  width: 1.05rem;
}

/* Light/dark theme toggle (icon button in header) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  width: 2rem;
  border-radius: 0.375rem;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
  color: var(--primary);
  background-color: color-mix(in oklab, var(--surface) 60%, transparent);
}

.theme-toggle svg {
  height: 1.1rem;
  width: 1.1rem;
}

/* Show the sun in light mode, the moon in dark mode */
.theme-toggle .theme-toggle__sun { display: none; }
.theme-toggle .theme-toggle__moon { display: block; }
:root[data-theme="light"] .theme-toggle .theme-toggle__sun { display: block; }
:root[data-theme="light"] .theme-toggle .theme-toggle__moon { display: none; }

/* ---------- Decorative grain ---------- */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: radial-gradient(
      ellipse at 20% 0%,
      var(--primary) 0%,
      transparent 55%
    ),
    radial-gradient(ellipse at 90% 30%, var(--accent) 0%, transparent 60%);
}

.grain--soft {
  opacity: 0.08;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 9999px;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.btn--primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 0 24px var(--glow);
  transition: transform 0.2s;
}

.btn--primary:hover {
  transform: translateY(-2px);
}

.btn--ghost {
  border: 1px solid var(--hairline);
  background-color: var(--surface);
  color: var(--foreground);
  transition: background-color 0.2s;
}

.btn--ghost:hover {
  background-color: var(--surface-elevated);
}

.btn__icon {
  height: 1rem;
  width: 1rem;
  transition: transform 0.2s;
}

.btn--primary:hover .btn__icon {
  transform: translateX(2px);
}

/* ---------- Image placeholders ---------- */
.placeholder {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background-color: var(--surface);
}

.placeholder__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
}

.placeholder__icon {
  height: 1.5rem;
  width: 1.5rem;
  opacity: 0.5;
}

.placeholder__label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Aspect-ratio variants */
.ratio-3-4 {
  aspect-ratio: 3 / 4;
}
.ratio-4-3 {
  aspect-ratio: 4 / 3;
}
.ratio-16-9 {
  aspect-ratio: 16 / 9;
}
.ratio-1-1 {
  aspect-ratio: 1 / 1;
}

/* ---------- Home: hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
}

.hero__inner {
  position: relative;
  display: grid;
  gap: 2.5rem;
  padding-block: 5rem;
}

.hero__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--primary);
}

.eyebrow__rule {
  height: 1px;
  width: 2rem;
  background-color: var(--primary);
}

.hero__title {
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

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

.hero__lede {
  margin-top: 1.5rem;
  max-width: 36rem;
  font-size: 1rem;
  line-height: 1.625;
  color: var(--muted-foreground);
  text-wrap: balance;
}

.hero__lede .strong {
  color: var(--foreground);
}

.hero__actions {
  margin-top: 2.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero__media {
  position: relative;
}

.hero__glow {
  display: none;
  position: absolute;
  bottom: -1rem;
  left: -1rem;
  height: 6rem;
  width: 6rem;
  border-radius: 9999px;
  border: 1px solid color-mix(in oklab, var(--primary) 40%, transparent);
  background-color: color-mix(in oklab, var(--primary) 10%, transparent);
  filter: blur(40px);
}

/* ---------- Home: feature row ---------- */
.features {
  border-top: 1px solid var(--hairline);
}

.features__grid {
  display: grid;
  gap: 1px;
  background-color: var(--hairline);
}

.feature {
  background-color: var(--background);
  padding: 2rem;
}

.feature__kicker {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
}

.feature__title {
  margin-top: 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.feature__text {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--muted-foreground);
}

/* ---------- Story / article ---------- */
.article {
  max-width: 48rem;
  margin-inline: auto;
  padding-block: 4rem;
}

.article__title {
  margin-top: 1rem;
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.prose {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  font-size: 1rem;
  line-height: 1.625;
  color: var(--muted-foreground);
}

.prose .strong {
  color: var(--foreground);
}

.prose .placeholder {
  width: 100%;
}

.placeholder--narrow {
  max-width: 28rem;
}

/* ---------- CV ---------- */
.cv {
  max-width: 64rem;
  margin-inline: auto;
  padding-block: 2.5rem;
}

.cv__groups {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Each section is a card, matching the entry cards */
.cv__section {
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  background-color: color-mix(in oklab, var(--surface) 55%, transparent);
}

.cv__section.is-open {
  background-color: color-mix(in oklab, var(--surface) 85%, transparent);
  border-color: var(--primary);
}

/* Section-level accordion */
.cv__section-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1rem;
  text-align: left;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
}

.cv__section-toggle:hover {
  background-color: color-mix(in oklab, var(--surface) 75%, transparent);
}

.cv__section.is-open > .cv__section-toggle {
  border-radius: 0.5rem 0.5rem 0 0;
}

.cv__section.is-open > .cv__section-toggle:hover {
  background-color: color-mix(in oklab, var(--surface) 95%, transparent);
}

.cv__heading {
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--primary);
}

.cv__section-chevron {
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
  color: var(--primary);
  transition: transform 0.3s;
}

/* Collapsible section body */
.cv__section-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease-out, opacity 0.3s ease-out;
}

.cv__section-panel-inner {
  overflow: hidden;
  padding: 0 1rem 1rem;
}

/* Open state */
.cv__section.is-open .cv__section-panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

.cv__section.is-open .cv__section-chevron {
  transform: rotate(180deg);
}

/* Always-open section (e.g. Summary): heading, no toggle, no animation */
.cv__section--static {
  display: block;
}

.cv__heading--static {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem 0;
}

.cv__section-body {
  display: block;
  padding: 0.75rem 1rem 1rem;
}

.cv__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cv__item {
  scroll-margin-top: 8rem;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  background-color: color-mix(in oklab, var(--surface) 55%, transparent);
}

/* Deep-link target: keep clear of the sticky header, then briefly flash */
.cv__section {
  scroll-margin-top: 6rem;
}

@keyframes cv-flash {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  15% { box-shadow: 0 0 0 3px var(--primary); }
  60% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 55%, transparent); }
}

.cv__flash {
  animation: cv-flash 1.8s ease-out 1;
}

/* Accordion trigger */
.cv__trigger {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  padding: 1.1rem 0.9rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
}

.cv__trigger:hover {
  background-color: color-mix(in oklab, var(--surface) 75%, transparent);
}

.cv__heads {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

/* Title keeps a readable minimum; when it can't sit beside the pills, the
   pills wrap to their own row (instead of crushing the title). */
.cv__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  flex: 1 1 60%;
  min-width: min(100%, 12rem);
}

.cv__title-row .cv__role-title {
  overflow-wrap: break-word;
}

.cv__chevron {
  margin-top: 0.25rem;
  height: 1rem;
  width: 1rem;
  flex-shrink: 0;
  color: var(--muted-foreground);
  transition: transform 0.3s;
}

/* Accordion panel — collapsed by default, expands via .is-open */
.cv__panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease-out, opacity 0.3s ease-out;
}

.cv__panel-inner {
  overflow: hidden;
}

.cv__panel-content {
  padding: 0.25rem 0.5rem 1.25rem;
}

/* Entry title (the bold heading inside a trigger) */
.cv__role-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--foreground);
}

/* Panel content: simple single-column flow for dense CV data */
.cv__panel-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  grid-template-columns: none;
}

/* Open state */
.cv__item.is-open > .cv__panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* Open entry brightens above the resting card so it clearly contrasts.
   Scoped to the open item's OWN trigger/content (> chain) so nested opens don't stack the tint. */
.cv__item.is-open {
  background-color: var(--surface-elevated);
  border-color: var(--primary);
}

.cv__item.is-open > .cv__trigger {
  border-radius: 0.5rem 0.5rem 0 0;
  padding-inline: 0.9rem;
}

.cv__item.is-open > .cv__trigger:hover {
  background-color: color-mix(in oklab, var(--surface-elevated) 88%, var(--foreground) 12%);
}

.cv__item.is-open > .cv__panel > .cv__panel-inner > .cv__panel-content {
  padding-inline: 0.9rem;
}

.cv__item.is-open > .cv__trigger .cv__chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

/* Role / description prose inside a panel */
.cv__role {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

/* Institution — department subtitle, and organization line, inside expanded cards */
.cv__subtitle {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--foreground);
}

.cv__org {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
}

.cv__subtitle + .cv__org {
  margin-top: -0.05rem;
}

/* Meta chips (dates, hours, by, venue…) — pinned to the right, never shrink.
   The title text yields space first; these stack (wrap) only when they can't fit one row. */
.cv__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 0 0 auto;
  justify-content: flex-end;
  align-items: baseline;
}

.cv__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  background-color: var(--surface);
  font-size: 0.75rem;
}

.cv__chip-k {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.cv__chip-v {
  font-family: var(--font-mono);
  color: var(--foreground);
}

/* Standardized widths per title-row pill type, so every pill of a type aligns.
   The value cell flexes to fill the fixed chip width. */
.cv__chip--period,
.cv__chip--hours,
.cv__chip--date {
  justify-content: space-between;
}

.cv__chip--period { width: min(13.5rem, 100%); }
.cv__chip--date   { width: min(8.5rem, 100%); }
.cv__chip--hours  { width: min(6.5rem, 100%); }

.cv__chip--period .cv__chip-v,
.cv__chip--hours .cv__chip-v,
.cv__chip--date .cv__chip-v {
  text-align: right;
}

/* Relocated detail pills (By / Venue) at the top of expanded content */
.cv__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Links */
.cv__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--primary);
  font-size: 0.85rem;
  transition: opacity 0.2s;
}

.cv__link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

.cv__link--sm {
  font-size: 0.78rem;
}

.cv__ext-icon {
  height: 0.8rem;
  width: 0.8rem;
  flex-shrink: 0;
}

.cv__source {
  margin: 0;
}

/* Embedded certificate / document image */
.cv__media {
  margin: 0;
  max-width: 26rem;
}

.cv__media-link {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: zoom-in;
}

.cv__media-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background-color: var(--surface);
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* Hover affordance: dim slightly + zoom, and reveal a magnifier hint */
.cv__media-link:hover .cv__media-img,
.cv__media-link:focus-visible .cv__media-img {
  transform: scale(1.04);
  filter: brightness(0.6);
}

.cv__media-link::after {
  content: "";
  position: absolute;
  inset: 0;
  display: flex;
  opacity: 0;
  transition: opacity 0.3s ease;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 2.25rem 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3M11 8v6M8 11h6'/%3E%3C/svg%3E");
}

.cv__media-link:hover::after,
.cv__media-link:focus-visible::after {
  opacity: 1;
}

/* Thumbnail with descriptive text alongside it */
.cv__media-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
}

.cv__media-row .cv__media {
  flex: 0 0 auto;
}

.cv__media-desc {
  flex: 1 1 16rem;
  min-width: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

/* Multiple variant thumbnails (e.g. Original / English) laid side by side */
.cv__media-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.cv__media-group .cv__media {
  flex: 0 1 13rem;
  max-width: 13rem;
}

/* Figure-set thumbnail: a small badge marks it as a multi-figure gallery */
.cv__media--figures {
  max-width: 18rem;
}

.cv__media-badge {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: 0.4rem;
  background-color: color-mix(in oklab, var(--background) 72%, #000 28%);
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.cv__media-badge svg { height: 0.85rem; width: 0.85rem; }

/* Placeholder shown until the real figure image is uploaded */
.cv__media-link--broken {
  cursor: zoom-in;
}

.cv__media-link--broken .cv__media-img {
  display: none;
}

.cv__media-link--broken::before {
  content: "Figures — preview pending";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 9rem;
  padding: 1rem;
  text-align: center;
  border: 1px dashed color-mix(in oklab, var(--foreground) 28%, transparent);
  border-radius: var(--radius);
  background-color: color-mix(in oklab, var(--surface) 60%, transparent);
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

/* ---------- Lightbox (figure carousel with side legend) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 4.5rem;
  background-color: color-mix(in oklab, var(--background) 80%, #000 20%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lightbox.is-open {
  display: flex;
}

.lightbox__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(94vw, 1180px);
  max-height: 90vh;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background-color: var(--surface);
}

/* Top bar (rounds the panel's top corners; panel itself can't clip arrows) */
.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  flex-shrink: 0;
}

.lightbox__bar-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  min-width: 0;
}

.lightbox__title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
}

.lightbox__article {
  font-size: 0.95rem;
  color: var(--primary);
  white-space: nowrap;
}

.lightbox.has-source .lightbox__article { display: inline; }
.lightbox__article { display: none; }

.lightbox__bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lightbox__zoom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lightbox__zoombtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.6rem;
  width: 1.6rem;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.2s;
}

.lightbox__zoombtn:hover { color: var(--primary); }
.lightbox__zoombtn svg { height: 1.15rem; width: 1.15rem; }

.lightbox__slider {
  width: 11rem;
  max-width: 26vw;
  accent-color: var(--primary);
  cursor: pointer;
}

.lightbox__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.1rem;
  width: 2.1rem;
  border-radius: 0.45rem;
  color: var(--foreground);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.lightbox__icon:hover {
  background-color: var(--surface-elevated);
  color: var(--primary);
}

.lightbox__icon svg { height: 1.35rem; width: 1.35rem; }

/* Body: figure on the left, legend panel on the right */
.lightbox__body {
  display: flex;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.lightbox__figure {
  flex: 1 1 64%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
  background-color: var(--surface);
  touch-action: none;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;
  transform-origin: center center;
  transition: transform 0.18s ease-out;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox.is-zoomed .lightbox__img { cursor: grab; }
.lightbox.is-panning .lightbox__img { cursor: grabbing; transition: none; }

/* Placeholder when a figure image hasn't been uploaded yet */
.lightbox.img-broken .lightbox__img { display: none; }
.lightbox.img-broken .lightbox__figure::after {
  content: "Figure preview pending — upload the image to display it here.";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 16rem;
  padding: 2rem;
  text-align: center;
  border: 1px dashed color-mix(in oklab, var(--foreground) 25%, transparent);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 0.95rem;
}

.lightbox__legend {
  flex: 1 1 36%;
  min-width: 0;
  max-width: 24rem;
  padding: 1.25rem 1.25rem 1.5rem;
  border-left: 1px solid var(--hairline);
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--foreground);
}

.lightbox:not(.has-legend) .lightbox__legend { display: none; }

.lightbox__msg {
  display: none;
  margin: auto;
  padding: 3rem 2rem;
  max-width: 30rem;
  text-align: center;
  color: var(--foreground);
  font-size: 0.95rem;
  line-height: 1.6;
}

.lightbox__msg a { color: var(--primary); }

/* Circular prev/next, half-outside the panel edges */
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  height: 3rem;
  width: 3rem;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background-color: var(--surface-elevated);
  color: var(--foreground);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s, color 0.2s;
  z-index: 3;
}

.lightbox__nav:hover { background-color: var(--primary); color: var(--primary-foreground); }
.lightbox__nav svg { height: 1.5rem; width: 1.5rem; }
.lightbox__nav--prev { left: -1.5rem; }
.lightbox__nav--next { right: -1.5rem; }
.lightbox.is-multi .lightbox__nav { display: inline-flex; }

@media (max-width: 720px) {
  .lightbox { padding: 1rem 2.5rem; }
  .lightbox__body { flex-direction: column; }
  .lightbox__legend {
    flex: none;
    max-width: none;
    border-left: none;
    border-top: 1px solid var(--hairline);
    max-height: 30vh;
  }
  .lightbox__img { max-height: 50vh; }
  .lightbox__slider { width: 7rem; }
}

/* Alma-mater stats */
.cv__stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cv__stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cv__stat-label {
  font-size: 0.78rem;
  color: var(--muted-foreground);
}

.cv__stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--foreground);
}

/* Expandable stat that reveals the ranking chart */
.cv__stat--expand {
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  background-color: color-mix(in oklab, var(--surface) 55%, transparent);
}

.cv__stat--expand.is-open {
  background-color: var(--surface-elevated);
  border-color: var(--primary);
}

.cv__chart-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  padding: 0.85rem 0.9rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
}

.cv__chart-toggle:hover {
  background-color: color-mix(in oklab, var(--surface) 75%, transparent);
}

.cv__stat--expand.is-open > .cv__chart-toggle {
  border-radius: 0.5rem 0.5rem 0 0;
}

.cv__chart-toggle-right {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.cv__chart-toggle .cv__chevron {
  margin-top: 0;
}

.cv__stat--expand.is-open .cv__chart-toggle .cv__chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.cv__chart-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease-out, opacity 0.3s ease-out;
}

.cv__stat--expand.is-open .cv__chart-panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

.cv__chart-panel-inner {
  overflow: hidden;
}

.cv__chart-frame {
  padding: 0.9rem;
}

.cv__chart {
  width: 100%;
  height: 26rem;
  overflow: hidden;
}

/* Nested (level-3) accordion list — cards, same as top level, just slightly inset */
.cv__list--nested {
  margin-top: 0.5rem;
  gap: 0.6rem;
}

.cv__item--sub > .cv__trigger {
  padding: 0.8rem 0.6rem;
}

.cv__item--sub .cv__role-title {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--foreground);
}

/* Content-less entries (only chips, nothing to expand): render exactly like
   normal cards. No chevron, so reserve its width on the right of .cv__heads
   (chevron 1rem + trigger gap 1rem) so the pills align with expandable entries. */
.cv__item--static > .cv__trigger--static {
  cursor: default;
}

.cv__item--static > .cv__trigger--static > .cv__heads {
  padding-right: 2rem;
}

.cv__item--static > .cv__trigger--static:hover {
  background-color: color-mix(in oklab, var(--surface) 75%, transparent);
}

/* Permanently-open, flat like Summary: no card border or inner divider,
   sits directly on the section background as one continuous surface. */
.cv__item--flat {
  border: none;
  border-radius: 0;
  background-color: transparent;
}

.cv__static-head {
  padding: 0 0 0.5rem;
}

.cv__static-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ---------- CV header & informational sections ---------- */
.cv__header {
  margin-bottom: 2.5rem;
}

.cv__name {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.cv__tagline {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

.cv__contact {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cv__contact-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.cv__contact-label {
  min-width: 4rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.cv__summary {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted-foreground);
  max-width: 52rem;
}

/* Public Profile — 2×2 card grid */
.cv__pp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  max-width: 38rem;
}

.cv__pp-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  background-color: color-mix(in oklab, var(--surface) 55%, transparent);
  color: var(--foreground);
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.cv__pp-card:hover {
  background-color: var(--surface-elevated);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.cv__pp-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  color: var(--primary);
}

.cv__pp-icon svg {
  width: 100%;
  height: 100%;
}

.cv__pp-name {
  font-size: 0.92rem;
  font-weight: 500;
}

@media (max-width: 520px) {
  .cv__pp-grid { grid-template-columns: 1fr; }
}

.cv__profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.cv__profile-item {
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-block: 2rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* Top row: icon clusters (profiles | contact) */
.footer__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2rem;
}

.footer__icons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  width: 2.25rem;
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  color: var(--muted-foreground);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.footer__icon:hover {
  color: var(--primary);
  border-color: color-mix(in oklab, var(--primary) 40%, transparent);
  background-color: color-mix(in oklab, var(--surface) 70%, transparent);
}

.footer__icon svg {
  height: 1.1rem;
  width: 1.1rem;
}

/* Bottom row: copyright + place */
.footer__bottom {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.site-footer__place {
  letter-spacing: 0.025em;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 640px) {
  .footer__bottom {
    flex-direction: row;
    align-items: center;
  }

  .footer__top {
    justify-content: space-between;
  }
}

@media (min-width: 768px) {
  .hero__inner {
    grid-template-columns: 1.2fr 1fr;
    gap: 4rem;
    padding-block: 7rem;
  }

  .hero__title {
    font-size: 3.75rem;
  }

  .hero__lede {
    font-size: 1.125rem;
  }

  .hero__glow {
    display: block;
  }

  .features__grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .article {
    padding-block: 6rem;
  }

  .article__title {
    font-size: 3rem;
  }

  .cv {
    padding-block: 3.5rem;
  }

  .cv__name {
    font-size: 2.5rem;
  }
}
