:root {
  --bg: #f7f5f0;
  --code-bg: #eeebe3;
  --text: #3a3631;
  --muted: #756e63;
  --line: #e6e1d6;
  --accent: #7d6d55;

  --ease: cubic-bezier(0.23, 1, 0.32, 1);

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1815;
    --code-bg: #221f1b;
    --text: #e0dbd1;
    --muted: #9b9486;
    --line: #2c2823;
    --accent: #b9a98b;
  }
}

:root[data-theme="dark"] {
  --bg: #1a1815;
  --code-bg: #221f1b;
  --text: #e0dbd1;
  --muted: #9b9486;
  --line: #2c2823;
  --accent: #b9a98b;
}

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

/* Base */
html {
  scroll-behavior: smooth;
  scroll-padding-top: env(safe-area-inset-top, 0px);
  -webkit-text-size-adjust: 100%;
  user-select: none;
}

body {
  margin: 0;

  background: var(--bg);
  color: var(--text);

  font-family: "Newsreader", Georgia, "Times New Roman", serif;

  font-size: 1.1875rem;
  line-height: 1.8;
  font-weight: 400;

  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;

  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

::selection {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Layout */
main {
  max-width: 54rem;
  margin: 0 auto;
  padding: 6rem 1.5rem 7rem;
}

/* Links */
a {
  color: inherit;

  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;

  transition:
    color 0.2s ease,
    text-decoration-color 0.2s ease;
}

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

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--accent);
    text-decoration-color: var(--accent);
  }
}

/* Typography */
h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
}

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

.mono {
  font-family: "IBM Plex Mono", ui-monospace, monospace;

  font-size: 0.78rem;
  color: var(--muted);
}

/* Animation */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

main > * {
  animation: rise 0.5s var(--ease) both;
}

main > :nth-child(2) {
  animation-delay: 60ms;
}

main > :nth-child(3) {
  animation-delay: 120ms;
}

main > :nth-child(4) {
  animation-delay: 180ms;
}

main > :nth-child(5) {
  animation-delay: 240ms;
}

main > :nth-child(6) {
  animation-delay: 300ms;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  @keyframes rise {
    from {
      opacity: 1;
    }

    to {
      opacity: 1;
    }
  }
}

/* Mobile */
@media (max-width: 480px) {
  body {
    font-size: 1.125rem;
  }

  main {
    padding-top: 4rem;
  }
}

/* Reading progress */
.progress {
  position: fixed;

  left: 0;
  right: 0;
  top: 0;

  height: calc(2px + env(safe-area-inset-top, 0px));

  z-index: 10;
  pointer-events: none;
}

.progress span {
  display: block;

  height: 3px;

  margin-top: env(safe-area-inset-top, 0px);

  background: var(--accent);

  opacity: 0.45;

  transform-origin: left;
  transform: scaleX(0);

  transition: transform 0.15s linear;
}

/* Navigation */
nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;

  margin-bottom: 6rem;

  font-size: 0.95rem;
  color: var(--muted);
}

nav a {
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
}

/* Header */
header {
  margin-bottom: 4.5rem;
}

.meta {
  margin-bottom: 1.25rem;

  font-size: 0.95rem;
  color: var(--muted);
}

h1 {
  font-size: clamp(2.1rem, 6vw, 2.8rem);

  line-height: 1.15;
  letter-spacing: -0.015em;
}

.bold {
  font-weight: bold;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.lede {
  margin: 1.5rem 0 0;

  font-size: 1.25rem;
  line-height: 1.6;

  color: var(--muted);
  font-style: italic;
}

/* Article */
article > p {
  margin: 1.6rem 0 0;
}

article > p:first-child {
  margin-top: 0;
}

h2 {
  margin: 4.5rem 0 1.25rem;

  font-size: 2.25rem;
  line-height: 1.3;
}

h2 + p {
  margin-top: 0;
}

/* Blockquote */
blockquote {
  margin: 3rem 0;
  padding: 0 0 0 1.5rem;

  border-left: 1px solid var(--line);

  font-size: 1.3rem;
  line-height: 1.6;

  font-style: italic;
  color: var(--muted);
}

/* Code */
.code-label {
  margin: 2.5rem 0 0.5rem;
}

pre {
  margin: 0 0 2.5rem;
  padding: 1.25rem 1.4rem;

  overflow-x: auto;

  background: var(--code-bg);
  border-radius: 8px;

  font-family: "IBM Plex Mono", ui-monospace, monospace;

  font-size: 0.84rem;
  line-height: 1.75;

  -webkit-overflow-scrolling: touch;
}

pre code {
  font: inherit;
}

.code-tag {
  background: var(--code-bg);
  padding: 10px 10px;
  font-size: 15px;
  font-family: monospace;
  border-radius: 10px 10px;
}

/* Lists */
ul {
  margin: 1.6rem 0 0;
  padding-left: 1.2rem;
}

li {
  margin-top: 0.55rem;
  padding-left: 0.25rem;
}

/* Divider */
hr {
  border: 0;
  border-top: 1px solid var(--line);

  margin: 4rem 0;
}

/* Closing */
.closing {
  color: var(--muted);
  font-style: italic;
}

/* Footer */
footer {
  margin-top: 5rem;
  padding-top: 1.75rem;

  border-top: 1px solid var(--line);

  display: flex;
  justify-content: space-between;
  align-items: baseline;

  gap: 1rem;
  flex-wrap: wrap;

  font-size: 0.95rem;
  color: var(--muted);
}

/* Theme toggle */
.theme-toggle {
  font: inherit;
  font-size: 0.95rem;

  color: var(--muted);

  background: none;
  border: 0;

  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;

  border-radius: 4px;

  cursor: pointer;

  transition:
    color 0.2s ease,
    transform 0.15s var(--ease);
}

.theme-toggle:active {
  transform: scale(0.97);
}

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

@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover {
    color: var(--accent);
  }
}

/* image related code  */
/* Diagrams */

/* .diagram-container {
  width: 100%;
  max-width: 100%;
  margin: 3rem 0;
  overflow: hidden;
}

.extra-img-attr {
  display: block;
  width: 80%;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.diagram {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: none;
}

:root[data-theme="light"] .diagram-light {
  display: block;
}

:root[data-theme="dark"] .diagram-dark {
  display: block;
} */

.diagram-container {
  width: 100%;
  margin: 3rem 0;
  overflow: hidden;
}

.diagram {
  display: none;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* Theme visibility */
:root[data-theme="light"] .diagram-light {
  display: block;
}

:root[data-theme="dark"] .diagram-dark {
  display: block;
}

/* Optional size modifier */
.diagram.extra-img-attr {
  width: 80%;
  margin-inline: auto;
}

.diagram-container figcaption {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}


