/* ── Terminal Theme: Green Phosphor CRT ── */

:root {
  --bg: #050805;
  --bg-panel: #0a0f0a;
  --bg-header: #11210f;
  --border: #1f3b1f;
  --border-bright: #2f5f2f;
  --text: #39ff14;
  --text-dim: #7CFC00;
  --text-muted: #3bb63b;
  --text-bright: #7fff7f;
  --accent: #39ff14;
  --cursor: #39ff14;
  --lh: 1.4rem;
  --font-mono: ui-monospace, SF Mono, Menlo, Consolas, "Cascadia Mono", "Segoe UI Mono", monospace;
  --scanline-opacity: 0.22;
  --glow: 0 0 3px rgba(57, 255, 20, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  line-height: var(--lh);
}

body {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 220px minmax(470px, 720px) 360px;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Scanline overlay ── */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px 4px
  );
}

/* CRT off: disable scanlines and glow */
body.crt-off::after {
  display: none;
}
body.crt-off {
  --glow: none;
  --scanline-opacity: 0;
}
body.crt-off * {
  text-shadow: none !important;
}

/* ── Sidebar (console) ── */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: var(--lh) 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  grid-column: 1;
  grid-row: 1 / 3;
}

.sidebar-header {
  color: var(--text-dim);
  margin: 0;
  padding: 0;
}

.sidebar-header::after {
  content: "────────────────────────";
  display: block;
  color: var(--border);
  overflow: hidden;
  white-space: nowrap;
  margin-top: 0;
  margin-bottom: var(--lh);
}

.sidebar-header .prompt {
  color: var(--text-muted);
}

.site-title a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  text-shadow: var(--glow);
}

.site-title a:hover,
.site-title a:focus {
  color: var(--text-bright);
}

.site-tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 var(--lh);
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0 0.5rem;
  line-height: var(--lh);
  display: block;
  border-radius: 3px;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar nav a::before {
  content: "▸ ";
  color: var(--text-muted);
}

.sidebar nav a:hover,
.sidebar nav a:focus {
  background: var(--border);
  color: var(--text);
  outline: none;
}

.sidebar nav a[aria-current="page"] {
  background: var(--border);
  color: var(--text);
}

.sidebar nav a[aria-current="page"]::before {
  content: "▸ ";
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-footer::before {
  content: "────────────────────────";
  display: block;
  color: var(--border);
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: var(--lh);
}

/* ── Sidebar terminal command/output pairs ── */
.terminal-pair {
  margin-top: var(--lh);
}

.terminal-pair:first-child {
  margin-top: 0;
}

.terminal-prompt {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 0;
  opacity: 0.7;
  line-height: var(--lh);
}

.prompt-symbol {
  color: var(--text-dim);
  margin-right: 0.3em;
}

.terminal-output {
  color: var(--text);
  font-weight: 700;
  text-shadow: var(--glow);
  line-height: var(--lh);
}

/* ── Main output pane ── */
main {
  padding: calc(var(--lh) * 2) 2.5rem;
  max-width: 720px;
  grid-column: 2;
  grid-row: 1;
}

/* Command line header */
.command-line {
  color: var(--text-muted);
  margin: 0 0 var(--lh);
  padding: 0;
  line-height: var(--lh);
}

.command-line::after {
  content: "────────────────────────────────────────────────────────────────────────────────────────────────────";
  display: block;
  color: var(--border-bright);
  overflow: hidden;
  white-space: nowrap;
  margin: 0 0 var(--lh);
}

.command-line .prompt {
  color: var(--text-dim);
}

.command-line .cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--cursor);
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}

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

.typed-text {
  display: block;
}

/* ── Typography ── */

h1, h2, h3, h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: var(--lh);
  margin: calc(var(--lh) * 2) 0 0;
}

h1::before {
  content: "## ";
  color: var(--text-muted);
  font-weight: 400;
}

h2::before {
  content: "# ";
  color: var(--text-muted);
  font-weight: 400;
}

h3::before {
  content: "> ";
  color: var(--text-muted);
  font-weight: 400;
}

h1::after {
  content: "════════════════════════════════════════════════════════════════════════════════════════════════════";
  display: block;
  color: var(--border-bright);
  font-weight: 400;
  overflow: hidden;
  white-space: nowrap;
  margin: 0 0 var(--lh);
}

