/* ==========================================================================
   Mayanka Medhe, personal site
   Design tokens, layout, components. No framework, no build step.
   ========================================================================== */

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

:root {
  color-scheme: light;

  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-sunk: #F2F2EE;
  --ink: #16171A;
  --muted: #5E6068;
  --rule: #E4E4E0;
  --accent: #0F5C4E;
  --accent-soft: #E6F1ED;
  --shadow: 0 1px 2px rgba(22, 23, 26, .04), 0 8px 24px rgba(22, 23, 26, .06);
  --shadow-lift: 0 2px 4px rgba(22, 23, 26, .06), 0 16px 40px rgba(22, 23, 26, .10);

  --font-display: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --step--1: clamp(.78rem, .76rem + .12vw, .84rem);
  --step-0: clamp(1rem, .97rem + .16vw, 1.0625rem);
  --step-1: clamp(1.13rem, 1.08rem + .26vw, 1.28rem);
  --step-2: clamp(1.35rem, 1.26rem + .44vw, 1.65rem);
  --step-3: clamp(1.75rem, 1.55rem + .95vw, 2.5rem);
  --step-4: clamp(2.25rem, 1.85rem + 1.95vw, 3.6rem);

  --container: 1040px;
  --measure: 68ch;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0E0F11;
    --surface: #16181B;
    --surface-sunk: #1C1F22;
    --ink: #ECEDEE;
    --muted: #9A9DA3;
    --rule: #26282C;
    --accent: #4FD1B5;
    --accent-soft: #14312B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0E0F11;
  --surface: #16181B;
  --surface-sunk: #1C1F22;
  --ink: #ECEDEE;
  --muted: #9A9DA3;
  --rule: #26282C;
  --accent: #4FD1B5;
  --accent-soft: #14312B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .45);
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: .18em;
  text-decoration-thickness: 1px;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
  transition: color .15s ease, border-color .15s ease;
}

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

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

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

/* --- Utilities ------------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.measure {
  max-width: var(--measure);
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--bg);
  padding: .65rem 1rem;
  border: 0;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}

.skip:focus {
  left: 0;
}

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header.is-stuck {
  border-bottom-color: var(--rule);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.75rem;
}

.site-header__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -.025em;
  color: var(--ink);
  border: 0;
  white-space: nowrap;
}

.site-header__name:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(.75rem, 2vw, 1.5rem);
}

.site-nav a {
  color: var(--muted);
  border: 0;
  font-size: var(--step--1);
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a.is-cv {
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .3rem .8rem;
  background: var(--surface);
}

.site-nav a.is-cv:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
}

.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun,
.theme-toggle[data-resolved="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon,
.theme-toggle[data-resolved="dark"] .icon-moon {
  display: none;
}

@media (max-width: 34rem) {
  .site-nav .is-section {
    display: none;
  }
}

/* --- Hero ----------------------------------------------------------------- */

.hero {
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(2rem, 5vw, 3.5rem);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: start;
}

.hero__eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .72rem;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(1.85rem, 1.55rem + 1.15vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 1.25rem;
}

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

.hero__lede {
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.55;
}

.hero__lede strong {
  color: var(--ink);
  font-weight: 500;
}

.hero__lede + .hero__lede {
  margin-top: .85rem;
}

.hero__photo {
  border-radius: var(--radius);
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  box-shadow: var(--shadow);
  background: var(--surface-sunk);
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.75rem;
}

.hero__links a {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--step--1);
  font-weight: 500;
}

.hero__links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero__links svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* Affiliation strip */

.affiliations {
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem .85rem;
  color: var(--muted);
}

.affiliations dt {
  font-family: var(--font-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  opacity: .8;
}

.affiliations dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--ink);
}

.affiliations dt {
  margin-right: .4rem;
}

.affiliations dd + dd::before {
  content: "·";
  color: var(--muted);
  opacity: .5;
  margin-right: .85rem;
}

@media (max-width: 46rem) {
  .hero__grid {
    grid-template-columns: 1fr;
  }

  .hero__photo {
    width: clamp(120px, 34vw, 160px);
    order: -1;
  }
}

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

.section {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
  border-top: 1px solid var(--rule);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.section__head h2 {
  font-size: var(--step-2);
  font-weight: 600;
}

/* --- Work cards ----------------------------------------------------------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: clamp(1rem, 2.5vw, 1.5rem);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--rule));
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}

.card__media img,
.card__media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Two images in one frame: photos sit side by side, wide figures stack. */
.card__media--split,
.card__media--stack {
  display: grid;
  gap: 1px;
  background: var(--rule);
}

.card__media--split {
  grid-template-columns: 1fr 1fr;
}

.card__media--stack {
  grid-template-rows: 1fr 1fr;
}

/* Diagrams carry their own white ground and small type, so they are fitted
   whole rather than cropped, and keep that white ground in both themes. */
.card__media--figure {
  background: #fff;
}

.card__media--figure img {
  object-fit: contain;
  padding: 4px;
  background: #fff;
}

.card__media a {
  display: block;
  border: 0;
  height: 100%;
  min-height: 0;
}

.card__media a:focus-visible {
  outline-offset: -3px;
}

/* Crop anchors for photos whose subject is not centered. */
.card__media img.pos-left {
  object-position: 36% center;
}

.card__media img.pos-high {
  object-position: center 20%;
}

.card__media img.pos-right {
  object-position: 72% center;
}

/* YouTube loops sit over their still and are cropped to fill the slot like a
   photo. Clicks pass through to the link, which opens the video on YouTube. */
.card__media a.yt {
  position: relative;
  overflow: hidden;
  container-type: size;
}

.card__media a.yt iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100cqw, 177.78cqh);
  height: max(100cqh, 56.25cqw);
  transform: translate(-50%, -50%);
  border: 0;
  pointer-events: none;
}

