/* 0xsd — lean retro-terminal blog
   Dark, monospace, quiet. No about page, no bloat.
   Inspired by a terminal window: dim background, phosphor-green accents,
   a soft glow, and a lot of breathing room.
*/

:root {
  /* terminal palette */
  --bg:          #0d1014;   /* window background */
  --bg-soft:     #12161c;   /* rows / insets */
  --bg-glow:     #161c24;   /* hover */
  --ink:         #c8d3c8;   /* body text (slightly warm green-grey) */
  --ink-dim:     #7f8b83;   /* muted */
  --ink-faint:   #56615a;   /* very muted */
  --accent:      #8fce6e;   /* phosphor green — titles, cursor */
  --accent-soft: #6fbf8a;
  --line:        #1d242e;   /* rules */
  --line-soft:   #171d25;
  --sel:         rgba(143, 206, 110, 0.18);

  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", "Cascadia Code",
          "Fira Code", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  min-height: 100vh;
  /* faint scanline / vignette for terminal feel, kept subtle */
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%,
                    rgba(143,206,110,0.06), transparent 60%),
    linear-gradient(var(--bg), var(--bg));
}

/* gentle phosphor glow on the whole page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0,0,0,0.12) 3px,
      rgba(0,0,0,0.12) 3px
    );
  opacity: .5;
  mix-blend-mode: overlay;
  z-index: 9999;
}

main {
  max-width: 46rem;         /* ~736px, a comfortable terminal width */
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 5rem) 1.5rem 3rem;
}

/* ---------- shared bits ---------- */

h1 {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
  font-size: clamp(1.55rem, 5vw, 2.15rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 .35rem;
  text-shadow: 0 0 18px rgba(143, 206, 110, 0.28);
  word-break: break-word;
}

/* blinking terminal cursor after the title */
.cursor {
  color: var(--accent);
  font-weight: 400;
  animation: blink 1.1s steps(1) infinite;
  margin-left: .1em;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; opacity: .7; }
}

/* breadcrumb line: 0xsd / Posts  */
.crumb {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--ink-dim);
  margin: 0 0 2.1rem;
  display: flex;
  align-items: baseline;
  gap: .45rem;
  flex-wrap: wrap;
}
.crumb .brand span:first-child { color: var(--accent); }
.crumb .dot { color: var(--ink-faint); }
.crumb a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color .15s ease;
}
.crumb a:hover { color: var(--accent); }
.crumb a:active { color: var(--accent-soft); }

/* "11 posts · newest first" line */
.byline {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-faint);
  margin: 0 0 2.2rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.subtitle {
  color: var(--ink);
  font-size: clamp(1.05rem, 2.4vw, 1.22rem);
  margin: .2rem 0 1rem;
  max-width: 34rem;
  line-height: 1.5;
}

/* ---------- index list ---------- */

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

.row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  padding: 1.05rem 0.9rem;
  margin: 0 -0.9rem;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .16s ease, transform .16s ease;
}
.row:first-child { border-top: 1px solid var(--line-soft); }

.row-date {
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--ink-faint);
  flex: 0 0 6.6rem;
  padding-top: .18rem;
  letter-spacing: .01em;
  white-space: nowrap;
}

.row-main { flex: 1; min-width: 0; }

.row-title {
  display: block;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.45;
  letter-spacing: -0.005em;
  transition: color .15s ease;
  word-break: break-word;
}

.row-sub {
  font-size: .88rem;
  color: var(--ink-dim);
  margin: .28rem 0 0;
  max-width: 36rem;
  line-height: 1.5;
}

.row-arrow {
  font-family: var(--mono);
  color: var(--ink-faint);
  font-size: 1.1rem;
  flex: 0 0 auto;
  padding-top: .18rem;
  transition: color .15s ease, transform .16s ease, opacity .15s ease;
  opacity: .55;
}

/* row hover — the whole row lights up like a selected terminal line */
.row:hover {
  background: var(--bg-glow);
  transform: translateX(2px);
}
.row:hover .row-title,
.row:hover .row-date,
.row:hover .row-sub { color: var(--accent); }
.row:hover .row-arrow {
  color: var(--accent);
  opacity: 1;
  transform: translateX(3px);
}
.row:active { background: var(--bg-soft); }

.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------- post page ---------- */

article { margin-top: .5rem; }

article p {
  margin: 0 0 1.25rem;
  color: var(--ink);
  max-width: 42rem;
  orphans: 3;
  widows: 3;
}

article h2, article h3 {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
  margin: 2.1rem 0 .7rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
article h2 { font-size: 1.25rem; }
article h3 { font-size: 1.08rem; }
article h2:first-child, article h3:first-child { margin-top: .6rem; }

article ul {
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
  max-width: 42rem;
}
article li { margin: .45rem 0; }
article li::marker { color: var(--accent-soft); }

article a {
  color: var(--accent-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(111, 191, 138, 0.35);
  transition: color .15s ease, border-color .15s ease;
}
article a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

article strong { color: var(--ink); }
article em { color: var(--ink-dim); }

article code {
  font-family: var(--mono);
  font-size: .9em;
  color: var(--accent);
  background: var(--bg-soft);
  padding: .1em .4em;
  border-radius: 5px;
}

article hr {
  border: none;
  border-top: 1px dashed var(--line);
  margin: 1.8rem 0;
  max-width: 42rem;
}

article figure {
  margin: 1.8rem 0;
  max-width: 42rem;
}

article img {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
}

article figcaption {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--ink-faint);
  margin-top: .55rem;
  line-height: 1.5;
}

/* back nav */
.nav-end { margin-top: 2.5rem; }
.nav-end a {
  font-family: var(--mono);
  font-size: .88rem;
  color: var(--ink-dim);
  text-decoration: none;
  display: inline-flex;
  gap: .4rem;
  padding: .6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.nav-end a:hover {
  color: var(--accent);
  border-color: rgba(143,206,110,.4);
  background: var(--bg-glow);
}

/* ---------- footer ---------- */

footer {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.6rem 1.5rem 2.5rem;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--ink-faint);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
footer span:first-child { color: var(--accent); }
footer a {
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
footer a:hover {
  color: var(--accent);
  border-color: rgba(143, 206, 110, .4);
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  body { font-size: 16px; }

  main {
    padding: 1.5rem 1rem 2.25rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .crumb { margin-bottom: 1.4rem; }
  .byline { margin-bottom: 1.5rem; }

  .row {
    flex-direction: column;
    gap: .2rem;
    padding: 1rem .25rem;
    margin: 0;
    border-radius: 0;
    min-height: 56px;
    transform: none;
  }
  .row:hover { transform: none; }
  .row:first-child { border-top: 1px solid var(--line-soft); }

  .row-date {
    flex-basis: auto;
    padding-top: 0;
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .row-title { font-size: 1.05rem; }
  .row-sub { margin-top: .35rem; }
  .row-arrow { display: none; }

  h1 { font-size: clamp(1.45rem, 7vw, 1.9rem); }

  article p, article ul, article figure { max-width: none; }
  article img { border-radius: 6px; }

  footer {
    padding: 1.25rem 1rem calc(1.75rem + env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ---------- accessibility / print ---------- */

::selection { background: var(--sel); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .row, .row-arrow { transition: none; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #1a1a1a; }
  body::before { display: none; }
  main, footer { max-width: 100%; }
  h1, article h2, article h3, .crumb, .byline, .row-title, .row-date { color: #1a1a1a; }
  .row { border-bottom: 1px solid #eee; }
  .cursor { display: none; }
}
