/* blog.kooskleven.com — common.css
   Light greyscale palette (white page, pale grey sidebar, 50% grey, black) with coral and
   turquoise reserved for hover and active states. Serif type.
   Left column: picture + banner, site nav, blog nav, social links.
   Right column: <main>. Copyright runs full width underneath. */

@import url("https://fonts.googleapis.com/css2?family=Young+Serif&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;1,6..72,400&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  /* Light greyscale, after the posterized portrait: white, 50% grey, black */
  --bg:        #ffffff;   /* page */
  --bg-dark:   #f3f3f3;   /* sidebar, panels, code */
  --bg-hi:     #e9e9e9;   /* hover fills */
  --line:      #dedede;
  --line-2:    #c8c8c8;
  --comment:   #a8a8a8;   /* disabled */
  --grey:      #808080;   /* the 50% grey */
  --dim:       #666666;   /* meta text */
  --fg-dim:    #2b2b2b;   /* body text */
  --fg:        #111111;   /* headings */
  --strong:    #000000;   /* heaviest edges and fills */
  --on-strong: #ffffff;   /* text on --strong */

  /* The copyright bar stays dark */
  --footer-bg: #0b0b0b;
  --footer-fg: #8f8f8f;

  /* Pops of colour, for hover / active / focus only.
     The -ink versions are darker so text stays readable on white. */
  --coral:          #ff6b81;
  --coral-ink:      #c7334f;
  --turquoise:      #1fd1b0;
  --turquoise-ink:  #0a8a73;

  --side: 14rem;   /* width of the picture, and everything under it */

  --display: "Young Serif", "Georgia", "Times New Roman", serif;
  --body:    "Newsreader", "Georgia", "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg-dim);
  font: 400 1rem/1.65 var(--body);
}

a { color: var(--fg); text-decoration-color: var(--grey); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--turquoise-ink); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--turquoise-ink); outline-offset: 2px; }
::selection { background: var(--coral); color: var(--fg); }

/* ---------- Two-column grid ---------- */

#everything {
  display: grid;
  grid-template-columns: calc(var(--side) + 4rem) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto 1fr;
  grid-template-areas:
    "title  main"
    "site   main"
    "blog   main"
    "social main"
    ".      main";
  min-height: 100vh;
  background:
    linear-gradient(to right,
      var(--bg-dark) calc(var(--side) + 4rem),
      var(--line) calc(var(--side) + 4rem),
      var(--line) calc(var(--side) + 4rem + 1px),
      transparent 0);
}

#site-title   { grid-area: title; }
#site-nav     { grid-area: site; }
#blog-nav     { grid-area: blog; }
footer.site   { grid-area: social; }
#everything > main { grid-area: main; }


#site-title, #site-nav, #blog-nav, footer.site {
  width: var(--side);
  margin-left: 2rem;
}

/* ---------- Picture + banner ---------- */

#site-title {
  position: relative;
  margin-top: 2.25rem;
}

#profile-pic img {
  display: block;
  width: 100%;
  height: auto;
}

#site-title .title {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  width: 88%;
  padding: 0.4rem 0.5rem 0.45rem;
  background: var(--bg-dark);
  border-bottom: 3px solid var(--strong);
  text-align: center;
  line-height: 1;
}

#site-title .title a {
  color: var(--fg);
  font: 400 1.05rem var(--display);
  letter-spacing: 0.01em;
  text-decoration: none;
}

#site-title .title a:hover { color: var(--coral-ink); }

/* ---------- home / blog, side by side ---------- */

#site-nav ul {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

#site-nav li { flex: 1; }

#site-nav a {
  display: block;
  padding: 0.5rem 0 0.4rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 2px solid var(--line-2);
}

#site-nav li:last-child a { color: var(--strong); border-bottom-color: var(--strong); }  /* this site is the blog */
#site-nav a:hover { color: var(--turquoise-ink); background: var(--bg-hi); }

/* ---------- Blog nav + search ---------- */

#blog-nav ul {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}

#blog-nav li { border-bottom: 1px solid var(--line); }

#blog-nav a {
  display: block;
  padding: 0.4rem 0.25rem;
  font-size: 0.9rem;
  color: var(--fg-dim);
  text-decoration: none;
}

#blog-nav a:hover { color: var(--turquoise-ink); background: var(--bg-hi); }