/* Subject sits right of center in the frame. */
.card__media a.yt--right iframe {
  transform: translate(-68%, -50%);
}

/* Placeholder shown until a real file lands in media/work/ */
.card__media::after {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  background:
    repeating-linear-gradient(
      -45deg,
      transparent 0 8px,
      color-mix(in oklab, var(--muted) 7%, transparent) 8px 9px
    );
}

.card__media.is-empty::after {
  display: grid;
}

.card__media.is-empty img {
  display: none;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1.15rem 1.25rem 1.35rem;
  flex: 1;
}

.card__meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: baseline;
}

.card__meta span + span::before {
  content: "·";
  margin-right: .35rem;
  opacity: .55;
}

.card h3 {
  font-size: var(--step-1);
  font-weight: 600;
}

.card h3 a {
  color: inherit;
  border: 0;
}

.card h3 a:hover {
  color: var(--accent);
}

.card__desc {
  color: var(--muted);
  font-size: calc(var(--step-0) * .95);
  line-height: 1.6;
  flex: 1;
}

.metric {
  align-self: flex-start;
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  margin-top: .25rem;
  padding: .3rem .65rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.metric__value {
  font-weight: 700;
}

.metric__label {
  color: color-mix(in oklab, var(--accent) 75%, var(--ink));
  opacity: .85;
}

/* --- Timeline ------------------------------------------------------------- */

.timeline {
  display: grid;
  gap: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  padding-block: 1.35rem;
  border-top: 1px solid var(--rule);
}

.timeline li:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline__when {
  color: var(--muted);
  padding-top: .2rem;
}

.timeline__role {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: .2rem;
}

.timeline__org {
  color: var(--muted);
  display: block;
  margin-bottom: .5rem;
}

.timeline__detail {
  color: var(--muted);
  font-size: calc(var(--step-0) * .95);
  max-width: var(--measure);
}

.badge {
  display: inline-block;
  margin-top: .6rem;
  padding: .25rem .6rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 500;
}

@media (max-width: 40rem) {
  .timeline li {
    grid-template-columns: 1fr;
    gap: .4rem;
  }
}

/* --- Publications --------------------------------------------------------- */

.pubs li {
  padding-block: 1.1rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}

.pubs li:first-child {
  border-top: 0;
  padding-top: 0;
}

.pubs__title {
  font-weight: 500;
  color: var(--ink);
  margin-bottom: .3rem;
}

.pubs__authors,
.pubs__venue {
  color: var(--muted);
  font-size: calc(var(--step-0) * .95);
}

.pubs__authors .self {
  color: var(--ink);
  font-weight: 600;
}

.pubs__venue {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  margin-top: .3rem;
}

.pubs__links,
.card__links {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .55rem;
}

.pubs__links a,
.card__links a {
  padding: .2rem .55rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink);
}

.pubs__links a:hover,
.card__links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Education ------------------------------------------------------------ */

.edu li {
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}

.edu li:first-child {
  border-top: 0;
  padding-top: 0;
}

.edu__school {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -.02em;
}

.edu__degree {
  color: var(--muted);
  display: block;
  margin-top: .15rem;
}

.edu__extra {
  color: var(--muted);
  font-size: calc(var(--step-0) * .95);
  margin-top: .4rem;
}

/* --- Skills --------------------------------------------------------------- */

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
}

.skills h3 {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .75rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.chips li {
  padding: .25rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink);
}

/* --- Volunteering --------------------------------------------------------- */

.volunteer li {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  padding-block: 1rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}

.volunteer li:first-child {
  border-top: 0;
  padding-top: 0;
}

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

.volunteer__what strong {
  font-weight: 500;
}

.volunteer__what span {
  display: block;
  color: var(--muted);
  font-size: calc(var(--step-0) * .95);
  margin-top: .15rem;
}

@media (max-width: 40rem) {
  .volunteer li {
    grid-template-columns: 1fr;
    gap: .3rem;
  }
}

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

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: var(--step--1);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem 1.5rem;
}

.site-footer a {
  color: var(--muted);
  border-bottom-color: var(--rule);
}

.site-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Motion --------------------------------------------------------------- */

/* Content is visible by default. The hidden start state is opt-in, applied only once
   the head script confirms JS is running and motion is allowed, so a failed script,
   a crawler, or Reader mode never gets a blank page. */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}

.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: none;
}

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

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .js-reveal .reveal {
    opacity: 1;
    transform: none;
  }
}

/* --- Print ---------------------------------------------------------------- */

@media print {
  .site-header,
  .theme-toggle,
  .card__media,
  .site-footer {
    display: none;
  }

  .js-reveal .reveal {
    opacity: 1;
    transform: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    break-inside: avoid;
    border-color: #ccc;
  }
}
