/*
 * style.css — Crafting Sandbox Documentation Site Styles
 * =======================================================
 * Organized into sections:
 *   1. Color theme variables (CSS custom properties)
 *   2. Reset and base
 *   3. Typography / fonts
 *   4. Banner / header
 *   5. Navigation panel
 *   6. Content area
 *   7. Outline panel (right-side TOC)
 *   8. Search box and results overlay
 *   9. Code blocks and inline code
 *  10. Tables
 *  11. Blockquotes and callouts
 *  12. Responsive / utility
 */

/* ==========================================================================
   1. Color theme variables (CSS custom properties)
   ========================================================================== */
:root {
  /* Primary brand blue */
  --color-primary:       #2563eb;
  --color-primary-dark:  #1d4ed8;
  --color-primary-light: #3b82f6;
  --color-primary-pale:  #dbeafe;

  /* Slate shades for UI chrome */
  --color-bg:            #f8fafc;
  --color-surface:       #ffffff;
  --color-border:        #e2e8f0;
  --color-border-dark:   #cbd5e1;

  /* Text */
  --color-text:          #1e293b;
  --color-text-muted:    #64748b;
  --color-text-faint:    #94a3b8;
  --color-heading:       #0f172a;

  /* Navigation */
  --color-nav-bg:        #f1f5f9;
  --color-nav-active-bg: #dbeafe;
  --color-nav-active:    #1d4ed8;
  --color-nav-hover-bg:  #e2e8f0;

  /* Banner — bg matches crafting.svg's built-in background */
  --color-banner-bg:     #002127;
  --color-banner-text:   #f1f5f9;
  --color-banner-logo:   #60a5fa;

  /* Outline panel */
  --color-outline-bg:    #f8fafc;
  --color-outline-active:#2563eb;

  /* Code */
  --color-code-bg:       #1e293b;
  --color-code-text:     #e2e8f0;
  --color-inline-code-bg:#f1f5f9;
  --color-inline-code:   #0f172a;

  /* Sizes */
  --banner-height:        4.5rem; /* matches crafting.svg original height */
  --nav-width:            15rem;
  --outline-width:        13.75rem;
  --content-max-width:    53.75rem;
}

/* ==========================================================================
   2. Reset and base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 1rem;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--banner-height) + 1rem);
}

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

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--color-primary-dark);
}

/* ==========================================================================
   3. Typography / fonts
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-heading);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.6em;
  margin-bottom: 0.5em;
}

h1 { font-size: 2rem;   margin-top: 0; }
h2 { font-size: 1.5rem; padding-bottom: 0.3em; border-bottom: 0.0625rem solid var(--color-border); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem;   font-weight: 600; }

p  { margin-bottom: 1em; }

ul, ol {
  margin-bottom: 1em;
  padding-left: 1.6em;
}

li { margin-bottom: 0.25em; }

strong { font-weight: 600; }

hr {
  border: none;
  border-top: 0.0625rem solid var(--color-border);
  margin: 2em 0;
}

/* ==========================================================================
   4. Banner / header
   ========================================================================== */
#banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--banner-height);
  padding: 0 1.25rem;
  background: var(--color-banner-bg);
  box-shadow: 0 0.0625rem 0.25rem rgba(0,0,0,0.3);
}

/* Logo / title link — crafting.svg is loaded here as a background image.
   CSS resolves url() relative to style.css, so the single reference works
   for all pages regardless of their directory depth. */
#banner .logo a {
  display: block;
  width: 12.78rem;          /* original 17.75rem scaled down 28% */
  height: 2.88rem;          /* original 4rem scaled down 28% */
  background-image: url('crafting.svg');
  background-repeat: no-repeat;
  background-size: 12.78rem 2.88rem;
  text-decoration: none;
  opacity: 1;
  transition: opacity 0.15s;
}

#banner .logo a:hover {
  opacity: 0.85;
  text-decoration: none;
}

/* ==========================================================================
   5. Navigation panel
   ========================================================================== */
#layout {
  display: flex;
  min-height: calc(100vh - var(--banner-height));
}

#nav {
  width: var(--nav-width);
  min-width: var(--nav-width);
  background: var(--color-nav-bg);
  border-right: 0.0625rem solid var(--color-border);
  padding: 1rem 0 2rem 0;
  position: sticky;
  top: var(--banner-height);
  height: calc(100vh - var(--banner-height));
  overflow-y: auto;
  flex-shrink: 0;
}

