/* ===== The user guide on both theme pages =====
   renderUserGuide (views/public/components/themeDetailParts.js) and
   public/js/theme-guide.js: search, the contents list, the other-language link,
   a chapter's lead, links to a row, pictures that open in the picture viewer.
   The rows themselves are styled in website.min.css (.theme-accordion).
   Logical properties throughout, so the English page mirrors the Arabic one. */

.theme-guide-tools {
  display: grid;
  gap: 10px;
  margin: 4px 0 28px;
}
.theme-guide-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

/* ---- search ---- */
.theme-guide-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 0;
  margin: 0;
}
.theme-guide-search svg {
  position: absolute;
  inset-inline-start: 14px;
  color: var(--gray-400);
  pointer-events: none;
  transition: color 0.2s ease;
}
.theme-guide-search input {
  width: 100%;
  min-width: 0;
  height: 46px;
  margin: 0;
  padding-block: 0;
  padding-inline: 42px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  font-family: var(--font);
  font-size: 16px; /* 16px: a phone does not zoom into the field */
  color: var(--dark);
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.theme-guide-search input::placeholder {
  color: var(--gray-400);
  opacity: 1;
}
.theme-guide-search input:hover {
  border-color: var(--gray-300);
}
.theme-guide-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.theme-guide-search:focus-within svg {
  color: var(--primary);
}
.theme-guide-search input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* ---- the other language ---- */
.theme-guide-otherlang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 50px;
  background: var(--primary-50);
  color: var(--primary-dark);
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.theme-guide-otherlang svg {
  flex: none;
}
.theme-guide-otherlang:hover,
.theme-guide-otherlang:focus-visible {
  background: var(--primary);
  color: var(--white);
  outline: none;
}

/* ---- contents ---- */
.theme-guide-toc {
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  transition: box-shadow 0.2s ease;
}
.theme-guide-toc:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.theme-guide-toc > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
  list-style: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.theme-guide-toc > summary::-webkit-details-marker {
  display: none;
}
.theme-guide-toc > summary > svg:first-child {
  flex: none;
  color: var(--primary);
}
.theme-guide-toc > summary:hover,
.theme-guide-toc > summary:focus-visible {
  background: var(--gray-50);
  color: var(--primary);
  outline: none;
}
.theme-guide-chev {
  flex: none;
  margin-inline-start: auto;
  color: var(--gray-400);
  transition: transform 0.25s ease;
}
.theme-guide-toc[open] > summary {
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  border-block-end: 1px solid var(--gray-100);
}
.theme-guide-toc[open] .theme-guide-chev {
  transform: rotate(180deg);
}
.theme-guide-toc nav {
  max-height: min(60vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 16px 14px;
}
.theme-guide-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.theme-guide-toc nav > ol {
  columns: 2 240px;
  column-gap: 32px;
}
.theme-guide-toc nav > ol > li {
  padding-block: 4px 10px;
}
.theme-guide-toc nav > ol > li > a {
  display: block;
  padding-block: 4px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--dark);
  break-after: avoid;
  transition: color 0.2s ease;
}
.theme-guide-toc li li {
  break-inside: avoid;
}
.theme-guide-toc li li a {
  display: block;
  padding-block: 3px;
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--gray-100);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--dark-500);
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}
.theme-guide-toc a:hover,
.theme-guide-toc a:focus-visible {
  color: var(--primary);
  border-color: var(--primary);
  outline: none;
}

