:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Berkeley Mono", "SFMono-Regular", ui-monospace, "Cascadia Mono",
    "Roboto Mono", Menlo, Monaco, "Liberation Mono", "Courier New", monospace;
  color: #1db954;
  background-color: #1a1a1a;
}

body.home {
  background-color: #111111;
  background-image: url("home-background.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.layout {
  display: flex;
  gap: 48px;
  min-height: 100vh;
  align-items: flex-start;
  padding: 48px;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 48px;
  align-self: start;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.page-content {
  margin-top: 0;
}

h1 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

nav a,
.content a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0;
  font-size: 14px;
  letter-spacing: 0;
}

nav a:hover,
nav a:focus,
.content a:hover,
.content a:focus {
  text-decoration: underline;
}

.sidebar nav {
  position: relative;
}

.sidebar nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0;
  font-size: 14px;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  outline: none;
}

.nav-dropdown summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown summary::after {
  content: ">";
  display: inline-block;
  transform-origin: 50% 50%;
  transition: transform 140ms ease;
}

.nav-dropdown[open] summary::after {
  transform: rotate(90deg);
}

.nav-dropdown .nav-menu {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  background: rgba(47, 143, 47, 0.08);
  border: 1px solid rgba(47, 143, 47, 0.28);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.nav-dropdown .nav-menu a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0;
}

.reading-intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background-color: #222222;
  border-radius: 12px;
  font-size: 12px;
  margin-bottom: 24px;
}

.reading-intro-quotes p,
.reading-intro-notes p {
  margin: 0;
}

.reading-intro-quotes {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.reading-intro-quotes p:not(:last-child) {
  margin-bottom: 1lh;
}

.reading-intro-notes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reading-intro-notes a {
  font-size: 12px;
}

.reading-wrap {
  padding-left: 0;
  padding-right: 0;
  --accent-green: #2f8f2f;
  --col-gap: 28px;
  --row-gap: 10px;
  --year-col-width: 4ch;
  --year-col-gap: 12px;
}

.reading-year-block {
  margin: 0 0 34px 0;
}

.reading-year-header {
  display: flex;
  align-items: center;
  gap: var(--year-col-gap);
  margin: 0 0 14px 0;
}

.reading-year-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
  width: var(--year-col-width);
}

.reading-year-rule {
  height: 1px;
  background: var(--accent-green);
  flex: 1;
}

.reading-grid {
  display: grid;
  grid-template-columns: 1.7fr 1.2fr 0.35fr;
  column-gap: var(--col-gap);
  row-gap: var(--row-gap);
  align-items: start;
  padding-left: calc(var(--year-col-width) + var(--year-col-gap));
}

.reading-cell {
  text-align: left;
  font-size: 14px;
}