#blog-nav li:has(form) { border-bottom: 0; padding-bottom: 0.9rem; }
#blog-nav li:has(form) + li { border-top: 1px solid var(--line); }

#blog-nav form { display: flex; gap: 0.5rem; }

/* Shared by the sidebar search and the search page:
   square edges and hard offset shadows, like the next/prev boxes. */

#blog-nav input[type="search"],
.blog-search-fields input[type="search"],
.sort-by-wrap select {
  min-width: 0;
  padding: 0.35rem 0.55rem;
  font: 0.85rem var(--body);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--grey);
  border-radius: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#blog-nav input[type="search"] { flex: 1; }

#blog-nav input[type="search"]::placeholder,
.blog-search-fields input[type="search"]::placeholder { color: var(--comment); }

/* the browser's clear (x) button, in black instead of the default blue */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 0.7rem;
  height: 0.7rem;
  cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='M1 1l8 8M9 1l-8 8' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat center / contain;
}

#blog-nav input[type="search"]:hover,
.blog-search-fields input[type="search"]:hover,
.sort-by-wrap select:hover { border-color: var(--strong); }

#blog-nav input[type="search"]:focus,
.blog-search-fields input[type="search"]:focus,
.sort-by-wrap select:focus {
  outline: none;
  border-color: var(--strong);
  box-shadow: 3px 3px 0 var(--turquoise);
}

#blog-nav button,
.blog-search-fields button {
  padding: 0.35rem 0.75rem;
  font: 500 0.85rem var(--body);
  color: var(--on-strong);
  background: var(--strong);
  border: 1px solid var(--strong);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--grey);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#blog-nav button:hover,
#blog-nav button:focus-visible,
.blog-search-fields button:hover,
.blog-search-fields button:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--coral);
}
#blog-nav button:active,
.blog-search-fields button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--turquoise);
}

/* ---------- Search page: fields, checkboxes, sort ---------- */

/* Same shape as the sidebar search: box and button on one row,
   the field checkboxes on the row beneath. */
.blog-search-fields {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  align-items: center;
  column-gap: 0.5rem;
  row-gap: 0.75rem;
  margin: 0 0 1rem;
}
.blog-search-fields input[type="search"] {
  grid-column: 1 / 5;
  grid-row: 1;
  align-self: stretch;
}
.blog-search-fields button {
  grid-column: 5;
  grid-row: 1;
  align-self: stretch;
}
.blog-search-fields label {
  grid-row: 2;
  margin-right: 0.75rem;
}

.blog-search-fields label,
.sort-by-wrap label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: 0.8rem var(--mono);
  color: var(--dim);
  cursor: pointer;
}
.blog-search-fields label:hover { color: var(--fg); }

.blog-search-fields input[type="checkbox"] {
  appearance: none;
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--grey);
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.blog-search-fields label:hover input[type="checkbox"] { border-color: var(--strong); }
.blog-search-fields input[type="checkbox"]:checked {
  background: var(--strong);
  border-color: var(--strong);
  box-shadow: inset 0 0 0 2px var(--bg);   /* a white ring inside the square */
}
.blog-search-fields input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--bg), 2px 2px 0 var(--turquoise);
}

.sort-by-wrap {
  margin: 0 0 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--line-2);
}
.sort-by-wrap select {
  appearance: none;
  padding-right: 1.9rem;
  cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23000'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
}

/* ---------- Social links ---------- */

#social-links {
  margin: 1.75rem 0 2.25rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

#social-links a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0;
  color: var(--fg-dim);
  text-decoration: none;
}

#social-links a:hover { color: var(--turquoise-ink); }

#social-links img {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0.18rem;
  object-fit: contain;
}

/* ---------- Main column ---------- */

#everything > main {
  width: 100%;
  max-width: 40rem;
  padding: 2.75rem 3rem 4rem;
}

main h1 {
  font: 400 clamp(2.1rem, 4.5vw, 3.2rem)/1 var(--display);
  color: var(--fg);
  letter-spacing: -0.01em;
  margin: 0 0 2.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--strong);
}

main h2 {
  font: italic 400 0.9rem/1.3 var(--body);
  color: var(--dim);
  margin: 0 0 0.3rem;
}

main h3 {
  font: 400 1.45rem/1.2 var(--display);
  margin: 0 0 0.25rem;
}

main h3 a { color: var(--fg); text-decoration: none; }
main h3 a:hover { color: var(--turquoise-ink); }

