/* style.css */
/* Global, Severance-style minimal black & white, with subtle pixel background */

:root {
  --bg: #000000;
  --bg-elevated: #050505;
  --border-subtle: #222222;
  --text-main: #f5f5f5;
  --text-muted: #9f9f9f;
  --accent-soft: #ffffff;
}

/* Basic black page with pixelated grayscale backdrop */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: "Libertinus Serif", serif;
  font-weight: 400;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow: hidden;
}

/* Pixelated background as a faint layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.18;                           /* keep it subtle */
  filter: grayscale(1) contrast(1.1);
  pointer-events: none;
  z-index: -2;
}

/* Dark vignette overlay to make it feel like a black book */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.8)),
    radial-gradient(circle at bottom, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.9));
  pointer-events: none;
  z-index: -1;
}

/* Layout container */
#app {
  position: relative;
  display: flex;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* SIDEBAR
   ------------------------------------------------------------------ */

#sidebar {
  width: 280px;
  max-width: 75vw;
  background-color: var(--bg);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 24px 32px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
  max-height: 100vh;
}
#header-sidebar{
    display: flex;
    gap: 10%;
  }

/* Logo / mark area */
#logo-area {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.site-mark {
  font-size: 20px;
  color: var(--accent-soft);
}

.site-sub {
  margin-top: 6px;
  font-size: 16px;
  color: var(--text-muted);
}

/* Scrollable nav area */
#sidebar-content {
  margin-top: 24px;
  padding-right: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
}

/* Custom minimal scrollbars for sidebar */
#sidebar-content::-webkit-scrollbar {
  width: 6px;
}
#sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}
#sidebar-content::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: 3px;
}

/* Nav sections */
.nav-section {
  margin-bottom: 22px;
}

.nav-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Nav items */
.nav-item {
  display: block;
  width: 90%;
  padding: 4px 0;
  padding-left: 10px;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 15px;
  color: var(--text-main);
  opacity: 0.7;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition:
    color 0.15s ease,
    opacity 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.nav-item:hover {
  opacity: 1;
  color: var(--accent-soft);
  border-color: #444444;
  background-color: rgba(255, 255, 255, 0.02);
}

.nav-item.active {
  opacity: 1;
  color: var(--accent-soft);
  border-color: var(--accent-soft);
  background-color: rgba(255, 255, 255, 0.04);
}

/* MAIN / BOOK AREA
   ------------------------------------------------------------------ */

#codex {
  flex: 1 1 auto;
  position: fixed;
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.88);
  overflow: hidden;
}

/* Header row (just holds the hamburger and hidden <select>) */
#codex-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 18px 36px 0;
  box-sizing: border-box;
  z-index: 5;
}

/* Mobile sidebar toggle */
#sidebar-toggle {
  display: none; /* shown only on small screens */
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.85);
  color: var(--text-main);
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 999px;
  line-height: 1;
}

/* Hide native select visually (but keep for codex.js) */
#contents {
  display: none;
}

/* Book container */
#book {
  padding: 40px 48px 72px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
  margin-top:10vh;
}

#book > * {
  max-width: 720px;
  width: 100%;
}

/* Scrollbar for book */
#book::-webkit-scrollbar {
  width: 8px;
}
#book::-webkit-scrollbar-track {
  background: transparent;
}
#book::-webkit-scrollbar-thumb {
  background: #333333;
  border-radius: 4px;
}

/* Typography inside book area */
#book {
  font-size: 20px;
  line-height: 1.7;
}

#book h1,
#book h2,
#book h3,
#book h4 {
  font-weight: 600;
  margin-top: 2.4em;
  margin-bottom: 0.6em;
  letter-spacing: 0.03em;
}

#book h1 {
  font-size: 1.8rem;
}
#book h2 {
  font-size: 1.4rem;
}
#book h3 {
  font-size: 1.2rem;
}
#book h4 {
  font-size: 1.05rem;
}

#book p {
  margin: 0 0 1.15em;
}

#book em,
#book i {
  font-style: italic;
}

#book strong,
#book b {
  font-weight: 600;
}

