:root {
  --bg: #0e0f0c;
  --fg: #c9c2a8;
  --dim: #88816d;
  --accent: #e0c060;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 72px 16px 56px;
}

main {
  display: grid;
  justify-items: center;
  gap: 24px;
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

pre {
  color: var(--fg);
  position: relative;
  overflow: hidden;
  margin: 0;
  font: inherit;
  font-size: clamp(7px, 2.3vw, 18px);
  line-height: 1.15;
  white-space: pre;
}

.ship {
  display: inline-block;
  animation: float 7s ease-in-out infinite;
  transform-origin: 50% 38%;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-0.35em) rotate(-0.3deg); }
  75% { transform: translateY(0.25em) rotate(0.3deg); }
}

.sky {
  position: absolute;
  inset: 0 0 auto 0;
  height: 5.75em;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
}

.cloud {
  position: absolute;
  top: 0.1em;
  left: 100%;
  color: var(--dim);
  animation: drift 56s linear infinite;
}

.c1 { animation-delay: -10s; }
.c2 { top: 1.9em; animation-delay: -28s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100% - 70ch)); }
}

.name { color: #e8e8e8; }

.tagline { margin: -8px 0 0; text-align: center; }

a { color: var(--accent); }

.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus-visible {
  position: fixed;
  z-index: 4;
  top: 12px;
  left: 12px;
  width: auto;
  height: auto;
  padding: 10px 14px;
  margin: 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--accent);
  outline: 2px solid #e8e8e8;
  outline-offset: 2px;
}
#main-content:focus { outline: none; }

a.connect {
  color: var(--accent);
  text-decoration: none;
  font-size: clamp(15px, 4.4vw, 22px);
  border: 1px solid #3a3828;
  padding: 12px 20px;
  border-radius: 4px;
  white-space: nowrap;
}

a.connect:hover, a.connect:focus-visible {
  border-color: var(--accent);
  outline: none;
}

a.connect::before { content: "> "; color: var(--dim); }

.cursor { display: inline-block; width: 0.6em; animation: blink 1.1s steps(1) infinite; }

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