/* ---- nothing found ---- */
.theme-guide-empty {
  margin: 0;
  padding: 18px 16px;
  border: 1px dashed var(--gray-300);
  border-radius: 12px;
  background: var(--white);
  color: var(--dark-500);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.theme-guide-empty:empty {
  display: none;
}
.theme-guide .theme-guide-section[hidden],
.theme-guide .theme-accordion[hidden] {
  display: none !important;
}

/* ---- a chapter's lead, under its title ---- */
.theme-guide-lead {
  margin: -4px 0 16px;
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--dark-500);
  overflow-wrap: anywhere;
}
.theme-guide-lead p {
  margin: 0 0 8px;
}
.theme-guide-lead > :last-child,
.theme-guide-lead > :last-child > :last-child {
  margin-bottom: 0;
}
.theme-guide-lead ul,
.theme-guide-lead ol {
  margin: 8px 0;
  padding-inline-start: 20px;
}
.theme-guide-lead img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* ---- rows: links to a row land under the bars; long words wrap ---- */
.theme-guide .theme-guide-section,
.theme-guide .theme-accordion {
  scroll-margin-top: 100px;
}
.md-page .theme-guide .theme-guide-section,
.md-page .theme-guide .theme-accordion {
  scroll-margin-top: calc(var(--md-header-h, 84px) + 76px);
}
.theme-guide .theme-accordion-body-inner {
  overflow-wrap: anywhere;
}
/* A closed row's body is out of the tab order and out of reach of a screen
   reader (max-height: 0 only clips it): hidden once it has finished closing,
   shown as soon as it starts opening, so both animations stay as they are. */
.theme-guide .theme-accordion-body {
  visibility: hidden;
  transition:
    max-height 0.35s ease,
    visibility 0s linear 0.35s;
}
.theme-guide .theme-accordion.open .theme-accordion-body {
  visibility: visible;
  transition-delay: 0s;
}
/* The chapter title a followed link moves the keyboard to (tabindex -1) */
.theme-guide .theme-guide-section-title:focus {
  outline: none;
}

/* ---- pictures for one kind of screen (the build marks them): a picture of
   the hover menu is no use on a phone, a phone-only one none on a computer ---- */
@media (max-width: 600px) {
  .theme-guide [data-guide-desktop-only] {
    display: none !important;
  }
}
@media not all and (max-width: 600px) {
  .theme-guide [data-guide-phone-only] {
    display: none !important;
  }
}
.theme-guide .theme-accordion-body-inner a,
.theme-guide-lead a {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 3px;
  transition:
    color 0.2s ease,
    text-decoration-color 0.2s ease;
}
.theme-guide .theme-accordion-body-inner a:hover,
.theme-guide .theme-accordion-body-inner a:focus-visible,
.theme-guide-lead a:hover,
.theme-guide-lead a:focus-visible {
  color: var(--primary);
  text-decoration-color: currentColor;
  outline: none;
}

/* ---- pictures open in the picture viewer ---- */
.theme-guide .theme-accordion-body-inner img,
.theme-guide-lead img,
.theme-guide-section-img img {
  cursor: zoom-in;
  transition:
    box-shadow 0.25s ease,
    opacity 0.25s ease;
}
.theme-guide .theme-accordion-body-inner img:hover,
.theme-guide-lead img:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
}
.theme-guide-section-img img:hover {
  opacity: 0.94;
}
.theme-guide a img {
  cursor: pointer;
}

/* ---- no ring on a click or a tap; keyboard focus shows the hover state ---- */
.theme-guide a:focus:not(:focus-visible),
.theme-guide button:focus:not(:focus-visible),
.theme-guide summary:focus:not(:focus-visible),
.tlb-overlay button:focus:not(:focus-visible) {
  outline: none;
}
.theme-guide .theme-accordion-title:focus {
  outline: none;
}
.theme-guide .theme-accordion-title:focus-visible {
  background: var(--gray-50);
  color: var(--primary);
}
.tlb-overlay button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.22);
}

@media (max-width: 480px) {
  .theme-guide-otherlang {
    min-height: 42px;
    padding: 0 14px;
    font-size: 14px;
  }
  .theme-guide-toc nav {
    padding: 8px 14px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-guide-search svg,
  .theme-guide-search input,
  .theme-guide-otherlang,
  .theme-guide-toc,
  .theme-guide-toc > summary,
  .theme-guide-chev,
  .theme-guide-toc a,
  .theme-guide .theme-accordion-body-inner img,
  .theme-guide-lead img,
  .theme-guide-section-img img {
    transition: none;
  }
}
