:root {
  --header: hsl(0, 0%, 5%);
  --subtext: hsl(0, 0%, 10%);
  --bg: hsl(0, 0%, 95%);
  --visited: hsl(0, 0%, 15%);
}

[data-theme="dark"] {
  --header: hsl(0, 0%, 95%);
  --subtext: hsl(0, 0%, 90%);
  --bg: hsl(0, 0%, 5%);
  --visited: hsl(0, 0%, 85%);
  --icon-inv: 1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --header: hsl(0, 0%, 95%);
    --subtext: hsl(0, 0%, 90%);
    --bg: hsl(0, 0%, 5%);
    --visited: hsl(0, 0%, 85%);
    --icon-inv: 1;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--subtext);
  min-height: 100vh;
  line-height: 1.6;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-center {
  flex-wrap: wrap;
  justify-content: center;
}

/* Logo */
.logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--header);
}

.logo-link img {
  width: 30px;
  height: 30px;
  filter: invert(var(--icon-inv, 0));
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--header);
}

/* Nav buttons */
.nav-btn,
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--header);
  background: 0;
  border: 0;
  cursor: pointer;
  font-size: 1rem;
  outline: 0;
}

.nav-btn:hover,
.theme-toggle:hover {
  opacity: 0.7;
}

/* Icons */
.nav-btn img,
.theme-toggle img,
.icon-list img {
  width: 20px;
  height: 20px;
  filter: invert(var(--icon-inv, 0));
  flex-shrink: 0;
}

/* Main */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

h2 {
  color: var(--header);
  margin: 2rem 0 1rem;
  font-size: 1.5rem;
}

h3 {
  color: var(--header);
  margin: 1.5rem 0 0.75rem;
}

p {
  margin-bottom: 1rem;
}

/* Icon lists */
.icon-list {
  list-style: none;
}

.icon-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

/* ASCII art */
.ascii-art {
  font-family: monospace;
  color: var(--subtext);
  text-align: center;
  margin: 2rem 0;
  white-space: pre;
  overflow-x: auto;
  margin-left: var(--ascii-offset, 0);
}

/* ASCII grid — row-based layout for embedding icons */
.ascii-grid {
  font-family: monospace;
  color: var(--subtext);
  text-align: center;
  margin: 2rem 0;
  display: inline-block;
}

.ascii-row {
  display: flex;
  align-items: center;
  height: 1.6em;
}

.ascii-row span {
  white-space: pre;
  height: 1.6em;
  line-height: 1.6em;
  opacity: 0.8;
}

.ascii-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  flex-shrink: 0;
  line-height: 0;
}

.ascii-icon img {
  width: 1.6em;
  height: 1.6em;
  filter: brightness(0) invert(var(--icon-inv, 0));
  display: block;
}

/* QR code */
.qr-code {
  display: block;
  margin: 2rem auto;
  width: 200px;
  height: auto;
  filter: invert(var(--icon-inv, 0));
}

/* Quote */
.quote-section {
  text-align: center;
  margin: 2rem 0;
  font-style: italic;
  color: var(--subtext);
}

.quote-author {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.9rem;
  color: var(--subtext);
}

/* Entries */
.entry-list {
  list-style: none;
}

.entry-item {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--subtext);
  border-radius: 4px;
}

.entry-link {
  text-decoration: none;
  display: block;
}

.entry-link h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  color: var(--header);
}

.entry-link.visited h3 {
  color: var(--visited);
}

.entry-meta {
  font-size: 0.9rem;
  color: var(--subtext);
  margin-top: 0.25rem;
}

.phase-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 3px;
  background: var(--header);
  color: var(--bg);
  font-weight: 400;
}

/* Contact icons */
.contact-icons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.contact-icons a {
  display: inline-block;
  line-height: 0;
}

.contact-icons img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(var(--icon-inv, 0));
  display: block;
}

/* Misc */
.spacer {
  height: 1rem;
}

.media-figure {
  margin: 1.5rem 0;
  text-align: center;
}

.media-figure img,
.media-figure video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.figure-caption {
  font-size: 0.85rem;
  color: var(--subtext);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Mobile */
@media (max-width: 600px) {
  .topbar {
    padding: 1rem;
  }

  .topbar-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  main {
    padding: 1rem;
  }
}
