:root {
  /* Minimal neutral grayscale ramp - no hue, easy on the eyes */
  --bg: #1a1a1a;       /* page background */
  --bg-alt: #222222;   /* nav + code surfaces */
  --border: #383838;   /* lines, borders, dividers */
  --text: #e0e0e0;     /* body copy - readable, not washed out */
  --dim: #8c8c8c;      /* secondary / meta text */
  --hi: #ffffff;       /* headings - clear step up from body */

  /* Link color. No :visited state on purpose - a link stays blue once
     visited, so its color is stable and predictable. */
  --link: #6cb6ff;     /* approachable blue */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Liberation Mono", "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.6;
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar Navigation (Desktop) */
nav {
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

nav a {
  color: var(--hi);
  text-decoration: none;
  transition: color 0.15s ease;
}

nav a:hover {
  color: var(--hi);
}

nav > a {
  color: var(--hi);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 1.1rem;
}

nav ul,
.nav-main-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

nav li {
  margin-bottom: 0.6rem;
}

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

nav li a:hover {
  color: #a8d3ff;
}

.nav-bottom {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
}

.nav-bottom .prompt {
  color: var(--hi);
}

.nav-bottom .whoami {
  color: var(--dim);
  margin: 0.2rem 0 0.4rem;
}

.nav-about-link {
  font-size: 0.85rem;
  color: var(--link);
  text-decoration: none;
}

.nav-about-link:hover {
  color: #a8d3ff;
}

/* Main Content Area */
main {
  padding: 3rem 2.5rem;
  max-width: 68rem;
  min-width: 0; /* Prevents grid column expansion from children */
  width: 100%;
}

article {
  width: 100%;
  min-width: 0;
}

/* One level up, rendered above the page content by base.html */
.up-link {
  margin: 0 0 1.1rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.up-link a {
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.up-link a:hover {
  color: var(--link);
  border-bottom-color: currentColor;
}

/* Headings */
h1, h2, h3 {
  color: var(--hi);
  font-weight: 700;
  margin: 1.8rem 0 0.6rem;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; margin-top: 0; color: var(--hi); letter-spacing: -0.01em; }
h2 {
  font-size: 1.4rem;
  color: var(--hi);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.15rem; color: var(--hi); }

.zola-anchor {
  color: var(--dim);
  text-decoration: none;
  font-weight: 400;
  margin-right: 0.3em;
}
.zola-anchor:hover {
  color: var(--hi);
}

p {
  margin-bottom: 1.2rem;
  color: var(--text);
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-color: var(--border);
}

a:hover {
  color: #a8d3ff;
  text-decoration-color: currentColor;
}

ul, ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

strong {
  color: var(--hi);
}

small {
  color: var(--dim);
  font-size: 0.85rem;
}

/* Code & Pre Blocks */
code {
  font-family: inherit;
  background: var(--bg-alt);
  color: #ffffff;
  padding: 0.18em 0.45em;
  border-radius: 4px;
  font-size: 0.88em;
}

pre,
pre.giallo,
pre[style] {
  background-color: var(--bg-alt) !important;
  border: 1px solid var(--border);     /* Sharp 1px border */
  border-radius: 8px;                     /* Zero border-radius for raw plaintext look */
  box-shadow: none;                     /* No shadow */
  padding: 0.85rem 1rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.45;
  margin: 1.2rem 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Fenced blocks keep their GitHub Dark syntax colours; only inline
     `code` is forced to plain white. */
}

pre code,
pre.giallo code {
  background: none !important;
  padding: 0;
  color: var(--text);
  font-size: 0.88rem;
}

/* Custom Scrollbar for Pre Blocks */
pre::-webkit-scrollbar {
  height: 6px;
}
pre::-webkit-scrollbar-track {
  background: var(--bg);
}
pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 3px solid var(--hi);
  color: var(--text);
  background: var(--bg-alt);
  border-radius: 0 4px 4px 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

table {
  border-collapse: collapse;
  margin: 1rem 0;
  width: 100%;
}

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

th {
  background: var(--bg-alt);
  color: var(--hi);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.profile-pic-main {
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--hi);
  flex-shrink: 0;
}

.profile-pic-about {
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--hi);
  display: block;
  margin-bottom: 1.5rem;
}

.intro {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 50rem) {
  body {
    grid-template-columns: 100%;
    grid-template-rows: auto 1fr;
    font-size: 0.92rem;
  }

  /* Fixed / Sticky Nav Header on Phone */
  nav {
    position: sticky;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: rgba(34, 34, 34, 0.95);
    backdrop-filter: blur(8px);
    padding: 0.75rem 1rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    column-gap: 1rem;
    row-gap: 0.4rem;
    z-index: 100;
  }

  nav > a {
    font-size: 1rem;
  }

  nav ul {
    display: flex;
    flex-wrap: wrap;
    column-gap: 0.75rem;
    row-gap: 0.25rem;
    margin: 0;
    align-items: center;
  }

  nav li {
    margin: 0;
    display: inline-flex;
    align-items: center;
  }

  .nav-bottom {
    display: none;
  }

  main {
    padding: 1.25rem 1rem;
    width: 100%;
    max-width: 100vw;
  }

  .intro {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-pic-main {
    width: 5.5rem;
    height: 5.5rem;
  }

  pre {
    padding: 0.75rem;
    margin: 1rem 0;
  }

  /* Bad Apple mobile: tighter frame around the easter egg */
  .bad-apple {
    min-height: auto;
    gap: 1rem;
  }

  .badapple-stage {
    max-width: 100%;
    padding: 0.4rem 0.5rem;
  }

  html {
    /* Accounts for the height of the sticky nav bar + a little extra padding */
    scroll-padding-top: 4.5rem;
  }

}

/* Inline style replacements */
.project-desc {
  color: var(--dim);
  margin: 0.2rem 0 0;
}

/* Random section (content/random, grouped by tag) */
.lrn-searchbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0 0;
}

.lrn-search {
  flex: 1 1 18rem;
  min-width: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.lrn-search::placeholder {
  color: var(--dim);
}
.lrn-search:focus {
  outline: none;
  border-color: var(--link);
}
.lrn-search::-webkit-search-cancel-button {
  filter: grayscale(1) invert(0.7);
}

.lrn-searchbar small {
  color: var(--dim);
  white-space: nowrap;
}

.lrn-clear {
  font: inherit;
  font-size: 0.8rem;
  color: var(--dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25em 0.6em;
  cursor: pointer;
}
.lrn-clear:hover {
  color: var(--hi);
  border-color: var(--hi);
}

.lrn-empty {
  color: var(--dim);
  margin: 1.5rem 0 0;
}

.lrn-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.lrn-entry {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.lrn-entry:last-child {
  border-bottom: 1px solid var(--border);
}

.lrn-entry-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.lrn-entry-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.lrn-entry-desc {
  margin: 0.35rem 0 0;
  color: var(--text);
}

.lrn-date {
  color: var(--dim);
}

.lrn-crumb {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.5rem 0 0;
}

.lrn-badge,
.lrn-status {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--dim);
  white-space: nowrap;
}

/* Problem difficulty */
.lrn-easy { color: #9fd89f; border-color: #3d5a3d; }
.lrn-medium { color: #e3c78a; border-color: #5c5133; }
.lrn-hard { color: #e39a9a; border-color: #5c3a3a; }

/* Reading status */
.lrn-status-reading { color: #9ec7e3; border-color: #3d5266; }
.lrn-status-finished { color: #9fd89f; border-color: #3d5a3d; }
.lrn-status-dropped { color: #9a9a9a; border-color: #4a4a4a; }

.lrn-meta {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.lrn-author {
  color: var(--dim);
}

.lrn-tag {
  font-size: 0.75rem;
  padding: 0.12em 0.45em;
  border-radius: 3px;
  background: var(--bg-alt);
  color: var(--link);
  border: 1px solid var(--border);
  text-decoration: none;
}
.lrn-tag:hover {
  background: var(--border);
  color: var(--link);
}

.lrn-ext {
  font-size: 0.85rem;
}

.lrn-related {
  margin: 0.4rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.85rem;
}
.lrn-related a {
  color: var(--link);
}

.lrn-terms {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}
.lrn-terms li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.random-howto {
  margin: 1.5rem 0;
}
.random-howto details {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
  padding: 0.6rem 0.9rem;
}
.random-howto summary {
  cursor: pointer;
  color: var(--hi);
  font-weight: 700;
  font-size: 0.9rem;
}
.random-howto details[open] summary {
  margin-bottom: 0.6rem;
}
.random-howto pre {
  margin: 0.6rem 0 0;
}

/* Bad Apple Easter Egg */
html.ba-html,
html.ba-html body {
  overflow: hidden;
  height: 100%;
}

body.ba-page {
  overflow: hidden;
}

.bad-apple {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 1.5rem;
}

.bad-apple-back {
  color: var(--dim);
  font-size: 0.85rem;
  text-decoration: none;
}

.bad-apple-back:hover {
  color: var(--hi);
}

.badapple-stage {
  width: 100%;
  max-width: 40rem;
  border: 2px solid var(--hi);
  border-radius: 8px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.75rem 1rem;
  max-height: 80vh;
}

.badapple-frame {
  margin: 0 auto;
  padding: 0;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  box-sizing: border-box;
  line-height: 1.05;
  /* Scale with viewport width AND height so all 64 columns and 32 rows
     always fit without any scrollbar. */
  font-size: min(clamp(0.3rem, 1.35vw, 1.05rem), calc((78vh - 2rem) / 34));
  color: #ffffff;
  letter-spacing: 0;
  white-space: pre;
  font-family: "Liberation Mono", "Courier New", monospace;
}

.bad-apple-footer {
  color: var(--dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* Smooth scrolling and anchor offset */
html {
  scroll-behavior: smooth;
}

/* Offsets any heading or anchor target when scrolled into view */
h1, h2, h3, h4, h5, h6, [id] {
  scroll-margin-top: 4.5rem;
}
