/* Hyperdraw — Learn
   Editorial design system. Distinctive serif display type (Fraunces) over a
   clean sans body (Inter), a creative violet→fuchsia→amber identity gradient,
   and full light/dark theming. Built to feel like a craft publication, not a
   doc dump. Falls back gracefully to system fonts if the webfont fails. */

:root {
  --max-width: 44rem;
  --wide-width: 70rem;

  /* Brand gradient — the creative through-line. */
  --grad: linear-gradient(105deg, #7c3aed 0%, #db2777 48%, #f59e0b 100%);

  /* Light theme. */
  --fg: #15131a;
  --fg-strong: #0a0810;
  --muted: #5b5670;
  --faint: #8b8699;
  --link: #7c3aed;
  --link-hover: #db2777;
  --bg: #fbfaff;
  --bg-elev: #ffffff;
  --border: #ece9f5;
  --border-strong: #ddd8ec;
  --code-bg: #f3f0fb;
  --shadow: 0 1px 2px rgba(20, 19, 26, 0.04), 0 8px 24px -12px rgba(124, 58, 237, 0.18);
  --shadow-lift: 0 2px 4px rgba(20, 19, 26, 0.06), 0 18px 40px -16px rgba(124, 58, 237, 0.32);

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e9e6f2;
    --fg-strong: #ffffff;
    --muted: #a59fbb;
    --faint: #756f8a;
    --link: #c4a5ff;
    --link-hover: #ff9ecb;
    --bg: #0c0a12;
    --bg-elev: #14111d;
    --border: #221d33;
    --border-strong: #2e2742;
    --code-bg: #1a1626;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(124, 58, 237, 0.5);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.5), 0 22px 48px -18px rgba(219, 39, 119, 0.5);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 0;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: -0.003em;
  background-color: var(--bg);
  /* Soft mesh of brand colours bleeding from the top — subtle, never loud. */
  background-image:
    radial-gradient(60rem 40rem at 15% -10%, rgba(124, 58, 237, 0.1), transparent 60%),
    radial-gradient(50rem 38rem at 95% -6%, rgba(219, 39, 119, 0.09), transparent 55%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(219, 39, 119, 0.22);
}

a {
  color: var(--link);
  text-decoration-color: color-mix(in oklab, var(--link) 35%, transparent);
  text-underline-offset: 0.18em;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--link-hover);
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  color: var(--fg-strong);
  letter-spacing: -0.02em;
  line-height: 1.12;
  font-weight: 600;
}

/* ---- Header ------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0;
  padding: 0.85rem max(1.25rem, calc(50% - var(--wide-width) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.site-header__brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg-strong);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.site-header__brand::before {
  content: '';
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.28rem;
  background: var(--grad);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--link) 14%, transparent);
}

/* ---- Layout ------------------------------------------------------------- */

.article-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3.5rem 1.25rem 1rem;
}

/* Two-column variant for article pages: main content + sticky sidebar with
   "more articles". Collapses to a single column on narrow viewports. */
.article-main--with-sidebar {
  max-width: var(--wide-width);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 3.5rem;
  align-items: start;
}

.article-main--with-sidebar > .article {
  min-width: 0;
}

.article-main--with-sidebar > .sidebar {
  position: sticky;
  top: 5rem;
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
}

