/* ==========================================================================
   lo:ng — REPL / terminal theme
   Single typeface: Departure Mono (pixel monospace). Dark only.
   Palette: Tokyo Night, refined.
   ========================================================================== */

@font-face {
  font-family: "Departure Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Departure-Mono/DepartureMono-Regular.woff2") format("woff2"),
       url("fonts/Departure-Mono/DepartureMono-Regular.woff") format("woff");
}

:root {
  /* palette */
  --bg:        #1a1b26;
  --surface:   #20222e;
  --surface-2: #24283b;
  --fg:        #c0caf5;
  --fg-dim:    #a9b1d6;
  --muted:     #565f89;
  --line:      #2c3047;
  --accent:    #ff9e64; /* orange — brand */
  --purple:    #bb9af7;
  --cyan:      #7dcfff;
  --green:     #9ece6a;
  --red:       #f7768e;

  --grid:      rgba(122, 162, 247, 0.045);
  --selection: #343b58;

  /* type */
  --mono: "Departure Mono", ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  /* metrics */
  --measure: 50rem;       /* ~720px content column */
  --pad: clamp(1.25rem, 4vw, 2.5rem);
  --radius: 2px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--muted) var(--bg);
}

body {
  font-family: var(--mono);
  font-size: 1.0625rem;          /* 17px; crisp on hi-dpi */
  line-height: 1.65;
  color: var(--fg);
  background-color: var(--bg);
  letter-spacing: 0.01em;
  min-height: 100vh;
  overflow-x: hidden;
}

/* terminal grid + scanline signature, fixed behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: center;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 28%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 50% 28%, #000 35%, transparent 100%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(
    0deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 3px);
  opacity: 0.35;
  pointer-events: none;
}

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

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

.icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- links ---------- */
a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 2px solid var(--purple);
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
a:hover { border-bottom-color: var(--accent); color: var(--accent); }

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

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.85rem;
}
.brand {
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: var(--bg);
  padding: 0.05em 0.4em;
  border-bottom: none;
  transition: background-color .2s ease;
}
.brand:hover { background: var(--purple); color: var(--bg); }

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2.4vw, 1.6rem);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav a {
  color: var(--accent);
  border-bottom: none;
  white-space: nowrap;
}
.nav a:hover { color: var(--purple); }
.nav .icon { width: 18px; height: 18px; display: block; }

/* ---------- main + footer ---------- */
main { padding-block: clamp(2.5rem, 7vw, 5rem); }
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  padding-block: 1.6rem;
}
.site-footer a { color: var(--muted); border-bottom-color: var(--line); }
.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- prompt primitives ---------- */
.prompt {
  color: var(--fg-dim);
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}
.prompt .ps1 { color: var(--green); }
.prompt .ps1 .path { color: var(--cyan); }
.prompt .cmd { color: var(--fg); }
.prompt .flag { color: var(--purple); }
.comment { color: var(--muted); }

.cursor {
  color: var(--accent);
  font-weight: 400;
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ---------- home / hero ---------- */
.hero { max-width: 44rem; }
.avatar {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 1px solid var(--line);
  margin-bottom: 1.6rem;
  filter: grayscale(0.15) contrast(1.05);
  transition: transform .8s ease, filter .3s ease;
}
.avatar:hover { transform: rotate(360deg); filter: grayscale(0) contrast(1.05); }

.hero .name {
  font-size: clamp(2.6rem, 9vw, 4rem);
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0.2rem 0 1.4rem;
}
.hero .name .caret { color: var(--purple); margin-right: 0.28em; }

.hero .bio {
  font-size: 1.0625rem;
  color: var(--fg-dim);
  max-width: 38rem;
  margin-bottom: 2rem;
}
.hero .bio a { color: var(--fg); }

/* ---------- link menu (home) ---------- */
.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.7rem;
  margin-top: 0.9rem;
}
.links a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  background: var(--surface);
  font-size: 0.92rem;
}
.links a .icon { width: 18px; height: 18px; flex: none; color: var(--accent); transition: color .15s ease; }
.links a::before { content: "›"; color: var(--muted); transition: color .15s ease; }
.links a:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.links a:hover .icon,
.links a:hover::before { color: var(--bg); }

