/* ==========================================================================
   Tue Le — personal homepage
   Warm paper, one blue accent, Space Grotesk for anything that names things.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */

:root {
  --bg: #fbfaf7;
  --bg-soft: #f2f0ea;
  --text: #1c1b18;
  --text-2: #4c4a44;
  --text-3: #8a8780;
  --rule: #e3e0d8;
  --rule-2: #cdc9be;
  --accent: #1a5fd0;
  --accent-hover: #12459c;
  --accent-wash: rgba(26, 95, 208, 0.09);
  --chip: #edeae3;
  --live: #a4530f;
  --accepted: #127a43;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shell: 860px;
  --pad: clamp(20px, 5vw, 32px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg: #17171a;
  --bg-soft: #201f23;
  --text: #eceae5;
  --text-2: #b8b5ae;
  --text-3: #85827c;
  --rule: #2c2b30;
  --rule-2: #3d3c42;
  --accent: #7aaeff;
  --accent-hover: #a8c9ff;
  --accent-wash: rgba(122, 174, 255, 0.13);
  --chip: #26252a;
  --live: #e0a45f;
  --accepted: #5cc98c;
}

/* ---------- 2. Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

sup {
  font-size: 0.68em;
  line-height: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--chip);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--rule-2);
  border-radius: 6px;
  z-index: 50;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad) 72px;
}

/* ---------- 3. Top bar / tabs ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 14px;
  margin-bottom: 38px;
  border-bottom: 1px solid var(--rule);
}

.tabs {
  display: flex;
  gap: 5px;
}

.tabs a {
  padding: 6px 13px;
  border-radius: 7px;
  color: var(--text-3);
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.tabs a:hover {
  color: var(--text);
  background: var(--bg-soft);
  text-decoration: none;
}

.tabs a.is-active {
  color: var(--accent);
  background: var(--accent-wash);
  font-weight: 600;
}

.theme-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.theme-btn:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.theme-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-btn .ic-moon,
:root[data-theme="dark"] .theme-btn .ic-sun {
  display: none;
}

:root[data-theme="dark"] .theme-btn .ic-moon {
  display: block;
}

/* ---------- 4. Panels & block headings ---------- */

.panel {
  animation: fade 0.28s var(--ease) both;
}

html.js .panel[hidden] {
  display: none;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel {
    animation: none;
  }
}

.block {
  display: block;
  margin-top: 40px;
}

.block-h,
.panel-h {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.block-h::before,
.panel-h::before {
  content: "";
  width: 18px;
  height: 2px;
  flex: none;
  border-radius: 2px;
  background: var(--accent);
}

.panel-h {
  margin-top: 42px;
}

.panel > .panel-h:first-child {
  margin-top: 0;
}

.panel-note {
  margin: -6px 0 16px 29px;
  font-size: 13.5px;
  color: var(--text-3);
}

.block-foot {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
}

.panel-foot {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
  color: var(--text-3);
}

/* ---------- 5. Home: intro ---------- */

.intro {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.avatar {
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 999px;
  object-fit: cover;
  background: var(--bg-soft);
  box-shadow: 0 0 0 1px var(--rule-2), 0 0 0 5px var(--bg), 0 0 0 6px var(--accent-wash);
}

.intro-id h1 {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.028em;
}

.handles {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: auto;
  align-self: center;
  justify-content: flex-end;
}

.handles a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 31px;
  padding: 0 11px;
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.handles svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: currentColor;
  opacity: 0.75;
  transition: opacity 0.15s var(--ease);
}

.handles a:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
  text-decoration: none;
}

.handles a:hover svg {
  opacity: 1;
}

.lead {
  margin-bottom: 16px;
  font-size: 16.5px;
  line-height: 1.68;
}

/* Sits with the intro paragraphs now, so it needs no rule above it. */
.contact {
  font-size: 16.5px;
}

/* ---------- 6. Home: recently ---------- */

.news-list {
  display: grid;
  gap: 14px;
  padding-left: 22px;
  border-left: 1px solid var(--rule);
}

.news-list li {
  position: relative;
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 14px;
  align-items: baseline;
  font-size: 15px;
}

.news-list li::before {
  content: "";
  position: absolute;
  left: -25.5px;
  top: 0.6em;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 0 0 1.5px var(--rule-2);
}

.news-list li:first-child::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.when {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.news-list .what {
  color: var(--text-2);
}

/* ---------- 7. Publications ---------- */

.pubs {
  display: grid;
}

.pub {
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
}

.pub:first-child {
  padding-top: 0;
}

.pub:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.pub-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.42;
  letter-spacing: -0.008em;
}

.pub-toggle {
  display: block;
  width: 100%;
  position: relative;
  padding: 0 0 0 22px;
  margin: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s var(--ease);
}

.pub-toggle:hover {
  color: var(--accent);
}

.chev {
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 7px;
  height: 7px;
  border-right: 1.8px solid var(--text-3);
  border-bottom: 1.8px solid var(--text-3);
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease), border-color 0.15s var(--ease);
}

