/* Shared shell for both language versions of the epitaph. */

:root {
  color-scheme: dark;
  --bg: #050706;
  --panel-top: #0c1210;
  --panel-bottom: #080c0a;
  --line: #1b2a23;
  --ink: #d8e8de;
  --dim: #6d8477;
  --accent: #5ee08f;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    monospace;
}

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

html {
  height: 100%;
}

body {
  /* svh keeps the layout still while mobile browser chrome collapses. */
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  /* If the works list outgrows the viewport, start at the top and scroll
     instead of clipping the title bar. */
  align-items: safe center;
  padding:
    max(clamp(0.9rem, 4vw, 3rem), env(safe-area-inset-top))
    max(clamp(0.9rem, 4vw, 3rem), env(safe-area-inset-right))
    max(clamp(0.9rem, 4vw, 3rem), env(safe-area-inset-bottom))
    max(clamp(0.9rem, 4vw, 3rem), env(safe-area-inset-left));
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Phosphor haze */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      46rem 28rem at 50% 8%,
      rgba(94, 224, 143, 0.1),
      transparent 65%
    ),
    radial-gradient(
      40rem 24rem at 50% 118%,
      rgba(94, 224, 143, 0.05),
      transparent 70%
    );
}

/* Scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025) 0 1px,
    transparent 1px 3px
  );
  opacity: 0.55;
  mix-blend-mode: screen;
}

.term {
  position: relative;
  width: min(48rem, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow:
    0 2.5rem 6rem -2rem rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(94, 224, 143, 0.05),
    0 0 6rem -1.5rem rgba(94, 224, 143, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  overflow: hidden;
  animation: boot 0.6s ease-out both;
}

.bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.95rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
  font-size: 0.75rem;
  color: var(--dim);
  user-select: none;
}

.dots {
  display: flex;
  gap: 0.42rem;
}

.dots i {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: #2b3a32;
}

.dots i:nth-child(1) {
  background: #f2635c;
}
.dots i:nth-child(2) {
  background: #e0b23f;
}
.dots i:nth-child(3) {
  background: #4fbf6a;
}

.bar .path {
  color: #8fa89a;
  letter-spacing: 0.02em;
}

.bar .dims {
  margin-left: auto;
  opacity: 0.7;
}

.screen {
  display: flex;
  flex-direction: column;
  padding: clamp(1.4rem, 4.5vw, 2.5rem) clamp(1.1rem, 4vw, 2.4rem)
    clamp(1.2rem, 3.5vw, 1.7rem);
}

.cmd {
  margin: 0;
  font-size: clamp(0.72rem, 1.9vw, 0.82rem);
  color: var(--dim);
  white-space: nowrap;
}

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

.cmd .word {
  color: #b6c9be;
}

.cmd .file {
  color: #e6f2ea;
}

.typed {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  width: 11ch;
  animation: type 0.9s steps(11, end) both;
}

.epitaph {
  margin: clamp(0.8rem, 2.5vw, 1.35rem) 0 clamp(1.1rem, 3vw, 1.9rem);
  /* 6.2vw keeps the longest Chinese line (12 glyphs) inside a 320px screen. */
  font-size: clamp(1.15rem, 6.2vw, 2.4rem);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.012em;
  text-wrap: balance;
  text-shadow: 0 0 26px rgba(94, 224, 143, 0.22);
  animation: rise 0.9s 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

html[lang="zh-CN"] .epitaph {
  letter-spacing: 0.01em;
}

/* Semantic line units: inline by default, whole lines on narrow screens. */
.epitaph .seg {
  display: inline;
}

.cursor {
  display: inline-block;
  width: 0.58ch;
  height: 1.02em;
  margin-left: 0.14em;
  vertical-align: -0.1em;
  background: var(--accent);
  box-shadow: 0 0 1rem rgba(94, 224, 143, 0.45);
  animation: blink 1.1s step-end infinite;
}

.note {
  margin: 0 0 1rem;
  font-size: clamp(0.68rem, 1.7vw, 0.78rem);
  color: #5b7264;
  text-wrap: balance;
  animation: rise 0.8s 0.85s ease-out both;
}

