/* worker53 — terminal shell, zero client JS */

:root {
  --bg: #070a08;
  --bg-panel: #0c110e;
  --bg-elev: #101612;
  --fg: #b7e0c2;
  --fg-dim: #5f8a6c;
  --fg-bright: #d8ffe4;
  --accent: #3dff8a;
  --warn: #c9a227;
  --line: rgba(61, 255, 138, 0.18);
  --line-strong: rgba(61, 255, 138, 0.35);
  --font: "IBM Plex Mono", "SF Mono", "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  --chat-w: min(22rem, 38vw);
  --music-h: 5.75rem;
  --top-h: 2.75rem;
  --dock-h: 0px;
  --pad: 0.85rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  padding-bottom: calc(var(--music-h) + var(--dock-h) + var(--safe-b) + 0.35rem);
}

/* CRT veil */
.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.12) 0,
      rgba(0, 0, 0, 0.12) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.45) 100%);
  opacity: 0.45;
}

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

a:hover {
  color: var(--fg-bright);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.mob-only {
  display: none;
}

.lede-mob {
  display: none;
}

/* —— top —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--top-h);
  padding: var(--safe-t) var(--pad) 0;
  padding-top: max(var(--safe-t), 0px);
  height: calc(var(--top-h) + var(--safe-t));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 8, 0.92);
  backdrop-filter: blur(6px);
}

.brand {
  color: var(--fg-bright);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.cursor {
  animation: blink 1.1s step-end infinite;
  color: var(--accent);
}

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

.nav {
  display: flex;
  gap: 1.25rem;
  text-transform: lowercase;
}

.nav a {
  color: var(--fg-dim);
}

.nav a:hover {
  color: var(--accent);
}

/* —— layout —— */
.shell {
  display: grid;
  grid-template-columns: 1fr var(--chat-w);
  min-height: calc(100vh - var(--top-h) - var(--music-h) - var(--dock-h) - 0.5rem);
  min-height: calc(100dvh - var(--top-h) - var(--music-h) - var(--dock-h) - 0.5rem);
}

.main {
  padding: 1.25rem var(--pad) 2rem;
  border-right: 1px solid var(--line);
  max-width: 52rem;
}

.intro {
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--line);
}

.prompt {
  margin: 0 0 0.5rem;
  color: var(--accent);
}

.prompt-inline {
  color: var(--accent);
}

.intro h1 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: 0.02em;
}

.lede {
  margin: 0;
  color: var(--fg-dim);
  max-width: 36ch;
}

.intro-links {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
}

.intro-links a {
  font-family: ui-monospace, monospace;
  color: var(--accent);
}

.block {
  scroll-margin-top: calc(var(--top-h) + var(--safe-t) + 0.75rem);
  margin-bottom: 2.75rem;
}

.block-title {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.block-lede {
  margin: -0.5rem 0 1rem;
  max-width: 36rem;
  color: var(--fg-dim);
  font-size: 0.8rem;
  line-height: 1.45;
}

.block-live .block-title {
  color: var(--accent, var(--fg-bright));
}

.block-archive {
  opacity: 0.92;
}

.block-archive .block-title {
  color: var(--fg-dim);
}

/* projects */
.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.85rem 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.project:last-child {
  border-bottom: 1px solid var(--line);
}

.project-thumb {
  width: 4.5rem;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--bg-elev);
}

.project-thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  font-size: 0.65rem;
}

.project h2 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg-bright);
}

.project-meta {
  margin: 0 0 0.35rem;
  color: var(--fg-dim);
  font-size: 0.75rem;
}

.project-meta a {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.02em;
}

.project-tag {
  font-size: 0.7rem;
  text-transform: lowercase;
  opacity: 0.85;
}

