/* ========================================================================
   cheat.zxzx.app — The Programmer's Reference Manual
   Theme: Thick computer encyclopedia manual
   ======================================================================== */

:root {
  --paper: #fffaf0;
  --soft: #f4efe3;
  --line: #d7cdb9;
  --paper-dark: #e8e0d0;
  --paper-edge: #d4c9b0;
  --ink: #1a1a1a;
  --ink-light: #444;
  --ink-faded: #888;
  --accent: #8b0000;
  --accent-light: #b22222;
  --blue: #00008b;
  --blue-link: #0000cc;
  --code-fg: #1a1a1a;
  --code-comment: #5a7a4a;
  --code-keyword: #3a5a8a;
  --code-string: #8a5a3a;
  --highlight: #fff3a8;
  --spine-bg: #2c1810;
  --spine-text: #d4c9b0;
  --tab-active: #8b0000;
  --tab-inactive: #a09080;
  --border: var(--line);
  --shadow: rgba(0,0,0,0.15);
}

/* ============================================
   ZXZX 2026 DESIGN PASS — Printed reference manual
   ============================================ */

body {
  background:
    linear-gradient(rgba(255,250,240,.72), rgba(255,250,240,.72)),
    repeating-linear-gradient(90deg, rgba(80,55,28,.04) 0 1px, transparent 1px 16px),
    #e4d2ad;
}

.book-wrapper {
  box-shadow: 18px 18px 0 rgba(68, 39, 17, 0.18), 0 28px 80px rgba(68,39,17,.24);
}

.book-content {
  background:
    linear-gradient(90deg, rgba(116,74,29,.08), transparent 24px),
    #fff8e7;
}

.book-header {
  border-bottom: 3px double rgba(68,39,17,.35);
}

.header-title {
  letter-spacing: 0;
}

.search-bar,
.toc,
.page-area {
  box-shadow: inset 0 0 0 1px rgba(68,39,17,.08);
}

.chapter-tab {
  border-radius: 0;
}

.chapter-tab.active {
  transform: translateY(-2px);
}

code,
pre,
.code-block {
  background: #282016 !important;
  color: #f8ecd0 !important;
}

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

body {
  font-family: 'Source Serif 4', 'Georgia', 'Times New Roman', serif;
  background: var(--soft);
  color: var(--ink);
  min-height: 100vh;
  padding: 20px;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* ===== BOOK WRAPPER ===== */
.book-wrapper {
  display: flex;
  max-width: 960px;
  width: 100%;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
}

/* ===== BOOK SPINE ===== */
.book-spine {
  width: 52px;
  min-width: 52px;
  background: linear-gradient(180deg, #3d2818 0%, #2c1810 20%, #2c1810 80%, #3d2818 100%);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 6px;
  border-right: 1px solid var(--line);
  position: relative;
}
.book-spine::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.08), transparent);
}
.spine-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: var(--spine-text);
  font-family: 'Playfair Display', serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  transform: rotate(180deg);
  white-space: nowrap;
}
.spine-volume {
  writing-mode: vertical-rl;
  color: #c0a060;
  font-size: 9px;
  font-family: 'Share Tech Mono', monospace;
  transform: rotate(180deg);
}
.spine-logo {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: #c0a060;
  letter-spacing: 1px;
}

/* ===== BOOK CONTENT ===== */
.book-content {
  flex: 1;
  background: var(--paper);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.book-content::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
  z-index: 2;
}

/* ===== HEADER ===== */
.book-header {
  background: linear-gradient(180deg, var(--soft) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
  padding: 0 24px 16px;
}
.header-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.edition-text {
  font-size: 11px;
  color: var(--ink-faded);
  font-style: italic;
}
.lang-switcher {
  display: flex;
  gap: 3px;
}
.lang-btn {
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 2px 8px;
  font-size: 10px;
  font-family: 'Source Serif 4', serif;
  cursor: pointer;
  color: var(--ink-light);
  border-radius: 0;
}
.lang-btn:hover { background: #ccc4b0; }
.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.header-title-area {
  text-align: center;
  padding: 8px 0 12px;
}
.header-icon-row {
  font-size: 36px;
  margin-bottom: 6px;
}
.header-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: 1px;
}
.header-subtitle {
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 6px;
  font-style: italic;
}
.header-meta {
  font-size: 11px;
  color: var(--ink-faded);
  margin-top: 6px;
  font-family: 'Share Tech Mono', monospace;
}
.meta-sep { margin: 0 6px; }

.back-to-portal {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--blue-link);
  text-decoration: underline;
  font-family: 'Share Tech Mono', monospace;
}
.back-to-portal:hover { color: var(--accent); }