/* ~/works — the things left behind. Rendered by worker/works.ts. */
.works-block {
  margin: 0 0 clamp(0.9rem, 2.5vw, 1.2rem);
  animation: rise 0.8s 0.95s ease-out both;
}

.works-block .cmd {
  margin-bottom: 0.55rem;
}

.total {
  margin: 0 0 0.3rem;
  font-size: clamp(0.6rem, 1.5vw, 0.68rem);
  color: #3c5045;
  user-select: none;
}

.works {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.work {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: baseline;
  column-gap: 1.05rem;
  row-gap: 0.18rem;
  padding: 0.5rem;
  margin-inline: -0.5rem;
  border-radius: 6px;
  color: inherit;
  /* A touch larger than the status text: this is the part worth clicking. */
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease;
}

.work .perm {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.95em;
  letter-spacing: 0.02em;
  color: #3c5045;
  user-select: none;
}

.work .name {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  color: #e6f2ea;
  overflow-wrap: anywhere;
  transition:
    color 0.18s ease,
    text-shadow 0.18s ease;
}

.work .desc {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.95em;
  color: var(--dim);
  text-wrap: pretty;
}

.work .state {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88em;
  color: var(--dim);
  user-select: none;
}

.work .state::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #2b3a32;
}

.work .state.live {
  color: var(--accent);
}

.work .state.live::before {
  background: var(--accent);
  box-shadow: 0 0 0.5rem rgba(94, 224, 143, 0.7);
}

.work .state.wip::before {
  background: transparent;
  box-shadow: inset 0 0 0 1px #4b6154;
}

.work .arrow {
  grid-column: 4;
  grid-row: 1;
  color: #33463c;
  transition:
    color 0.18s ease,
    transform 0.18s ease;
}

.work:hover {
  background: rgba(94, 224, 143, 0.055);
}

.work:hover .name {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(94, 224, 143, 0.5);
}

.work:hover .desc {
  color: #8fa89a;
}

.work:hover .arrow,
.work:focus-visible .arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.work:focus-visible {
  outline: 1px solid rgba(94, 224, 143, 0.65);
  outline-offset: 2px;
  background: rgba(94, 224, 143, 0.055);
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  margin: 0;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
  font-size: clamp(0.66rem, 1.6vw, 0.75rem);
  color: var(--dim);
  animation: rise 0.8s 1s ease-out both;
}

.status .ok {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
}

.status .ok::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0.6rem rgba(94, 224, 143, 0.8);
}

.status .sep {
  color: #33463c;
}

@keyframes type {
  from {
    width: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes boot {
  from {
    opacity: 0;
    transform: translateY(0.6rem) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* Narrow screens: one semantic phrase per line. The 47rem ceiling covers
   iPad mini portrait, where the Chinese line would otherwise break mid-phrase. */
@media (max-width: 47rem) {
  .epitaph .seg {
    display: block;
  }

  /* Drop the permission column; the description keeps its own line. */
  .work {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .work .perm {
    display: none;
  }

  .work .name {
    grid-column: 1;
  }

  .work .desc {
    grid-column: 1 / -1;
  }

  .work .state {
    grid-column: 2;
  }

  .work .arrow {
    grid-column: 3;
  }
}

@media (max-width: 40rem) {
  .term {
    border-radius: 10px;
  }
}

/* Status bar reads as a two-column tmux bar instead of wrapping mid-pipe. */
@media (max-width: 34rem) {
  .status {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: space-between;
    gap: 0.5rem 1.25rem;
  }

  .status .sep {
    display: none;
  }
}

@media (max-width: 30rem) {
  .bar .dims {
    display: none;
  }

  .screen {
    padding-inline: 1.05rem;
  }

  body::after {
    opacity: 0.45;
  }
}

/* Landscape phones have very little height to play with. */
@media (max-height: 27rem) {
  .screen {
    padding-block: 1rem 1.1rem;
  }

  .epitaph {
    margin-block: 0.6rem 0.9rem;
  }

  .note {
    margin-bottom: 0.7rem;
  }

  .status {
    padding-top: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .term,
  .epitaph,
  .note,
  .status,
  .works-block,
  .typed {
    animation: none;
  }
  .typed {
    width: auto;
  }
  .cursor {
    animation: none;
  }
}