/* ---------- generic article headings ---------- */
.page-head { margin-bottom: 3rem; max-width: 44rem; }
.page-head h1 {
  font-size: clamp(2rem, 6vw, 2.9rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.page-head .lead { color: var(--fg-dim); margin-top: 0.8rem; max-width: 40rem; }

h2.section {
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--fg);
  margin: 3.2rem 0 1.4rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.01em;
}
h2.section .hash { color: var(--purple); }
h2.section a { color: inherit; border-bottom: none; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
h2.section a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.section-note { color: var(--muted); font-size: 0.9rem; margin: -0.8rem 0 1.4rem; }

/* ---------- plot dump card grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.1rem;
}
.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card.wide { grid-column: 1 / -1; }

.card-media {
  display: grid;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.card-media.two { grid-template-columns: 1fr 1fr; }
.card-media a { border-bottom: none; display: block; background: var(--surface-2); }
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  transition: opacity .15s ease;
}
.card-media a:hover img { opacity: 0.82; }

/* tall / portrait figures: show whole image instead of cropping */
.card-media.fit { background: var(--surface-2); }
.card-media.fit img {
  object-fit: contain;
  aspect-ratio: auto;
  height: auto;
  max-height: 460px;
}

.card-body { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.card-title { font-size: 1rem; line-height: 1.35; color: var(--fg); }
.card-title a { color: inherit; border-bottom-color: var(--purple); }
.card-title a:hover { color: var(--accent); }
.card-note { font-size: 0.82rem; color: var(--muted); }
.card-links { font-size: 0.82rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.2rem; margin-top: auto; }
.card-links .k { color: var(--green); }
.card-links a { border-bottom: none; color: var(--cyan); }
.card-links a:hover { color: var(--accent); }

/* ---------- talks ---------- */
.talks { display: flex; flex-direction: column; gap: 0; max-width: 44rem; }
.talk {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.4rem 1.6rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
}
.talk:last-child { border-bottom: 1px solid var(--line); }
.talk .date { color: var(--accent); font-size: 0.85rem; letter-spacing: 0.04em; padding-top: 0.15rem; }
.talk .venue { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.35rem; }
.talk .venue a { color: var(--muted); border-bottom-color: var(--line); }
.talk .venue a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.talk .title { font-size: 1.1rem; line-height: 1.4; }
.talk .title a { color: var(--fg); border-bottom-color: var(--purple); }
.talk .title a:hover { color: var(--accent); }
.talk .title .caret { color: var(--purple); margin-right: 0.3em; }

/* ---------- deck launcher (hidden quick-access overlay) ---------- */
.launcher {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 12vh, 9rem) 1rem 1rem;
  background: rgba(13, 14, 20, 0.72);
  backdrop-filter: blur(3px);
}
.launcher[hidden] { display: none; }
.launcher-box {
  width: 100%;
  max-width: 44rem;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--accent);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.launcher-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}
.launcher-head .ps1 { color: var(--green); white-space: nowrap; }
.launcher-head .ps1 .path { color: var(--cyan); }
#deck-filter {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  caret-color: var(--accent);
}
.launcher-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; }
.launcher-list .deck {
  display: block;
  padding: 0.45rem 0.7rem;
  border: none;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.launcher-list .deck.active,
.launcher-list .deck:hover { background: var(--accent); color: var(--bg); }
.launcher-empty { padding: 1rem; color: var(--muted); }
.launcher-empty[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 40rem) {
  .site-header .wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }
  .nav { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 0.6rem 1.2rem; }
}

@media (max-width: 34rem) {
  .talk { grid-template-columns: 1fr; gap: 0.3rem; }
  .talk .date { padding-top: 0; }
  .card-media.two { grid-template-columns: 1fr; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .cursor { opacity: 1; }
}
