/* ==========================================================================
   DYSFÁZKA — UX ENHANCEMENTS LAYER
   Search modal, TOC, reading progress, related articles, themes
   ========================================================================== */

/* ---------- COLOR PALETTE ----------
   Bold, saturated, no muted tones.
   Pear (#CBD83B), Indigo (#A88AED), Ivory (#FFFEEC).
*/
:root {
  /* Backgrounds */
  --bg: #FFFEEC;
  --bg-soft: #FFFEEC;
  --bg-card: #FFFFFF;
  --bg-deep: #2A2540;

  /* Text — strong, dark, full contrast */
  --text: #1A1530;
  --text-muted: #3D3658;
  --text-soft: #6B6485;

  /* Primary — Indigo (full saturation) */
  --accent: #A88AED;
  --accent-hover: #8E6DD9;
  --accent-soft: #A88AED;

  /* Secondary — Pear (full saturation) */
  --teal: #CBD83B;
  --teal-soft: #CBD83B;

  /* Tertiary */
  --sage: #A88AED;
  --sage-soft: #A88AED;

  /* Lines — solid, defined, not faint */
  --line: #1A1530;
  --line-soft: #2A2540;

  --shadow-accent: 0 6px 0 0 #1A1530;
}


/* ==========================================================================
   READING PROGRESS BAR (top of viewport)
   ========================================================================== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width 80ms linear;
  pointer-events: none;
}


/* ==========================================================================
   SEARCH MODAL (Cmd/Ctrl + K)
   ========================================================================== */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
  margin-right: 8px;
}

.search-trigger:hover {
  border-color: var(--accent);
  color: var(--text);
}

.search-trigger kbd {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-family: inherit;
  color: var(--text-muted);
}

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 42, 56, 0.5);
  backdrop-filter: blur(8px);
  z-index: 9998;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn 0.15s ease;
}

.search-overlay.is-open {
  display: flex;
}

.search-modal {
  width: 92%;
  max-width: 640px;
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: searchIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes searchIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

.search-input {
  width: 100%;
  padding: 18px 20px;
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-soft);
}

.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
}

.search-result {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}

.search-result:hover,
.search-result.is-active {
  background: var(--bg-soft);
}

.search-result-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  margin: 0 0 2px;
}

.search-result-cat {
  font-size: 0.76rem;
  color: var(--accent);
  margin: 0;
}

.search-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.search-footer {
  padding: 10px 16px;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--text-soft);
  display: flex;
  gap: 16px;
}

.search-footer kbd {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: inherit;
}


/* ==========================================================================
   (Theme switcher removed — single palette: Pear + Indigo + Ivory)
   ========================================================================== */


/* ==========================================================================
   TABLE OF CONTENTS (sticky sidebar on long pages)
   ========================================================================== */
.toc-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
}

@media (min-width: 1100px) {
  .toc-wrapper.has-toc {
    grid-template-columns: 1fr 240px;
  }
}

.toc {
  display: none;
}

@media (min-width: 1100px) {
  .toc {
    display: block;
    position: sticky;
    top: 100px;
    align-self: start;
    font-size: 0.85rem;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 1.25rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
}

.toc-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  padding: 4px 0;
}

.toc a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  padding: 4px 8px;
  border-left: 2px solid transparent;
  margin-left: -8px;
  transition: all 0.15s;
  line-height: 1.4;
}

.toc a:hover {
  color: var(--accent);
}

.toc a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}

.toc li.toc-h3 a {
  padding-left: 18px;
  font-size: 0.8rem;
}


/* ==========================================================================
   RELATED ARTICLES SECTION
   ========================================================================== */
.related-section {
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--line);
}

.related-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  font-style: italic;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.related-card {
  display: block;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.related-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.related-card-cat {
  font-size: 0.74rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.related-card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}


/* ==========================================================================
   FEEDBACK WIDGET (was this helpful?)
   ========================================================================== */
.feedback-widget {
  margin: 3rem 0 0;
  padding: 1.5rem;
  background: var(--bg-soft);
  border-radius: var(--radius);
  text-align: center;
}

.feedback-question {
  font-size: 0.95rem;
  margin: 0 0 1rem;
  color: var(--text);
}

.feedback-btns {
  display: inline-flex;
  gap: 0.75rem;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.feedback-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.feedback-btn.is-selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.feedback-thanks {
  display: none;
  font-size: 0.92rem;
  color: var(--accent);
  font-style: italic;
}

.feedback-widget.is-thanked .feedback-btns { display: none; }
.feedback-widget.is-thanked .feedback-thanks { display: block; }


/* ==========================================================================
   "STARTING HERE" BANNER (sticky helper for new visitors)
   ========================================================================== */
.starter-banner {
  background: var(--teal);
  border-bottom: 1px solid var(--line);
  padding: 10px 1rem;
  text-align: center;
  font-size: 0.88rem;
  position: relative;
  display: none;
}

.starter-banner.is-visible {
  display: block;
}

.starter-banner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.starter-banner a:hover {
  text-decoration: underline;
}

.starter-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-soft);
  padding: 4px 8px;
  border-radius: 4px;
}

.starter-close:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}


/* ==========================================================================
   PRINT-FRIENDLY
   ========================================================================== */
@media print {
  .topbar, .header, .footer, .nav, .reading-progress, .toc, .related-section,
  .feedback-widget, .search-trigger, .starter-banner, .theme-switcher,
  .menu-toggle, .nav-cta, .cta-band {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .container, .container-narrow, .container-wide {
    max-width: 100%;
    padding: 0;
  }

  .section {
    padding: 1rem 0;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  p, li {
    page-break-inside: avoid;
  }
}


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


/* ==========================================================================
   FOCUS STYLES — accessible
   ========================================================================== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}


/* ==========================================================================
   TYPOGRAPHY POLISH for article prose
   ========================================================================== */
.prose {
  line-height: 1.75;
  font-size: 1.02rem;
}

.prose p {
  margin-bottom: 1.1em;
}

.prose h2 {
  margin-top: 2.5em;
  margin-bottom: 0.8em;
}

.prose h3, .prose h4, .prose h5 {
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin: 1em 0 1.5em;
}

.prose li {
  margin-bottom: 0.6em;
  line-height: 1.7;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }


/* ==========================================================================
   MOBILE: improve tap targets and search trigger
   ========================================================================== */
@media (max-width: 900px) {
  .search-trigger {
    padding: 6px 10px;
  }
  .search-trigger-label {
    display: none;
  }
  .search-trigger kbd {
    display: none;
  }
  .theme-switcher {
    display: none;
  }
}