main p { margin: 0 0 1rem; }
#front-page h3 + p { color: var(--grey); font-size: 0.8rem; letter-spacing: 0.02em; }
#front-page .latest > p:last-child a { color: var(--fg-dim); font-size: 0.85rem; }  /* tag links */

main img { max-width: 100%; height: auto; }

article > h3 { margin-top: 1.75rem; }

main h4 {
  font: italic 500 1.05rem/1.3 var(--body);
  color: var(--fg);
  margin: 1.5rem 0 0.25rem;
}

/* ---------- Post header ---------- */

article > header h1 { margin-bottom: 1rem; }

article > header .lede {
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--fg);
  margin: 0 0 0.75rem;
}

article > header .published-at {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--grey);
}

article > header .related-tags {
  font-size: 0.85rem;
  margin: 0.2rem 0 0;
  color: var(--dim);
}

article > header .related-tags a { color: var(--fg-dim); }

article > header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--line-2);
}

/* ---------- Next / prev: a box under the article, right-aligned ---------- */

#blog-post-links { margin-top: 2.5rem; }

#blog-post-links nav {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  padding: 0.75rem;
  background: var(--bg-dark);
  border: 1px solid var(--line);
}

#blog-post-links ul {
  display: flex;
  flex-direction: row-reverse;   /* markup is next, prev; show prev on the left */
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#blog-post-links a {
  display: block;
  padding: 0.5rem 0.85rem;
  font: 400 0.9rem/1.25 var(--display);
  text-decoration: none;
  color: var(--strong);
  background: var(--bg);
  border: 1px solid var(--strong);
  border-radius: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#blog-post-links li:first-child a::after  { content: "\00a0\2192"; }  /* next -> */
#blog-post-links li:last-child  a::before { content: "\2190\00a0"; }  /* <- prev */

/* Selectable: a hard offset shadow, like the portrait's */
#blog-post-links a[href]:not([href=""]) {
  box-shadow: 4px 4px 0 var(--grey);
}
#blog-post-links a[href]:not([href=""]):hover,
#blog-post-links a[href]:not([href=""]):focus-visible {
  color: var(--on-strong);
  background: var(--strong);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--coral);
}
#blog-post-links a[href]:not([href=""]):active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--turquoise);
}

/* Not selectable: no href, an empty href, or .inactive */
#blog-post-links a.inactive,
#blog-post-links a:not([href]),
#blog-post-links a[href=""] {
  color: var(--comment);
  background: transparent;
  border: 1px dashed var(--line-2);
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

/* ---------- Copyright ---------- */

#copyright-footer {
  padding: 0.9rem 2rem;
  font-size: 0.8rem;
  color: var(--footer-fg);
  background: var(--footer-bg);
}

/* ---------- Small screens: one column ---------- */

/* Stop iOS from resizing text on rotate */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 46rem) {
  html, body { font-size: 1.0625rem; }    /* 17px body text on phones */

  #everything {
    display: block;
    min-height: 0;
    background: none;
  }

  /* Left panel becomes a top panel: same pale grey band, same order */
  #site-title, #site-nav, #blog-nav, footer.site {
    margin-left: auto;
    margin-right: auto;
  }
  #site-title { margin-top: 0; padding-top: 1.5rem; }
  #site-nav, #blog-nav, footer.site { width: min(100% - 2.5rem, 20rem); }
  #site-title, #site-nav, #blog-nav {
    background: var(--bg-dark);
    box-shadow: 0 0 0 100vmax var(--bg-dark);   /* stretch the grey edge to edge */
    clip-path: inset(0 -100vmax);
  }
  #blog-nav { padding: 1.5rem 0; }
  #blog-nav ul { margin-top: 0; }   /* a top margin here would leak out as a white gap */
  #site-title { width: 12rem; }
  #blog-nav + main,
  #blog-nav ~ main { border-top: 1px solid var(--line); }

  /* Bigger tap targets */
  #site-nav a { padding: 0.75rem 0 0.65rem; font-size: 1rem; }
  #blog-nav a { padding: 0.7rem 0.25rem; font-size: 1rem; }

  /* 16px+ inputs keep iOS from zooming in on focus */
  #blog-nav input[type="search"],
  .blog-search-fields input[type="search"],
  .sort-by-wrap select,
  #blog-nav button,
  .blog-search-fields button { font-size: 1rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }

  #everything > main { padding: 2rem 1.25rem 2.5rem; }
  main h1 { margin-bottom: 1.5rem; }
  #blog-post article { overflow-wrap: break-word; }

  /* Next / prev: full width, easy to hit */
  #blog-post-links nav { width: 100%; margin-left: 0; }
  #blog-post-links li { flex: 1 1 8rem; }
  #blog-post-links a { padding: 0.75rem 0.85rem; text-align: center; }

  footer.site { padding-top: 0.5rem; }
  #copyright-footer { text-align: center; }
}

