/* korkorran.github.io — stylesheet */

:root {
  --bg: #fdfdfc;
  --fg: #1c1c1a;
  --muted: #6b6b66;
  --accent: #a3572a;
  --rule: #e4e2dc;
  --code-bg: #f4f2ed;
  --syn-comment: #8a8578;
  --syn-string: #4a7c3f;
  --syn-keyword: #8a4b8a;
  --syn-constant: #b06020;
  --syn-entity: #2b6a91;
  --syn-punctuation: #6b6b66;
  --measure: 44rem;
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --fg: #e6e4df;
    --muted: #9a978f;
    --accent: #e0996a;
    --rule: #33333a;
    --code-bg: #202027;
    --syn-comment: #7d7a72;
    --syn-string: #9dc27a;
    --syn-keyword: #d29ad2;
    --syn-constant: #e8a763;
    --syn-entity: #82bede;
    --syn-punctuation: #9a978f;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 1.5rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

.wrapper {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

/* Every image box below states BOTH dimensions, and leaves the artwork's own
   proportions to object-fit. This is deliberate: SVG intrinsic sizing is not
   reliable across engines. The article banner, for one, declares width="100%"
   and no height, so it carries no intrinsic dimensions at all — only a viewBox
   ratio. Firefox infers a size from that; WebKit does not, and the image blows
   up. Relying on `width: auto` or `height: auto` for an SVG invites the same
   class of bug, so nothing here does.

   The triskele is a single black path, so it also has to be inverted in dark
   mode or it disappears against the background. */
.site-logo {
  width: 1.71em; /* 641 / 600 of the height, the triskele's own ratio */
  height: 1.6em;
  object-fit: contain;
  margin-right: 0.45em;
  vertical-align: -0.35em;
}

@media (prefers-color-scheme: dark) {
  .site-logo {
    filter: invert(1);
  }
}

.site-nav {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.9rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--accent);
}

/* ---------- typography ---------- */

h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 600;
}

h1 {
  font-size: 1.9rem;
  margin: 2.5rem 0 0.5rem;
}

h2 {
  font-size: 1.3rem;
  margin: 2.25rem 0 0.5rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

blockquote {
  margin: 1.5rem 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

/* ---------- code ---------- */

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
}

/* Syntax highlighting. Hilite emits one class per TextMate scope
   (e.g. "ocaml-keyword-other"), so match on scope families rather than on a
   fixed list of languages. */

pre code [class*="comment"] {
  color: var(--syn-comment);
  font-style: italic;
}

pre code [class*="string"],
pre code [class*="char"] {
  color: var(--syn-string);
}

pre code [class*="keyword"] {
  color: var(--syn-keyword);
}

pre code [class*="constant"],
pre code [class*="numeric"] {
  color: var(--syn-constant);
}

pre code [class*="entity"],
pre code [class*="function"] {
  color: var(--syn-entity);
}

pre code [class*="punctuation"] {
  color: var(--syn-punctuation);
}

/* ---------- heading anchors ---------- */

h1 .anchor,
h2 .anchor,
h3 .anchor {
  float: left;
  margin-left: -1em;
  width: 1em;
  opacity: 0;
  text-decoration: none;
  color: var(--muted);
}

h1 .anchor::before,
h2 .anchor::before,
h3 .anchor::before {
  content: "#";
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor {
  opacity: 1;
}

@media (max-width: 40rem) {
  h1 .anchor,
  h2 .anchor,
  h3 .anchor {
    display: none;
  }
}

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

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

.post-list li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.post-list h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.post-list h2 a {
  color: inherit;
  text-decoration: none;
}

.post-list h2 a:hover {
  color: var(--accent);
}

.post-list p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- listing banners ---------- */

.post-list-banner {
  display: block;
  width: 100%;
  /* Shorter than the banner on the article page: in a list it is a cue, not
     the subject. An explicit height, not a max-height, so the box never depends
     on the image reporting an intrinsic size. */
  height: 9rem;
  object-fit: cover;
  margin: 0 0 0.85rem;
  border-radius: 5px;
}

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

.post-banner {
  display: block;
  width: 100%;
  /* A fixed height rather than a max-height: the box is then the same in every
     engine, and object-fit crops the artwork into it. A wide image loses a
     little top and bottom; a square one is cropped hard. */
  height: 18rem;
  object-fit: cover;
  margin: 1rem 0 0;
  border-radius: 6px;
}

/* The banner sits directly above the title, so the h1 does not need its usual
   top margin on top of it. */
.post-banner + h1 {
  margin-top: 1.25rem;
}

/* ---------- post meta ---------- */

.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-left: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  text-decoration: none;
}

.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- media ---------- */

img,
video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* ---------- comments ---------- */

.comments {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.comments h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

/* giscus injects an iframe of its own; keep it from overflowing the measure. */
.giscus,
.giscus-frame {
  width: 100%;
  max-width: 100%;
}

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

.site-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--muted);
}

.site-footer .spacer {
  margin-left: auto;
}