p, li, dt, dd, td, th {
  color: var(--text-dim);
  font-weight: 100;
  font-family: "Courier New", Courier, monospace;
  letter-spacing: -0.02em;
  line-height: var(--lh);
}

p {
  margin: 0 0 var(--lh);
}

ul, ol {
  margin: 0 0 var(--lh);
  padding: 0;
  list-style: none;
}

ul li {
  margin: 0;
  line-height: var(--lh);
  padding-left: 2ch;
  text-indent: -2ch;
}

ul li::before {
  content: "- ";
  color: var(--text-muted);
}

strong, b {
  color: var(--text);
  font-weight: 700;
}

ol {
  counter-reset: term-list;
}

ol li {
  counter-increment: term-list;
  line-height: var(--lh);
  padding-left: 3ch;
  text-indent: -3ch;
}

ol li::before {
  content: counter(term-list) ". ";
  color: var(--text-muted);
}

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

a:hover, a:focus {
  color: var(--text);
  outline: none;
}

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

/* ── Duotone image treatment ── */
/* ::before = shadow color (lighten blend), ::after = highlight color (darken blend) */
.duotone-container {
  position: relative;
  display: inline-block;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
}

.duotone-container img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(100%);
}

.duotone-container::before,
.duotone-container::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

/* highlight color — phosphor green maps onto bright pixels */
@supports (mix-blend-mode: darken) {
  .duotone-container::after {
    background-color: #55ef39;
    mix-blend-mode: darken;
  }
}

/* shadow color — near-black maps onto dark pixels */
@supports (mix-blend-mode: lighten) {
  .duotone-container::before {
    background-color: #050805;
    mix-blend-mode: lighten;
  }
}

body.crt-off .duotone-container::before,
body.crt-off .duotone-container::after {
  display: none;
}

body.crt-off .duotone-container img {
  filter: none;
}


/* ── Terminal images (non-headshot) ── */
.terminal-image-link {
  display: inline-block;
  text-decoration: none;
}

.terminal-image-link:hover .duotone-container,
.terminal-image-link:focus .duotone-container {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(57, 255, 20, 0.2);
}

/* ── Logo wall ── */
.logo-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--lh);
  margin: 0 0 var(--lh);
}

.logo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: var(--lh) 1rem calc(var(--lh) * 0.75);
  border: 1px solid var(--border);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  color: white;
  transition: border-color 0.15s;
}

.logo-item:hover {
  border-color: var(--border-bright);
}

.logo-item img {
  width: 100%;
  height: calc(var(--lh) * 2.5);
  object-fit: contain;
  object-position: center;
  display: block;
  filter: grayscale(100%);
  transition: opacity 0.15s;
  position: relative;
  z-index: 0;
}

/* Per-logo filter overrides (logos not yet converted to white-on-transparent) */
[data-company="regiondo"] img { filter: grayscale(100%) brightness(2); }
[data-company="envoy"] img { filter: invert(100%) grayscale(100%) brightness(1.5); }
[data-company="mt-cleverest"] img { filter: grayscale(100%) brightness(2.5); }
[data-company="mit-sloan"] img { filter: grayscale(100%) brightness(3.5); }
[data-company="uva-batten"] img { filter: grayscale(100%) brightness(2); }

/* Duotone green overlay — same treatment as headshot */
.logo-item::before,
.logo-item::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

@supports (mix-blend-mode: lighten) {
  .logo-item::before {
    background-color: #050805;
    mix-blend-mode: lighten;
  }
}

@supports (mix-blend-mode: darken) {
  .logo-item::after {
    background-color: #55ef39;
    mix-blend-mode: darken;
  }
}

.logo-name {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  position: relative;
  z-index: 2;
  letter-spacing: 0.05em;
}

body.crt-off .logo-item::before,
body.crt-off .logo-item::after {
  display: none;
}

body.crt-off .logo-item img {
  filter: none;
}

/* ── Nav items inside terminal-pair output ── */
.terminal-output .nav-item a {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 400;
  padding: 0 0.5rem;
  line-height: var(--lh);
  display: block;
  border-radius: 3px;
  transition: background-color 0.15s, color 0.15s;
}

.terminal-output .nav-item a::before {
  content: "▸ ";
  color: var(--text-muted);
}

.terminal-output .nav-item a:hover,
.terminal-output .nav-item a:focus {
  background: var(--border);
  color: var(--text);
  outline: none;
}