/* Links inside the book */
#book a {
  color: var(--accent-soft);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* BLOCKQUOTES, HR, ETC (minimal) */
#book blockquote {
  margin: 1.5em 0;
  padding-left: 1.25em;
  border-left: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-style: italic;
}

#book hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2.2em 0;
}

/* MOBILE & RESPONSIVE
   ------------------------------------------------------------------ */

#sidebar-overlay {
  display: none;
}

/* Medium screens */
@media (max-width: 1200px) {
  #book {
    padding: 32px 28px 60px;
  }
}

/* Mobile: sidebar slides out, hamburger shown */
@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
  }

  

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
            left: 5px;
        top: 5px;
    z-index: 20;
  }

  #codex-header {
    justify-content: flex-end;
    padding: 16px 20px 0;
  }

  #book {
    padding: 28px 18px 52px;
  }

  #sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    z-index: 9;
  }

  #sidebar-overlay.visible {
    display: block;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

/* Very small devices */
@media (max-width: 600px) {
  #book {
    font-size: 16px;
  }

  .nav-item {
    font-size: 12px;
  }

  .nav-section-title {
    font-size: 10px;
  }
}
/* -------------------------------------------------------
   Right-side References Drawer (TAB = TOGGLER)
------------------------------------------------------- */

:root {
  --refs-w: 340px;
  --refs-tab-w: 44px;
  --refs-bg: rgba(0, 0, 0, 0.92);
  --refs-border: #222;
}

#refs-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;

  z-index: 30;

  display: flex;
  align-items: stretch;

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

  /* CLOSED by default visually, JS will open it on load */
  width: var(--refs-tab-w);

  transition: width 180ms ease;
}

/* The always-visible vertical toggler */
#refs-tab {
  width: var(--refs-tab-w);
  background: rgba(0, 0, 0, 0.95);
  border-right: 1px solid var(--refs-border);

  display: flex;
  align-items: center;
  justify-content: center;

  color: #bdbdbd;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;

  cursor: pointer;
  user-select: none;

  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

#refs-tab:focus {
  outline: 1px solid #444;
  outline-offset: -4px;
}

/* Panel is hidden when closed */
#refs-panel {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--refs-bg);
}

/* OPEN state */
body.refs-open #refs-drawer {
  width: var(--refs-w);
}

body.refs-open #refs-panel {
  display: flex;
  flex-direction: column;
}

/* Header */
.refs-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;

  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--refs-border);
}

.refs-title {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.refs-subtitle {
  font-size: 12px;
  color: #9f9f9f;
  border: 1px solid #2a2a2a;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
}

/* Body */
.refs-body {
  padding: 12px 14px 16px;
  overflow: auto;
}

.refs-body::-webkit-scrollbar { width: 8px; }
.refs-body::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.refs-group { margin-bottom: 14px; }

.refs-group-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9f9f9f;
  margin: 8px 0 8px;
}

.refs-list { display: grid; gap: 6px; }

.refs-item {
  width: 100%;
  text-align: left;
  border: 1px solid #222;
  background: rgba(255,255,255,0.03);
  color: #f5f5f5;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;

  font-family: "Libertinus Serif", serif;
  font-size: 12px;
  line-height: 1.25;
}

.refs-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: #333;
}

.refs-item .refs-code {
  display: block;
  color: #9f9f9f;
  font-size: 11px;
  margin-bottom: 2px;
  font-size: 13px;
}

.refs-item .refs-label {
  display: block;
  color: #f5f5f5;
  font-size: 13px;
}

/* Give book breathing room when refs open (desktop only) */
@media (min-width: 901px) {
  body.refs-open #book {
    padding-right: calc(48px + var(--refs-w));
  }
}

/* Mobile: do not reserve right padding (panel overlays) */
@media (max-width: 900px) {
  body.refs-open #book {
    padding-right: 18px;
  }

  #refs-drawer {
    width: var(--refs-tab-w);
  }

  body.refs-open #refs-drawer {
    width: min(var(--refs-w), 92vw);
  }
}

.refs-item .refs-reason {
  display: block;
  margin-top: 4px;
  color: #9f9f9f;
  font-size: 15px;
  line-height: 1.35;
}