.project-live {
  border-left: 2px solid var(--accent, #3d8b7a);
  padding-left: 0.65rem;
  margin-left: -0.65rem;
}

.project-archive .project h2,
.project-archive h2 {
  font-weight: 500;
}

.project-list-archive .project-meta a {
  opacity: 0.9;
}

.project p {
  margin: 0;
  color: var(--fg-dim);
}

/* stats */
.note {
  margin: 0 0 1rem;
  color: var(--fg-dim);
  font-size: 0.78rem;
}

.note-warn {
  color: var(--warn);
  border-left: 2px solid var(--warn);
  padding-left: 0.6rem;
}

.stat-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}

.stat {
  padding: 0.85rem 0.75rem 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.stat-value {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  color: var(--accent);
  font-weight: 600;
}

.stat-label,
.stat-source {
  margin: 0;
  font-size: 0.72rem;
  color: var(--fg-dim);
  text-transform: lowercase;
}

.stat-source {
  margin-top: 0.2rem;
  opacity: 0.85;
}

/* —— chat pane —— */
.chat-pane {
  position: sticky;
  top: calc(var(--top-h) + var(--safe-t));
  height: calc(100vh - var(--top-h) - var(--safe-t) - var(--music-h) - var(--dock-h) - 0.5rem);
  height: calc(100dvh - var(--top-h) - var(--safe-t) - var(--music-h) - var(--dock-h) - 0.5rem);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--line);
  padding: 0;
  z-index: 20;
  scroll-margin-top: calc(var(--top-h) + var(--safe-t));
}

.chat-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem var(--pad);
  border-bottom: 1px solid var(--line);
}

.chat-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-label {
  color: var(--fg-dim);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.who {
  color: var(--accent);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who::before {
  content: "@";
  color: var(--fg-dim);
  font-weight: 400;
}

.inline-form {
  margin: 0;
}

.linkish,
.chat-close,
.music-close {
  font: inherit;
  color: var(--fg-dim);
  background: none;
  border: 1px solid var(--line);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  text-transform: lowercase;
  text-decoration: none;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
}

.linkish:hover,
.chat-close:hover,
.music-close:hover {
  color: var(--accent);
  border-color: var(--line-strong);
  text-decoration: none;
}

.chat-pane .note-warn {
  margin: 0.5rem var(--pad) 0;
  font-size: 0.72rem;
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 0.5rem var(--pad);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  -webkit-overflow-scrolling: touch;
}

.chat-log li {
  margin: 0;
  padding: 0;
  border: 0;
}

.chat-meta {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  color: var(--fg-dim);
}

.chat-body {
  margin: 0;
  color: var(--fg);
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  padding: 0.55rem var(--pad) 0.65rem;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}

.chat-compose textarea {
  width: 100%;
  resize: none;
  font: inherit;
  font-size: 1rem; /* avoid iOS zoom on focus */
  color: var(--fg-bright);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.55rem 0.55rem;
  min-height: 2.8rem;
  border-radius: 0;
}

.chat-compose textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.chat-compose textarea::placeholder {
  color: var(--fg-dim);
}

.send {
  font: inherit;
  font-size: 0.9rem;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 0 0.9rem;
  cursor: pointer;
  text-transform: lowercase;
  align-self: stretch;
  min-width: 4.2rem;
}

.send:hover {
  filter: brightness(1.08);
}

/* —— music bar —— */
.music-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--dock-h) + var(--safe-b));
  z-index: 40;
  height: var(--music-h);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 0 0.75rem;
  align-items: center;
  padding: 0.4rem var(--pad) 0.35rem;
  border-top: 1px solid var(--line-strong);
  background: rgba(8, 12, 10, 0.96);
  backdrop-filter: blur(8px);
  scroll-margin-bottom: calc(var(--dock-h) + var(--safe-b) + 0.5rem);
}

.music-head {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-self: center;
}

.music-label {
  color: var(--fg-dim);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.track-rail {
  grid-column: 2;
  grid-row: 1 / 3;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  align-items: center;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.track {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: min(18rem, 70vw);
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  scroll-snap-align: start;
}

.track h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-bright);
  white-space: nowrap;
}

.track-artist {
  display: none;
}

