/* Shared stylesheet. build.py copies this to assets/style.css, which both the
   generated post pages AND the hand-written index.html link — so edit this
   file, never assets/style.css (it is overwritten on every build).
   index.html defines no palette of its own; it consumes the :root below. */

:root {
  --bg:     #0b0e11;
  --panel:  #141a22;
  --fg:     #dbe4ed;   /* 15.1:1  body text                        */
  --mute:   #adbdcc;   /* 10.1:1  secondary text — most of the page */
  --dim:    #93a2b1;   /*  7.4:1  meta lines, reference links       */
  --faint:  #66737f;   /*  4.0:1  decoration only, never body text  */
  --rule:   #262f3a;
  --accent: #63f5a5;   /* 13.9:1  section names, headings           */
  --link:   #4fc3ff;   /*  9.8:1  links — vivid, always underlined  */
  --bright: #f7fafd;   /* 18.5:1  titles                            */
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--rule) var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.7 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", "Noto Sans Mono CJK TC", monospace;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---- layout ------------------------------------------------------------ */

.wrap {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 0 3rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ---- left-hand article menu -------------------------------------------- */

.sidebar {
  position: sticky;
  top: 2.5rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  font-size: 0.88rem;
  padding-right: 0.5rem;
}

.sidebar a { text-decoration: none; }

.sidebar .home {
  display: block;
  color: var(--accent);
  font-weight: 600;
}

.sidebar .all {
  display: block;
  margin-top: 0.35rem;
  color: var(--link);
  font-size: 0.8rem;
}

.sidebar ul { margin: 1.75rem 0 0; padding: 0; list-style: none; }

.sidebar li.year {
  margin: 1.4rem 0 0.5rem;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.sidebar li.year:first-child { margin-top: 0; }

.sidebar li a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.7rem;
  border-left: 2px solid var(--rule);
  color: var(--link);
  line-height: 1.45;
}

.sidebar li a:hover { color: var(--accent); border-left-color: var(--dim); }

.sidebar li a.current {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ---- article ----------------------------------------------------------- */

article { min-width: 0; }

article > header { padding-bottom: 1.75rem; border-bottom: 1px solid var(--rule); }

article h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  line-height: 1.3;
  color: var(--bright);
}

.meta { margin: 0.6rem 0 0; color: var(--dim); font-size: 0.84rem; }

article h1[id], article h2, article h3, article h4, article h5, article h6 {
  margin: 2.5rem 0 0.9rem;
  line-height: 1.35;
}

/* The body's own leading h1 usually repeats the title; tone it down. */
article h1[id] { font-size: 1.35rem; color: var(--bright); }
article h2 { font-size: 1.1rem; color: var(--accent); }
article h3 { font-size: 0.98rem; color: var(--accent); }
article h4, article h5, article h6 { font-size: 0.9rem; color: var(--mute); }

article p { margin: 1.1rem 0; }

article ul, article ol { margin: 1.1rem 0; padding-left: 1.4rem; }
article li { margin: 0.3rem 0; }

article blockquote {
  margin: 1.3rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--rule);
  color: var(--mute);
}

article hr { margin: 2.25rem 0; border: 0; border-top: 1px solid var(--rule); }

article img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.4rem 0;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--panel);
}

/* responsive video embeds */
.video-container {
  position: relative;
  margin: 1.4rem 0;
  padding-top: 56.25%;                 /* 16:9 */
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--panel);
}

.video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* inline code */
article :not(pre) > code {
  padding: 0.1em 0.36em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--panel);
  color: #a5d6ff;
  font-size: 0.9em;
  word-break: break-word;
}

/* code blocks */
article pre {
  margin: 1.4rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--panel);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 4;
}

article pre code { color: var(--fg); }

/* ---- post index -------------------------------------------------------- */

ul.index { margin: 0.8rem 0 2rem; padding: 0; list-style: none; }

ul.index li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--rule);
}

ul.index .when { color: var(--faint); font-size: 0.8rem; white-space: nowrap; }

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

footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--dim);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 52rem) {
  .wrap { grid-template-columns: minmax(0, 1fr); gap: 2rem 0; padding-top: 2rem; }

  .sidebar {
    position: static;
    max-height: 14rem;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--panel);
  }
}
