/* =========================================================
   Globalna stilska podešavanja koja nadopunjuju custom.scss
   ========================================================= */

/* Navbar blends into page background */
.navbar {
  background-color: #F6F1E8 !important;
  box-shadow: none !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.navbar .navbar-brand,
.navbar .nav-link {
  color: #14213D !important;
}
.navbar .nav-link:hover {
  color: #B08538 !important;
}

/* Hide index.qmd (home page) entry from sidebar TOC */
.sidebar-item:has(a.sidebar-link[href="./index.html"]),
.sidebar-item:has(a.sidebar-link[href="../index.html"]) {
  display: none !important;
}

/* Standalone pages (landing, vodic, resursi, alat): no book sidebar, centered content */
body.standalone-page #quarto-sidebar,
body.standalone-page #quarto-margin-sidebar,
body.standalone-page .sidebar.sidebar-navigation {
  display: none !important;
}
body.standalone-page .page-columns {
  display: block !important;
  grid-template-columns: 1fr !important;
}
body.standalone-page main.content,
body.standalone-page #quarto-document-content {
  max-width: 1100px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 1.5rem !important;
  padding-right: 1.5rem !important;
  width: auto !important;
  grid-column: 1 / -1 !important;
}

/* PDF button in navbar — styled as a pill button */
.navbar a.nav-link[href*=".pdf"] {
  background-color: #14213D !important;
  color: #FAFAF5 !important;
  border-radius: 4px;
  padding: 0.3rem 0.8rem !important;
  font-weight: 600;
  font-size: 0.85rem;
  margin-left: 0.5rem;
}
.navbar a.nav-link[href*=".pdf"]:hover {
  background-color: #B08538 !important;
  color: #FAFAF5 !important;
}
/* Hide PDF button on landing page */
body.standalone-page .navbar a.nav-link[href*=".pdf"] {
  display: none !important;
}

/* PDF download button in book sidebar — make it prominent */
.sidebar-tools-main {
  padding: 0.75rem 1rem !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.sidebar-tools-main a[href*=".pdf"] {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  background-color: #14213D !important;
  color: #FAFAF5 !important;
  padding: 0.5rem 0.9rem !important;
  border-radius: 4px;
  text-decoration: none !important;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background-color 0.15s ease;
}
.sidebar-tools-main a[href*=".pdf"]:hover {
  background-color: #B08538 !important;
  color: #FAFAF5 !important;
}
.sidebar-tools-main a[href*=".pdf"]::after {
  content: "Preuzmi PDF";
}
.sidebar-tools-main a[href*=".pdf"] i {
  font-size: 1rem;
}

/* Sakrij landing page (index) iz sidebara */
.sidebar-item:has(a[href$="index.html"]),
.sidebar-item:has(a[href="./"]),
.sidebar-item:has(a[href="../"]),
a.sidebar-link[href$="index.html"],
a.sidebar-item-text[href$="index.html"] {
  display: none !important;
}

/* Topla off-white pozadina (a la fatih.ai), bez noise teksture */
body {
  background-color: #F6F1E8;
}

/* Glavni stupac teksta — udobnih ~70 znakova / red */
main#quarto-document-content,
main.content > section,
main.content > p,
main.content > .quarto-title-block ~ section {
  /* ne stiskamo Quarto layout, samo proseu damo max-width */
}

/* Quarto stavlja članak unutar .content; targetiramo "prose" */
.quarto-book main.content {
  max-width: none; /* dopuštamo punu Quarto strukturu (sidebar + margin) */
}

/* Sami pasusi/listevi imaju komforan max-width */
main.content > section > p,
main.content > section > ul,
main.content > section > ol,
main.content > section > blockquote,
main.content > section > .callout,
main.content > section > .sourceCode,
main.content > p,
main.content > ul,
main.content > ol,
main.content > blockquote {
  max-width: 70ch;
}

/* Slike i tablice mogu biti šire */
main.content figure,
main.content table,
main.content .quarto-figure {
  max-width: 100%;
}

/* Slike */
img {
  max-width: 100%;
  height: auto;
}

/* =========================================================
   Reading progress bar (top of viewport)
   ========================================================= */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #14213D 0%, #B08538 100%);
  z-index: 9999;
  transition: width 0.08s linear;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(176, 133, 56, 0.4);
}

