/*
 * Site style overrides for the Terminal theme, after Gibson's Neuromancer:
 * ICE cyan on a "dead channel" black, faint cyberspace grid, hex-indexed sections.
 * Loaded after the theme's CSS, so anything here wins.
 * Colours: change the three variables in :root below.
 */

/* Dark only, on screen. Printing switches to black on white (see the end of this file). */
:root {
  --background: #0b0f14;
  --foreground: #d3dde6;
  --accent: #5ccfe6;
  --muted: color-mix(in srgb, var(--foreground) 60%, transparent);
  --rule: color-mix(in srgb, var(--foreground) 12%, transparent);
  --grid: color-mix(in srgb, var(--accent) 4%, transparent);
  --font-size: 0.95rem;
  --line-height: 1.7em;
  color-scheme: dark;
}

/* Two-digit lowercase hex, used as 0x01, 0x02, ... */
@counter-style hex {
  system: numeric;
  symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
  pad: 2 "0";
}

/* Cyberspace grid: very faint, fixed behind the content */
body {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

/* No programming ligatures: show -> and != as typed */
body,
code,
pre {
  font-variant-ligatures: none;
}

/* Layout: wide page like the template; long text blocks are capped separately */
.container {
  max-width: 1100px;
}

/* Header: name in accent, muted tagline, thin rule */
.header {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.header__logo {
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 14px;
}

.header__logo::after {
  display: none;
}

.logo {
  background: none;
  color: var(--accent);
  padding: 0;
  white-space: pre;
}

.tagline {
  color: var(--muted);
  font-size: 0.9em;
}

/* Menu: hex-indexed links */
.navigation-menu {
  margin: 14px 0 0;
}

.navigation-menu__inner,
.menu__dropdown {
  counter-reset: nav;
}

.navigation-menu__inner > li,
.menu__dropdown > li {
  counter-increment: nav;
}

.navigation-menu__inner > li > a::before,
.menu__dropdown > li > a::before {
  content: "0x" counter(nav, hex) " ";
  color: var(--accent);
  opacity: 0.7;
}

.navigation-menu a,
.menu__trigger {
  color: var(--foreground);
  text-decoration: none;
  white-space: pre;
}

.navigation-menu a:hover,
.navigation-menu a:focus-visible {
  color: var(--accent);
}

.menu__dropdown {
  border: 1px solid var(--rule);
}

/* Section headings: hex-indexed h2s on every page */
.post-content,
.index-content {
  counter-reset: section;
}

.post-content h2,
.index-content h2 {
  counter-increment: section;
}

.post-content h2::before,
.index-content h2::before {
  content: "0x" counter(section, hex);
  color: var(--accent);
  font-weight: 400;
  margin-right: 0.75em;
}

h1, h2, h3, h4 {
  font-weight: 600;
}

/* Titles: foreground colour, no dotted underline */
.post-title {
  color: var(--foreground);
  border-bottom: none;
  padding-bottom: 0;
}

.post-title::after {
  display: none;
}

.post-title a {
  color: inherit;
  white-space: pre-wrap;
}

.post-title a:hover {
  color: var(--accent);
}

/* Links: accent colour, quiet underline */
a {
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.post-meta {
  color: var(--muted);
}

/* Blockquotes: simple left rule instead of a ">" prompt */
blockquote {
  border-top: none;
  border-bottom: none;
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 20px;
}

blockquote::before {
  display: none;
}

/* List bullets: keep the dash, but muted */
.post ul li:not(:empty)::before {
  color: var(--muted);
}

/* Code: inline code in foreground on a light tint, not accent-coloured */
code {
  color: var(--foreground);
  background: color-mix(in srgb, var(--foreground) 6%, transparent);
  padding: 1px 4px;
}

pre code {
  background: none;
  padding: 0;
}

.highlight,
pre {
  border-color: var(--rule);
  background: var(--background);
}

/* Tables */
table,
th,
td {
  border: none;
}

th,
td {
  padding: 6px 16px 6px 0;
  border-bottom: 1px solid var(--rule);
}

th {
  text-transform: none;
  border-bottom-color: var(--muted);
}

/* Buttons such as "Read more" */
.button.inline,
.read-more {
  padding: 0;
  background: none;
  color: var(--accent);
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
}

/* Footer, with the hex accent from hugo.toml's copyright */
.footer {
  font-size: 0.85em;
}

.hexdump {
  margin-left: 10px;
  color: var(--accent);
  letter-spacing: 0.05em;
  cursor: help;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Print / save as PDF: black on white, no grid, no navigation, link targets shown */
@media print {
  :root {
    --background: #fff;
    --foreground: #000;
    --accent: #0b6e80;
    --grid: transparent;
    color-scheme: light;
  }

  body {
    background: #fff;
    font-size: 11pt;
  }

  .header {
    display: block;
    border-bottom: 1px solid #999;
  }

  .navigation-menu,
  .menu,
  .menu--mobile,
  .footer,
  .pagination {
    display: none !important;
  }

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

  .post-content a[href^="http"]::after,
  .index-content a[href^="http"]::after,
  .post-content a[href^="mailto:"]::after,
  .index-content a[href^="mailto:"]::after {
    content: " (" attr(href) ")";
    color: #555;
    font-size: 0.85em;
    word-break: break-all;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  pre,
  table,
  blockquote {
    break-inside: avoid;
  }
}

/* ---------- Home page (layouts/index.html) ---------- */

.home {
  counter-reset: section;
}

.home h2 {
  counter-increment: section;
  scroll-margin-top: 20px;
}

.home h2::before {
  content: "0x" counter(section, hex);
  color: var(--accent);
  font-weight: 400;
  margin-right: 0.75em;
}

.home section {
  margin-bottom: 50px;
}

/* Hero: name, tagline, bio and buttons on the left; photo with location and profile links on the right */
/* Grid: name and tagline, then bio, on the left; photo and links on the right.
   On small screens: name, then photo and links, then bio. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  grid-template-areas:
    "head side"
    "text side";
  grid-template-rows: auto 1fr;
  column-gap: 40px;
  margin: 30px 0 60px;
}

.hero__head {
  grid-area: head;
}

.hero__text {
  grid-area: text;
  min-width: 0;
}

.hero__bio {
  margin-top: 10px;
  max-width: 72ch;
}

.hero__side {
  grid-area: side;
  margin-top: 10px;
}

.hero__figure {
  position: relative;
  width: 210px;
  margin: 0;
  padding: 0;
}

/* Photo hover (static/js/jack-in.js): terminal boot, then ASCII portrait, inside the photo's circle */
.hero__figure[data-jack] {
  cursor: crosshair;
}

.jack {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

.jack__ascii,
.jack__term {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.jack__ascii {
  transition: opacity 0.4s;
}

.jack__term {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0 0 30px;
  background: #05080b;
  color: var(--accent);
  font-size: 10.5px;
  line-height: 1.75;
  white-space: pre;
}

.jack__term .head {
  color: var(--foreground);
  font-weight: 700;
}

.jack__term .cursor::after {
  content: "\2588";
  margin-left: 1px;
  animation: jack-blink 0.8s steps(1) infinite;
}

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

.hero__figure figcaption {
  margin: 0;
  padding: 6px 0 0;
  color: var(--muted);
  background: none;
  font-size: 0.8em;
}

/* Location and profile links under the photo, one per line with an icon */
.social {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.social li {
  margin: 0 0 8px;
  padding: 0;
}

.social li::before {
  display: none;
}

.social li,
.social a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.social a {
  text-decoration: none;
}

.social a:hover,
.social a:focus-visible {
  color: var(--accent);
}

.social a:hover span,
.social a:focus-visible span {
  text-decoration: underline;
}

.social .icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.hero__photo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  border: none;
}

.hero__name {
  margin: 0;
  font-size: calc(var(--font-size) * 1.7);
  color: var(--accent);
  white-space: pre;
}

.hero__tagline {
  margin: 6px 0 12px;
  color: var(--muted);
}

/* Bracketed link lists: [code] [abstract] ... */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.links li::before {
  content: "[";
  color: var(--muted);
}

.links li::after {
  content: "]";
  color: var(--muted);
}

.links a {
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

/* About: cv / email buttons */
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.cta a.button {
  padding: 2px 14px;
  font-weight: 400;
  color: var(--background);
  background: var(--accent);
  border: 1px solid var(--accent);
}

.cta a.button--ghost {
  color: var(--accent);
  background: none;
}

.cta a.button:hover {
  filter: brightness(1.15);
}

/* Featured work cards */
.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
}

.work:last-of-type {
  border-bottom: 1px solid var(--rule);
}

.work__banner {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 360px;
  margin: 0 auto;
  padding: 0;
  border: none;
}

.work__title {
  margin: 0 0 6px;
  font-size: calc(var(--font-size) * 1.05);
}

.work__title a {
  color: var(--foreground);
  text-decoration: none;
}

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

.work__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  font-size: 0.8em;
  line-height: 1.6;
  padding: 0 6px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.badge--venue {
  color: var(--muted);
  border-color: var(--rule);
}

.badge--highlight {
  color: var(--background);
  background: var(--accent);
}

/* [abstract] [bibtex] [press] toggles and their panels */
button.toggle {
  display: inline;
  padding: 0;
  font: inherit;
  font-weight: 400;
  color: var(--accent);
  background: none;
  border: none;
}

button.toggle:hover,
button.toggle[aria-expanded="true"] {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.panel {
  margin-top: 10px;
  padding: 8px 14px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  font-size: 0.9em;
}

.panel p {
  margin: 0 0 8px;
}

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

.panel pre {
  margin: 0;
  padding: 0;
  border: none;
  white-space: pre-wrap;
}

.press {
  margin: 0;
  padding-left: 1.2em;
}

.work__summary,
.work__authors {
  margin: 0 0 8px;
}

.work__authors {
  color: var(--muted);
  font-size: 0.9em;
}

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

/* Talks, awards and service: year headings or a date column, then text */
.year {
  margin: 22px 0 8px;
  font-size: var(--font-size);
  color: var(--muted);
  font-weight: 400;
}

.year::before {
  content: "// ";
  color: var(--accent);
}

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

.dated > li {
  display: grid;
  grid-template-columns: 4em 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.dated time {
  color: var(--muted);
}

.dated p {
  margin: 0;
}

.talk__sub {
  display: block;
  color: var(--muted);
}

.dated .links {
  margin-top: 2px;
}

/* Publications and teaching: title line with the period on the right */
.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Two columns: title and all details on the left, dates alone in a fixed column on the right */
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19ch;
  column-gap: 3em;
  align-items: baseline;
  margin-bottom: 16px;
}

.entry > * {
  grid-column: 1;
}

.entry__head {
  display: contents;
}

.entry__what {
  grid-column: 1;
}

.entry__when {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
  white-space: nowrap;
}

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

.entry__sub p {
  display: inline;
  margin: 0;
}

.entry .links {
  margin-top: 2px;
}

.entry__points {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.entry__points > li {
  position: relative;
  padding-left: 1.4em;
}

.entry__points > li::before {
  content: "-";
  position: absolute;
  left: 0.3em;
  color: var(--muted);
}

/* Highlight: ==text== in data/ fields, yellow text */
mark {
  background: none;
  color: #f5c542;
  padding: 0;
}

/* Text not yet reviewed by Sergei ("[TODO review]" in data/): local preview only, the deploy build refuses it */
mark.todo {
  background: #f5c542;
  color: #0b0f14;
  padding: 0 4px;
  margin-right: 4px;
  font-size: 0.8em;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 684px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "side"
      "text";
    grid-template-rows: auto;
    row-gap: 20px;
  }

  .hero__side {
    max-width: 300px;
    margin-top: 0;
  }

  .work {
    gap: 12px;
  }

  .dated > li {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 12px;
  }

  .entry {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry__when {
    grid-column: 1;
    grid-row: auto;
    text-align: left;
  }
}
