/* ------------------------------------------------------------------ *
   Rohit blog — styling inspired by darioamodei.com
   Dark by default, with a light/dark toggle. Typeface: Calibri.
 * ------------------------------------------------------------------ */

/* Self-hosted Calibri so it renders everywhere, even where it isn't
   installed. `local()` uses the system copy first if present, otherwise
   the browser loads the bundled file. Paths resolve relative to this
   stylesheet, so they work on every page. */
@font-face {
  font-family: 'Calibri';
  src: local('Calibri'), url('fonts/Calibri.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Calibri';
  src: local('Calibri Bold'), local('Calibri-Bold'), url('fonts/Calibrib.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Calibri';
  src: local('Calibri Italic'), url('fonts/Calibrii.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Calibri';
  src: local('Calibri Bold Italic'), url('fonts/Calibriz.ttf') format('truetype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root,
[data-theme='dark'] {
  --bg: #1c1c1c;
  --text: #e9e8e3;
  --muted: #9a988f;
  --rule: #343330;
  --code-bg: #292826;
  --selection: #45443f;
  --link-underline: rgba(233, 232, 227, 0.45);
  --switch-track: #3a3934;
  --switch-knob: #f0efe9;
  --switch-x: 20px; /* knob sits on the right in dark mode */
  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #fbfbf9;
  --text: #22221f;
  --muted: #6b6a63;
  --rule: #e4e3dc;
  --code-bg: #efeee8;
  --selection: #dbe6ff;
  --link-underline: rgba(34, 34, 31, 0.35);
  --switch-track: #d7d6cf;
  --switch-knob: #ffffff;
  --switch-x: 0px; /* knob sits on the left in light mode */
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Calibri, Carlito, 'Segoe UI', Candara, 'Trebuchet MS', system-ui, sans-serif;
  font-size: 19px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.2s ease, color 0.2s ease;
}

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

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 24px 140px;
}

/* ---------- header (name + toggle) ---------- */

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
}

.site-title {
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--text);
  text-decoration: none;
}

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

/* ---------- links ---------- */

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-underline);
  transition: text-decoration-color 0.15s ease;
}

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

/* ---------- homepage intro + categories ---------- */

.intro {
  margin-bottom: 10px;
}

.intro p {
  margin: 0 0 1.15em;
}

.category {
  margin-top: 2.4em;
}

.category h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 0.5em;
}

.post-list {
  margin: 0;
  padding-left: 1.25em;
}

.post-list li {
  margin: 0.42em 0;
}

.post-list li::marker {
  color: var(--muted);
}

/* ---------- post page ---------- */

.post .back {
  display: inline-block;
  margin-bottom: 1.8em;
  font-size: 0.98rem;
  color: var(--muted);
  text-decoration: none;
}

.post .back:hover {
  color: var(--text);
}

.post-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.15em;
}

.post-date {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 1.7em;
}

.post-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 1.7em 0 0.5em;
}

.post-body h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.5em 0 0.4em;
}

.post-body p {
  margin: 0 0 1.15em;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.15em;
  padding-left: 1.4em;
}

.post-body li {
  margin: 0.35em 0;
}

.post-body li::marker {
  color: var(--muted);
}

.post-body blockquote {
  margin: 1.3em 0;
  padding: 0.15em 0 0.15em 1.1em;
  border-left: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

.post-body code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.12em 0.38em;
  border-radius: 5px;
}

.post-body pre {
  background: var(--code-bg);
  padding: 16px 18px;
  border-radius: 10px;
  overflow: auto;
  margin: 1.3em 0;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.84em;
  line-height: 1.55;
}

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

.post-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2em 0;
}

.post-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.3em 0;
  font-size: 0.95em;
}

.post-body th,
.post-body td {
  border: 1px solid var(--rule);
  padding: 0.5em 0.7em;
  text-align: left;
}

/* ---------- dark / light toggle ---------- */

.theme-toggle {
  flex: 0 0 auto;
  margin-top: 6px;
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
}

.theme-toggle .switch {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--switch-track);
  position: relative;
  transition: background 0.2s ease;
}

.theme-toggle .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--switch-knob);
  transform: translateX(var(--switch-x));
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.theme-toggle:focus-visible .switch {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body {
    font-size: 18px;
  }
  .wrap {
    padding: 44px 20px 100px;
  }
  .site-title {
    font-size: 1.7rem;
  }
  .post-title {
    font-size: 1.7rem;
  }
}
