/* ==========================================================================
   Cypherpunk Theme — Dark terminal aesthetic with brutalist layout
   Palette: black (#0a0a0a) + yellow (#ffcc00)
   Typography: Computer Modern (body) + JetBrains Mono (UI)
   ========================================================================== */

:root {
  --bg: #0a0a0a;
  --fg: #ffcc00;
  --fg-dim: #997a00;
  --fg-bright: #ffe066;
  --paper-bg: rgba(255, 248, 220, 0.88);
  --paper-text: #1a1a1a;
  --paper-muted: #555;
  --border: #ffcc00;
  --font-body: "Computer Modern Serif", "CMU Serif", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Courier New", Consolas, monospace;
  --font-serif: 'EB Garamond', 'Georgia', serif;
  --max-width: 900px;
  --gap: 1.5rem;
}

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

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

/* --- Base --- */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

a:hover {
  color: var(--fg-bright);
}

/* --- Binary Rain Canvas --- */
#binary-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 2px solid var(--border);
  backdrop-filter: blur(4px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav {
  display: flex;
  flex: 1;
  justify-content: space-evenly;
  align-items: center;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border: 2px solid var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 204, 0, 0.1);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 2px solid var(--fg);
  padding: 0.4rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--fg);
}

/* --- Main Content --- */
.site-main {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1rem var(--gap) 2rem;
}

/* --- Paper Scrap Cards --- */
.paper-scrap {
  background-image: url('/img/textures/textured-paper.png');
  background-repeat: repeat;
  color: #2a2420;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.7;
  padding: 1rem 1.25rem;
  margin-bottom: var(--gap);
  border: 3px solid #ffcc00;
  outline: 3px solid #997a00;
  outline-offset: 0px;
  position: relative;
  isolation: isolate;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.paper-scrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(252, 245, 225, 0.1);
  pointer-events: none;
  z-index: 0;
}

.paper-scrap > * {
  position: relative;
  z-index: 1;
}

.paper-scrap h1,
.paper-scrap h2,
.paper-scrap h3,
.paper-scrap h4,
.paper-scrap h5,
.paper-scrap h6 {
  font-family: var(--font-body);
  color: var(--paper-text);
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.paper-scrap h1 {
  font-size: 2rem;
}

.paper-scrap h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0.3em;
  margin-top: 1.5em;
}

.paper-scrap h3 {
  font-size: 1.25rem;
}

.paper-scrap p {
  margin-bottom: 1em;
}

.paper-scrap a {
  color: #1a5276;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.paper-scrap a:hover {
  color: #0a0a0a;
}

.paper-scrap ul,
.paper-scrap ol {
  margin: 0.5em 0 1em 1.5em;
}

.paper-scrap li {
  margin-bottom: 0.3em;
}

.paper-scrap blockquote {
  border-left: 3px solid var(--fg-dim);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--paper-muted);
  font-style: italic;
}

.paper-scrap code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: #f0f0f0;
  padding: 0.15em 0.35em;
  border: 1px solid #ddd;
}

.paper-scrap pre {
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 1rem;
  overflow-x: auto;
  margin: 1em 0;
  border: 2px solid var(--fg-dim);
}

.paper-scrap pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

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

.paper-scrap table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.paper-scrap th,
.paper-scrap td {
  border: 1px solid #ddd;
  padding: 0.5em 0.75em;
  text-align: left;
}

.paper-scrap th {
  background: #f5f5f5;
  font-weight: 700;
}

/* --- Hero (Homepage) --- */
.hero {
  text-align: left;
  padding: 2rem 0 2rem;
}

.hero-title {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  visibility: hidden; /* shown by typewriter.js */
}

/* --- Hero Split (Image + Bio) --- */
.hero-split {
  display: flex;
  gap: 2rem;
  align-items: stretch;
  margin-bottom: 2rem;
}

/* --- Cipher Image Box --- */
.cipher-box {
  flex: 0 0 40%;
  max-width: 400px;
  border: 3px solid #ffcc00;
  outline: 3px solid #997a00;
  outline-offset: 0px;
  background: var(--bg);
}

.cipher-grid-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg);
}

