/* Posting 3 homepage: "the page is a terminal".
   Everything sits on one monospace cell grid: widths are counted in `ch`
   and heights in `lh` (one text row). Sections are TUI panes with their
   title set into the top border, numbered for the 1-6 keys. Only the
   wordmark and the double-height headings break the one-size rule, and
   they still land on whole rows. Colours come from the active Posting
   theme (palettes.css, with screen colours in home-palettes.css).
   Behaviour (panes, jump mode, command palette) is in javascripts/home.js.
   Sizes assume Material's 125% root. */

/* ---- Material chrome on the homepage ---------------------------------- */

body {
  background: var(--bg);
}

.md-dialog {
  display: none;
}

@media (min-width: 76.25em) {
  /* The empty main area sits over the homepage and swallows clicks. The nav
     drawer it holds is only needed at narrower widths. */
  body > div.md-container > main {
    display: none;
  }
}

/* ---- The terminal --------------------------------------------------------- */

#p3-home {
  --gutter: max(16px, 3ch);
  position: relative;
  font-family: var(--font-grid);
  font-size: 0.75rem;
  line-height: 1.6;
  font-variant-ligatures: none;
  color: var(--text);
  padding-bottom: 4lh;
  overflow-x: clip;
}

@media (max-width: 40em) {
  #p3-home {
    font-size: 0.7rem;
  }
}

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

#p3-home p,
#p3-home h1,
#p3-home h2,
#p3-home h3,
#p3-home dl,
#p3-home dd,
#p3-home figure {
  margin: 0;
}

#p3-home h1,
#p3-home h2 {
  /* Double-height rows, like DEC's ESC #3 / ESC #4 lines. */
  font-family: var(--font-grid);
  font-size: 2em;
  line-height: 1.6;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text) !important;
  text-wrap: balance;
}

#p3-home a {
  color: var(--primary-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--primary-text) 45%, transparent);
  text-underline-offset: 0.25em;
}

#p3-home a:hover {
  text-decoration-color: currentColor;
}

#p3-home :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#p3-home code {
  font: inherit;
  color: var(--warning-text);
  background: none !important;
  border: 0 !important;
  padding: 0;
  white-space: nowrap;
}

#p3-home kbd {
  font: inherit;
  font-weight: 700;
  color: var(--accent-text);
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}

#p3-home button,
#p3-home aside,
#p3-home input {
  font: inherit;
  color: inherit;
}

.c-comment {
  color: var(--dim);
  font-style: italic;
}

.c-ok { color: var(--success-text); }
.c-err { color: var(--error-text); }

.term {
  max-width: 164ch;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Panes ---------------------------------------------------------------- */

.pane {
  position: relative;
  margin-top: 2.5lh;
  padding: 1.5lh 4ch;
  border: 1px solid var(--border);
  border-radius: 0.5ch;
  scroll-margin-top: 5.5rem;
  transition: border-color 0.2s;
}

.pane:focus {
  outline: none;
}

.pane[data-active] {
  border-color: var(--primary);
}

.pane.sub {
  margin-top: 0;
  padding: 1lh 2ch;
}

.pane-title,
.pane-meta,
.pane-foot {
  position: absolute;
  top: calc(-0.5lh - 0.5px);
  left: 2ch;
  max-width: calc(100% - 4ch);
  padding-inline: 1ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  background: var(--bg);
}

.pane-title b {
  color: var(--accent-text);
}

.pane[data-active] > .pane-title {
  color: var(--text);
  font-weight: 700;
}

.pane-meta,
.pane-foot {
  left: auto;
  right: 2ch;
  color: var(--dim);
}

.pane-foot {
  top: auto;
  bottom: calc(-0.5lh - 0.5px);
}

@media (max-width: 40em) {
  .pane {
    padding: 1.5lh 2ch;
  }

  .pane.sub {
    padding: 1lh 1ch;
  }

  .pane-meta {
    display: none;
  }
}

.pane-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.5lh;
  max-width: 72ch;
  margin-bottom: 2lh;
}

.pane-head p:not(.c-comment) {
  color: var(--body-text);
}

.cursor {
  display: inline-block;
  width: 1ch;
  height: 1.15em;
  margin-left: 0.3ch;
  vertical-align: -0.2em;
  background: var(--accent);
  animation: blink 1.06s steps(1) infinite;
}

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