.terminal-output .nav-item.active a {
  background: var(--border);
  color: var(--text);
}

.terminal-output .nav-item.active a::before {
  color: var(--accent);
}

/* ── Speaking topic audience ── */
.topics-list li {
  margin-bottom: var(--lh);
}

.topic-audience {
  display: block;
  margin-top: 0.25rem;
  margin-left: 1ch;
  color: #6a8a6a;
  font-size: 0.82rem;
}

.topic-audience::before {
  content: "→ ";
  color: #6a8a6a;
}

/* ── Speaking quotes ── */
.speaking-quote {
  margin: 0 0 0 var(--lh);
  line-height: var(--lh);
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.85rem;
}

.speaking-quote::before {
  content: "> ";
  color: var(--border-bright);
}

/* ── Media / Research / Open Source pages ── */
.media-meta {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.media-description {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0.25rem 0 0;
  line-height: var(--lh);
}

.media-empty {
  color: var(--text-muted);
}

.research-role {
  display: block;
  color: #6a8a6a;
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.research-role::before {
  content: "→ ";
  color: #6a8a6a;
}

/* ── Content lists (media / research / open-source) ── */
.content-list li {
  margin-bottom: calc(var(--lh) * 0.6);
}

.content-list li > .media-description,
.content-list li > .oss-tags,
.content-list li > .research-role {
  text-indent: 0;
}

.oss-tags {
  margin: 0.3rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1ch;
}

.oss-tag {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.oss-tag::before { content: "[ "; }
.oss-tag::after  { content: " ]"; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--lh);
  margin-top: var(--lh);
}

.photo-caption {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0.4rem 0 0;
}

/* ── Footer ── */
footer {
  margin: calc(var(--lh) * 2) 0 0;
  padding: 0 2.5rem calc(var(--lh) * 1.5);
  font-size: 0.8rem;
  color: var(--text-muted);
  grid-column: 2;
  grid-row: 2;
}

footer::before {
  content: "────────────────────────────────────────────────────────────────────────────────────────────────────";
  display: block;
  color: var(--border);
  overflow: hidden;
  white-space: nowrap;
  margin: 0 0 var(--lh);
}

.footer-social {
  margin: 0;
  font-size: 0.75rem;
  line-height: var(--lh);
}

.footer-social a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-social a:hover,
.footer-social a:focus {
  color: var(--text-dim);
}

/* ── CRT toggle button ── */
.crt-toggle {
  position: fixed;
  bottom: var(--lh);
  right: 1rem;
  z-index: 1001;
  background: var(--bg-panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0 0.75rem;
  line-height: var(--lh);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
}

.crt-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Right image panel ── */
.image-panel {
  padding: calc(var(--lh) * 2) 1.5rem 0;
  border-left: 1px solid var(--border);
}

.image-panel .duotone-container {
  width: 100%;
}

.image-panel .duotone-container img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Responsive ── */

/* Medium: sidebar left, image folds above main (220 + 470 + 360 = 1050) */
@media (max-width: 1049px) {
  body {
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto;
  }
  .sidebar {
    grid-column: 1;
    grid-row: 1 / 4;
  }
  .image-panel {
    grid-column: 2;
    grid-row: 1;
    border-left: 1px solid var(--border);
    padding: calc(var(--lh) * 2) 1.5rem var(--lh);
  }
  .image-panel .duotone-container {
    max-width: 280px;
  }
  main {
    grid-column: 2;
    grid-row: 2;
  }
  footer {
    grid-column: 2;
    grid-row: 3;
  }
}

/* Mobile: single column, order: sidebar → image → main */
@media (max-width: 689px) {
  body {
    display: flex;
    flex-direction: column;
  }
  .sidebar {
    order: 1;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: var(--lh) 1rem;
  }
  .sidebar nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
  }
  .sidebar nav a {
    font-size: 0.8rem;
  }
  .image-panel {
    order: 2;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: var(--lh) 1rem;
  }
  .image-panel .duotone-container {
    max-width: 200px;
  }
  main {
    order: 3;
    padding: var(--lh) 1rem;
    max-width: 100%;
  }
  footer {
    order: 4;
  }
  .crt-toggle {
    bottom: calc(var(--lh) / 2);
    right: 0.5rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .command-line .cursor,
  .typed-text {
    animation: none !important;
  }
  body::after {
    display: none !important;
  }
}