.cipher-grid {
  display: grid;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.cipher-tile {
  position: relative;
  overflow: hidden;
  font-family: var(--font-mono);
  line-height: 1;
}

.cipher-tile-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.cipher-tile-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  pointer-events: none;
}

.cipher-hover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cipher-grid-container.hovered .cipher-hover-img {
  opacity: 1;
}

.cipher-caption {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg);
  text-align: center;
  padding: 0.5rem;
  background: var(--bg);
  letter-spacing: 0.03em;
}

.bio-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 0;
  align-self: stretch;
}

/* --- Home Grid --- */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
  margin-top: 2rem;
}

.home-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  background: var(--bg);
  border: 3px solid #ffcc00;
  outline: 3px solid #997a00;
  outline-offset: 0px;
  padding: 1.5rem;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
  color: var(--fg);
  opacity: 0.9;
}

.home-card:hover {
  transform: translateY(-2px);
  background: var(--bg);
  color: var(--fg-bright);
  opacity: 1;
}

.home-card-icon {
  margin-bottom: 1rem;
  text-align: center;
}

.home-card-icon svg {
  width: 56px;
  height: 56px;
  color: #ffcc00;
  filter: drop-shadow(0 0 4px rgba(255, 204, 0, 0.4));
  transition: color 0.15s, filter 0.15s;
}

.home-card:hover .home-card-icon svg {
  color: #ffee55;
  filter: drop-shadow(0 0 8px rgba(255, 204, 0, 0.6));
}

.home-card h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--fg);
  margin-bottom: 0.5em;
}

.home-card:hover h2 {
  color: var(--fg-bright);
}

.home-card p {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--fg-dim);
  line-height: 1.5;
  flex: 1;
}

.home-card-cta {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--fg);
  padding: 0.3rem 0.8rem;
  transition: background 0.15s, color 0.15s;
  align-self: flex-start;
}

.home-card:hover .home-card-cta {
  background: var(--fg);
  color: var(--bg);
}

/* --- CTA Card Background Visuals --- */
.home-card {
  position: relative;
  overflow: hidden;
}

.home-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.15s;
}

.home-card:hover::before {
  opacity: 0.2;
}

.home-card > * {
  position: relative;
  z-index: 1;
}

/* Publications - deep blue with document grid */
.home-card--publications::before {
  background:
    radial-gradient(ellipse at 80% 80%, #1a3a5c 0%, transparent 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 18px,
      rgba(100, 160, 255, 0.15) 18px,
      rgba(100, 160, 255, 0.15) 19px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 60px,
      rgba(100, 160, 255, 0.08) 60px,
      rgba(100, 160, 255, 0.08) 61px
    );
}

/* Projects - dark green with angle bracket pattern */
.home-card--projects::before {
  background:
    radial-gradient(ellipse at 20% 80%, #1a4a2e 0%, transparent 70%),
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 20px,
      rgba(80, 200, 120, 0.1) 20px,
      rgba(80, 200, 120, 0.1) 21px
    ),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 20px,
      rgba(80, 200, 120, 0.1) 20px,
      rgba(80, 200, 120, 0.1) 21px
    );
}

/* Blog - dark purple with horizontal rules */
.home-card--blog::before {
  background:
    radial-gradient(ellipse at 50% 20%, #3a1a5c 0%, transparent 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 12px,
      rgba(160, 100, 255, 0.12) 12px,
      rgba(160, 100, 255, 0.12) 13px
    );
}

/* Media - dark amber with diagonal wave */
.home-card--media::before {
  background:
    radial-gradient(ellipse at 80% 20%, #5c2a1a 0%, transparent 70%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 15px,
      rgba(255, 160, 60, 0.1) 15px,
      rgba(255, 160, 60, 0.1) 16px
    ),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 30px,
      rgba(255, 160, 60, 0.06) 30px,
      rgba(255, 160, 60, 0.06) 31px
    );
}

/* Card-specific icon colors */
.home-card--publications .home-card-icon svg {
  color: #6496ff;
}

.home-card--projects .home-card-icon svg {
  color: #50c878;
}

.home-card--blog .home-card-icon svg {
  color: #a064ff;
}

.home-card--media .home-card-icon svg {
  color: #ffa03c;
}

