/* "Terminal" Theme — green-phosphor VT100.
 *
 * The site's thesis is one federal research index rendered through eras of the
 * web: 1996 GeoCities (Retro), 1990s newsprint comic (Uncanny), modern editorial
 * (Clean). This is the era before all of them — the government terminal — and it
 * doubles as the dark mode the site otherwise lacks.
 *
 * Costs nothing to ship: JetBrains Mono is already in the base font request, and
 * there are no image assets. Every rule is scoped under `body.theme-terminal`.
 *
 * Contrast: phosphor on crt is ~14:1 and amber ~10.6:1, both AAA at any size.
 * There are deliberately TWO secondary greens, because one token can't do both
 * jobs: --label (8.9:1) carries every piece of small secondary text and every
 * label glyph, while --dim (6.1:1) is reserved for the visited-link state, where
 * it has to stay visibly distinct from --phosphor to read as a state at all.
 * Brightening --dim to fix label legibility collapses that separation from
 * 2.19:1 to 1.24:1 — hence the split. --rule is borders only, never text.
 */

body.theme-terminal {
  --crt:      #0A0F0A; /* the tube, barely-not-black                    */
  --phosphor: #33FF66; /* P1 green — body text, the whole voice         */
  --amber:    #FFB000; /* the other phosphor — headings, active states  */
  --label:    #6FC98A; /* secondary text & label glyphs (AAA, 8.9:1)    */
  --dim:      #4FA86B; /* visited-link state ONLY (6.1:1, + underline)  */
  --rule:     #1E5B33; /* borders, hairlines, table rules               */
  --panel:    #0E1A12; /* a shade up from the tube, for filled blocks   */

  background-color: var(--crt);
  background-image: none;
  color: var(--phosphor);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

body:not(.theme-terminal) .terminal-only { display: none !important; }

/* Scanlines: a 2%-opacity comb over the whole viewport. Dropped entirely when
   the reader has asked for reduced motion or increased contrast. */
body.theme-terminal::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(51, 255, 102, 0.02) 0 1px,
    transparent 1px 3px
  );
}
@media (prefers-reduced-motion: reduce), (prefers-contrast: more) {
  body.theme-terminal::after { display: none; }
}

body.theme-terminal .container {
  width: 92%;
  max-width: 1000px;
  margin: 28px auto;
  padding: 0 0 40px;
  background: transparent;
  border: none;
}

/* Other eras' furniture doesn't belong in this one. */
body.theme-terminal .ticker,
body.theme-terminal .retro-img,
body.theme-terminal .hit-counter,
body.theme-terminal hr {
  display: none;
}

/* ------------------------------------------------------------------ MOTD head */
body.theme-terminal .crt-head {
  border: 1px solid var(--rule);
  padding: 12px 14px;
  margin: 0 0 26px;
  background: var(--panel);
}
body.theme-terminal .motd,
body.theme-terminal .motd-2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label);
}
body.theme-terminal .crt-prompt {
  margin: 10px 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
}
body.theme-terminal .cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--amber);
  animation: crt-blink 1.1s step-end infinite;
}
@keyframes crt-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  body.theme-terminal .cursor { animation: none; }
}

/* --------------------------------------------------------------- typography */
body.theme-terminal h1,
body.theme-terminal h2,
body.theme-terminal h3 {
  font-family: inherit;
  color: var(--amber);
  text-align: left;
  text-shadow: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  line-height: 1.2;
}
body.theme-terminal h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 6px 0 10px;
}
body.theme-terminal h1::before { content: "$ "; color: var(--label); }
body.theme-terminal h2 {
  font-size: 1.1rem;
  margin: 30px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
body.theme-terminal h2::before { content: "## "; color: var(--label); }
body.theme-terminal h3 { font-size: 0.95rem; margin: 22px 0 10px; }

body.theme-terminal .center { text-align: left; }
body.theme-terminal .center p { max-width: 78ch; margin-bottom: 1.1rem; }
body.theme-terminal .hero-main > p { max-width: 84ch; }

body.theme-terminal .kicker {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--crt);
  background: var(--phosphor);
  padding: 2px 8px;
  margin: 0 0 10px;
}

body.theme-terminal .disclaimer,
body.theme-terminal .table-note,
body.theme-terminal .proj-desc,
body.theme-terminal .cs-shots-note {
  font-size: 0.78rem;
  color: var(--label);
}
body.theme-terminal .disclaimer::before,
body.theme-terminal .table-note::before { content: "# "; }

