/* ==========================================================================
   rafaelrios.dev
   ========================================================================== */

/* Fonts (self-hosted, SIL Open Font License)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/assets/fonts/source-serif-4-opsz-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("/assets/fonts/source-serif-4-opsz-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-600-normal.woff2") format("woff2");
}

:root {
  --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Source Serif 4", Charter, Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #ffffff;
  --surface: #f4f4f2;
  --text: #111111;
  --text-soft: #555555;
  --muted: #999999;
  --border: #ececea;
  --rule: #111111;
  --accent: #ff5a1f;
  --selection: #ffd9c9;

  --code-bg: #111111;
  --code-text: #e8e6e1;

  --measure: 44rem;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0e;
    --surface: #1a1a19;
    --text: #f2f1ee;
    --text-soft: #a3a29d;
    --muted: #6f6e6a;
    --border: #262624;
    --rule: #f2f1ee;
    --accent: #ff6a33;
    --selection: #5c2a14;

    --code-bg: #181817;
  }
}

/* Minimal reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, video, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; }

::selection { background: var(--selection); }

/* Base
   -------------------------------------------------------------------------- */
html { scroll-padding-top: 2rem; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--muted);
  text-underline-offset: 0.2em;
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

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

.container {
  width: 100%;
  max-width: calc(var(--measure) + 3rem);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.dot { color: var(--accent); }
.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.4rem 0.8rem;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* Header / footer
   -------------------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2rem 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.site-logo {
  font-weight: 600;
  text-decoration: none;
}
.site-logo:hover { color: var(--text); }

.site-nav { display: flex; gap: 1.5rem; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 6rem;
  padding-block: 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.site-footer a { color: inherit; }

/* Home
   -------------------------------------------------------------------------- */
.hero { margin-top: 4.5rem; }

.hero__name {
  font-size: 2.125rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
}

.hero__intro {
  margin-top: 0.75rem;
  max-width: 30rem;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.posts {
  list-style: none;
  padding: 0;
  margin-top: 3rem;
  border-top: 1.5px solid var(--rule);
}

.posts__item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: 0.9rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.posts__title {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.35;
  transition: color 0.15s;
}
.posts__title::after {
  content: " →";
  opacity: 0;
  transition: opacity 0.15s;
}
.posts__item:hover .posts__title { color: var(--accent); }
.posts__item:hover .posts__title::after { opacity: 1; }

.posts__meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.posts__meta--new { color: var(--accent); }

@media (max-width: 34rem) {
  .hero { margin-top: 3rem; }
  .hero__name { font-size: 1.875rem; }
  .posts__item { flex-direction: column; gap: 0.15rem; }
}

/* Post and page
   -------------------------------------------------------------------------- */
.post__header { margin-top: 4.5rem; margin-bottom: 2.5rem; }

.post__meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.post__title {
  margin-top: 0.75rem;
  font-size: clamp(2rem, 1.5rem + 2.2vw, 2.625rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.post__lede {
  margin-top: 1rem;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.post__cover { margin-bottom: 2.5rem; }
.post__cover img { width: 100%; border-radius: var(--radius); }

.post__footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1.5px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
.post__footer a { text-decoration: none; }

/* Post content (markdown)
   -------------------------------------------------------------------------- */
.prose {
  font-family: var(--font-body);
  font-size: 1.1875rem;
  line-height: 1.7;
  font-optical-sizing: auto;
}
.prose > * + * { margin-top: 1.4em; }

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}
.prose h2 { font-size: 1.375rem; margin-top: 2.4em; }
.prose h3 { font-size: 1.125rem; margin-top: 2.2em; }
.prose h4 { font-size: 0.95rem; margin-top: 2em; color: var(--text-soft); }
.prose h2 + *,
.prose h3 + *,
.prose h4 + * { margin-top: 0.75em; }

.prose strong { font-weight: 700; }

.prose ul,
.prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }
.prose li > ul,
.prose li > ol { margin-top: 0.4em; }
.prose li::marker { color: var(--muted); }
.prose ul > li::marker { content: "– "; }

.prose blockquote {
  padding-left: 1.25em;
  border-left: 2px solid var(--accent);
  color: var(--text-soft);
  font-style: italic;
}
.prose blockquote > * + * { margin-top: 1em; }

.prose hr {
  border: 0;
  margin-block: 3em;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-mono);
}
.prose hr::before {
  content: "* * *";
  letter-spacing: 0.5em;
}

.prose img,
.prose video {
  border-radius: var(--radius);
  margin-inline: auto;
}

/* Image caption: an italic-only paragraph right after an image */
.prose p:has(> img:only-child) + p > em:only-child {
  display: block;
  margin-top: -0.6em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-style: normal;
  color: var(--muted);
}

.prose figure figcaption {
  margin-top: 0.75em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.prose table {
  width: 100%;
  font-family: var(--font-ui);
  border-collapse: collapse;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}
.prose th,
.prose td {
  padding: 0.55em 0.9em 0.55em 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.prose th {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom-color: var(--text);
}

/* Code
   -------------------------------------------------------------------------- */
code, pre, kbd { font-family: var(--font-mono); }

.prose :not(pre) > code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85em;
  overflow-wrap: break-word;
}

.prose kbd {
  padding: 0.1em 0.45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 0.8em;
}

.prose pre {
  margin-inline: -1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.875rem;
  line-height: 1.65;
  overflow-x: auto;
  tab-size: 2;
}

@media (min-width: 46rem) {
  .prose pre {
    margin-inline: -2rem;
    padding-inline: 2rem;
    border-radius: var(--radius);
  }
}

.prose pre code {
  font-size: inherit;
  background: none;
}

/* Prism token colors (markup generated at build time by the syntax highlight plugin) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: #8b8478; font-style: italic; }
.token.punctuation { color: #b9b1a4; }
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted { color: #f28b82; }
.token.boolean,
.token.number { color: #f5b971; }
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted { color: #a8d38c; }
.token.operator,
.token.entity,
.token.url { color: #d7cfc2; }
.token.atrule,
.token.attr-value,
.token.keyword { color: #ff8a5c; }
.token.function,
.token.class-name { color: #82c3f5; }
.token.regex,
.token.important,
.token.variable { color: #f5d07a; }
.token.important,
.token.bold { font-weight: bold; }
.token.italic { font-style: italic; }

/* Diff: ```diff-js etc. */
.token.deleted:not(.prefix) { background: rgba(242, 139, 130, 0.12); display: block; }
.token.inserted:not(.prefix) { background: rgba(168, 211, 140, 0.12); display: block; }

/* Highlighted lines: ```js/2-3 */
.highlight-line { display: inline-block; min-width: 100%; }
.highlight-line-active {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 3px 0 0 var(--accent);
  margin-inline: -1.5rem;
  padding-inline: 1.5rem;
}
