/*
 * Home page: `systemctl status ehsan`.
 *
 * Loaded only by overrides/home.html, and every rule is scoped to
 * `.st-home`, so nothing here reaches the blog. Colours come from the
 * bondad theme's variables, so the light and dark schemes both work.
 */

/* The light/dark toggle, alone in the top-right corner: overrides/home.html
   replaces the site header with it. */
.st-topbar {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 1;
  display: flex;
  color: var(--md-default-fg-color--light);
  /* Zensical's script adds its header shadow class here too. */
  box-shadow: none;
}

.st-topbar .md-header__button:hover,
.st-topbar .md-header__button:focus-visible {
  color: var(--md-primary-fg-color);
}

.st-home {
  /* Status green. The theme defines it per scheme (#3DDC97 dark, #13784F
     light); the fallback is the dark value for a non-bondad palette. */
  --st-green: var(--bondad-green, #3DDC97);
  --st-muted: var(--md-default-fg-color--light);
  --st-accent: var(--md-primary-fg-color);

  display: flex;
  flex-direction: column;
  gap: 3rem;
  max-width: 44rem;              /* 880px at the theme's 20px root */
  margin: 1.6rem auto 0;
  font-family: var(--md-code-font-family);
  font-feature-settings: "liga" 0, "calt" 0;
  color: var(--md-default-fg-color);
}

/* The section and its output. */
.st-home .st-section {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-width: 0;                  /* let the scroll box shrink, not the page */
}

.md-typeset .st-home .st-prompt {
  margin: 0;
  font-family: inherit;
  font-size: 0.9rem;             /* 18px */
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--md-default-fg-color);
}

.st-home .st-dollar {
  color: var(--st-accent);
}

/* Horizontal scroll for the preformatted block, so long lines never wrap
   and never push the page sideways. */
.st-home .st-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.2rem;
}

.st-home .st-scroll:focus-visible {
  outline: 0.1rem solid var(--st-accent);
  outline-offset: 0.2rem;
}

.st-home .st-out {
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 100%;
  /* Room for the last Docs link's 44px tap target, which the scroll box
     would otherwise clip. */
  padding-bottom: 0.4rem;
  font-size: 0.8rem;             /* 16px */
  line-height: 1.75;
  white-space: pre;
}

/* Unit line: big, bold, pulsing dot. Overrides the theme's h1 styles,
   including its "> " prompt, which would double up with the dot. */
.md-typeset .st-home .st-unit {
  margin: 0 0 0.7rem;
  font-family: inherit;
  font-size: clamp(1.1rem, 3.4vw, 1.5rem);   /* 22px → 30px */
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--md-default-fg-color);
}

.md-typeset .st-home .st-unit::before {
  content: none;
}

.st-home .st-dot {
  color: var(--st-green);
  animation: st-pulse 1.6s ease-in-out infinite;
}

.st-home .st-desc {
  font-weight: 500;
  color: var(--st-muted);
}

.st-home .st-label,
.st-home .st-hint {
  color: var(--st-muted);
}

.st-home .st-ok {
  font-weight: 800;
  color: var(--st-green);
}

/* Docs links: bold, accent. The rows keep the status lines' rhythm; the
   44px tap target comes from an invisible ::after on each link instead of
   taller rows. Neighbouring targets overlap by 16px; a tap there goes to
   the lower link. */
.st-home .st-docs,
.st-home .st-docs > .st-val {
  display: flex;
  align-items: center;
}

.st-home .st-docs--first {
  margin-top: 0.7rem;
}

.md-typeset .st-home .st-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  color: var(--st-accent);
  text-decoration: none;
}

.md-typeset .st-home .st-link::after {
  content: "";
  position: absolute;
  left: -0.25em;
  right: -0.25em;
  top: 50%;
  height: 2.2rem;                /* 44px */
  transform: translateY(-50%);
}

/* Brand icon in front of a link's text (GitHub, LinkedIn). */
.st-home .st-icon {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  margin-right: 0.5em;
}

