/* ========================================
   CUSTOM STYLES FOR HONKIT
   ======================================== */

/* ========================================
   HIDE SEPIA THEME OPTION
   ======================================== */

/* Hide Sepia theme button in theme selector */
.dropdown-menu .buttons button[data-theme="1"],
.dropdown-menu button[data-theme="sepia"],
.dropdown-menu .color-theme-1,
button.color-theme-1 {
  display: none !important;
}

/* Alternative: Hide by position (2nd button in color theme row) */
.dropdown-menu .buttons:last-child button:nth-child(2) {
  display: none !important;
}

/* Align remaining theme buttons (White and Night) */
.dropdown-menu .buttons:last-child {
  display: flex !important;
  justify-content: space-between !important;
  width: 100% !important;
}

.dropdown-menu .buttons:last-child button {
  flex: 1 !important;
  margin: 0 2px !important;
}

/* ========================================
   LOGO IN SIDEBAR
   ======================================== */

/* Add logo at the top of the sidebar */
.book-summary:before {
  content: "";
  display: block;
  background-image: url("../assets/logo.svg");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  height: 60px;
  margin: 20px 15px 15px 15px;
}

/* Use black logo for Sepia theme */
.book.color-theme-2 .book-summary:before {
  background-image: url("../assets/logo-black.svg");
}

/* ========================================
   LEFT SIDEBAR NAVIGATION
   ======================================== */

/* Sidebar background colors for each theme */
/* White theme */
.book.color-theme-0 .book-summary {
  background: #fafafa !important;
}

/* Sepia theme */
.book.color-theme-1 .book-summary {
  background: #f3ebca !important;
}

/* Night theme */
.book.color-theme-2 .book-summary {
  background: #1c1f2b !important;
}

/* Unified font size for all menu items */
.book-summary ul.summary li a,
.book-summary ul.summary li span {
  font-size: 14px !important;
  line-height: 1.6 !important;
  padding: 8px 15px !important;
}

/* Tables - improve styling and make "View Details" links prominent */
.markdown-section table,
.book .book-body .page-wrapper .page-inner section.normal table,
table {
  border-collapse: collapse !important;
  width: 100% !important;
  margin: 20px 0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  table-layout: fixed !important;
  display: table !important;
}

/* Fixed column widths for consistent alignment */
.markdown-section table th:nth-child(1),
.markdown-section table td:nth-child(1),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(1),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(1),
table th:nth-child(1),
table td:nth-child(1) {
  width: 90px !important;
  min-width: 90px !important;
  max-width: 90px !important;
}

.markdown-section table th:nth-child(2),
.markdown-section table td:nth-child(2),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(2),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(2),
table th:nth-child(2),
table td:nth-child(2) {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
}

.markdown-section table th:nth-child(3),
.markdown-section table td:nth-child(3),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(3),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(3),
table th:nth-child(3),
table td:nth-child(3) {
  width: 140px !important;
  min-width: 140px !important;
  max-width: 140px !important;
}

.markdown-section table th:nth-child(4),
.markdown-section table td:nth-child(4),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(4),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(4),
table th:nth-child(4),
table td:nth-child(4) {
  width: 140px !important;
  min-width: 140px !important;
  max-width: 140px !important;
}

.markdown-section table th:nth-child(5),
.markdown-section table td:nth-child(5),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(5),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(5),
table th:nth-child(5),
table td:nth-child(5) {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
}

.markdown-section table th:nth-child(6),
.markdown-section table td:nth-child(6),
.book .book-body .page-wrapper .page-inner section.normal table th:nth-child(6),
.book .book-body .page-wrapper .page-inner section.normal table td:nth-child(6),
table th:nth-child(6),
table td:nth-child(6) {
  width: 140px !important;
  min-width: 140px !important;
  max-width: 140px !important;
}

table th {
  background: #f6f8fa;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid #e1e4e8;
  font-size: 13px;
  color: #24292e;
  white-space: normal;
}

table td {
  padding: 6px 12px;
  border: 1px solid #e1e4e8;
  vertical-align: middle;
  font-size: 13px;
  white-space: normal;
}

table tr:hover {
  background: #f6f8fa;
  transition: background 0.2s ease;
}

/* Change button style when row is hovered */
table tr:hover a {
  background: #0366d6 !important;
  color: white !important;
  border-color: #0366d6 !important;
  transform: translateX(2px) !important;
  box-shadow: 0 2px 6px rgba(3, 102, 214, 0.4) !important;
}

/* Style inline code in tables */
table code {
  background: #f0f0f0;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
  color: #e83e8c;
}

/* Make "View Details" links more prominent */
table a {
  display: inline-block !important;
  padding: 6px 12px !important;
  background: #f6f8fa !important;
  color: #57606a !important;
  border: 1px solid #d0d7de !important;
  text-decoration: none !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
  text-align: center !important;
  min-width: 110px !important;
}

table a:hover {
  background: #0366d6 !important;
  color: white !important;
  border-color: #0366d6 !important;
  transform: translateX(2px) !important;
  box-shadow: 0 2px 6px rgba(3, 102, 214, 0.4) !important;
}

table a:active {
  background: #0256c4 !important;
  border-color: #0256c4 !important;
  transform: translateX(0) !important;
}

/* Section headers */
h2 {
  border-bottom: 2px solid #e1e4e8;
  padding-bottom: 8px;
  margin-top: 32px;
  margin-bottom: 16px;
}

h3 {
  margin-top: 24px;
  margin-bottom: 12px;
  color: #24292e;
}

h4 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #24292e;
}

