/* ============================================================
   Sciencemj — site pages (CV-style layout)
   Same design tokens as the live site; calmer, list-first layout.
   No cards, mono for dates and meta, one marquee in the profile.
   ============================================================ */

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

/* Every divider on the page reads from these two, so weight and colour are
   tunable in one place. --border-2 is the stronger of the two token borders. */
:root {
  --rule-color: var(--muted-2);
  --rule: 1px solid var(--rule-color);
  --rule-strong: 2px solid var(--rule-color);
}

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

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

a { color: inherit; }

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

.wrap { max-width: 820px; margin: 0 auto; padding-inline: var(--s-5); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: var(--s-2) var(--s-4); border-radius: 0 0 var(--r-sm) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

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

/* ---------- Nav ---------- */

.nav {
  position: sticky; top: 0; z-index: 20; overflow: hidden;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: var(--rule);
  /* pages.js writes --glow-x/--glow-y on pointermove */
  --glow-x: 50%; --glow-y: 50%;
  --glow-tint: color-mix(in srgb, var(--accent) 20%, transparent);
}
[data-theme="dark"] .nav { --glow-tint: color-mix(in srgb, var(--accent) 30%, transparent); }

.nav::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(220px circle at var(--glow-x) var(--glow-y),
    var(--glow-tint), transparent 70%);
  opacity: 0; transition: opacity .4s ease;
}
.nav:hover::after, .nav:focus-within::after { opacity: 1; }

.nav-in {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); min-height: 56px;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display); font-weight: 600; text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-mk {
  width: 22px; height: 22px; border-radius: var(--r-xs);
  background: var(--grad); display: grid; place-items: center;
}
.brand-mk svg { width: 16px; height: 16px; }
.brand-accent { color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: var(--s-4); }
.nav-link {
  font-size: var(--text-sm); color: var(--muted); text-decoration: none;
}
.nav-link:hover { color: var(--ink); }
.nav-link[aria-current="page"] {
  color: var(--ink); border-bottom: 2px solid var(--accent); padding-bottom: 2px;
}

.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: none; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--ink-2); cursor: pointer; padding: 0;
}
.icon-btn:hover { border-color: var(--border-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- Profile ---------- */

.profile { padding-block: var(--s-7) var(--s-6); }

.profile-head {
  display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-4);
}
.profile-mark {
  flex: none; width: 52px; height: 52px; border-radius: var(--r-md);
  background: var(--grad); display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.profile-mark svg { width: 34px; height: 34px; }

.profile-name {
  font-family: var(--font-display); font-size: var(--text-2xl);
  font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.15;
}
.profile-role {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--accent); letter-spacing: 0.02em; margin: var(--s-1) 0 0;
}
.profile-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) 224px;
  gap: var(--s-6); align-items: start;
}
.profile-bio { margin: 0; color: var(--ink-2); }
.profile-bio + .profile-bio { margin-top: var(--s-3); }

.profile-rail { border-left: var(--rule); padding-left: var(--s-5); }
.rail-title {
  font-family: var(--font-display); font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin: 0 0 var(--s-3);
}
.rail-links { display: grid; gap: var(--s-2); }
.rail-links a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none;
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.02em;
}
.rail-links a:hover {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}
.rail-links svg { width: 17px; height: 17px; }

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

.skills-marquee {
  margin-top: var(--s-5); padding-top: var(--s-4);
  border-top: 1px dashed var(--rule-color);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}
.skills-track { display: flex; width: max-content; animation: marquee 42s linear infinite; }
.skills-set { display: flex; flex-wrap: nowrap; gap: var(--s-2); padding-right: var(--s-2); }
.skills-marquee:hover .skills-track,
.skills-marquee:focus-within .skills-track { animation-play-state: paused; }

@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- Sub-page header ---------- */

.page-head { padding-block: var(--s-7) var(--s-5); }
.page-title {
  font-family: var(--font-display); font-size: var(--text-3xl);
  font-weight: 600; letter-spacing: -0.02em; margin: 0;
}
.page-lead { margin: var(--s-3) 0 0; color: var(--ink-2); max-width: 62ch; }

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

