/* ---------------------------------------------------------------------------
   Sebo Diaz — personal site
   Retro terminal, ice palette: cool near-white paper by day, cold near-black
   with steel-blue phosphor by night.
   Fully monospace (JetBrains Mono, a free stand-in for Berkeley Mono).
--------------------------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --fg: #1f2328;
  --fg-muted: #59636e;
  --border: #d1d9e0;
  --accent: #0969da;
  --accent-2: #c2277e;
  --accent-soft: rgba(9, 105, 218, 0.35);
  --glow: none;
  --selection: #fbd0e8;
  --radius: 2px;

  --code-comment: #6e7781;
  --code-keyword: #cf222e;
  --code-string: #0a3069;
  --code-number: #0550ae;
  --code-function: #8250df;
  --code-class: #116329;

  --display: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", "Fira Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0f1216;
  --bg-subtle: #181d24;
  --fg: #e5e9ee;
  --fg-muted: #8b97a5;
  --border: #2a323c;
  --accent: #8fc1e8;
  --accent-2: #ff5fa2;
  --accent-soft: rgba(143, 193, 232, 0.4);
  --glow: 0 0 8px rgba(255, 95, 162, 0.55);
  --selection: #47203a;

  --code-comment: #8b949e;
  --code-keyword: #ff7b72;
  --code-string: #a5d6ff;
  --code-number: #79c0ff;
  --code-function: #d2a8ff;
  --code-class: #7ee787;
}

/* ------------------------------------------------------------------ base */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
}

::selection {
  background: var(--selection);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

/* links inside running text carry a quiet permanent underline */
.article-body a,
.intro-text > p:not(.intro-email):not(.intro-social) a,
.home-section p a {
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 0.16em;
}

.article-body a:hover,
.intro-text > p:not(.intro-email):not(.intro-social) a:hover,
.home-section p a:hover {
  text-decoration-color: var(--accent);
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, var(--accent), var(--accent-2)) 1;
}

.site-nav {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--fg);
}

.site-name:hover {
  text-decoration: none;
  color: var(--accent);
}

.cursor {
  color: var(--accent-2);
  text-shadow: var(--glow);
  margin-left: 2px;
  animation: blink 1.2s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.nav-links a {
  font-family: var(--mono);
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

#theme-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  cursor: pointer;
}

#theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
}

/* show the icon for the theme you would switch TO */
[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon {
  display: none;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--fg-muted);
  text-align: center;
}

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

/* ascii margin texture: denser toward the page edges, silent under the
   text column — a typographic vignette that focuses the center */
.ascii-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  contain: strict;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 14px;
  white-space: pre;
  color: var(--fg-muted);
  opacity: 0.5;
  /* soften the top and bottom so the panels feel lit from the middle */
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}

[data-theme="dark"] .ascii-bg {
  opacity: 0.55;
}

/* ------------------------------------------------------------- homepage */