/* --- List Pages --- */
.list-title {
  font-family: var(--font-mono);
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.5rem;
  visibility: hidden; /* shown by typewriter.js */
}

.list-intro {
  margin-bottom: 2rem;
}

.list-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

.list-card {
  display: block;
  text-decoration: none;
  transition: transform 0.15s;
}

.list-card:hover {
  transform: translateX(4px);
}

.list-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.25em;
}

.list-card time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--paper-muted);
}

.list-card p {
  margin-top: 0.5em;
  font-size: 0.95rem;
  color: var(--paper-muted);
}

/* --- Single Page --- */
.single-page .article-header {
  margin-bottom: 1.5rem;
}

.single-page .article-header h1 {
  visibility: hidden; /* shown by typewriter.js */
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--paper-text);
}

.article-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--paper-muted);
  display: block;
  margin-top: 0.5rem;
}

/* --- Contact Page --- */
#contact-form {
  max-width: 500px;
}

#contact-form .form-group {
  margin-bottom: 1.25rem;
}

#contact-form label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--paper-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

#contact-form input[type="text"],
#contact-form input[type="email"],
#contact-form textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--paper-text);
  background: #f5f5f0;
  border: 2px solid #ccc;
  outline: none;
  transition: border-color 0.15s;
}

#contact-form input:focus,
#contact-form textarea:focus {
  border-color: #997a00;
}

#contact-form textarea {
  resize: vertical;
  min-height: 120px;
}

#contact-form .pub-btn {
  font-size: 0.9rem;
  padding: 0.6rem 2rem;
  border-width: 2px;
  background: #000;
}

#contact-form .pub-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.9);
}

#contact-form .pub-btn:hover:not(:disabled) {
  background: rgba(40, 35, 0, 0.9);
}

.form-ok { color: #2e7d32; }
.form-err { color: #c62828; }

/* --- Puzzle Vi Terminal --- */
.puzzle-vi {
  background: #000;
  color: #e0e0e0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  margin-top: 1.5rem;
  border: 2px solid var(--fg);
  min-height: 6rem;
  max-height: 22rem;
  overflow-y: auto;
  overflow-x: hidden;
}


.puzzle-vi-prompt {
  display: none;
  color: var(--fg);
}

.puzzle-vi-cursor {
  animation: blink 0.8s step-end infinite;
  color: var(--fg);
}

/* Command lines ($ ...) */
.puzzle-vi .vi-cmd {
  color: var(--fg);
}

/* Python code output */
.puzzle-vi .vi-code {
  color: rgba(255, 204, 0, 0.6);
}

/* Info/progress lines */
.puzzle-vi .vi-info {
  color: rgba(255, 204, 0, 0.5);
}

.puzzle-vi .vi-progress {
  color: rgba(255, 204, 0, 0.4);
}

/* Success lines */
.puzzle-vi .vi-success {
  color: #4ec94e;
}

/* Error lines */
.puzzle-vi .vi-error {
  color: #c62828;
}

/* Decode animation */
.puzzle-vi .vi-label {
  color: rgba(255, 204, 0, 0.5);
}

.puzzle-vi .vi-scramble {
  color: var(--fg);
}

.puzzle-vi .vi-locked {
  color: var(--fg);
}

.puzzle-vi .vi-decode-live {
  letter-spacing: 0.08em;
}

.noscript-fallback {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 2px dashed var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.noscript-fallback pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  border: 1px solid var(--fg-dim);
}

.noscript-label {
  display: block;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg);
}

.noscript-input {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--fg-dim);
}

/* Terminal box for typewriter titles */
[data-typewriter] {
  display: inline-block;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid var(--fg);
  padding: 0.3rem 0.6rem;
}

/* --- Typewriter prompt (permanent #) --- */
.tw-prompt {
  margin-right: 0.4em;
  color: var(--fg);
}

/* --- Typewriter cursor --- */
.tw-cursor {
  animation: blink 0.8s step-end infinite;
}

.tw-cursor-done {
  animation: blink 0.8s step-end infinite;
}