.section { padding-block: var(--s-6); border-top: var(--rule-strong); }

/* ---------- "More" link ---------- */

.more {
  display: inline-flex; align-items: center;
  margin-top: var(--s-5);
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--border-2); border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-4);
}
.more:hover { border-color: var(--accent); background: var(--accent-soft); }

.sec-title {
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin: 0 0 var(--s-5);
}

/* ---------- Rows ---------- */

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-5); }

.row { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-4); }
.row--proj { grid-template-columns: 128px 1fr; gap: var(--s-5); }

/* Dated rows read body-first with the date trailing at the right edge. The
   contact page keeps the plain .row, where that column is a label, not a date. */
.row--dated { grid-template-columns: 1fr auto; }
.row--dated .row-body { grid-column: 1; grid-row: 1; }
.row--dated .row-when { grid-column: 2; grid-row: 1; text-align: right; }

.row-when {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--muted); line-height: 1.5; padding-top: 4px; white-space: nowrap;
}

.row-body { min-width: 0; }

.row-title {
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: 500;
  color: var(--ink); text-decoration: none; letter-spacing: -0.01em;
  display: inline-block; line-height: 1.4;
}
a.row-title:hover { color: var(--accent); }

.row-org { font-size: var(--text-sm); color: var(--ink-2); margin: 2px 0 0; }
.row-desc { margin: var(--s-1) 0 0; color: var(--ink-2); max-width: 62ch; }

.row-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3);
  margin-top: var(--s-2); font-size: var(--text-xs);
}
.row-kind, .row-meta { font-family: var(--font-mono); color: var(--muted); }
.row-links { display: inline-flex; gap: var(--s-3); }
.row-links a {
  font-family: var(--font-mono); color: var(--accent); text-decoration: none;
}
.row-links a:hover { text-decoration: underline; }

.row-tags { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); }
.tag, .skill {
  font-size: var(--text-xs); color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 1px var(--s-2); white-space: nowrap;
}

/* ---------- Project thumbnails ---------- */

.proj-thumb-link { display: block; text-decoration: none; }
.proj-thumb {
  /* height:auto is required — the img width/height attributes are presentational
     hints, and a definite height would win over aspect-ratio. */
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.proj-thumb--none {
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted-2);
}

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

.site-footer {
  border-top: var(--rule-strong);
  margin-top: var(--s-6); padding-block: var(--s-5) var(--s-7);
  font-size: var(--text-xs); color: var(--muted);
}
.site-footer-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.mono { font-family: var(--font-mono); }

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

@media (prefers-reduced-motion: reduce) {
  .nav::after { transition: none; }
  .skills-track { animation: none; width: auto; }
  .skills-set { flex-wrap: wrap; }
  .skills-set[aria-hidden="true"] { display: none; }
}

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

@media (max-width: 720px) {
  .profile-cols { grid-template-columns: 1fr; gap: var(--s-5); }
  .profile-rail {
    border-left: 0; border-top: var(--rule);
    padding-left: 0; padding-top: var(--s-4);
  }
}

@media (max-width: 640px) {
  .profile { padding-block: var(--s-6) var(--s-5); }
  .profile-mark { width: 44px; height: 44px; }
  .profile-mark svg { width: 28px; height: 28px; }
  .row { grid-template-columns: 1fr; gap: var(--s-2); }
  .row--proj { grid-template-columns: 88px 1fr; gap: var(--s-4); }
  .row-when { padding-top: 0; }
  /* Too narrow to sit two columns side by side — the date goes back on top. */
  .row--dated { grid-template-columns: 1fr; }
  .row--dated .row-body, .row--dated .row-when { grid-column: 1; grid-row: auto; }
  .row--dated .row-when { text-align: left; }
  /* The nav links are the only way between pages — keep them on small screens. */
  .nav-right { gap: var(--s-3); }
  .nav-link { font-size: var(--text-xs); }
  .brand-name { display: none; }
}
