@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Regular.woff2') format('woff2');
  font-stretch: normal;
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Oblique.woff2') format('woff2');
  font-stretch: normal;
  font-weight: normal;
  font-style: italic;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Bold.woff2') format('woff2');
  font-stretch: normal;
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Bold-Oblique.woff2') format('woff2');
  font-stretch: normal;
  font-weight: bold;
  font-style: italic;
}


/* Additional custom CSS for the website. */
:root {
  --page-width: 65em;
}

body {
  font-family: 'Berkeley Mono', monospace;
}

/* Strip borders from every iframe site-wide so embeds sit flush with the page. */
iframe {
  border: none;
}

.blog-summary {
  padding-top: 2em;
}

/* Blog card styles */
.blog-card-container {
  display: flex;
}

.blog-card-left {
  flex: 1;
}

.blog-card-right {
  flex: 3;
  margin-top: 2em;
}

/* Add rounded corners to banner images */
.banner-image {
  border-radius: 8px;
  max-width: 98%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Dark mode button overrides for pagination */
body.dark-mode .btn,
body.dark-mode .btn-primary,
body.dark-mode .btn-ghost {
  color: var(--font-color) !important;
  background-color: var(--background-color) !important;
  border-color: var(--primary-color) !important;
}

body.dark-mode .btn-primary {
  background-color: var(--primary-color) !important;
  color: var(--invert-font-color) !important;
  border-color: var(--primary-color) !important;
}

body.dark-mode .btn-ghost {
  background-color: transparent !important;
  color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}

body.dark-mode .btn.disabled,
body.dark-mode .btn:disabled {
  opacity: 0.5;
  color: var(--secondary-color) !important;
}

body.dark-mode .btn-primary.disabled,
body.dark-mode .btn-primary:disabled {
  color: #fff !important;
}

/* Dark mode overrides for inline code and code blocks */
body.dark-mode code,
body.dark-mode pre,
body.dark-mode pre code {
  background-color: #232326 !important;
  color: #e8e9ed !important;
  border-radius: 4px;
  border: 1px solid #333;
}

body.dark-mode code {
  padding: 0.2em 0.4em;
  font-size: 95%;
}

/* Citation/BibTeX block styling */
#citation-text,
#citation-text span,
#citation-text span[style] {
  font-family: 'Berkeley Mono', monospace;
}

/* Dark mode overrides for citation/BibTeX block */
body.dark-mode #citation-text,
body.dark-mode #citation-text span,
body.dark-mode #citation-text span[style] {
  color: #e8e9ed !important;
  font-family: 'Berkeley Mono', monospace;
}

body.dark-mode #citation-text span[style*="color: darkblue"] {
  color: #62c4ff !important;
}
body.dark-mode #citation-text span[style*="color: green"] {
  color: #7fd962 !important;
}
body.dark-mode #citation-text span[style*="color: maroon"] {
  color: #ffb86c !important;
}
body.dark-mode #citation-text span[style*="color: black"] {
  color: #e8e9ed !important;
}