/* --- Footer --- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 2px solid var(--border);
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(4px);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.footer-icons {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-icon svg {
  width: 20px;
  height: 20px;
  fill: var(--fg);
  transition: fill 0.15s;
}

.footer-icon:hover svg {
  fill: var(--fg-bright);
}

.footer-copy {
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

/* --- Bio Lower Section --- */
.bio-lower {
  display: flex;
  gap: 2rem;
  align-items: stretch;
  margin-bottom: 2rem;
}

.bio-lower-text {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  align-self: stretch;
}

/* --- Photo Gallery --- */
.gallery-box {
  flex: 0 0 50%;
  max-width: 500px;
}

.gallery-heading {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--fg-dim);
  text-align: left;
}

.gallery {
  position: relative;
  border: 3px solid #ffcc00;
  outline: 3px solid #997a00;
  outline-offset: 0px;
  background: var(--bg);
  overflow: hidden;
}

.gallery-slide {
  display: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.gallery-slide.active {
  display: block;
  opacity: 1;
}

.gallery-slide img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}

.gallery-caption {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
  padding: 0.5rem 0.75rem;
  line-height: 1.4;
  background: var(--bg);
  min-height: 3.5em;
}

.gallery-prev,
.gallery-next {
  position: absolute;
  top: 0;
  height: 260px;
  width: 40px;
  background: rgba(10, 10, 10, 0.5);
  color: var(--fg);
  border: none;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-prev {
  left: 0;
}

.gallery-next {
  right: 0;
}

.gallery:hover .gallery-prev,
.gallery:hover .gallery-next {
  opacity: 1;
}

.gallery-prev:hover,
.gallery-next:hover {
  background: rgba(10, 10, 10, 0.8);
}

/* --- Animations --- */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* --- Publications Section --- */
.publications-page {
  max-width: var(--max-width);
  margin: 0 auto;
}

.publications-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: var(--bg);
  padding: 0.75rem 1rem 0;
  border: 2px solid var(--fg-dim);
  border-bottom: none;
  margin-bottom: 0;
}

.publications-tabs {
  display: flex;
  gap: 0;
}

.pub-tab {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 1.5rem;
  color: var(--fg-dim);
  text-decoration: none;
  border: 1px solid var(--fg-dim);
  border-bottom: 2px solid var(--fg);
  background: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
}

.pub-tab:hover {
  color: var(--fg);
  border-color: var(--fg);
  background: rgba(255, 204, 0, 0.05);
}

.pub-tab--active {
  color: var(--fg);
  background: rgba(255, 204, 0, 0.1);
  border-color: var(--fg);
  border-bottom: 2px solid var(--bg);
}

.publications-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
}

.publications-profiles {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.pub-profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  transition: color 0.15s;
}

.pub-profile-link:hover {
  color: var(--fg-bright);
}

.pub-profile-link svg {
  width: 20px;
  height: 20px;
}

.pub-action-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--fg);
  color: var(--fg);
  transition: background 0.15s, color 0.15s;
}

.pub-action-btn:hover {
  background: rgba(255, 204, 0, 0.05);
  color: var(--fg);
}

/* Publication grid container */
.publications-grid-container {
  background: rgba(0, 0, 0, 0.65);
  padding: 2rem;
  border: 2px solid var(--fg-dim);
}

/* Publication cards grid */
.publications-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.pub-card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 3px solid var(--fg);
  outline: 3px solid var(--fg-dim);
  outline-offset: 0px;
  transition: transform 0.15s;
  text-decoration: none;
  color: var(--fg);
  position: relative;
  overflow: hidden;
}

.pub-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.12);
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 5;
}

.pub-card:hover::after {
  opacity: 0;
}

.pub-card:hover {
  transform: translateY(-2px);
  color: var(--fg-bright);
}

.pub-card-image {
  overflow: hidden;
  border-bottom: 2px solid var(--fg-dim);
}

.pub-card-image img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.pub-card .pub-card-content {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  background-image: url('/img/textures/textured-paper.png');
  background-repeat: repeat;
  background-color: #f5f0e0;
  color: #2a2420;
  position: relative;
  isolation: isolate;
}

.pub-card .pub-card-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(252, 245, 225, 0.1);
  pointer-events: none;
  z-index: 0;
}