/* -------------------------------------------------------------------- links */
body.theme-terminal a {
  color: var(--phosphor);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
}
body.theme-terminal a:visited { color: var(--dim); }
/* Inverse video on hover — the only "highlight" a terminal has. */
body.theme-terminal a:hover,
body.theme-terminal a:focus-visible {
  color: var(--crt);
  background: var(--phosphor);
  text-decoration: none;
}
body.theme-terminal a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- sections */
body.theme-terminal .projects-section {
  border: 1px solid var(--rule) !important;
  padding: 16px 18px;
  margin-bottom: 24px;
  background: var(--panel);
}
body.theme-terminal .projects-section p,
body.theme-terminal .projects-section ul { max-width: 78ch; }

/* --------------------------------------------------------------------- lists */
body.theme-terminal ul { list-style: none; padding: 0; }
body.theme-terminal ul li {
  padding: 7px 0 7px 18px;
  position: relative;
  line-height: 1.55;
  border-bottom: 1px solid var(--rule);
}
body.theme-terminal ul li::before {
  content: "-";
  position: absolute;
  left: 0;
  color: var(--label);
}
body.theme-terminal ul li i { color: var(--label); font-style: normal; font-size: 0.9em; }
body.theme-terminal code {
  color: var(--amber);
  background: rgba(255, 176, 0, 0.08);
  padding: 0 3px;
}

/* -------------------------------------------------------- projects listing */
body.theme-terminal table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.86rem;
}
body.theme-terminal th {
  text-align: left;
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--crt);
  background: var(--dim);
  border: none;
  padding: 6px 10px;
}
body.theme-terminal td {
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: 10px;
  vertical-align: top;
}
body.theme-terminal .proj-name {
  display: inline-block;
  color: var(--amber);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
body.theme-terminal .proj-name a { color: var(--amber); text-decoration: none; }
body.theme-terminal .proj-name a:visited { color: var(--amber); }
body.theme-terminal .proj-name a:hover { color: var(--crt); background: var(--amber); }
body.theme-terminal .proj-desc { display: block; margin-top: 4px; line-height: 1.45; }
body.theme-terminal td.links a { font-size: 0.82rem; }

/* Status reads like a service check rather than a marquee. */
body.theme-terminal .blink {
  animation: none;
  color: var(--phosphor);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
body.theme-terminal .blink::before { content: "\25CF  "; color: var(--phosphor); }

/* Row thumbnails: a bracketed slug, not a photo — this era had no images. */
body.theme-terminal .proj-thumb {
  float: left;
  width: 56px;
  height: 38px;
  margin: 2px 12px 2px 0;
  border: 1px solid var(--rule);
  background: var(--crt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
body.theme-terminal .proj-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(1.5) brightness(0.8) contrast(1.1);
}
body.theme-terminal .proj-thumb[data-initial]::after {
  content: "[" attr(data-initial) "]";
  color: var(--label);
  font-size: 0.7rem;
}
body.theme-terminal .proj-text { display: block; overflow: hidden; }

/* ---------------------------------------------------------------- filter flags */
body.theme-terminal .filter-bar {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
body.theme-terminal .filter-btn {
  font-family: inherit;
  font-size: 0.8rem;
  text-transform: lowercase;
  color: var(--phosphor);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
}
body.theme-terminal .filter-btn::before { content: "--"; color: var(--label); }
body.theme-terminal .filter-btn:hover { border-color: var(--phosphor); }
body.theme-terminal .filter-btn.active {
  color: var(--crt);
  background: var(--phosphor);
  border-color: var(--phosphor);
}
body.theme-terminal .filter-btn.active::before { color: var(--crt); }
body.theme-terminal .filter-btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- function-key tabs */
body.theme-terminal .tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 20px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
}
body.theme-terminal .tab {
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--phosphor);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 8px 12px;
  cursor: pointer;
}
body.theme-terminal .tabs .tab:nth-child(1)::before { content: "[F1] "; color: var(--label); }
body.theme-terminal .tabs .tab:nth-child(2)::before { content: "[F2] "; color: var(--label); }
body.theme-terminal .tabs .tab:nth-child(3)::before { content: "[F3] "; color: var(--label); }
body.theme-terminal .tab:hover { border-color: var(--phosphor); }
body.theme-terminal .tab[aria-selected="true"] {
  color: var(--crt);
  background: var(--amber);
  border-color: var(--amber);
}
body.theme-terminal .tab[aria-selected="true"]::before { color: var(--crt); }
body.theme-terminal .tab:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* --------------------------------------------------------- featured accordion */
body.theme-terminal .featured { margin: 10px 0 6px; }
body.theme-terminal .feat-accordion { display: flex; flex-direction: column; gap: 10px; }
body.theme-terminal .feat-item {
  border: 1px solid var(--rule);
  background: var(--panel);
}
body.theme-terminal .feat-item[open] { border-color: var(--dim); }
body.theme-terminal .feat-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}
body.theme-terminal .feat-item summary::-webkit-details-marker { display: none; }
body.theme-terminal .feat-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
body.theme-terminal .feat-name {
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.9rem;
}
body.theme-terminal .feat-q { font-size: 0.8rem; color: var(--label); line-height: 1.4; }
body.theme-terminal .feat-item summary::after { content: "[+]"; flex: 0 0 auto; color: var(--label); }
body.theme-terminal .feat-item[open] summary::after { content: "[-]"; color: var(--amber); }
body.theme-terminal .feat-panel { padding: 0 14px 14px; }
body.theme-terminal .feat-shot { display: block; border: 1px solid var(--rule); }
body.theme-terminal .feat-shot img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(1.4) brightness(0.82) contrast(1.05);
}
body.theme-terminal .feat-links { margin: 12px 0 0; font-size: 0.8rem; color: var(--label); }
body.theme-terminal .feat-item summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* -------------------------------------------------------------- accordions */
body.theme-terminal details.accordion-section summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 14px;
}
body.theme-terminal details.accordion-section summary::-webkit-details-marker { display: none; }
body.theme-terminal details.accordion-section summary::before { content: none !important; }
body.theme-terminal details.accordion-section summary h2 { margin: 0; flex-grow: 1; }
body.theme-terminal details.accordion-section summary::after { content: "[+]"; color: var(--label); }
body.theme-terminal details[open].accordion-section summary::after { content: "[-]"; color: var(--amber); }