/* ---- Buttons -------------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1lh 2ch;
}

#p3-home a.btn {
  display: inline-block;
  padding: 0.25lh 2ch;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
}

#p3-home a.btn::before { content: "[ "; color: var(--dim); }
#p3-home a.btn::after { content: " ]"; color: var(--dim); }

#p3-home a.btn:hover {
  border-color: var(--primary);
  color: var(--primary-text);
}

#p3-home a.btn.primary {
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
}

#p3-home a.btn.primary::before,
#p3-home a.btn.primary::after {
  color: inherit;
  opacity: 0.55;
}

#p3-home a.btn.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ---- Prompt --------------------------------------------------------------- */

.prompt {
  display: flex;
  align-items: stretch;
  max-width: 80ch;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface);
}

#p3-home .prompt code {
  flex: 1;
  min-width: 0;
  padding: 0.5lh 2ch;
  overflow-x: auto;
  color: var(--text);
  scrollbar-width: thin;
}

.prompt .ps1 {
  color: var(--success-text);
  user-select: none;
}

.prompt .copy {
  flex: none;
  padding: 0 2ch;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border);
}

.prompt .copy b {
  color: var(--accent-text);
  margin-right: 0.5ch;
}

.prompt .copy:hover {
  color: var(--text);
  background: var(--panel);
}

.prompt .copy[data-copied] {
  color: var(--success-text);
}

@media (prefers-reduced-motion: no-preference) {
  .typed {
    display: inline-block;
    vertical-align: bottom;
    overflow: hidden;
    width: 60ch;
    animation: type 1.5s steps(60, end) 0.4s both;
  }
}

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

/* ---- [1] posting ---------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2lh 6ch;
  margin-bottom: 2.5lh;
}

@media (min-width: 70em) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 44ch;
    align-items: start;
  }
}

.hero-main {
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1lh;
  min-width: 0;
}

.wordmark {
  /* The name typed at a prompt: triple-size, and line-height set so it
     fills exactly two text rows. */
  margin: 0;
  font-family: var(--font-grid);
  font-size: 3em;
  line-height: calc(2 * 1.6 / 3);
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  width: max-content;
}

.wordmark .ps1 {
  color: var(--dim);
  font-weight: 400;
  user-select: none;
}

@media (prefers-reduced-motion: no-preference) {
  .wordmark {
    /* Types out one cell at a time: "❯ posting" plus the cursor. */
    animation: boot 0.6s steps(10, end) both;
  }
}

@keyframes boot {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

#p3-home h1 {
  max-width: 26ch;
}

.lede {
  max-width: 66ch;
  color: var(--body-text);
}

.lede strong {
  color: var(--text);
  font-weight: 700;
}

.fetch {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-width: 0;
}

.fetch-host b { color: var(--primary-text); }
.fetch-host span { color: var(--muted); }
.fetch-rule { color: var(--dim); }

.fetch dl div {
  display: grid;
  grid-template-columns: 10ch minmax(0, 1fr);
}

.fetch dt {
  font-weight: 700;
  color: var(--accent-text);
}

.fetch dt::after {
  content: ":";
}

.fetch dd {
  color: var(--body-text);
}

.fetch .blocks {
  display: block;
  justify-self: start;
  margin-block: 1lh;
  padding: 0;
  cursor: pointer;
  background: none;
  border: 0;
}

.fetch .blocks > span {
  display: flex;
}

.fetch .blocks i {
  display: block;
  width: 3ch;
  height: 1lh;
  background: var(--c);
}

.fetch .blocks:hover i {
  height: 1lh;
  box-shadow: inset 0 -0.25lh 0 color-mix(in oklab, var(--bg) 40%, transparent);
}

.fetch-note {
  color: var(--muted);
}

.window {
  padding: 0.6lh 1ch 0.5lh !important;
}

.window .tui {
  border-radius: 0.3ch;
}

.theme-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5lh;
  margin-top: 1.5lh;
}

.theme-label {
  color: var(--body-text);
}

#p3-home .theme-line .palette-picker {
  gap: 0 3ch;
}

#p3-home .theme-line .palette-picker button {
  gap: 1ch;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  transition: none;
}

#p3-home .theme-line .palette-picker button::before {
  content: "( )";
  color: var(--dim);
}

#p3-home .theme-line .palette-picker button[aria-checked="true"] {
  color: var(--text);
  font-weight: 700;
}

#p3-home .theme-line .palette-picker button[aria-checked="true"]::before {
  content: "(\2022)";
  color: var(--accent-text);
}

#p3-home .theme-line .palette-picker button:hover {
  color: var(--text);
}

#p3-home .theme-line .palette-picker .sw i {
  width: 1ch;
  height: 0.9em;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

/* ---- [2] keys ------------------------------------------------------------- */

.tour {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2lh 3ch;
}