.pub-card .pub-card-content > * {
  position: relative;
  z-index: 1;
}

.pub-card .pub-card-title {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #1a1a1a;
  margin-bottom: 0.4em;
  line-height: 1.3;
}

.pub-card:hover .pub-card-title {
  color: #000;
}

.pub-card .pub-card-authors {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #4a4540;
  margin-bottom: 0.3em;
  line-height: 1.4;
}

.pub-card .pub-card-venue {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #4a4540;
  margin-bottom: 0.75em;
}

.pub-card .pub-card-summary {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: #2a2420;
  line-height: 1.5;
  flex: 1;
  margin-bottom: 0.75em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pub-card .pub-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  position: relative;
  z-index: 10;
}

/* Publication buttons */
.pub-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--fg);
  color: var(--fg);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  display: inline-block;
}

.pub-btn:hover {
  background: rgba(255, 204, 0, 0.05);
  color: var(--fg);
}

.pub-card .pub-card-content .pub-btn {
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--fg);
  transition: background 0.15s;
  position: relative;
  z-index: 10;
  cursor: pointer;
}

.pub-card .pub-card-content .pub-btn:hover {
  background: #1a1700;
  color: var(--fg);
}

.pub-btn.on-card {
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid var(--fg);
}

.pub-btn.on-card:hover {
  background: #1a1700;
}

.pub-btn--small {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
}

/* List view layout */
.pub-list-layout {
  display: flex;
  gap: 2rem;
}

.pub-year-nav {
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 4rem;
}

.pub-year-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-dim);
  padding: 0.2rem 0.4rem;
  transition: color 0.15s;
}

.pub-year-link:hover {
  color: var(--fg-bright);
}

.pub-list-entries {
  flex: 1;
  min-width: 0;
}

.pub-list-year {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--fg);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--fg-dim);
}

.pub-list-year:first-child {
  margin-top: 0;
}

.pub-list-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 204, 0, 0.15);
}

.pub-list-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg);
  flex: 1 1 100%;
  line-height: 1.4;
}

.pub-list-title:hover {
  color: var(--fg-bright);
}

.pub-list-authors {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
  flex: 1 1 auto;
}

.pub-list-venue {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
  font-style: italic;
}

.pub-list-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
}

/* List view paper texture container */
.publications-list-container {
  background-image: url('/img/textures/textured-paper.png');
  background-repeat: repeat;
  background-color: #f5f0e0;
  padding: 2rem;
  border: 2px solid var(--fg-dim);
  margin-top: 0;
  position: relative;
  isolation: isolate;
}

.publications-list-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(252, 245, 225, 0.1);
  pointer-events: none;
  z-index: 0;
}

.publications-list-container > * {
  position: relative;
  z-index: 1;
}

.publications-list-container .pub-list-year {
  color: #1a1a1a;
  border-bottom-color: #4a4540;
}

.publications-list-container .pub-list-title {
  color: #1a1a1a;
}

.publications-list-container .pub-list-title:hover {
  color: #000;
}

.publications-list-container .pub-list-authors {
  color: #4a4540;
}

.publications-list-container .pub-list-venue {
  color: #4a4540;
}

.publications-list-container .pub-list-entry {
  border-bottom-color: rgba(42, 36, 32, 0.2);
}

.publications-list-container .pub-btn {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--fg);
  transition: background 0.15s;
}

.publications-list-container .pub-btn:hover {
  background: #1a1700;
  color: var(--fg);
}

.publications-list-container .pub-year-nav {
  border-right-color: rgba(42, 36, 32, 0.2);
}

.publications-list-container .pub-year-link {
  color: #4a4540;
}

.publications-list-container .pub-year-link:hover,
.publications-list-container .pub-year-link.active {
  color: #1a1a1a;
}

/* Single publication page */
.pub-single {
  max-width: var(--max-width);
  margin: 0 auto;
}

.pub-single-header {
  margin-bottom: 2rem;
}

.pub-single-header h1 {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--fg);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.pub-single-authors {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-dim);
  margin-bottom: 0.3rem;
}

.pub-single-venue {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-bottom: 1rem;
}