/* ------------------------------------------------------- identity & socials */
body.theme-terminal .hero { margin-top: 4px; }
body.theme-terminal .identity { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
body.theme-terminal .headshot {
  width: 96px;
  height: 96px;
  margin: 0;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 0;
  box-shadow: none;
  /* run the photo through the phosphor */
  filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(1.5) brightness(0.85) contrast(1.15);
}
body.theme-terminal .identity-text h1 { margin: 0; }
body.theme-terminal .social-links { display: flex; gap: 12px; margin: 14px 0 26px; }
body.theme-terminal .social-links a {
  color: var(--phosphor);
  border: 1px solid var(--rule);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.theme-terminal .social-links a:hover { color: var(--crt); background: var(--phosphor); }

/* --------------------------------------------------------------- switcher */
body.theme-terminal #theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--phosphor);
  background: var(--crt);
  border: 1px solid var(--phosphor);
  border-radius: 0;
  padding: 10px 14px;
  cursor: pointer;
}
body.theme-terminal #theme-toggle::before { content: "[ESC] "; color: var(--label); }
body.theme-terminal #theme-toggle:hover { color: var(--crt); background: var(--phosphor); }
body.theme-terminal #theme-toggle:hover::before { color: var(--crt); }
body.theme-terminal #theme-toggle .tt-caret { font-size: 0.7em; }
body.theme-terminal #theme-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

body.theme-terminal .theme-menu {
  position: fixed;
  top: 62px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 230px;
  padding: 6px;
  background: var(--crt);
  border: 1px solid var(--phosphor);
  border-radius: 0;
}
body.theme-terminal .theme-menu[hidden] { display: none; }
body.theme-terminal .theme-menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: inherit;
  color: var(--phosphor);
  text-align: left;
  cursor: pointer;
}
body.theme-terminal .theme-menu-item .tm-name {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
body.theme-terminal .theme-menu-item .tm-hint {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label);
}
body.theme-terminal .theme-menu-item:hover { background: var(--panel); }
body.theme-terminal .theme-menu-item[aria-checked="true"] { background: var(--phosphor); color: var(--crt); }
body.theme-terminal .theme-menu-item[aria-checked="true"] .tm-hint { color: var(--crt); }
body.theme-terminal .theme-menu-item[aria-checked="true"] .tm-name::before { content: "> "; }
body.theme-terminal .theme-menu-item:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