@media (max-width: 52rem) {
  .article-main--with-sidebar {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .article-main--with-sidebar > .sidebar {
    position: static;
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 2.5rem;
  }
}

/* ---- Index / home ------------------------------------------------------- */

.article-main > h1 {
  font-size: clamp(2.6rem, 7vw, 4rem);
  line-height: 1;
  margin: 0.5rem 0 0.75rem;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}

.article-section {
  margin: 3.5rem 0;
}

.article-section > h2 {
  font-size: 1.6rem;
  margin: 0 0 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.article-section > h2::before {
  content: '';
  width: 0.5rem;
  height: 1.45rem;
  border-radius: 1rem;
  background: var(--grad);
}

.article-section__blurb {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0 0 1.5rem;
}

.article-index {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.article-index li {
  margin: 0;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.article-index li::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--grad);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.article-index li:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-strong);
}
.article-index li:hover::before {
  opacity: 1;
}

.article-index li > a {
  text-decoration: none;
}
.article-index li > a strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
  line-height: 1.2;
  transition: color 0.15s ease;
}
.article-index li:hover > a strong {
  color: var(--link);
}
.article-index li > p {
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.article-index__langs {
  color: var(--faint);
  font-size: 0.82rem;
  margin: 0.7rem 0 0 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Article ------------------------------------------------------------ */

.article__head {
  margin-bottom: 2.5rem;
}

.article__head h1 {
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  font-weight: 600;
  margin: 0 0 0.6rem;
  font-optical-sizing: auto;
}

.article__meta {
  color: var(--faint);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

/* Prose ----------------------------------------------------------------- */

.article__body {
  font-size: 1.0625rem;
}

.article__body > * + * {
  margin-top: 1.15rem;
}

.article__body h2 {
  font-size: 1.75rem;
  margin-top: 2.75rem;
  margin-bottom: 0.4rem;
}

.article__body h3 {
  font-size: 1.32rem;
  margin-top: 2rem;
  margin-bottom: 0.3rem;
}

.article__body p {
  margin: 0 0 1.15rem;
}

.article__body a {
  font-weight: 500;
}

.article__body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: block;
  margin: 1.75rem 0;
}

.article__body ul,
.article__body ol {
  margin: 0 0 1.15rem;
  padding-left: 1.4rem;
}
.article__body li {
  margin: 0.35rem 0;
}
.article__body li::marker {
  color: var(--link);
}

.article__body blockquote {
  margin: 1.75rem 0;
  padding: 0.4rem 0 0.4rem 1.4rem;
  border-left: 3px solid transparent;
  border-image: var(--grad) 1;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--fg-strong);
}
.article__body blockquote p {
  margin: 0.3rem 0;
}

.article__body code {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 0.4em;
  border: 1px solid var(--border);
}

.article__body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.92rem;
  line-height: 1.55;
  box-shadow: var(--shadow);
}
.article__body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.article__body hr {
  border: 0;
  height: 1px;
  background: var(--border-strong);
  margin: 2.5rem 0;
}

.article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  font-size: 0.95rem;
}
.article__body th,
.article__body td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.article__body th {
  font-weight: 600;
  color: var(--fg-strong);
  border-bottom: 2px solid var(--border-strong);
}

/* Retracted state ------------------------------------------------------- */

.article--retracted .article__head h1 {
  text-decoration: line-through;
  text-decoration-color: rgba(219, 39, 119, 0.55);
  text-decoration-thickness: 2px;
}

.article__retracted-body {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
}

.article__retracted-body summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
}

/* ---- Footer ------------------------------------------------------------- */

.site-footer {
  max-width: var(--wide-width);
  margin: 5rem auto 0;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--link);
}
.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.site-footer__nav a {
  font-weight: 500;
}

/* ---- Listing pages (archive / month / tags) ----------------------------- */

.page-lede {
  color: var(--muted);
  font-size: 1.02rem;
  margin: 0 0 2rem;
}
.page-lede a {
  font-weight: 500;
}

.archive {
  display: flex;
  flex-direction: column;
}

.archive__month {
  font-size: 1.15rem;
  margin: 2.25rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.archive__month:first-child {
  margin-top: 0;
}
.archive__month a {
  color: inherit;
  text-decoration: none;
}
.archive__month a:hover {
  color: var(--link);
}

.archive__item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
}
.archive__link {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg-strong);
}
.archive__link:hover {
  color: var(--link);
}
.archive__date {
  margin-left: auto;
  flex: none;
  color: var(--faint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.archive__badge {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.45rem;
  border-radius: 0.4rem;
  color: #dc2626;
  background: color-mix(in oklab, #dc2626 14%, var(--bg-elev));
}
.archive__item--retracted .archive__link {
  text-decoration: line-through;
  text-decoration-color: rgba(219, 39, 119, 0.5);
  color: var(--muted);
}

/* Tag cloud */
.tag-cloud {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--fg-strong);
  font-weight: 500;
  font-size: calc(0.95rem * var(--w, 1));
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tag-chip:hover {
  transform: translateY(-2px);
  border-color: var(--link);
  color: var(--link);
}
.tag-chip__count {
  font-size: 0.72em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}
.pager__link {
  font-weight: 600;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  color: var(--fg-strong);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.pager__link:hover {
  border-color: var(--link);
  color: var(--link);
}
.pager__link--disabled {
  color: var(--faint);
  border-color: transparent;
  pointer-events: none;
}
.pager__status {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Pagefind search UI — themed to the site palette. */
.search-ui {
  margin-top: 1.5rem;
  --pagefind-ui-primary: var(--link);
  --pagefind-ui-text: var(--fg);
  --pagefind-ui-background: var(--bg-elev);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--code-bg);
  --pagefind-ui-border-radius: 0.75rem;
  --pagefind-ui-font: var(--sans);
}