/* ===== SEARCH BAR ===== */
.search-bar {
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.search-input {
  flex: 1;
  height: 28px;
  border: 1px solid var(--line);
  padding: 2px 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  border-radius: 0;
}
.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.search-count {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--ink-faded);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

/* ===== TABLE OF CONTENTS ===== */
.toc {
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  padding: 0;
}
.toc-header {
  background: var(--soft);
  padding: 6px 24px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
}
.toc-icon { font-size: 14px; }
.toc-body {
  padding: 10px 24px 10px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}
.toc-item {
  font-size: 12px;
  color: var(--blue-link);
  cursor: pointer;
  text-decoration: none;
  font-family: 'Source Serif 4', serif;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background 0.15s;
}
.toc-item:hover {
  background: var(--highlight);
  color: var(--accent);
}
.toc-item .toc-page {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: var(--ink-faded);
  margin-left: 4px;
}

/* ===== CHAPTER TABS ===== */
.chapter-tabs {
  display: flex;
  padding: 0 24px;
  gap: 2px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  padding-top: 6px;
}
.chapter-tab {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 0;
  background: var(--soft);
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faded);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  position: relative;
  top: 2px;
}
.chapter-tab:hover {
  background: var(--paper);
  color: var(--ink-light);
}
.chapter-tab.active {
  background: var(--paper);
  color: var(--accent);
  border-color: var(--accent);
  border-bottom: 2px solid var(--paper);
  top: 0;
}
.tab-icon { font-size: 14px; }

/* ===== PAGE AREA ===== */
.page-area {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  position: relative;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(0,0,0,0.02) 27px,
      rgba(0,0,0,0.02) 28px
    ),
    var(--paper);
  max-height: 70vh;
}
.page-inner {
  padding: 20px 28px 30px;
}

/* Page margin line (like a ruled notebook) */
.page-area::before {
  content: '';
  position: absolute;
  left: 56px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(139,0,0,0.1);
  z-index: 1;
  pointer-events: none;
}

/* ===== CHEATSHEET SECTIONS ===== */
.sheet-chapter {
  margin-bottom: 30px;
}
.sheet-chapter.hidden { display: none; }

.chapter-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
  border-bottom: 3px solid var(--accent);
  padding-bottom: 6px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chapter-number {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: var(--accent);
  background: var(--paper-dark);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
}

/* Section headings */
.sheet-section {
  margin-bottom: 20px;
  page-break-inside: avoid;
}
.sheet-section.search-hidden { display: none; }

.section-heading {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--border);
  scroll-margin-top: 20px;
}

/* Command / property entries */
.entry {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0;
  position: relative;
}
.entry.search-hidden { display: none; }
.entry.search-match {
  border-left-color: #006400;
  background: var(--highlight);
}

.entry-cmd {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  word-break: break-all;
}
.entry-cmd code {
  background: var(--soft);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 13px;
}
.entry-desc {
  font-size: 13px;
  color: var(--ink-light);
  line-height: 1.5;
}

/* Code blocks */
.code-block {
  background: var(--soft);
  color: var(--code-fg);
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 0;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid var(--line);
}
.code-block .comment { color: var(--code-comment); }
.code-block .keyword { color: var(--code-keyword); }
.code-block .string { color: var(--code-string); }

/* Inline code */
.entry-cmd code,
code.inline {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  background: var(--soft);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 0;
}

/* ===== FOOTER ===== */
.book-footer {
  background: var(--soft);
  border-top: 1px solid var(--line);
  padding: 10px 24px;
  text-align: center;
  font-size: 11px;
  font-family: 'Share Tech Mono', monospace;
  color: var(--ink-faded);
}
.footer-link {
  color: var(--blue-link);
  text-decoration: underline;
}
.footer-link:hover { color: var(--accent); }
.footer-sep { margin: 0 6px; color: var(--border); }

/* ===== PAGE NUMBERS ===== */
.page-number {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: var(--ink-faded);
  text-align: center;
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ===== HIGHLIGHT FOR SEARCH ===== */
mark {
  background: var(--highlight);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 1px;
}

/* ===== SCROLLBAR ===== */
.page-area::-webkit-scrollbar { width: 12px; }
.page-area::-webkit-scrollbar-track { background: var(--soft); }
.page-area::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 2px solid var(--soft);
  border-radius: 0;
}
.page-area::-webkit-scrollbar-thumb:hover { background: var(--ink-faded); }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  body { padding: 8px; }
  .book-spine { display: none; }
  .book-content { border-radius: 0; }
  .header-title { font-size: 22px; }
  .chapter-tabs { padding: 0 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chapter-tab { padding: 6px 12px; font-size: 11px; white-space: nowrap; }
  .page-inner { padding: 14px 16px 20px; }
  .entry { padding: 6px 10px; margin-bottom: 10px; }
  .search-field { flex-wrap: wrap; }
  .search-label { width: 100%; }
  .page-area::before { display: none; }
  .toc-body { padding: 8px 12px; }
  .toc-item { font-size: 11px; }
  .book-header { padding: 0 14px 12px; }
}

@media (max-width: 400px) {
  .header-title { font-size: 18px; }
  .chapter-tab .tab-label { display: none; }
  .chapter-tab .tab-icon { font-size: 18px; }
  .entry { padding: 6px 8px; }
  .entry-cmd { font-size: 12px; }
  .code-block { font-size: 11px; padding: 8px 10px; }
}