.content .reading-title a {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid rgba(47, 143, 47, 0.45);
  border-radius: 6px;
  background: rgba(47, 143, 47, 0.10);
  text-decoration: none;
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.content .reading-title a:hover,
.content .reading-title a:focus {
  background: rgba(47, 143, 47, 0.16);
  border-color: rgba(47, 143, 47, 0.70);
  text-decoration: none;
}

.reading-year {
  white-space: nowrap;
}

@font-face {
  font-family: "Berkeley Mono";
  src: url("fonts/BerkeleyMono-Regular.woff2") format("woff2"),
    url("fonts/BerkeleyMono-Regular.woff") format("woff"),
    url("fonts/BerkeleyMono-Regular.otf") format("opentype"),
    url("fonts/BerkeleyMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Berkeley Mono";
  src: url("fonts/BerkeleyMono-Bold.woff2") format("woff2"),
    url("fonts/BerkeleyMono-Bold.woff") format("woff"),
    url("fonts/BerkeleyMono-Bold.otf") format("opentype"),
    url("fonts/BerkeleyMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@media (max-width: 680px) {
  .layout {
    padding: 18px;
    gap: 18px;
  }

  .sidebar {
    width: auto;
    position: relative;
    top: auto;
  }

  .nav-dropdown {
    display: block;
  }

  .nav-dropdown .nav-menu {
    min-width: 0;
    width: fit-content;
    max-width: 100%;
  }

  .reading-intro {
    padding: 16px;
    font-size: 12px;
  }

  .reading-grid {
    grid-template-columns: 1fr auto;
    column-gap: 14px;
    row-gap: 8px;
    padding-left: 0;
  }

  .reading-grid > .reading-cell:nth-child(3n + 1) {
    grid-column: 1 / -1;
    margin-top: 12px;
  }

  .reading-grid > .reading-cell:nth-child(3n + 2) {
    grid-column: 1 / 2;
    font-size: 13px;
    opacity: 0.9;
  }

  .reading-grid > .reading-cell:nth-child(3n) {
    grid-column: 2 / 3;
    justify-self: end;
    font-size: 13px;
    opacity: 0.9;
    white-space: nowrap;
  }

  .content .reading-title a {
    padding: 2px 8px;
    border-radius: 7px;
    background: rgba(47, 143, 47, 0.07);
    border: 1px solid rgba(47, 143, 47, 0.38);
    line-height: 1.25;
  }

  .content .reading-title a:hover,
  .content .reading-title a:focus {
    background: rgba(47, 143, 47, 0.12);
    border-color: rgba(47, 143, 47, 0.60);
  }

  .reading-cell {
    font-size: 14px;
  }
}

/* ------------------------------
   Mobile layout fix (no desktop change)
--------------------------------- */
@media (max-width: 680px) {
  /* 1) Stack sidebar above content */
  .layout {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 14px;
  }

  /* 2) Sidebar becomes normal flow, full width */
  .sidebar {
    width: 100%;
    position: relative;   /* kill sticky on mobile */
    top: auto;
  }

  /* 3) Make content full width */
  .content {
    width: 100%;
    min-width: 0;
  }

  /* 4) If your nav dropdown panel exists, keep it from forcing a 2-col layout */
  nav {
    width: 100%;
  }

  /* If your dropdown menu uses a UL, make it act like a panel */
  nav ul {
    width: 100%;
    max-width: 420px;           /* keeps it from being huge on wide phones */
    background: rgba(47, 143, 47, 0.08);
    border: 1px solid rgba(47, 143, 47, 0.35);
    border-radius: 12px;
    padding: 10px 12px;
  }

  /* Make each nav link tap-friendly */
  nav a {
    display: block;
    padding: 8px 6px;
  }

  /* 5) Intro box spacing */
  .reading-intro {
    padding: 14px;
    border-radius: 12px;
  }

  /* ===== Reading list: restructure grid for narrow screens ===== */
  .reading-grid {
    grid-template-columns: 1fr auto;
    column-gap: 14px;
    row-gap: 8px;
    padding-left: 0; /* remove desktop offset */
  }

  /* Title spans both columns */
  .reading-grid > .reading-cell:nth-child(3n + 1) {
    grid-column: 1 / -1;
    margin-top: 12px;
  }

  /* Author left */
  .reading-grid > .reading-cell:nth-child(3n + 2) {
    grid-column: 1 / 2;
    font-size: 13px;
    opacity: 0.9;
  }

  /* Year right */
  .reading-grid > .reading-cell:nth-child(3n) {
    grid-column: 2 / 3;
    justify-self: end;
    font-size: 13px;
    opacity: 0.9;
    white-space: nowrap;
  }

  /* Title pill: smaller, cleaner */
  .content .reading-title a {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 7px;
    background: rgba(47, 143, 47, 0.07);
    border: 1px solid rgba(47, 143, 47, 0.38);
    text-decoration: none;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
  }

  .content .reading-title a:hover,
  .content .reading-title a:focus {
    background: rgba(47, 143, 47, 0.12);
    border-color: rgba(47, 143, 47, 0.60);
  }
}

/* ---------- Dropdown nav ---------- */
.site-nav {
  position: relative;
  width: 220px; /* desktop default */
}

.nav-trigger {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: inherit;
  text-decoration: none;
  user-select: none;
}

.nav-trigger:focus-visible {
  outline: 1px solid rgba(47, 143, 47, 0.6);
  outline-offset: 4px;
  border-radius: 8px;
}

.nav-arrow {
  display: inline-block;
  transition: transform 120ms ease;
}

.site-nav.open .nav-arrow {
  transform: rotate(90deg); /* > becomes v-ish */
}

/* hidden attribute handles initial closed state */
.nav-menu {
  margin: 10px 0 0 0;
  padding: 10px 12px;
  list-style: none;
  border-radius: 12px;
  border: 1px solid rgba(47, 143, 47, 0.35);
  background: rgba(47, 143, 47, 0.08);
  backdrop-filter: blur(6px);
}

.nav-menu li + li {
  margin-top: 6px;
}

.nav-menu a {
  display: block;
  padding: 8px 6px;
}

/* ---------- Mobile: full width, not cramped ---------- */
@media (max-width: 680px) {
  .site-nav {
    width: 100%;
  }

  .nav-menu {
    max-width: 420px;
  }
}