/* Custom scrollbar for nav */
#nav::-webkit-scrollbar { width: 0.25rem; }
#nav::-webkit-scrollbar-track { background: transparent; }
#nav::-webkit-scrollbar-thumb { background: var(--color-border-dark); border-radius: 0.25rem; }

/* Nav section header (collapsible) */
.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 1rem 0.45rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: 0;
}

.nav-section-header:hover {
  color: var(--color-text);
}

/* Chevron icon for collapsible */
.nav-section-header .chevron {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  color: var(--color-text-faint);
}

.nav-section-header.collapsed .chevron {
  transform: rotate(-90deg);
}

/* Nav subsection label */
.nav-subsection-label {
  padding: 0.5rem 1rem 0.2rem 1.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  margin-top: 0.35rem;
}

/* Individual nav link */
.nav-item {
  display: block;
  padding: 0.32rem 1rem 0.32rem 1.4rem;
  font-size: 0.875rem;
  color: var(--color-text);
  border-radius: 0;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--color-nav-hover-bg);
  color: var(--color-text);
  text-decoration: none;
}

/* Active / current page highlight */
.nav-item.active {
  background: var(--color-nav-active-bg);
  color: var(--color-nav-active);
  font-weight: 600;
  border-left: 0.1875rem solid var(--color-primary);
  padding-left: calc(1.4rem - 0.1875rem);
}

/* Top-level single nav link (e.g. Introduction) */
.nav-single {
  display: block;
  padding: 0.4rem 1rem 0.4rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  transition: background 0.12s;
}

.nav-single:hover {
  background: var(--color-nav-hover-bg);
  text-decoration: none;
}

.nav-single.active {
  background: var(--color-nav-active-bg);
  color: var(--color-nav-active);
  font-weight: 600;
  border-left: 0.1875rem solid var(--color-primary);
  padding-left: calc(1rem - 0.1875rem);
}

/* Collapsible nav content */
.nav-section-content {
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.nav-section-content.collapsed {
  max-height: 0 !important;
}

/* ==========================================================================
   6. Content area
   ========================================================================== */
#content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 3rem 2.5rem;
  max-width: var(--content-max-width);
}

/* Ensure content links are clearly visible */
#content a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s;
}

#content a:hover {
  text-decoration-color: currentColor;
}

/* ==========================================================================
   7. Outline panel (right-side TOC)
   ========================================================================== */
#outline-wrap {
  width: var(--outline-width);
  min-width: var(--outline-width);
  flex-shrink: 0;
  padding: 1.25rem 1rem 2rem 0.5rem;
  position: sticky;
  top: var(--banner-height);
  height: calc(100vh - var(--banner-height));
  overflow-y: auto;
}

#outline-wrap::-webkit-scrollbar { width: 0.1875rem; }
#outline-wrap::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 0.1875rem; }

#outline-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-faint);
  margin-bottom: 0.6rem;
  padding-left: 0.5rem;
}

/* TOC list */
#outline {
  list-style: none;
  padding: 0;
  margin: 0;
}

#outline li {
  margin-bottom: 0;
}

#outline a {
  display: block;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  border-left: 0.125rem solid transparent;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

#outline a:hover {
  color: var(--color-text);
  text-decoration: none;
}

/* Active TOC heading */
#outline a.active {
  color: var(--color-outline-active);
  border-left-color: var(--color-outline-active);
  font-weight: 500;
}

/* Indent h3 and h4 entries */
#outline li[data-level="3"] a { padding-left: 1.25rem; font-size: 0.78rem; }
#outline li[data-level="4"] a { padding-left: 2rem;    font-size: 0.75rem; }

/* ==========================================================================
   8. Search box and results overlay
   ========================================================================== */
#search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search-input {
  width: 13.75rem;
  padding: 0.35rem 0.75rem 0.35rem 2rem;
  background: rgba(255,255,255,0.1);
  border: 0.0625rem solid rgba(255,255,255,0.2);
  border-radius: 1.25rem;
  color: var(--color-banner-text);
  font-size: 0.875rem;
  outline: none;
  transition: background 0.2s, border-color 0.2s, width 0.2s;
}

#search-input::placeholder {
  color: rgba(255,255,255,0.45);
}

#search-input:focus {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.45);
  width: 17.5rem;
}

/* Search icon inside input */
#search-icon {
  position: absolute;
  left: 0.55rem;
  color: rgba(255,255,255,0.45);
  font-size: 0.85rem;
  pointer-events: none;
}

/* Search results dropdown */
#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 26.25rem;
  max-height: 26.25rem;
  overflow-y: auto;
  background: var(--color-surface);
  border: 0.0625rem solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.15);
  z-index: 200;
}