/* ------------------------------------------------------------ case studies */
body.theme-terminal .cs-kicker { margin: 6px 0 10px; }
body.theme-terminal .cs-tagline {
  font-size: 0.95rem;
  color: var(--phosphor);
  margin: 4px 0 16px;
  max-width: 70ch;
}
body.theme-terminal .cs-glance {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px;
  max-width: 820px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: var(--panel);
  font-size: 0.84rem;
  line-height: 1.5;
}
body.theme-terminal .cs-glance > div { display: contents; }
body.theme-terminal .cs-glance dt {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
  align-self: start;
}
body.theme-terminal .cs-glance dt::after { content: ":"; }
body.theme-terminal .cs-glance dd { margin: 0; color: var(--phosphor); }

body.theme-terminal .cs-question {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--amber);
  border-left: 2px solid var(--amber);
  padding-left: 12px;
  margin: 0 0 14px;
  max-width: 74ch;
}
body.theme-terminal .cs-related { font-size: 0.8rem; color: var(--label); margin: 22px 0 0; }
body.theme-terminal .cs-shots-title {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  flex-grow: 1;
}
body.theme-terminal .cs-shots-title::before { content: "## "; color: var(--label); }

body.theme-terminal .cs-shots { display: flex; flex-direction: column; gap: 32px; }
body.theme-terminal .cs-shot { margin: 0; }
body.theme-terminal .cs-shot-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
body.theme-terminal .shot-frame {
  display: block;
  border: 1px solid var(--rule);
  background: var(--crt);
}
body.theme-terminal .shot-frame img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(1.4) brightness(0.82) contrast(1.05);
}
body.theme-terminal .shot-frame:hover img { filter: none; }
body.theme-terminal .shot-frame.desktop { flex: 1 1 420px; min-width: 0; }
body.theme-terminal .shot-frame.mobile { flex: 0 0 auto; width: 170px; }
body.theme-terminal .cs-shot figcaption { margin-top: 10px; font-size: 0.8rem; color: var(--label); }

body.theme-terminal .cs-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
body.theme-terminal .cs-nav-link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--panel);
  text-decoration: none;
}
body.theme-terminal .cs-nav-link:hover { background: var(--panel); border-color: var(--phosphor); color: var(--phosphor); }
body.theme-terminal .cs-nav-next { text-align: right; align-items: flex-end; }
body.theme-terminal .cs-nav-dir { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--label); }
body.theme-terminal .cs-nav-title { color: var(--amber); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.04em; }
@media screen and (max-width: 560px) {
  body.theme-terminal .cs-nav { grid-template-columns: 1fr; }
  body.theme-terminal .cs-nav-next { text-align: left; align-items: flex-start; }
}

/* ------------------------------------------------------------------ footer */
body.theme-terminal .site-footer {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--label);
  font-size: 0.8rem;
}
body.theme-terminal .colophon { margin: 0 0 8px; color: var(--label); }
body.theme-terminal .colophon::before { content: "# "; }
body.theme-terminal .footer-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; }
body.theme-terminal .footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
body.theme-terminal .footer-thanks { margin: 8px 0 0; color: var(--phosphor); }
body.theme-terminal .crt-logout {
  margin: 12px 0 0;
  color: var(--label);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ mobile */
@media screen and (max-width: 768px) {
  body.theme-terminal .container {
    width: 100%;
    padding: 0 14px calc(92px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }

  body.theme-terminal table,
  body.theme-terminal tbody,
  body.theme-terminal tr,
  body.theme-terminal td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  body.theme-terminal th,
  body.theme-terminal tr:not(.project-item) { display: none; }
  body.theme-terminal tr.project-item {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--rule);
    background: var(--panel);
  }
  body.theme-terminal td { border: none; padding: 4px 0; overflow-wrap: anywhere; }
  body.theme-terminal td.links { display: block; }
  body.theme-terminal td.links a { display: inline-block; padding: 8px; }
  body.theme-terminal td.links a:first-child { padding-left: 0; }
  body.theme-terminal .proj-name a { display: inline-block; padding: 8px 0; }
  body.theme-terminal td:nth-child(3) { display: inline; padding: 0; font-size: 0.8rem; }

  body.theme-terminal .filter-btn { padding: 11px 14px; }

  body.theme-terminal #theme-toggle {
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    padding: 12px 16px;
  }
  body.theme-terminal .theme-menu {
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    min-width: 0;
  }

  body.theme-terminal .cs-glance { grid-template-columns: 1fr; gap: 1px 0; }
  body.theme-terminal .cs-glance dd { margin-bottom: 9px; }
  body.theme-terminal .shot-frame.desktop { flex-basis: 100%; }
  body.theme-terminal .shot-frame.mobile { width: 160px; }
  body.theme-terminal .footer-meta { flex-direction: column; }
}