.site-nav {
  position: fixed;
  z-index: 1;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.sections, .languages { display: flex; gap: 1ch; color: var(--dim); }
.sections a, .languages a { text-underline-offset: 0.2em; }
.sections [aria-current="page"], .languages [aria-current="page"] { color: var(--fg); }

.site-footer {
  justify-self: start;
  align-self: end;
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.language-entry main { gap: 16px; text-align: center; }
.language-entry h1, .language-entry p { margin: 0; }

.devlog-page main {
  width: 100%;
  max-width: 72ch;
  min-width: 0;
  margin-inline: auto;
  justify-items: stretch;
  align-self: start;
}

.devlog-page main > article { min-width: 0; padding-block: clamp(32px, 8vh, 80px); }
.devlog-page h1, .devlog-page h2, .devlog-page h3 {
  color: #e8e8e8;
  line-height: 1.2;
}
.devlog-page h1 { margin: 0; }

.devlog-intro { margin-bottom: clamp(40px, 8vh, 72px); }
.devlog-intro p { max-width: 58ch; margin-bottom: 0; color: var(--dim); }
.devlog-preview-note {
  margin: -40px 0 40px;
  padding: 10px 12px;
  border: 1px solid #3a3828;
  color: var(--accent);
  font-size: 0.875rem;
}

.post-list {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
  border-bottom: 1px solid #2a291f;
}

.post-card {
  padding: 28px 0 32px;
  border-top: 1px solid #2a291f;
}

.post-card h2 { margin: 10px 0 12px; font-size: clamp(20px, 4vw, 28px); }
.post-card h2 a { color: #e8e8e8; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.post-card p { max-width: 64ch; }
.post-card .post-excerpt { line-height: 1.6; }
.post-card .post-link { margin: 18px 0 0; }

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  margin-top: 36px;
  color: var(--dim);
}
.pagination > :last-child { justify-self: end; }
.pagination .page-count { grid-column: 2; text-align: center; font-size: 0.875rem; }

.post-meta {
  color: var(--dim);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-page main { max-width: 1000px; }

.post-page article {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 68ch;
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  gap: 0;
}

.post-page article > *, .post-header, .post-body, .post-toc { min-width: 0; }
.post-header h1, .post-meta, .post-toc a { overflow-wrap: anywhere; }

.post-header { margin: 12px 0 32px; }
.post-header .back-link { margin: 0 0 32px; }
.post-header .post-meta { margin: 0 0 12px; }
.post-header h1 { font-size: clamp(28px, 6vw, 48px); }
.post-header h1, .post-body h2, .post-body h3 { scroll-margin-top: 88px; }
.post-lede { margin: 20px 0 0; color: #aaa48d; font-size: 1.125rem; line-height: 1.55; }
.post-actions { margin: 22px 0 0; }

.copy-link {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.copy-link:hover, .copy-link:focus-visible { color: #f0d374; }
.copy-link:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

.copy-toast {
  position: fixed;
  z-index: 2;
  right: 20px;
  bottom: 20px;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  background: #171811;
  color: #e8e8e8;
  box-shadow: 0 8px 32px #0008;
}
.copy-toast.copy-failed { border-color: #a8614d; }

.heading-anchor {
  margin-left: 0.35ch;
  color: var(--dim);
  font-size: 0.7em;
  font-weight: normal;
  text-decoration: none;
  vertical-align: 0.08em;
}
.heading-anchor:hover, .heading-anchor:focus-visible { color: var(--accent); }
.heading-anchor:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.post-header h1:target, .post-body h2:target, .post-body h3:target { color: var(--accent); }

.post-toc {
  margin: 32px 0;
  padding: 20px;
  border-left: 2px solid #3a3828;
  background: #11120e;
}

.post-toc h2 { margin: 0 0 14px; font-size: 0.875rem; letter-spacing: 0.05em; text-transform: uppercase; }
.post-toc ol { display: grid; gap: 10px; margin: 0; padding-left: 2.2ch; color: var(--dim); }
.post-toc a { text-underline-offset: 0.2em; }

.post-body { font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif; font-size: 1.08rem; line-height: 1.75; }
.post-body h2, .post-body h3, .post-body code, .post-body pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
.post-body h2 { margin: 2.8em 0 0.8em; font-size: 1.45rem; }
.post-body h3 { margin: 2.2em 0 0.7em; font-size: 1.1rem; }
.post-body p, .post-body ul, .post-body ol, .post-body blockquote { margin: 0 0 1.35em; }
.post-body li + li { margin-top: 0.45em; }
.post-body blockquote { margin-inline: 0; padding: 4px 0 4px 20px; border-left: 2px solid var(--accent); color: #aaa48d; }
.post-body code { padding: 0.08em 0.3em; background: #171811; color: #e8e8e8; }
.post-body pre { overflow-x: auto; padding: 18px; background: #11120e; border: 1px solid #2a291f; font-size: 0.9rem; line-height: 1.55; white-space: pre; }
.post-body pre code { padding: 0; background: transparent; }

.post-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid #2a291f;
}
.post-footer nav { display: flex; justify-content: space-between; gap: 24px; }

@media (min-width: 960px) {
  .post-page article.has-toc {
    max-width: none;
    grid-template-columns: 190px minmax(0, 68ch);
    column-gap: 48px;
  }
  .post-page .has-toc > .post-header { grid-column: 2; grid-row: 1; }
  .post-page .has-toc > .post-toc {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    position: sticky;
    top: 88px;
    margin: 32px 0 0;
  }
  .post-page .has-toc > .post-body { grid-column: 2; grid-row: 2; }
  .post-page .has-toc > .post-footer { grid-column: 2; grid-row: 3; }
}

/* Desktop home: ship and name, the slogan, then the button as three groups. The block sits
   a little above centre using spare height only, and the art shrinks on short screens so the
   whole page, copyright included, fits without scrolling. */
@media (min-width: 720px) {
  .home { grid-template-rows: minmax(0, 2fr) auto minmax(0, 3fr) auto; padding-bottom: 18px; }
  .home main { grid-row: 2; gap: 0; margin-bottom: 2.5rem; }
  .home .site-footer { grid-row: 4; }
  /* ≈30 lines of art share what the rest of the page leaves. */
  .home pre { font-size: clamp(7px, min(2.3vw, (93vh - 302px) / 30), 18px); }
  .home .name { display: inline-block; margin-top: 1.5em; }
  .home .tagline { margin: 1.5rem 0 0; display: grid; gap: 0.25rem; }
  .home a.connect { margin-top: clamp(2rem, 7vh, 4rem); }
}

@media (prefers-reduced-motion: reduce) {
  .cursor, .ship, .cloud { animation: none; }
  .cloud { display: none; }
}

@media (max-width: 420px) {
  .site-nav { align-items: flex-start; }
  .sections, .languages { flex-wrap: wrap; }
  .post-footer nav { display: grid; }
  .pagination { grid-template-columns: 1fr 1fr; }
  .pagination .page-count { grid-column: 1 / -1; grid-row: 1; }
  .copy-toast { right: 16px; bottom: 16px; max-width: calc(100% - 32px); }
}