#search-results.visible {
  display: block;
}

/* Empty state */
#search-results .search-empty {
  padding: 1.25rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* Individual result item */
.search-result {
  display: block;
  padding: 0.7rem 1rem;
  border-bottom: 0.0625rem solid var(--color-border);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.12s;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: var(--color-nav-active-bg);
  text-decoration: none;
}

.search-result-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.2rem;
}

.search-result-snippet {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Highlighted search terms */
.search-result-snippet mark,
.search-result-title mark {
  background: #fef08a;
  color: inherit;
  padding: 0 0.0625rem;
  border-radius: 0.125rem;
}

/* ==========================================================================
   9. Code blocks and inline code
   ========================================================================== */
/* Block code */
pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1.25em;
  font-size: 0.875rem;
  line-height: 1.6;
  border: 0.0625rem solid rgba(255,255,255,0.05);
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  border: none; /* override the inline-code border */
}

/* codehilite wraps blocks in <div class="highlight"><pre>…</pre></div>.
   Make the div inherit our pre styling instead of adding its own box. */
div.highlight {
  background: transparent;
  border-radius: 0.5rem;
  margin-bottom: 1.25em;
  overflow: hidden; /* clip child pre's border-radius */
}

div.highlight pre {
  margin-bottom: 0; /* outer div already provides spacing */
}

/* Inline code */
code {
  background: var(--color-inline-code-bg);
  color: var(--color-inline-code);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  border: 0.0625rem solid var(--color-border);
}

/* ==========================================================================
   10. Tables
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25em;
  font-size: 0.9rem;
}

thead tr {
  background: var(--color-nav-bg);
  border-bottom: 0.125rem solid var(--color-border-dark);
}

thead th {
  text-align: left;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  color: var(--color-heading);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 0.0625rem solid var(--color-border);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--color-nav-bg);
}

tbody td {
  padding: 0.5rem 0.85rem;
  vertical-align: top;
}

/* ==========================================================================
   11. Blockquotes and callouts
   ========================================================================== */
blockquote {
  border-left: 0.25rem solid var(--color-primary);
  background: var(--color-primary-pale);
  margin: 1em 0;
  padding: 0.75rem 1rem;
  border-radius: 0 0.375rem 0.375rem 0;
  color: var(--color-text);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   12. Responsive / utility
   ========================================================================== */
/* Hide outline panel on narrower screens */
@media (max-width: 75rem) {
  #outline-wrap {
    display: none;
  }
}

/* Collapse nav on small screens */
@media (max-width: 50rem) {
  #nav {
    display: none;
  }
  #content {
    padding: 1.25rem 1rem 2rem 1rem;
  }
}

@media (max-width: 31.25rem) {
  #search-input {
    width: 8.75rem;
  }
  #search-results {
    width: 18.75rem;
  }
}