/* ================= Additions ================= */

:root {
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

/* 1. Atmosphere: a faint film grain instead of a flat fill */
body {
  background: var(--bg);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 2. Portrait: offset "print misregistration" shadow to match the posterized look */
#profile-pic img {
  box-shadow: 6px 6px 0 var(--grey), -3px -3px 0 var(--strong);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
#site-title:hover #profile-pic img {
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 var(--coral), -4px -4px 0 var(--strong);
}

/* 3. Metadata in mono: dates, tags, the "latest post" label */
main h2:first-child,
#front-page h3 + p,
.blog-post-list h3 + p,
article > header .published-at {
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* 4. Tags as pills (front page, archive, post header) */
/* Only the tag line of a post card or post header. (A bare "section p:last-child"
   also matched one-paragraph sections like the front-page blurb.) */
#front-page .latest > p:last-child a,
.blog-post-list li > p:last-child a,
article > header .related-tags a {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  font: 0.75rem var(--mono);
  color: var(--fg-dim);
  text-decoration: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
#front-page .latest > p:last-child a:hover,
.blog-post-list li > p:last-child a:hover,
article > header .related-tags a:hover {
  color: var(--turquoise);
  background: var(--fg-dim);
  border-color: var(--fg-dim);
}

/* 5. Post lists (front page + archive) as cards with an accent edge */
#front-page .latest,
.blog-post-list ol > li {
  position: relative;
  padding: 1.25rem 1.4rem 0.4rem;
  background: var(--bg-dark);
  border: 1px solid var(--line);
  border-left: 3px solid var(--grey);
  border-radius: 4px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
#front-page .latest:hover,
.blog-post-list ol > li:hover {
  border-left-color: var(--coral);
  transform: translateX(3px);
}
.blog-post-list ol {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.blog-post-list h3 + p { color: var(--grey); }

/* Front-page intro */
#front-page .blurb p {
  margin: 0 0 2.25rem;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--fg);
}

/* 6. Article body: real subheadings, animated links */
#blog-post article > h2 {
  font: 400 1.5rem/1.2 var(--display);
  color: var(--fg);
  margin: 2.25rem 0 0.75rem;
}
#front-page .blurb p a,
#blog-post article > p a,
#blog-post article li a {
  text-decoration: none;
  background: linear-gradient(var(--turquoise-ink), var(--turquoise-ink)) 0 100% / 0 1px no-repeat,
              linear-gradient(var(--line-2), var(--line-2)) 0 100% / 100% 1px no-repeat;
  transition: background-size 0.3s ease;
}
#front-page .blurb p a:hover,
#blog-post article > p a:hover,
#blog-post article li a:hover { color: var(--turquoise-ink); background-size: 100% 1px, 100% 1px; }

/* Subheadings inside a post get a little room before their paragraph */
#blog-post article > h3 { margin: 2.25rem 0 0.6rem; }
#blog-post article > h4 { margin: 1.75rem 0 0.4rem; }

/* 7. Code, quotes, rules: needed for a technical blog */
code, pre, kbd { font-family: var(--mono); font-size: 0.85em; }
:not(pre) > code {
  padding: 0.1em 0.35em;
  color: var(--strong);
  background: var(--bg-hi);
  border-radius: 3px;
}
pre {
  overflow-x: auto;
  padding: 1rem 1.2rem;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg-dark);
  border: 1px solid var(--line);
  border-top: 2px solid var(--grey);
  border-radius: 4px;
}
blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  font-style: italic;
  color: var(--fg);
  border-left: 3px solid var(--strong);
}
hr {
  border: 0;
  height: 1px;
  margin: 2.5rem 0;
  background: linear-gradient(to right, transparent, var(--line-2), transparent);
}
article img {
  border: 1px solid var(--line);
  border-radius: 4px;
}

/* 8. Wide screens: stop the text column hugging the sidebar */
@media (min-width: 80rem) {
  #everything > main { margin-left: 4vw; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}