.pub-single-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pub-single-image {
  margin-bottom: 2rem;
  border: 3px solid var(--fg);
  outline: 3px solid var(--fg-dim);
  outline-offset: 0px;
}

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

.pub-single-content {
  margin-bottom: 2rem;
}

/* --- Responsive (mobile) --- */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.98);
    border-bottom: 2px solid var(--border);
    flex-direction: column;
    padding: 0.5rem 0;
  }

  .site-nav.open {
    display: flex;
  }

  .nav-link {
    padding: 0.6rem var(--gap);
    font-size: 0.9rem;
    border: none;
  }

  .hero-title {
    font-size: 1.75rem;
  }

  .hero-split {
    flex-direction: column;
    align-items: stretch;
  }

  .cipher-box {
    width: 100%;
    max-width: none;
    flex: none;
  }

  .paper-scrap {
    padding: 0.75rem 0.625rem;
    font-size: 1rem;
  }

  .paper-scrap h1 {
    font-size: 1.5rem;
  }

  .paper-scrap h2 {
    font-size: 1.25rem;
  }

  .bio-lower {
    flex-direction: column;
    align-items: stretch;
  }

  .gallery-box {
    width: 100%;
    max-width: none;
    flex: none;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .publications-grid {
    grid-template-columns: 1fr;
  }

  .pub-year-nav {
    display: none;
  }

  .pub-list-layout {
    flex-direction: column;
  }

  .publications-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .list-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 400px) {
  .hero-title {
    font-size: 1.3rem;
    letter-spacing: 0.05em;
  }

  .paper-scrap {
    padding: 0.625rem 0.5rem;
  }

}

/* --- Blog Section --- */
.blog-page {
  max-width: var(--max-width);
  margin: 0 auto;
}

.blog-grid-container {
  background: rgba(0, 0, 0, 0.65);
  padding: 2rem;
  border: 2px solid var(--fg-dim);
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.blog-card-tags {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #6a6560;
  margin-bottom: 0.5em;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Projects Section --- */
.projects-page {
  max-width: var(--max-width);
  margin: 0 auto;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.project-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  padding: 1.5rem;
  background: var(--bg);
  border-bottom: 2px solid var(--fg-dim);
}

.project-monogram {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.pub-card:hover .project-monogram {
  opacity: 1;
}

.project-logo {
  max-height: 140px;
  max-width: 90%;
  object-fit: contain;
  opacity: 0.85;
  transition: opacity 0.2s;
  filter: brightness(0.9);
}

.pub-card:hover .project-logo {
  opacity: 1;
  filter: brightness(1);
}

.project-card-icon.light-bg {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  padding: 1rem;
}

.project-card-icon.light-bg .project-logo {
  filter: none;
  opacity: 1;
}

.projects-subtitle {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  margin: 2.5rem 0 1rem;
  border-bottom: 2px solid var(--fg-dim);
  padding-bottom: 0.5rem;
}

.projects-other {
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Media Section --- */
.media-page {
  max-width: var(--max-width);
  margin: 0 auto;
}

.media-section-box {
  background: rgba(0, 0, 0, 0.65);
  padding: 2rem;
  border: 2px solid var(--fg-dim);
  margin-bottom: 2rem;
}

.media-section-title {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  margin: 0 0 1rem;
  border-bottom: 2px solid var(--fg-dim);
  padding-bottom: 0.5rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.media-card {
  cursor: default;
}

.media-card-thumb {
  position: relative;
  overflow: hidden;
  border-bottom: 2px solid var(--fg-dim);
  background: #000;
}

.media-card-thumb img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.media-card:hover .media-card-thumb img {
  opacity: 0.85;
}

.media-play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 2;
}

.media-card:hover .media-play-overlay {
  opacity: 1;
}

.media-press {
  margin-bottom: 2rem;
}

.media-press ul {
  list-style: disc;
  margin-left: 1.5em;
}

.media-press li {
  margin-bottom: 0.5em;
}

@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Print --- */
@media print {
  #binary-rain,
  .site-header,
  .site-footer {
    display: none;
  }

  .paper-scrap {
    background: white;
    background-image: none;
    color: black;
    padding: 0;
    box-shadow: none;
  }

  body {
    background: white;
    color: black;
  }
}