.md-typeset .st-home .st-link:hover,
.md-typeset .st-home .st-link:focus-visible {
  color: var(--md-accent-fg-color);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Journal: the log lines under the unit info. Smaller than the status
   block, with its own scroll box. Colours are the theme's per-scheme
   tokens; the fallbacks are the dark values for a non-bondad palette.
   Contrast on the page background: prefix 6.1 / 5.3, message 12.7 / 12.9,
   amber 11.1 / 5.8 (dark / light). */
.st-home .st-journal {
  padding-top: 1rem;             /* 20px */
  border-top: 0.05rem solid var(--bondad-border, var(--md-default-fg-color--lightest));
}

/* A flex column, like .st-out: with white-space: pre, a block container
   would render the newlines between the line <div>s as blank lines. */
.st-home .st-log-out {
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 100%;
  font-size: 0.7rem;             /* 14px */
  line-height: 1.9;
  white-space: pre;
  /* One step softer than the status values: 60% text, 40% muted. */
  color: color-mix(in srgb, var(--md-default-fg-color) 60%, var(--st-muted));
}

.st-home .st-log-prefix {
  color: var(--bondad-comment, var(--md-code-hl-comment-color));
}

.st-home .st-warn {
  color: var(--bondad-amber, #FFB86B);
}

/* Theme red: 6.75:1 dark, 5.1:1 light. */
.st-home .st-err {
  color: var(--bondad-red, #FF6B57);
}

/* Lines added live by javascripts/home-journal.js fade in. */
.st-home .st-log--new {
  animation: st-log-in 400ms ease-out both;
}

/* Opacity only: the script measures line positions while they fade. */
@keyframes st-log-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Live journal (with JavaScript; .st-js is set in overrides/home.html
   before the page renders): a fixed-height box, six rows here, so the
   page doesn't grow as lines arrive or jump when the script starts. The
   no-JS lines are hidden until the script replaces them. Fills from the
   top; once full (--full), new lines enter at the bottom and the oldest
   scroll off the top, as in a terminal. */
.st-js .st-home .st-log-out {
  height: calc(6 * 1.9em);
  overflow: hidden;
}

.st-js .st-home .st-log-out:not([data-live]) {
  visibility: hidden;
}

.st-home .st-log-out--full {
  justify-content: flex-end;
}

/* Closing prompt with a coral cursor block. */
.st-home .st-footer {
  /* Sit 20px under the journal, matching the 20px above its first line,
     instead of the full gap between sections (3rem, minus 2rem here). */
  margin-top: -2rem;
  display: flex;
  align-items: flex-end;
  padding-top: 1.2rem;
  border-top: 0.05rem solid var(--md-default-fg-color--lightest);
  font-size: 0.65rem;            /* 13px */
  color: var(--st-muted);
}

.st-home .st-cursor {
  display: inline-block;
  width: 0.56em;
  height: 0.12em;
  margin-left: 0.4em;
  margin-bottom: 0.15em;
  background: var(--md-primary-fg-color);
  animation: st-blink 1.1s steps(1) infinite;
}

/* Phones and narrow windows (under 720px, where the longest status line
   no longer fits). Scrolling sideways hid half of every line, so here the
   output reflows like a terminal resized narrow: labels stay right-aligned
   in a 9-character column, values wrap beside them, journal lines wrap
   with a hanging indent. The padding spaces in the markup collapse
   (white-space: normal), so the same markup serves both layouts. */
@media screen and (max-width: 44.9375em) {
  .st-home {
    gap: 2rem;
    margin-top: 0;
  }

  .st-home .st-section {
    gap: 1rem;
  }

  .st-home .st-footer {
    margin-top: -1rem;           /* 2rem gap here, so 20px as on desktop */
  }

  .st-home .st-out,
  .st-home .st-log-out {
    width: auto;
    white-space: normal;
  }

  .st-home .st-out {
    font-size: 0.7rem;           /* 14px */
    line-height: 1.7;
  }

  /* Unit line wraps under the name, not under the dot. */
  .md-typeset .st-home .st-unit {
    margin-bottom: 0.5rem;
    padding-left: 1.2em;
    text-indent: -1.2em;
    font-size: 1.1rem;           /* 22px */
  }

  .st-home .st-line {
    display: flex;
  }

  .st-home .st-line > .st-label {
    flex: none;
    width: 9ch;
    margin-right: 1ch;
    text-align: right;
  }

  .st-home .st-val {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* The hint's padding spaces collapse away here, so put one back. */
  .st-home .st-hint {
    margin-left: 1ch;
  }

  /* Keep a command-line flag in one piece instead of breaking it at its
     hyphens (`--break-` / `them`). */
  .st-home .st-arg {
    white-space: nowrap;
  }

  .st-home .st-log-out {
    font-size: 0.65rem;          /* 13px */
    line-height: 1.7;
  }

  .st-home .st-log {
    padding-left: 2ch;
    text-indent: -2ch;
  }

  /* Space between lines, above rather than below, so a full journal has
     no gap under its newest line. */
  .st-home .st-log + .st-log {
    margin-top: 0.3rem;
  }

  /* Only the time on phones: "22:22:07 Message", not the full
     "Nov 07 22:22:07 bondad ehsan[1]: Message", so lines wrap less. */
  .st-home .st-log-date,
  .st-home .st-log-src {
    display: none;
  }

  /* Five lines of two rows each, which is what nearly every message
     takes at 360-414px with the short prefix. A one-row message leaves
     the oldest line half scrolled off the top; a short fade there makes
     that read as scrolling, not clipping. */
  .st-js .st-home .st-log-out {
    height: calc(5 * 2 * 1.7em + 4 * 0.3rem);
  }

  .st-home .st-log-out--full {
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 1.2em);
    mask-image: linear-gradient(to bottom, transparent, #000 1.2em);
  }
}

@keyframes st-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

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

@media (prefers-reduced-motion: reduce) {
  .st-home .st-dot,
  .st-home .st-cursor,
  .st-home .st-log--new {
    animation: none;
  }
}