.track audio {
  width: 11rem;
  max-width: 46vw;
  height: 1.85rem;
  filter: invert(0.85) hue-rotate(80deg) saturate(2);
}

.music-legal {
  grid-column: 1 / -1;
  grid-row: 3;
  margin: 0;
  font-size: 0.62rem;
  color: var(--fg-dim);
  opacity: 0.8;
}

/* desktop: hide mobile dock */
.mob-dock {
  display: none;
}

code {
  font-family: inherit;
  color: var(--accent);
}

/* =========================================================
   MOBILE — phone-first shell
   Dock switches panels via :target (no JS)
   ========================================================= */
@media (max-width: 820px) {
  :root {
    --chat-w: 100%;
    --music-h: 4.6rem;
    --dock-h: 3.35rem;
    --pad: 0.75rem;
  }

  .crt {
    opacity: 0.22; /* less smear on small screens */
  }

  .mob-only {
    display: inline-flex;
  }

  .nav-desktop {
    display: none;
  }

  .lede-desk {
    display: none;
  }

  .lede-mob {
    display: block;
  }

  body {
    padding-bottom: calc(var(--music-h) + var(--dock-h) + var(--safe-b) + 0.25rem);
  }

  .shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .main {
    border-right: 0;
    max-width: none;
    padding: 1rem var(--pad) 1.5rem;
  }

  .intro {
    margin-bottom: 1.5rem;
    padding-bottom: 0.9rem;
  }

  .intro h1 {
    font-size: 0.98rem;
  }

  .project {
    grid-template-columns: 3.6rem 1fr;
    gap: 0.7rem;
  }

  .project-thumb {
    width: 3.6rem;
  }

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

  .shell {
    display: block;
  }

  /* chat: full-screen panel, shown only when URL is #chat (no JS) */
  .chat-pane {
    position: fixed;
    inset: calc(var(--top-h) + var(--safe-t)) 0 calc(var(--music-h) + var(--dock-h) + var(--safe-b)) 0;
    z-index: 45;
    height: auto;
    border: 0;
    border-top: 1px solid var(--line);
    display: none;
    flex-direction: column;
  }

  .chat-pane:target {
    display: flex;
  }

  .chat-log {
    max-height: none;
  }

  .chat-compose {
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  }

  /* music: compact bar; expand when #music */
  .music-bar {
    height: var(--music-h);
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: 0.35rem var(--pad);
    transition: height 0.2s ease, max-height 0.2s ease;
    overflow: hidden;
  }

  .music-head {
    grid-column: 1;
    grid-row: 1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .music-close {
    display: none;
  }

  .track-rail {
    grid-column: 1;
    grid-row: 2;
  }

  .music-legal {
    display: none;
  }

  .track {
    min-width: min(16.5rem, 85vw);
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.35rem 0.45rem;
  }

  .track audio {
    width: 100%;
    max-width: none;
    height: 2rem;
  }

  .music-bar:target {
    height: auto;
    max-height: 42vh;
    z-index: 46;
    padding-bottom: 0.5rem;
  }

  .music-bar:target .music-close {
    display: inline-flex;
  }

  .music-bar:target .track-rail {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 32vh;
    align-items: stretch;
    scroll-snap-type: none;
  }

  .music-bar:target .track {
    min-width: 0;
    width: 100%;
  }

  /* bottom dock */
  .mob-dock {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    height: calc(var(--dock-h) + var(--safe-b));
    padding: 0 0 var(--safe-b);
    border-top: 1px solid var(--line-strong);
    background: #050806;
  }

  .mob-dock a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
    text-decoration: none;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    min-height: var(--dock-h);
    -webkit-tap-highlight-color: transparent;
  }

  .mob-dock a:hover,
  .mob-dock a:active {
    color: var(--accent);
    background: rgba(61, 255, 138, 0.06);
    text-decoration: none;
  }
}

/* very small phones */
@media (max-width: 380px) {
  .mob-dock a {
    font-size: 0.65rem;
  }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
  .chat-pane,
  .music-bar {
    transition: none;
  }
}