/* =========================================================
   Hover preview tooltips za interne linkove (uz Quarto built-in)
   ========================================================= */
.internal-hover-preview {
  position: absolute;
  z-index: 10000;
  max-width: 380px;
  background: #2D3748;
  color: #FAFAF5;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.85rem 1rem;
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.22);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.internal-hover-preview.visible {
  opacity: 1;
  transform: translateY(0);
}
.internal-hover-preview .ihp-title {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  color: #B08538;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 768px) {
  body {
    font-size: 16px;
    background-size: 180px 180px;
  }

  table {
    font-size: 0.82rem;
  }

  pre {
    font-size: 0.75rem;
    overflow-x: scroll;
  }

  /* Drop cap manji na mobitelu */
  .has-dropcap::first-letter {
    font-size: 3.2rem !important;
  }

  /* Veliki broj poglavlja manji na mobitelu */
  header#title-block-header[data-chapter-num]::before {
    font-size: 4.5rem !important;
    opacity: 0.18 !important;
  }

  #reading-progress {
    height: 2px;
  }
}

/* =========================================================
   Hanging punctuation (Source Serif 4 podržava)
   ========================================================= */
html {
  hanging-punctuation: first last;
}

/* =========================================================
   Smooth scroll
   ========================================================= */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

/* =========================================================
   TOC overview block on index/landing page
   ========================================================= */
.toc-overview {
  background: transparent;
  border: none;
  padding: 0;
  margin: 1.25rem 0 2rem;
  max-width: 70ch;
}

/* Part headers */
.toc-overview .toc-part {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #4A5568;
  margin: 1.75rem 0 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.toc-overview .toc-part:first-child {
  margin-top: 0;
}

/* Each chapter row */
.toc-overview details.toc-chapter,
.toc-overview .toc-chapter-leaf {
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

/* Summary line (chapter title) */
.toc-overview details.toc-chapter > summary {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.97rem;
  color: #14213D;
  user-select: none;
}
.toc-overview details.toc-chapter > summary::-webkit-details-marker { display: none; }

/* Expand chevron */
.toc-overview details.toc-chapter > summary::after {
  content: "›";
  margin-left: auto;
  font-size: 1rem;
  color: #4A5568;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.toc-overview details.toc-chapter[open] > summary::after {
  transform: rotate(90deg);
}

/* Chapter number badge */
.toc-overview .toc-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: #4A5568;
  min-width: 1.6rem;
  flex-shrink: 0;
}

/* Chapter link inside summary */
.toc-overview details.toc-chapter > summary a {
  color: #14213D;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.12s;
}
.toc-overview details.toc-chapter > summary a:hover,
.toc-overview details.toc-chapter > summary:hover > a {
  color: #B08538;
}

/* Subchapter list */
.toc-overview details.toc-chapter > ul {
  margin: 0 0 0.6rem 2.1rem;
  padding: 0;
  list-style: none;
  max-width: none;
}
.toc-overview details.toc-chapter > ul li {
  margin: 0;
}
.toc-overview details.toc-chapter > ul li a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.88rem;
  color: #4A5568;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: color 0.12s, border-color 0.12s;
}
.toc-overview details.toc-chapter > ul li a:hover {
  color: #B08538;
  border-left-color: #B08538;
}

/* Leaf chapter (no subchapters, e.g. ch.16) */
.toc-overview .toc-chapter-leaf {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.45rem 0;
  font-size: 0.97rem;
  font-weight: 500;
}
.toc-overview .toc-chapter-leaf a {
  color: #14213D;
  text-decoration: none;
  transition: color 0.12s;
}
.toc-overview .toc-chapter-leaf a:hover {
  color: #B08538;
}

/* =========================================================
   Reduce motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  #reading-progress { transition: none; }
  html { scroll-behavior: auto !important; }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