/* Code blocks */
pre {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

code {
  background: #f6f8fa;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 85%;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 90%;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid #0366d6;
  background: #f6f8fa;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 4px;
}

blockquote p {
  margin: 0;
}

/* Lists */
ul,
ol {
  margin: 12px 0;
  padding-left: 24px;
}

li {
  margin: 6px 0;
  line-height: 1.6;
}

/* Links */
a {
  color: #0366d6;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Horizontal rules */
hr {
  border: 0;
  border-top: 2px solid #e1e4e8;
  margin: 24px 0;
}

/* Figure and figcaption styling */
figure {
  margin: 20px 0;
  text-align: center;
}

figure img {
  max-width: 100%;
  height: auto;
}

figcaption {
  text-align: center !important;
  font-style: italic;
  color: #6a737d;
  margin-top: 8px;
  font-size: 14px;
}

figcaption p {
  margin: 0 !important;
  text-align: center !important;
}

/* Status badges */
strong {
  font-weight: 600;
}

/* Improve spacing for opcode detail sections */
h3[id^="0x"] {
  /* No extra spacing - let default h3 styles apply */
}

/* Add scroll padding for anchor links */
html {
  scroll-padding-top: 20px;
}

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

/* Highlight target section when navigating via anchor */
:target {
  animation: highlight 2s ease;
}

@keyframes highlight {
  0% {
    background: #fff3cd;
  }
  100% {
    background: transparent;
  }
}

/* Appendix: Subcircuit Mapping Table - specific column widths */
#appendix-subcircuit-mapping-table + table th:nth-child(2),
#appendix-subcircuit-mapping-table + table td:nth-child(2) {
  width: 110px !important;
  min-width: 110px !important;
  max-width: 110px !important;
}

#appendix-subcircuit-mapping-table + table th:nth-child(6),
#appendix-subcircuit-mapping-table + table td:nth-child(6) {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
}

/* ========================================
   RIGHT SIDEBAR TABLE OF CONTENTS
   ======================================== */

/* Only show TOC on pages with .page-toc-enabled class */
.page-toc-enabled .book .book-body {
  padding-right: 300px !important;
}

.page-toc-enabled .page-toc {
  position: fixed !important;
  right: 0 !important;
  top: 0 !important;
  width: 280px !important;
  height: 100vh !important;
  overflow-y: auto !important;
  padding: 30px 20px !important;
  border-left: 1px solid rgba(0, 0, 0, 0.07) !important;
  z-index: 100 !important;
}

/* White theme TOC background */
.book.color-theme-0 .page-toc {
  background: #ffffff !important;
}

/* Sepia theme TOC background */
.book.color-theme-1 .page-toc {
  background: #f3ebca !important;
}

/* Night theme TOC background */
.book.color-theme-2 .page-toc {
  background: #1c1f2b !important;
}

.page-toc-enabled .page-toc h2 {
  font-size: 12px !important;
  font-weight: 700 !important;
  margin: 0 0 16px 0 !important;
  padding: 0 0 8px 0 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
}

/* White theme */
.book.color-theme-0 .page-toc h2 {
  color: #666 !important;
}

/* Sepia theme */
.book.color-theme-1 .page-toc h2 {
  color: #866f5a !important;
}

/* Night theme */
.book.color-theme-2 .page-toc h2 {
  color: #969896 !important;
}

.page-toc-enabled .page-toc ul {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.page-toc-enabled .page-toc li {
  margin: 0 0 4px 0 !important;
  padding: 0 !important;
}

.page-toc-enabled .page-toc a {
  display: block !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
  text-decoration: none !important;
  border-radius: 6px !important;
  transition: all 0.15s ease !important;
  border: none !important;
  background: transparent !important;
  min-width: auto !important;
  text-align: left !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
}

/* White theme */
.page-toc a {
  color: #333333 !important;
}
/* Sepia theme */
.book.color-theme-1 .page-toc a {
  color: #704214 !important;
}

/* Night theme */
.book.color-theme-2 .page-toc a {
  color: #bdcadb !important;
}

.page-toc-enabled .page-toc a:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  transform: translateX(2px) !important;
  box-shadow: none !important;
}

.page-toc-enabled .page-toc a.active {
  background: rgba(66, 153, 225, 0.15) !important;
  font-weight: 500 !important;
}

/* Scrollbar styling for TOC */
.page-toc-enabled .page-toc::-webkit-scrollbar {
  width: 6px;
}

.page-toc-enabled .page-toc::-webkit-scrollbar-track {
  background: transparent;
}

.page-toc-enabled .page-toc::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.page-toc-enabled .page-toc::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* This CSS rule has been removed to prevent hiding "On This Page" content on other pages */

/* When left menu is open: hide TOC below 1630px */
@media (max-width: 1629px) {
  body.page-toc-enabled .book.with-summary .book-body {
    padding-right: 0 !important;
  }

  body.page-toc-enabled .book.with-summary .page-toc {
    display: none !important;
  }
}

/* When left menu is closed: extend compact layout to 1320px */
@media (min-width: 1240px) and (max-width: 1319px) {
  .book:not(.with-summary) .book-body {
    padding-left: 0 !important;
    margin-left: 0 !important;
  }
}

/* When left menu is closed: extend compact layout to 1320px */
@media (min-width: 1240px) and (max-width: 1319px) {
  .page-inner {
    padding-right: 100px !important;
  }
}

/* Hide right TOC below 800px regardless of left menu state */
@media (max-width: 799px) {
  .page-toc-enabled .page-toc {
    display: none !important;
  }

  .page-toc-enabled .book .book-body {
    padding-right: 0 !important;
  }
}