/* ==========================================================================
   13. Syntax highlighting (Pygments one-dark theme)
   — generated from: HtmlFormatter(style='one-dark').get_style_defs('.highlight')
   — To change theme: run `python3 -c "from pygments.formatters import HtmlFormatter;
     print(HtmlFormatter(style='<THEME>').get_style_defs('.highlight'))"`
     and replace everything in this section.
   ========================================================================== */
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 0.3125rem; padding-right: 0.3125rem; }
span.linenos { color: inherit; background-color: transparent; padding-left: 0.3125rem; padding-right: 0.3125rem; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 0.3125rem; padding-right: 0.3125rem; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 0.3125rem; padding-right: 0.3125rem; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #7F848E } /* Comment */
.highlight .err { color: #ABB2BF } /* Error */
.highlight .esc { color: #ABB2BF } /* Escape */
.highlight .g { color: #ABB2BF } /* Generic */
.highlight .k { color: #C678DD } /* Keyword */
.highlight .l { color: #ABB2BF } /* Literal */
.highlight .n { color: #E06C75 } /* Name */
.highlight .o { color: #56B6C2 } /* Operator */
.highlight .x { color: #ABB2BF } /* Other */
.highlight .p { color: #ABB2BF } /* Punctuation */
.highlight .ch { color: #7F848E } /* Comment.Hashbang */
.highlight .cm { color: #7F848E } /* Comment.Multiline */
.highlight .cp { color: #7F848E } /* Comment.Preproc */
.highlight .cpf { color: #7F848E } /* Comment.PreprocFile */
.highlight .c1 { color: #7F848E } /* Comment.Single */
.highlight .cs { color: #7F848E } /* Comment.Special */
.highlight .gd { color: #ABB2BF } /* Generic.Deleted */
.highlight .ge { color: #ABB2BF } /* Generic.Emph */
.highlight .ges { color: #ABB2BF } /* Generic.EmphStrong */
.highlight .gr { color: #ABB2BF } /* Generic.Error */
.highlight .gh { color: #ABB2BF } /* Generic.Heading */
.highlight .gi { color: #ABB2BF } /* Generic.Inserted */
.highlight .go { color: #ABB2BF } /* Generic.Output */
.highlight .gp { color: #ABB2BF } /* Generic.Prompt */
.highlight .gs { color: #ABB2BF } /* Generic.Strong */
.highlight .gu { color: #ABB2BF } /* Generic.Subheading */
.highlight .gt { color: #ABB2BF } /* Generic.Traceback */
.highlight .kc { color: #E5C07B } /* Keyword.Constant */
.highlight .kd { color: #C678DD } /* Keyword.Declaration */
.highlight .kn { color: #C678DD } /* Keyword.Namespace */
.highlight .kp { color: #C678DD } /* Keyword.Pseudo */
.highlight .kr { color: #C678DD } /* Keyword.Reserved */
.highlight .kt { color: #E5C07B } /* Keyword.Type */
.highlight .ld { color: #ABB2BF } /* Literal.Date */
.highlight .m { color: #D19A66 } /* Literal.Number */
.highlight .s { color: #98C379 } /* Literal.String */
.highlight .na { color: #E06C75 } /* Name.Attribute */
.highlight .nb { color: #E5C07B } /* Name.Builtin */
.highlight .nc { color: #E5C07B } /* Name.Class */
.highlight .no { color: #E06C75 } /* Name.Constant */
.highlight .nd { color: #61AFEF } /* Name.Decorator */
.highlight .ni { color: #E06C75 } /* Name.Entity */
.highlight .ne { color: #E06C75 } /* Name.Exception */
.highlight .nf { color: #61AFEF; font-weight: bold } /* Name.Function */
.highlight .nl { color: #E06C75 } /* Name.Label */
.highlight .nn { color: #E06C75 } /* Name.Namespace */
.highlight .nx { color: #E06C75 } /* Name.Other */
.highlight .py { color: #E06C75 } /* Name.Property */
.highlight .nt { color: #E06C75 } /* Name.Tag */
.highlight .nv { color: #E06C75 } /* Name.Variable */
.highlight .ow { color: #56B6C2 } /* Operator.Word */
.highlight .pm { color: #ABB2BF } /* Punctuation.Marker */
.highlight .w { color: #ABB2BF } /* Text.Whitespace */
.highlight .mb { color: #D19A66 } /* Literal.Number.Bin */
.highlight .mf { color: #D19A66 } /* Literal.Number.Float */
.highlight .mh { color: #D19A66 } /* Literal.Number.Hex */
.highlight .mi { color: #D19A66 } /* Literal.Number.Integer */
.highlight .mo { color: #D19A66 } /* Literal.Number.Oct */
.highlight .sa { color: #98C379 } /* Literal.String.Affix */
.highlight .sb { color: #98C379 } /* Literal.String.Backtick */
.highlight .sc { color: #98C379 } /* Literal.String.Char */
.highlight .dl { color: #98C379 } /* Literal.String.Delimiter */
.highlight .sd { color: #98C379 } /* Literal.String.Doc */
.highlight .s2 { color: #98C379 } /* Literal.String.Double */
.highlight .se { color: #98C379 } /* Literal.String.Escape */
.highlight .sh { color: #98C379 } /* Literal.String.Heredoc */
.highlight .si { color: #98C379 } /* Literal.String.Interpol */
.highlight .sx { color: #98C379 } /* Literal.String.Other */
.highlight .sr { color: #98C379 } /* Literal.String.Regex */
.highlight .s1 { color: #98C379 } /* Literal.String.Single */
.highlight .ss { color: #98C379 } /* Literal.String.Symbol */
.highlight .bp { color: #E5C07B } /* Name.Builtin.Pseudo */
.highlight .fm { color: #56B6C2; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #E06C75 } /* Name.Variable.Class */
.highlight .vg { color: #E06C75 } /* Name.Variable.Global */
.highlight .vi { color: #E06C75 } /* Name.Variable.Instance */
.highlight .vm { color: #E06C75 } /* Name.Variable.Magic */
.highlight .il { color: #D19A66 } /* Literal.Number.Integer.Long */