body.dark-mode em,
body.dark-mode i {
  color: var(--font-color, #e8e9ed) !important;
  font-style: italic;
}

body.dark-mode {
  --background-color: #222225;
  --font-color: #e8e9ed;
  --primary-color: #62c4ff;
  --secondary-color: #a3abba;
  --invert-font-color: #222225;
}

.giscus {
  padding: 2rem 1rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  background: var(--background-color, #fff);
  box-sizing: border-box;
}

body.dark-mode .giscus {
  background: var(--background-color, #222225);
  box-shadow: 0 2px 8px rgba(0,0,0,0.32);
}

/* Search Modal Styles */
.search-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  padding: 10vh 1rem;
  overflow-y: auto;
}

.search-modal.active {
  display: block;
}

.search-modal-content {
  max-width: 600px;
  margin: 0 auto;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

body.dark-mode .search-modal-content {
  background-color: #222225;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.search-modal-header {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #eee;
  gap: 0.5rem;
}

body.dark-mode .search-modal-header {
  border-bottom-color: #333;
}

#search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: 'Berkeley Mono', monospace;
  background-color: #fff;
  color: #000;
}

body.dark-mode #search-input {
  background-color: #333;
  color: #e8e9ed;
  border-color: #555;
}

#search-input:focus {
  outline: none;
  border-color: var(--primary-color, #62c4ff);
}

.search-close {
  padding: 0.5rem 0.75rem;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  line-height: 1;
}

body.dark-mode .search-close {
  color: #aaa;
}

.search-close:hover {
  color: #000;
}

body.dark-mode .search-close:hover {
  color: #fff;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-result-item {
  display: block;
  padding: 1rem;
  text-decoration: none;
  border-radius: 4px;
  margin-bottom: 0.25rem;
  color: inherit;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

body.dark-mode .search-result-item:hover {
  background-color: #333;
}

.search-result-title {
  font-weight: bold;
  margin-bottom: 0.25rem;
  color: var(--primary-color, #0066cc);
}

body.dark-mode .search-result-title {
  color: var(--primary-color, #62c4ff);
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.search-result-date {
  font-size: 0.85rem;
  color: #666;
}

body.dark-mode .search-result-date {
  color: #999;
}

.search-result-type {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  background-color: var(--primary-color, #0066cc);
  color: #fff;
  border-radius: 3px;
  font-weight: 500;
}

body.dark-mode .search-result-type {
  background-color: var(--primary-color, #62c4ff);
  color: #222;
}

.search-result-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.search-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  background-color: #e8e8e8;
  border-radius: 3px;
  color: #555;
}

body.dark-mode .search-tag {
  background-color: #444;
  color: #ccc;
}

.search-result-summary {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.4;
}

body.dark-mode .search-result-summary {
  color: #aaa;
}

/* Search keyword highlighting */
.search-result-item mark {
  background-color: #fff59d;
  color: #000;
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
  font-weight: 500;
}

body.dark-mode .search-result-item mark {
  background-color: #ffd54f;
  color: #000;
}

.search-no-results,
.search-hint-initial {
  padding: 2rem;
  text-align: center;
  color: #666;
}

body.dark-mode .search-no-results,
body.dark-mode .search-hint-initial {
  color: #999;
}

.search-modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid #eee;
  text-align: center;
}

body.dark-mode .search-modal-footer {
  border-top-color: #333;
}

.search-hint {
  font-size: 0.85rem;
  color: #888;
}

.search-hint kbd {
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-family: 'Berkeley Mono', monospace;
}

body.dark-mode .search-hint kbd {
  background-color: #444;
  border-color: #555;
  color: #ccc;
}

/* Open Source Page Styles */
#maintained-projects,
#contributions,
#recent-activity {
  margin-bottom: 2.5rem;
}

.section-subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}

body.dark-mode .section-subtitle {
  color: #999;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.project-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  background-color: #fafafa;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
  border-color: var(--primary-color, #0066cc);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .project-card {
  background-color: #2a2a2d;
  border-color: #444;
}

body.dark-mode .project-card:hover {
  border-color: var(--primary-color, #62c4ff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.project-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--primary-color, #0066cc);
  text-decoration: none;
}

.project-name:hover {
  text-decoration: underline;
}

body.dark-mode .project-name {
  color: var(--primary-color, #62c4ff);
}

.project-language {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  background-color: #e8e8e8;
  border-radius: 4px;
  color: #555;
  white-space: nowrap;
}

body.dark-mode .project-language {
  background-color: #444;
  color: #ccc;
}

.project-description {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

body.dark-mode .project-description {
  color: #aaa;
}

.project-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.project-stats .stat {
  font-size: 0.85rem;
  color: #666;
}

body.dark-mode .project-stats .stat {
  color: #999;
}

.project-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.project-topics .topic {
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  background-color: var(--primary-color, #0066cc);
  color: #fff;
  border-radius: 3px;
}

body.dark-mode .project-topics .topic {
  background-color: var(--primary-color, #62c4ff);
  color: #222;
}

.project-updated {
  font-size: 0.8rem;
  color: #888;
}

body.dark-mode .project-updated {
  color: #777;
}

/* Activity Items */
.activity-item {
  border-left: 3px solid var(--primary-color, #0066cc);
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}

body.dark-mode .activity-item {
  border-left-color: var(--primary-color, #62c4ff);
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.activity-repo {
  font-weight: bold;
  color: var(--primary-color, #0066cc);
  text-decoration: none;
}

.activity-repo:hover {
  text-decoration: underline;
}

body.dark-mode .activity-repo {
  color: var(--primary-color, #62c4ff);
}

.activity-count {
  font-size: 0.85rem;
  color: #666;
  background-color: #eee;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

body.dark-mode .activity-count {
  background-color: #444;
  color: #ccc;
}

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

.activity-commits li {
  font-size: 0.9rem;
  color: #555;
  padding: 0.25rem 0;
  border-bottom: 1px solid #eee;
}

.activity-commits li::before,
.activity-commits li::after {
  content: none;
}

.activity-commits li:last-child {
  border-bottom: none;
}

body.dark-mode .activity-commits li {
  color: #aaa;
  border-bottom-color: #333;
}

.activity-commits code {
  font-size: 0.8rem;
  background-color: #f0f0f0;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  margin-right: 0.5rem;
}

body.dark-mode .activity-commits code {
  background-color: #333 !important;
  color: #ccc !important;
}

/* Contributions List */
.contributions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contribution-item {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1rem;
  background-color: #fafafa;
}

body.dark-mode .contribution-item {
  background-color: #2a2a2d;
  border-color: #444;
}

.contribution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.contribution-repo {
  font-weight: bold;
  color: #333;
}

body.dark-mode .contribution-repo {
  color: #e8e9ed;
}

.contribution-stats {
  font-size: 0.85rem;
  color: #666;
}

body.dark-mode .contribution-stats {
  color: #999;
}

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

.contribution-prs li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.contribution-prs li::before,
.contribution-prs li::after {
  content: none;
}

.pr-link {
  color: var(--primary-color, #0066cc);
  text-decoration: none;
  flex: 1;
}

.pr-link:hover {
  text-decoration: underline;
}

body.dark-mode .pr-link {
  color: var(--primary-color, #62c4ff);
}

.pr-state {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

.pr-state.pr-open {
  background-color: #28a745;
  color: #fff;
}

.pr-state.pr-closed {
  background-color: #dc3545;
  color: #fff;
}

.pr-state.pr-merged,
.pr-state:contains("merged") {
  background-color: #6f42c1;
  color: #fff;
}

.more-prs {
  color: #888;
  font-style: italic;
}

body.dark-mode .more-prs {
  color: #777;
}

/* Data Timestamp */
.data-timestamp {
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

body.dark-mode .data-timestamp {
  color: #666;
  border-top-color: #333;
}

/* Loading and Error States */
.loading {
  color: #888;
}

body.dark-mode .loading {
  color: #777;
}

.error {
  color: #dc3545;
}

/* terminal.css draws list markers as inline pseudo-elements on li.
   A block-level <p> inside an <li> (markdown "loose" lists) orphans the
   marker on its own line. Render the first paragraph inline so loose
   items match tight ones. */
#post_body li > p:first-child {
  display: inline;
  margin: 0;
}

/* terminal.css renders ol markers as in-flow inline pseudo-elements, so
   wrapped lines align under the number instead of the text. Give ordered
   lists a proper hanging indent: the number hangs in the margin and every
   text line aligns at the same edge. Excludes the dotted terminal-toc
   lists, which position their own markers on the right. */
ol:not(.terminal-toc) li {
  padding-left: 2.5em;
}
ol:not(.terminal-toc) li::before {
  position: absolute;
  left: 0;
  top: 0;
}

/* ============================================================
   Collection pages (books / projects / talks / teaching)
   Equal-emphasis uniform card grid, terminal identity.
   ============================================================ */

.collection-front {
  --hairline: rgba(21, 21, 21, 0.18);
  --hairline-strong: rgba(21, 21, 21, 0.34);
}

body.dark-mode .collection-front {
  --hairline: rgba(232, 233, 237, 0.16);
  --hairline-strong: rgba(232, 233, 237, 0.32);
}

/* One entrance for the page: the grid rises as a whole. */
@keyframes front-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.collection-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hairline-strong);
}

.collection-title {
  margin: 0;
  font-size: 1.6rem;
}

.collection-count {
  color: var(--secondary-color);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Equal-emphasis card grid: every artifact is one identical card. */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 2rem 0 0;
  animation: front-rise 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.artifact-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline-strong);
  background: var(--background-color);
  transition: border-color 140ms ease-out;
}

.artifact-card:hover {
  border-color: var(--primary-color);
}

.card-artwork {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--hairline);
  background: var(--background-color);
}

.card-artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Book covers are portrait objects: shelf cards lay the cover out at its
   natural ratio beside the content instead of letterboxing it in 16:9. */
.artifact-card.artifact-book {
  flex-direction: row;
  align-items: stretch;
}

.artifact-card.artifact-book .card-artwork {
  width: 38%;
  flex: 0 0 38%;
  aspect-ratio: auto;
  border-bottom: none;
  border-right: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--code-bg-color, #e8eff2);
}

.artifact-card.artifact-book .card-artwork img.artwork-cover-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

body.dark-mode .card-artwork.artwork-cover {
  background: #2a2a2d;
}

/* Shelves run wider so the cover and the text breathe side by side. */
.grid-shelf {
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
}

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

/* Command plates: artifacts without artwork show the real command that
   opens or clones them, set as a terminal prompt on the quiet tile. */
.command-plate {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 100%;
  padding: 1.25rem;
  background: var(--code-bg-color, #e8eff2);
}

body.dark-mode .command-plate {
  background: #2a2a2d;
}

.command-line {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--font-color);
  overflow-wrap: anywhere;
}

.command-prompt {
  color: var(--secondary-color);
  margin-right: 0.4em;
}

.command-caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.3em;
  vertical-align: -0.18em;
  background: var(--primary-color);
}

.artifact-card:hover .command-caret {
  animation: cursor-blink 1.1s steps(1) infinite;
}

/* Ultimate fallback for artifacts with no link at all. */
.plate-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--code-bg-color, #e8eff2);
  color: var(--secondary-color);
  font-size: 2.25rem;
}

body.dark-mode .plate-fallback {
  background: #2a2a2d;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.1rem 1.1rem;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

/* Title hovers shift color only. terminal.css paints every a:hover with a
   solid primary background; that invert-block must never land on titles,
   where it renders text unreadable. */
.card-title a {
  color: var(--font-color);
  text-decoration: none;
  background: transparent;
  transition: color 140ms ease-out;
}

.card-title a:hover {
  color: var(--primary-color);
  background: transparent;
}

body.dark-mode .card-title a {
  color: var(--font-color);
}

body.dark-mode .card-title a:hover {
  color: var(--primary-color);
  background: transparent;
}

.card-meta {
  margin: 0;
  color: var(--secondary-color);
  font-size: 0.85rem;
}

.card-summary {
  color: var(--secondary-color);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  margin-top: auto;
  padding-top: 0.75rem;
}

/* Prompt-style action row, shared by every card. */
.front-actions {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
}

.front-actions li {
  display: flex;
  align-items: center;
  /* terminal.css gives every li 20px padding-left for its list markers;
     the prompt row is not a list. */
  padding-left: 0;
}

/* terminal.css marks list items via li::before/::after (positioned absolute
   at the li's top-left); strip them, then draw our own separator on ::after
   with position: static so it flows between the links. */
.front-actions li::before,
.front-actions li::after {
  content: none;
}

.front-actions li:not(:last-child)::after {
  content: "·";
  position: static;
  top: auto;
  left: auto;
  margin: 0 0.6em;
  color: var(--secondary-color);
}

/* Within the collection system, link hovers shift color; the invert-block
   hover never applies. */
.front-actions a {
  color: var(--primary-color);
  text-decoration: none;
  background: transparent;
}

.front-actions a:hover {
  text-decoration: underline;
  background: transparent;
}

.collection-front a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .collection-title {
    font-size: 1.3rem;
  }

  .collection-grid {
    gap: 1rem;
  }
}

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

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

  .artifact-card:hover .command-caret {
    animation: none;
  }
}

/* Retreat prompt: the persistent, understated callout for the Learn
   Anything with AI retreat (issue #311). One line of site chrome in the
   footer that reads as a terminal command; hovering or focusing
   "executes" it after a short beat and prints its output lines. Remove
   after 2027-02-20 (see templates/macros/retreat.html). Ink colors are
   the quiet-gray tokens from DESIGN.md; everything else reuses
   terminal.css variables. */
.retreat-prompt {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0.5rem auto 0;
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: left;
  color: #727578;
  background: transparent;
  text-decoration: none;
  transition: color 140ms ease-out;
}

body.dark-mode .retreat-prompt {
  color: #a3abba;
}

/* Hovering is "the command about to run": the line brightens to the
   accent, and the caret stops blinking. terminal.css paints every
   a:hover with a solid primary background; the invert-block must never
   land here. */
.retreat-prompt:hover,
.retreat-prompt:focus {
  color: var(--primary-color);
  background: transparent;
  text-decoration: none;
}

.retreat-command {
  display: block;
}

/* The caret reuses the .command-caret geometry and the cursor-blink
   keyframe; here it blinks while idle, like a terminal waiting for
   input. */
.retreat-prompt .command-caret {
  animation: cursor-blink 1.1s steps(1) infinite;
}

.retreat-prompt.is-typing .command-caret,
.retreat-prompt:hover .command-caret,
.retreat-prompt:focus .command-caret {
  animation: none;
}

/* Output reveal: grid-template-rows 0fr -> 1fr in normal flow, never
   max-height. width: 0 with min-width: 100% gives the collapsed output
   zero intrinsic footprint, so the resting box is sized by the command
   alone and stays centered; expanded, the output spans exactly the
   command's width. The 350ms delay on the open state is the beat while
   the command "executes"; closing has no delay so it gets out of the
   way immediately. */
.retreat-output {
  display: grid;
  grid-template-rows: 0fr;
  width: 0;
  min-width: 100%;
  color: var(--font-color);
  transition: grid-template-rows 220ms ease-out;
}

.retreat-output-inner {
  display: block;
  min-height: 0;
  overflow: hidden;
}

.retreat-prompt:hover .retreat-output,
.retreat-prompt:focus .retreat-output {
  grid-template-rows: 1fr;
  transition-delay: 350ms;
}

.retreat-output-line {
  display: block;
  padding-left: 1.4em;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .retreat-prompt .command-caret {
    animation: none;
  }

  .retreat-prompt,
  .retreat-output {
    transition: none;
  }
}

/* Blog-footer easter egg: the retreat as a stray dev comment, replacing
   the prose paragraph once the footer prompt is site-wide. */
.blog-todo-comment {
  color: var(--secondary-color);
  font-size: 0.9rem;
}

/* Collapsing navigation: below 900px the header menu does not fit on one
   row, and terminal.css's justify-content: flex-end pushes the overflow
   off-screen to the LEFT, silently hiding the first items. So on small
   screens both navs collapse behind a prompt-line toggle that behaves
   like a command: "$ menu" / "$ links". The caret blinks while closed
   (secondary color; the primary blue caret stays unique to the retreat
   prompt), goes solid while open, and the menu prints below it with the
   same grid-template-rows 0fr -> 1fr reveal as the retreat output.
   Without JS (html.js absent) the toggles never render and both menus
   stay expanded, as they always were. */
.nav-toggle {
  display: none;
}

/* Desktop: the bar wrapper disappears from the layout (display: contents);
   its only visible child, the theme button, stays absolutely positioned
   against the container exactly as before. */
.nav-bar {
  display: contents;
}

@media (max-width: 900px) {
  /* The absolute theme button no longer floats over the title on small
     screens; it joins the menu bar instead, so the 70px body headroom
     reserved for it is no longer needed. */
  body {
    padding-top: 1.25rem;
  }

  .nav-header,
  .nav-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .theme-toggle {
    position: static;
    padding: 0.45rem 0.9rem;
  }

  html.js .nav-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--secondary-color);
    cursor: pointer;
    transition: color 140ms ease-out;
  }

  html.js .nav-toggle:hover {
    color: var(--font-color);
    background: transparent;
  }

  html.js .nav-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }

  .nav-toggle .command-caret {
    background: var(--secondary-color);
    animation: cursor-blink 1.1s steps(1) infinite;
  }

  .nav-toggle:hover .command-caret,
  .nav-toggle[aria-expanded="true"] .command-caret {
    animation: none;
  }

  html.js .menu-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 220ms ease-out;
  }

  html.js .menu-collapse.is-open {
    grid-template-rows: 1fr;
  }

  /* The panel list: one command per line, comfortable touch rows. */
  .menu-collapse > ul {
    min-height: 0;
    overflow: hidden;
    margin: 0; /* the UA's ul margin-bottom would leak into the 0fr track */
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    margin-top: 0;
  }

  .menu-collapse > ul li {
    margin: 0 0 0.35em 0;
    width: 100%;
  }

  .menu-collapse > ul li a {
    padding: 0.55em 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.js .menu-collapse {
    transition: none;
  }

  .nav-toggle .command-caret {
    animation: none;
  }
}