@media (min-width: 70em) {
  .tour {
    grid-template-columns: 36ch minmax(0, 1fr);
    align-items: start;
  }
}

.tour-list {
  padding-inline: 0 !important;
}

.tour-list:focus-within {
  border-color: var(--accent);
}

.tour-tabs {
  display: grid;
}

.tour-tabs button {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  width: 100%;
  padding: 0 2ch;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.tour-tabs button .t::before {
  content: "  ";
  white-space: pre;
}

.tour-tabs button kbd {
  color: var(--dim);
  font-weight: 400;
}

.tour-tabs button:hover {
  color: var(--text);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
}

.tour-tabs button[aria-selected="true"] {
  color: var(--text);
  font-weight: 700;
  background: var(--surface-3);
}

.tour-tabs button[aria-selected="true"] .t::before {
  content: "\276F ";
  color: var(--accent-text);
}

.tour-list:focus-within .tour-tabs button[aria-selected="true"] {
  color: var(--on-primary);
  background: var(--primary);
}

.tour-list:focus-within .tour-tabs button[aria-selected="true"] :is(kbd, .t::before) {
  color: inherit;
}

.tour-list:focus-within .tour-tabs button[aria-selected="true"] .t::before {
  color: inherit;
}

.tour-tabs button:focus-visible {
  outline-offset: -2px;
}

.tour-stage {
  min-width: 0;
}

.panel-desc {
  min-height: 2lh;
  margin-bottom: 0.5lh !important;
  color: var(--body-text);
}

.panel-desc::before {
  content: "\00BB  ";
  white-space: pre;
  color: var(--accent-text);
}

/* ---- [3] files ------------------------------------------------------------ */

.files {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1lh 6ch;
}

@media (min-width: 70em) {
  .files {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }

  /* The copy stays beside the shell session as it scrolls past. */
  .files > .pane-head,
  #toolkit > .pane-head {
    position: sticky;
    top: 5.5rem;
  }
}

.shell-pane {
  min-width: 0;
}

#p3-home pre.shell {
  margin: 0;
  overflow-x: auto;
  font: inherit;
  color: var(--text);
  background: none !important;
  border: 0 !important;
  padding: 0;
  scrollbar-width: thin;
}

.shell .pr { color: var(--success-text); user-select: none; }
.shell .cmd { color: var(--text); font-weight: 700; }
.shell .mut { color: var(--dim); }
.shell .dir { color: var(--primary-text); font-weight: 700; }
.shell .env { color: var(--warning-text); }
.shell .key { color: var(--primary-text); }
.shell .str { color: var(--success-text); }
.shell .var { color: var(--accent-text); }

/* ---- [4] toolkit ---------------------------------------------------------- */

@media (min-width: 70em) {
  #toolkit {
    display: grid;
    grid-template-columns: 30ch minmax(0, 1fr);
    gap: 0 6ch;
  }
}

.help {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1lh;
  max-width: 100ch;
}

.help div {
  display: grid;
  grid-template-columns: 22ch minmax(0, 1fr);
  gap: 0 1ch;
}

.help dt {
  display: flex;
  gap: 1ch;
  font-weight: 700;
  color: var(--primary-text);
  white-space: nowrap;
  overflow: hidden;
}

.help dt::after {
  content: "\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7\00B7";
  flex: 1;
  overflow: hidden;
  font-weight: 400;
  color: var(--dim);
}

.help dd {
  color: var(--body-text);
}

@media (max-width: 50em) {
  .help div {
    grid-template-columns: minmax(0, 1fr);
  }

  .help dt::after {
    content: none;
  }

  .help dd {
    padding-left: 4ch;
  }
}

/* ---- [5] upgrade ---------------------------------------------------------- */

.upgrade {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1lh 6ch;
}

.upgrade .pane-head {
  margin-bottom: 0;
}

.upgrade .actions {
  margin-top: 1lh;
}

@media (min-width: 70em) {
  .upgrade {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }
}

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

.carry li {
  display: flex;
  gap: 2ch;
  margin: 0 !important;
}

.carry .ok {
  font-weight: 700;
  color: var(--success-text);
}

.carry .f {
  display: flex;
  flex: 1;
  gap: 1ch;
  min-width: 0;
  color: var(--text);
  white-space: nowrap;
}

.carry .f::after {
  content: "................................................................";
  flex: 1;
  overflow: hidden;
  color: var(--dim);
}

.carry .note {
  color: var(--dim);
}

.bar {
  display: flex;
  gap: 2ch;
  margin-top: 1lh !important;
}

