@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Scripbox brand */
  --sb-orange: #f58024; /* logo wordmark + scripbox.com CSS */
  --sb-orange-legacy: #f17e2f; /* older favicon export, kept for reference */
  --sb-blue: #006dec;

  /* Light theme */
  --bg: #ffffff;
  --bg-soft: #f4f2f1;
  --ink: #181818;
  --body: #404040;
  --muted: #595959;
  --line: #e4e3e2;
  --line-strong: #c7c3c2;
  --link: var(--sb-blue);
  --link-hover: #0056bd;
  --accent: var(--sb-orange);
  --code-bg: #f4f2f1;
  --code-line: #e4e3e2;

  /* Syntax (light) */
  --tok-comment: #8a8683;
  --tok-keyword: #c2621b;
  --tok-string: #0b7a53;
  --tok-number: #006dec;
  --tok-name: #181818;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131211;
  --bg-soft: #1c1a19;
  --ink: #f6f4f3;
  --body: #d9d6d4;
  --muted: #a3a09e;
  --line: #302d2b;
  --line-strong: #3d3a38;
  --link: #6aa9ff;
  --link-hover: #93c0ff;
  --accent: var(--sb-orange);
  --code-bg: #1c1a19;
  --code-line: #302d2b;

  --tok-comment: #8c8784;
  --tok-keyword: #ffa45c;
  --tok-string: #7ddba0;
  --tok-number: #6aa9ff;
  --tok-name: #f6f4f3;
}

/* No-JS fallback: follow the OS setting. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;

    --bg: #131211;
    --bg-soft: #1c1a19;
    --ink: #f6f4f3;
    --body: #d9d6d4;
    --muted: #a3a09e;
    --line: #302d2b;
    --line-strong: #3d3a38;
    --link: #6aa9ff;
    --link-hover: #93c0ff;
    --accent: var(--sb-orange);
    --code-bg: #1c1a19;
    --code-line: #302d2b;

    --tok-comment: #8c8784;
    --tok-keyword: #ffa45c;
    --tok-string: #7ddba0;
    --tok-number: #6aa9ff;
    --tok-name: #f6f4f3;
  }
}

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

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

body {
  margin: 0 auto;
  max-width: 44rem;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--body);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Thin brand rule across the top of the page. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: var(--sb-orange);
  z-index: 10;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1.35rem 0 1.1rem;
  border-bottom: 1px solid var(--line);
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.logo {
  display: block;
  width: auto;
  height: 21px;
}

.logo--on-dark {
  display: none;
}

html[data-theme="dark"] .logo--on-light {
  display: none;
}

html[data-theme="dark"] .logo--on-dark {
  display: block;
}

/* No-JS fallback: follow the OS setting. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .logo--on-light {
    display: none;
  }

  html:not([data-theme]) .logo--on-dark {
    display: block;
  }
}

.site-title-tag {
  padding-left: 0.7rem;
  border-left: 1px solid var(--line-strong);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--muted);
}

.site-title:hover .site-title-tag {
  color: var(--ink);
}

.site-title:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
}

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

/* Theme switcher ----------------------------------------------------- */

.theme-switch {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-switch button:hover {
  color: var(--ink);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.theme-switch svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Main --------------------------------------------------------------- */

.site-main {
  padding: 2.25rem 0 0;
}

.page-title,
.post-title {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.lead {
  margin-top: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.section-title {
  margin: 2.75rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Post list ---------------------------------------------------------- */

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

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

.post-date {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-link {
  font-size: 1.05rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.post-link:hover {
  color: var(--link);
  text-decoration: none;
}

.post-excerpt {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Post --------------------------------------------------------------- */

.post-header {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.post-meta {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-content {
  padding-top: 0.5rem;
}

.post-content h2 {
  margin: 2.25rem 0 0.5rem;
  color: var(--ink);
  font-size: 1.32rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.post-content h3 {
  margin: 1.75rem 0 0.4rem;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 650;
}

.post-content > :first-child {
  margin-top: 0;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.post-content hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.post-content a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--line-strong);
}

.post-content a:hover {
  text-decoration-color: currentColor;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;
  font-size: 0.875em;
  padding: 0.15em 0.38em;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--ink);
}

pre {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--code-line);
  border-radius: 12px;
  background: var(--code-bg);
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: inherit;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 3px solid var(--sb-orange);
  color: var(--muted);
}

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

th,
td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--ink);
  font-weight: 600;
}

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

.site-footer {
  margin-top: 3.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer p {
  margin: 0;
}

/* Syntax highlighting (Rouge) ---------------------------------------- */

.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs {
  color: var(--tok-comment);
  font-style: italic;
}

.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt {
  color: var(--tok-keyword);
  font-weight: 600;
}

.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr {
  color: var(--tok-string);
}

.highlight .m,
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il {
  color: var(--tok-number);
}

.highlight .nf,
.highlight .nx,
.highlight .nc,
.highlight .nn,
.highlight .nv,
.highlight .na {
  color: var(--tok-name);
}

.highlight .o,
.highlight .ow,
.highlight .p,
.highlight .nb,
.highlight .bp,
.highlight .n {
  color: inherit;
}

.highlight .gd {
  color: #b3261e;
}

.highlight .gi {
  color: #0b7a53;
}

::selection {
  background: color-mix(in srgb, var(--sb-orange) 28%, transparent);
}

@media (max-width: 34rem) {
  body {
    font-size: 16px;
  }

  .page-title,
  .post-title {
    font-size: 1.65rem;
  }

  .site-header {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