.pub-toggle:hover .chev {
  border-color: var(--accent);
}

.pub-toggle[aria-expanded="true"] .chev {
  transform: rotate(45deg) translate(-1px, -1px);
}

.pub-abstract {
  padding: 11px 0 2px 22px;
  font-size: 14.5px;
  line-height: 1.66;
  color: var(--text-2);
}

.pub-abstract p {
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--accent-wash);
}

.abs-note {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}

.pub-authors {
  margin-top: 5px;
  padding-left: 22px;
  font-size: 14.5px;
  color: var(--text-2);
}

.pub-authors b {
  font-weight: 600;
  color: var(--text);
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 14px;
  margin-top: 7px;
  padding-left: 22px;
  font-size: 13.5px;
}

/* Green = accepted / published; the preprint overrides to amber below. */
.venue {
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: 5px;
  color: var(--accepted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.venue-live {
  color: var(--live);
}

/* ---------- 8. Experience rows ---------- */

.rows {
  display: grid;
  gap: 16px;
}

.row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  align-items: baseline;
}

.row .what {
  color: var(--text);
  font-size: 15px;
}

.row strong {
  font-weight: 600;
}

.row .sub {
  display: block;
  margin-top: 2px;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 400;
}

/* ---------- 9. Footer ---------- */

.site-footer {
  margin-top: 52px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- 10. Hidden authoring affordance ---------- */

.edit-hotzone {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 90;
  width: 40px;
  height: 40px;
}

.edit-hotzone:hover,
.edit-hotzone:focus-within,
.edit-hotzone.is-open {
  width: auto;
}

.edit-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px;
  padding: 5px 7px;
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateX(-8px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.edit-hotzone:hover .edit-bar,
.edit-hotzone:focus-within .edit-bar,
.edit-hotzone.is-open .edit-bar {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.edit-bar button {
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.edit-bar button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.edit-status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

[contenteditable="true"] {
  outline: 1px dashed var(--rule-2);
  outline-offset: 4px;
  border-radius: 3px;
}

/* ---------- 11. Small screens ---------- */

@media (max-width: 640px) {
  .shell {
    padding-bottom: 56px;
  }

  .intro {
    flex-wrap: wrap;
    gap: 14px;
  }

  .avatar {
    width: 68px;
    height: 68px;
  }

  .intro-id h1 {
    font-size: 26px;
  }

  .handles {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .news-list li,
  .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .tabs a {
    padding: 6px 10px;
    font-size: 14px;
  }

  .lead {
    font-size: 16px;
  }
}

@media print {
  .topbar,
  .edit-hotzone,
  .site-footer,
  .handles {
    display: none;
  }

  html.js .panel[hidden] {
    display: block;
  }

  .pub-abstract[hidden] {
    display: none;
  }
}