.bar .fill {
  flex: 1;
  height: 1lh;
  background: repeating-linear-gradient(90deg, var(--success) 0 calc(1ch - 2px), transparent calc(1ch - 2px) 1ch);
  transform-origin: left;
}

.bar .n {
  color: var(--success-text);
  font-weight: 700;
}

@media (max-width: 40em) {
  .carry .note { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .js-home .upgrade .carry li { opacity: 0; }
  .js-home .upgrade .bar .fill { transform: scaleX(0); }
  .js-home .upgrade .bar .n { opacity: 0; }

  .js-home #upgrade[data-seen] .carry li {
    animation: line-in 0.01s steps(1) both;
  }

  .js-home #upgrade[data-seen] .carry li:nth-child(2) { animation-delay: 0.18s; }
  .js-home #upgrade[data-seen] .carry li:nth-child(3) { animation-delay: 0.36s; }
  .js-home #upgrade[data-seen] .carry li:nth-child(4) { animation-delay: 0.54s; }
  .js-home #upgrade[data-seen] .carry li:nth-child(5) { animation-delay: 0.72s; }

  .js-home #upgrade[data-seen] .bar .fill {
    animation: fill 0.9s steps(24, end) 0.1s both;
  }

  .js-home #upgrade[data-seen] .bar .n {
    animation: line-in 0.01s steps(1) 1s both;
  }
}

@keyframes line-in {
  to { opacity: 1; }
}

@keyframes fill {
  to { transform: scaleX(1); }
}

/* ---- [6] install ---------------------------------------------------------- */

.closing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2lh 6ch;
}

@media (min-width: 70em) {
  .closing {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  }
}

.closing .col {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1lh;
  align-content: start;
  min-width: 0;
}

.closing .col p:not(.c-comment) {
  color: var(--body-text);
}

.closing .col .c-comment {
  margin-bottom: -1lh;
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5lh 3ch;
  margin-top: 2lh;
  padding-top: 1lh;
  border-top: 1px dashed var(--border);
  color: var(--dim);
}

.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1ch;
}

.site-foot nav a + a::before {
  content: "\2502";
  display: inline-block;
  margin-right: 1ch;
  color: var(--dim);
}

#p3-home .site-foot a {
  text-decoration: none;
}

#p3-home .site-foot a:hover {
  text-decoration: underline;
}

/* ---- Key bar -------------------------------------------------------------- */

.keybar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0 3ch;
  padding-inline: var(--gutter);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.keybar .mode {
  flex: none;
  padding: 0 1ch;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--primary);
}

#p3-home[data-mode="jump"] .keybar .mode {
  color: var(--on-accent);
  background: var(--accent);
}

.kb-panes,
.kb-actions {
  display: flex;
  gap: 0 2ch;
}

.keybar button {
  display: inline-flex;
  gap: 0.8ch;
  padding: 0.3lh 0;
  cursor: pointer;
  color: var(--muted);
  background: none;
  border: 0;
}

.keybar button b {
  color: var(--accent-text);
}

.keybar button:hover {
  color: var(--text);
}

.keybar button[aria-current="true"] {
  color: var(--text);
}

.keybar button[aria-current="true"] b {
  padding-inline: 0.5ch;
  color: var(--on-accent);
  background: var(--accent);
}

.keybar .pos {
  margin-left: auto;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 80em) {
  .kb-panes button span {
    display: none;
  }
}

@media (max-width: 50em), (pointer: coarse) {
  .keybar .mode,
  .keybar .kb-jump,
  .keybar .kb-copy,
  .keybar .pos {
    display: none;
  }

  .keybar {
    justify-content: space-between;
    gap: 0 2ch;
  }

  .kb-panes {
    gap: 0 1ch;
  }

  .kb-panes button {
    min-width: 3ch;
    justify-content: center;
    padding-block: 0.5lh;
  }

  .keybar button[data-action] b {
    display: none;
  }
}

.js-home .toasts {
  bottom: calc(2.5lh + 0.5rem);
}

/* ---- Jump mode ---------------------------------------------------- */

.jump-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  pointer-events: none;
  background: color-mix(in oklab, var(--bg) 30%, transparent);
}

#p3-home[data-mode="jump"] .jump-layer {
  display: block;
}

.jump-label {
  position: absolute;
  padding: 0 0.6ch;
  font: 700 0.7rem/1.35 var(--font-grid);
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--bg);
  transform: translate(-0.4ch, -45%);
}

.jump-label .hit {
  opacity: 0.45;
}

/* ---- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  #p3-home .cursor { animation: none; }
  #p3-home *, #p3-home *::before { transition: none !important; }
}