.intro {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.profile-pic {
  width: 150px;
  flex-shrink: 0;
  border-radius: var(--radius);
}

.intro-text h1 {
  margin: 0 0 0.15rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.intro-email {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}

.email-sep {
  color: var(--border);
}

.intro-text p {
  margin: 0 0 0.6rem;
}

.intro-social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.92rem;
}

.home-section {
  margin-top: 2.25rem;
}

.home-section h2 {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin: 0 0 1rem;
}

/* the "## " is the terminal wink — comment syntax as section marker */
.home-section h2::before {
  content: "## ";
  color: var(--accent);
}

.home-section ul {
  margin: 0;
  padding-left: 1.2rem;
}

.home-section li {
  margin-bottom: 0.3rem;
}

.news-list {
  list-style: none;
  padding: 0 !important;
}

.news-list li {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.news-date {
  font-family: var(--mono);
  flex: 0 0 5.5rem;
  color: var(--fg-muted);
  font-size: 0.8rem;
  padding-top: 0.1em;
}

/* ----------------------------------------------------------- publications */

.pub {
  display: flex;
  gap: 1.4rem;
  padding: 1.25rem 0;
}

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

.pub-thumb {
  flex: 0 0 170px;
  align-self: flex-start;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pub-thumb:hover {
  border-color: var(--fg-muted);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.pub-thumb img {
  display: block;
  width: 100%;
}

.pub-text {
  min-width: 0;
}

.pub-text p {
  margin: 0 0 0.35rem;
}

.pub-title {
  font-weight: 600;
  line-height: 1.4;
}

.pub-authors {
  font-size: 0.88rem;
  color: var(--fg-muted);
}

.pub-authors strong {
  color: var(--fg);
}

.pub-description {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 0.4rem !important;
}

.pub-links {
  margin-top: 0.5rem !important;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.88rem;
}

.venue-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.venue-tag::before {
  content: "[";
  color: var(--accent);
}

.venue-tag::after {
  content: "]";
  color: var(--accent);
}

/* --------------------------------------------------- notes/projects index */

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0 0 2rem;
  color: var(--fg-muted);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-item {
  display: flex;
  gap: 1.25rem;
  padding: 1.1rem 0;
}

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

.post-item-body {
  min-width: 0;
  flex: 1;
}

.post-thumb {
  flex: 0 0 130px;
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-thumb img {
  display: block;
  width: 100%;
}

.post-item-head {
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.post-title {
  font-weight: 600;
  color: var(--fg);
}

.post-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-date {
  font-family: var(--mono);
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.post-tags {
  margin: 0.3rem 0 0;
}

.post-description {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.tag + .tag::before {
  content: "\00b7\00a0";
  margin-left: 0.15rem;
}

/* -------------------------------------------------------------- articles */

.crumb {
  margin: 0 0 1.75rem;
  font-size: 0.88rem;
}

.crumb a {
  color: var(--fg-muted);
}

.crumb a:hover {
  color: var(--fg);
  text-decoration: none;
}

.article-title {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.article-meta {
  font-family: var(--mono);
  margin: 0 0 2.25rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.article-body {
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.75;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--sans);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.article-body h1,
.article-body h2 {
  font-size: 1.25rem;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.article-body h3 {
  font-size: 1.08rem;
  margin: 1.75rem 0 0.5rem;
}

.article-body p {
  margin: 0 0 1.15rem;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.15rem;
  padding-left: 1.5rem;
}

.article-body blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 1.2rem;
  border-left: 3px solid var(--border);
  color: var(--fg-muted);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.article-body table {
  border-collapse: collapse;
  margin: 0 0 1.15rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
}

.article-body figure {
  margin: 2rem 0;
  text-align: center;
}

.article-body figcaption {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
}

/* ------------------------------------------------------------ sidebar TOC */

.article {
  position: relative;
}

.toc {
  display: none;
}

@media (min-width: 1160px) {
  .toc {
    display: block;
    position: absolute;
    top: 0;
    left: calc(100% + 2.5rem);
    width: 176px;
    height: 100%;
  }

  .toc nav {
    position: sticky;
    top: 2rem;
  }

  .toc-inline {
    display: none;
  }
}

/* collapsible TOC at the top of the note when there is no margin for the rail */
.toc-inline {
  font-family: var(--sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin: 0 0 2rem;
}

.toc-inline summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.toc-inline ul {
  list-style: none;
  margin: 0.6rem 0 0.2rem;
  padding: 0;
}

.toc-inline a {
  display: block;
  font-size: 0.85rem;
  padding: 0.18rem 0;
  color: var(--fg-muted);
}

.toc-inline .toc-h3 a {
  padding-left: 1.1rem;
}

.toc-inline a:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 0.6rem;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--fg-muted);
  padding: 0.22rem 0 0.22rem 0.9rem;
  border-left: 1px solid transparent;
  margin-left: -1px;
}

.toc-h3 a {
  padding-left: 1.8rem;
}

.toc a:hover {
  color: var(--fg);
  text-decoration: none;
}

.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* anchored headings land clear of the viewport edge */
.article-body h2,
.article-body h3 {
  scroll-margin-top: 2rem;
}

/* wide equations scroll instead of overflowing */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}

.katex {
  font-size: 1.08em;
}

/* -------------------------------------------------------------- callouts */

/* Quiet, textbook-style boxes: one hairline rule, no fill, no color coding.
   The label line does the differentiating. */
.callout {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin: 1.75rem 0;
}

.callout > p:last-child {
  margin-bottom: 0;
}

.callout-label {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

/* ------------------------------------------------------------------ code */

code {
  font-family: var(--mono);
  font-size: 0.85em;
}

:not(pre) > code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.05em 0.35em;
}

pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0 0 1.15rem;
}

pre code {
  font-size: 1em;
  background: none;
  border: none;
  padding: 0;
}

.token.comment,
.token.prolog,
.token.cdata          { color: var(--code-comment); font-style: italic; }
.token.keyword,
.token.tag,
.token.important      { color: var(--code-keyword); }
.token.string,
.token.char,
.token.attr-value     { color: var(--code-string); }
.token.number,
.token.boolean,
.token.constant,
.token.symbol         { color: var(--code-number); }
.token.function       { color: var(--code-function); }
.token.class-name,
.token.builtin        { color: var(--code-class); }
.token.operator,
.token.punctuation    { color: inherit; }
.token.decorator,
.token.annotation     { color: var(--code-function); }

/* -------------------------------------------------------------- projects */

.project-header {
  text-align: center;
  margin-bottom: 1rem;
}

.project-header .article-title {
  margin-bottom: 0.75rem;
}

.project-authors {
  margin: 0 0 0.25rem;
}

.project-authors strong {
  font-weight: 600;
}

.project-affiliations {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
}

.project-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
}

.project-hero {
  margin: 1.5rem 0 2rem;
  text-align: center;
}

.project-hero img {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.project-hero figcaption {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.6rem;
}

.placeholder {
  font-family: var(--sans);
  background: var(--bg-subtle);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.92rem;
  margin: 0 0 1.15rem;
}

/* -------------------------------------------------------------------- cv */

.cv-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.cv-head .page-subtitle {
  margin-bottom: 0.5rem;
}

.cv-download-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn {
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.35rem 0.9rem;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

.cv-item {
  margin-bottom: 1rem;
}

.cv-item ul {
  margin-top: 0.25rem;
}

.cv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 0.2rem;
}

.cv-row > span:first-child,
.cv-row > strong:first-child {
  min-width: 0;
}

.cv-dates {
  flex-shrink: 0;
  color: var(--fg-muted);
  font-size: 0.88rem;
}

.cv-muted {
  color: var(--fg-muted);
  font-size: 0.92rem;
}

.cv-label-row {
  justify-content: flex-start;
}

.cv-label-row strong {
  flex: 0 0 11rem;
}

.cv-subhead {
  font-size: 0.95rem;
  margin: 1rem 0 0.5rem;
}

.cv-pubs {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

.cv-pubs li {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .cv-head {
    flex-direction: column;
  }

  .cv-row {
    flex-direction: column;
    gap: 0;
  }

  .cv-label-row strong {
    flex-basis: auto;
  }
}

/* name + contact block, only for the printed/PDF CV */
.cv-print-header {
  display: none;
}

/* printing the CV page yields a clean document */
@media print {
  /* the terminal theme is screen-only: print black-on-white */
  :root {
    --bg: #ffffff;
    --bg-subtle: #f4f4f4;
    --fg: #000000;
    --fg-muted: #444444;
    --border: #bbbbbb;
    --accent: #000000;
    --accent-soft: rgba(0, 0, 0, 0.35);
  }

  .site-header,
  .site-footer,
  .cv-download,
  .cv-download-group,
  .cv-head,
  .ascii-bg,
  .toc,
  .toc-inline,
  .crumb {
    display: none;
  }

  .home-section h2::before,
  .venue-tag::before,
  .venue-tag::after {
    content: "";
  }

  * {
    text-shadow: none !important;
  }

  .site-header {
    border-image: none;
  }

  .cv-print-header {
    display: block;
    text-align: center;
    border-bottom: 1px solid #000;
    padding-bottom: 0.6rem;
    margin-bottom: 0.75rem;
  }

  .cv-print-header h1 {
    margin: 0 0 0.2rem;
    font-size: 1.5rem;
  }

  .cv-print-header p {
    margin: 0;
    font-size: 0.85rem;
  }

  .cv-print-updated {
    color: #555;
    font-size: 0.78rem !important;
    margin-top: 0.15rem !important;
  }

  body {
    font-size: 10pt;
    line-height: 1.35;
  }

  .page {
    max-width: none;
    padding: 0;
  }

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

  /* compact vertical rhythm so the CV fits on two pages */
  .home-section {
    margin-top: 0.8rem;
  }

  .home-section h2 {
    color: #000;
    margin-bottom: 0.45rem;
    padding-bottom: 0.2rem;
  }

  .home-section li {
    margin-bottom: 0.1rem;
  }

  .cv-item {
    margin-bottom: 0.5rem;
    break-inside: avoid;
  }

  .cv-item ul {
    margin-top: 0.1rem;
    margin-bottom: 0.2rem;
  }

  .cv-row {
    margin-bottom: 0.05rem;
  }

  .cv-subhead {
    margin: 0.45rem 0 0.25rem;
  }

  .cv-pubs {
    margin-bottom: 0.4rem;
  }

  .cv-pubs li {
    margin-bottom: 0.25rem;
    break-inside: avoid;
  }

  .cv-print-header {
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
  }

  .cv-print-header h1 {
    font-size: 1.3rem;
  }
}

/* -------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  padding: 2rem;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-img {
  max-width: 92%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-caption {
  color: #eee;
  font-size: 0.92rem;
  max-width: 700px;
  text-align: center;
  margin-top: 1rem;
}

.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: #eee;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 640px) {
  .intro {
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
  }

  .intro-social {
    justify-content: center;
  }

  .pub {
    flex-direction: column;
    gap: 0.9rem;
  }

  .pub-thumb {
    flex-basis: auto;
    max-width: 320px;
  }

  .post-item {
    flex-direction: column;
    gap: 0.75rem;
  }

  .post-item-head {
    flex-direction: column;
    gap: 0.1rem;
  }
}
