:root {
    --width: 480px;
    --font-main: ui-monospace, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
    --font-secondary: ui-monospace, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
    --font-scale: 0.75rem;
    --background-color: #fff;
    --heading-color: #000;
    --text-color: #000;
    --link-color: #444;
    --visited-color: #444;
    --code-background-color: #f2f2f2;
    --code-color: #000;
    --blockquote-color: #000;
    --kbd-background-color: #f2f2f2;
    --kbd-color: #000;
    --kbd-border-color: #ccc;
    --kbd-shadow-color: #bbb;
    --border-color: #000;
    --lightbox-border-color: #555;
    --lightbox-overlay-color: rgba(0, 0, 0, 0.85);
}

@media (min-width: 640px) {
    :root {
        --width: 640px;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #2f3236;
        --heading-color: #ffffff;
        --text-color: #ffffff;
        --link-color: #999;
        --visited-color: #999;
        --code-background-color: #3a3d42;
        --code-color: #ffffff;
        --blockquote-color: #ccc;
        --kbd-background-color: #3a3d42;
        --kbd-color: #ffffff;
        --kbd-border-color: #555;
        --kbd-shadow-color: #222;
        --border-color: #888;
        --lightbox-border-color: #888;
        --lightbox-overlay-color: rgba(0, 0, 0, 0.92);
    }
}

body {
    font-family: var(--font-secondary);
    font-size: var(--font-scale);
    margin: auto;
    padding: 0 8px;
    max-width: var(--width);
    text-align: left;
    background-color: var(--background-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.7;
    color: var(--text-color);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-main);
    color: var(--heading-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 1.2em;
    font-weight: bold;
    font-style: normal;
}

h2 {
    font-size: 1em;
    font-weight: bold;
    font-style: italic;
}

h3 {
    font-size: 1em;
    font-weight: normal;
    font-style: italic;
}

h4, h5, h6 {
    font-size: 1em;
    font-weight: normal;
    font-style: italic;
}

a {
    color: var(--link-color);
    cursor: pointer;
    text-decoration: underline;
    font-weight: bold;
}

a:visited {
    color: var(--visited-color);
}

a:hover {
    text-decoration: none;
}

h1 a, h2 a, h3 a {
    color: inherit;
    font-weight: inherit;
}

nav a {
    margin-right: 8px;
}

strong, b {
    color: var(--heading-color);
}

button {
    margin: 0;
    cursor: pointer;
}

time {
    font-family: var(--font-main);
    font-style: normal;
    font-size: 15px;
}

main {
    line-height: 1.7;
}

table {
    width: 100%;
}

hr {
    border: 0;
    border-top: 1px dashed;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto;
}

pre {
    font-size: 0.75rem;
    font-family: var(--font-main);
    margin: 0 auto;
    overflow-x: auto;
}

pre code {
    line-height: 1.1;
    display: block;
    text-align: left;
    margin-left: 2rem;
}

code {
    font-family: var(--font-main);
    padding: 2px;
    background-color: var(--code-background-color);
    color: var(--code-color);
    border-radius: 3px;
}

blockquote {
    border-left: 1px solid #999;
    color: var(--blockquote-color);
    padding-left: 20px;
    font-style: italic;
}

kbd {
    border: 1px solid var(--kbd-border-color);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.9em;
    background-color: var(--kbd-background-color);
    color: var(--kbd-color);
    box-shadow: 0 1px 0 var(--kbd-shadow-color);
}

samp {
    display: block;
    font-size: 4em;
    font-family: var(--font-main);
    line-height: 1.4;
    padding: 0.2em 0;
    padding-left: 20px;
}

footer {
    padding: 25px 0;
    text-align: center;
}

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

.title h1 {
    font-size: 1.2em;
    text-decoration: none;
}

/* Blinking cursor after the site title */
.title h1::after {
    content: '█';
    position: relative;
    top: -2px;
    margin-left: -8px;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

a.title {
    text-decoration: none !important;
}

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

.inline {
    width: auto !important;
}

.highlight, .code {
    padding: 1px 15px;
    background-color: var(--code-background-color);
    color: var(--code-color);
    border-radius: 3px;
    margin-block-start: 1em;
    margin-block-end: 1em;
    overflow-x: auto;
}

.email {
    unicode-bidi: bidi-override;
    direction: rtl;
    text-decoration: underline;
}

.side-by-side {
    display: flex;
    gap: 10px;
}

.side-by-side img {
    width: 50%;
    height: auto;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

/* blog post list */
ul.blog-posts {
    list-style-type: none;
    padding: unset;
}

ul.blog-posts li {
    display: flex;
}

ul.blog-posts li span {
    flex: 0 0 130px;
}

ul.blog-posts li a:visited {
    color: var(--visited-color);
}

@media (max-width: 480px) {
    code, .highlight, .code {
        font-size: 0.7rem;
    }
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--lightbox-overlay-color);
  z-index: 100;
}

.lightbox:target {
  display: grid;
  place-items: center;
}

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border: 2px solid var(--lightbox-border-color);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  /* Ensures the image sits above the backdrop link */
  position: relative;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-color);
  text-decoration: none;
  /* Sits above everything including the backdrop */
  z-index: 101;
  opacity: 0.75;
}

.lightbox-close:hover {
  opacity: 1;
  color: var(--heading-color);
}

/* Upvote button: Heart (no count) */
#upvote-form > small {
  display: block;
  margin-top: 1.5rem;
}

.upvote-button {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
}

.upvote-button:hover {
  background: none;
  border-color: transparent;
}

.upvote-button svg {
  display: none;
}

.upvote-count {
  display: none;
}

.upvote-button::before {
  content: "♡";
  margin-right: 0;
  font-size: 1.4rem;
  color: var(--link);
  vertical-align: -0.09em;
  display: inline-block;
  transition: transform 0.15s ease;
}

@media (hover: hover) {
  .upvote-button:not([disabled]):hover::before {
    transform: scale(1.15);
  }
}

.upvote-button[disabled]::before {
  content: "♥";
}

.upvote-button[disabled] {
  color: var(--muted) !important;
  opacity: 0.7;
  cursor: default;
}
