/* ==================================================
   الجريدة الرسمية: أعداد (Figma 242-42840)
   template-parts/gazette-issue.php, single-gazette-item.php
   Loaded on the gazette pages only (functions/gazette.php).
   ================================================== */

/* ---------- Issue selector bar (under the brown band) ---------- */

.gazette-bar {
  background-color: var(--neutrals-300);
  padding: 12px var(--padding-horizontal);
}

.gazette-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
}

.gazette-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gazette-select {
  height: 40px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--neutrals-600);
  border-radius: 4px;
  background-color: #fff;
  color: var(--primary-500);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  cursor: pointer;
}

.gazette-select:focus {
  outline: 2px solid var(--primary-200);
  outline-offset: 1px;
}

.gazette-select-issue {
  min-width: 240px;
}

/* ---------- The site's dropdown (js/gazette.js) over the selects ---------- */

.gazette-select.is-enhanced {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.gazette-dropdown {
  position: relative;
}

.gazette-dropdown-button {
  position: relative;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  margin: 0;
  /* room on the left for the arrow */
  padding: 0 14px 0 40px;
  border: 1px solid var(--neutrals-600);
  border-radius: 4px;
  background-color: #fff;
  color: var(--primary-500);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: 1.4;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.gazette-dropdown-for-year .gazette-dropdown-button {
  min-width: 110px;
}

.gazette-dropdown-for-issue .gazette-dropdown-button {
  min-width: 260px;
}

.gazette-dropdown-button:hover,
.gazette-dropdown.is-open .gazette-dropdown-button {
  border-color: var(--primary-200);
}

.gazette-dropdown-button:focus-visible {
  outline: 2px solid var(--primary-200);
  outline-offset: 1px;
}

.gazette-dropdown-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the arrow, 16px from the left edge */
.gazette-dropdown-arrow {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease, margin-top 0.2s ease;
}

.gazette-dropdown.is-open .gazette-dropdown-arrow {
  margin-top: -2px;
  transform: rotate(-135deg);
}

/* the list: always under the button, about 7 rows tall at most */
.gazette-dropdown-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  box-sizing: border-box;
  min-width: 100%;
  max-height: 284px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  background-color: #fff;
  border: 1px solid var(--neutrals-600);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(70, 17, 26, 0.12);
}

.gazette-dropdown-list[hidden] {
  display: none;
}


.gazette-dropdown-option {
  padding: 9px 12px;
  border-radius: 2px;
  color: var(--text-900);
  font-size: var(--font-size-sm);
  line-height: 22px;
  white-space: nowrap;
  cursor: pointer;
}

.gazette-dropdown-option:hover,
.gazette-dropdown-option.is-active {
  background-color: var(--primary-50);
  color: var(--primary-500);
}

.gazette-dropdown-option[aria-selected="true"] {
  background-color: var(--primary-500);
  color: var(--neutrals-50);
  font-weight: var(--font-weight-medium);
}

.gazette-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  /* the arrows (fill: currentColor) */
  color: var(--heading-color);
}

.gazette-nav.is-disabled svg path {
  fill: var(--neutrals-600);
}

/* ---------- Layout: فهرس العدد + content ---------- */

.gazette-page {
  padding: 48px var(--padding-horizontal) 96px;
}

.gazette-empty {
  margin: 0;
  color: var(--primary-500);
  font-size: var(--font-size-md);
  text-align: center;
}

.gazette-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

/* ---------- فهرس العدد (sticky) ---------- */

.gazette-toc {
  align-self: stretch;
}

.gazette-toc-inner {
  position: sticky;
  top: 140px;
  /* always fits the screen: the same space under it as above it (the 51px
     between the header and the list); longer lists scroll inside */
  /* border-box: padding and border count in that height */
  box-sizing: border-box;
  max-height: calc(100vh - 140px - 51px);
  max-height: calc(100dvh - 140px - 51px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  border: 1px solid var(--neutrals-500);
  background-color: var(--neutrals-100);
  /* the scrollbar on the right (in RTL it would be on the left): the box
     scrolls as LTR, its content stays RTL */
  direction: ltr;
  transition: top 0.35s ease, max-height 0.35s ease;
}

.gazette-toc-inner > * {
  direction: rtl;
}


/* scrolling up shows the header's menu bar again: the list moves down under
   it (and gets shorter by as much), back up when the menu hides */
body:has(.site-header.is-scrolled:not(.is-condensed)) .gazette-toc-inner {
  top: 200px;
  max-height: calc(100vh - 200px - 51px);
  max-height: calc(100dvh - 200px - 51px);
}

@media (prefers-reduced-motion: reduce) {
  .gazette-toc-inner {
    transition: none;
  }
}

.gazette-toc-title {
  margin: 0 0 16px;
  color: var(--heading-color);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

.gazette-toc-group + .gazette-toc-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--neutrals-500);
}

a.gazette-toc-section {
  display: block;
  margin-bottom: 8px;
  color: var(--primary-500);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

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

.gazette-toc-item a {
  position: relative;
  display: block;
  padding: 4px 16px 4px 0;
  color: var(--text-900);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  text-decoration: none;
}

.gazette-toc-item.is-child a {
  padding-right: 32px;
  font-size: var(--font-size-xs);
}

.gazette-toc-item a:hover {
  color: var(--primary-500);
  text-decoration: underline;
}

/* the section being read: arrow + bold */
.gazette-toc-item.is-current a {
  color: var(--primary-500);
  font-weight: var(--font-weight-bold);
}

.gazette-toc-item.is-current a::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 8px;
  height: 10px;
  transform: translateY(-50%);
  background-color: var(--primary-200);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

/* ---------- Sections and body cards ---------- */

.gazette-section {
  scroll-margin-top: 140px;
}

.gazette-section + .gazette-section {
  margin-top: 48px;
}

.gazette-card {
  scroll-margin-top: 140px;
  padding: 8px 24px;
  border: 1px solid var(--neutrals-500);
  background-color: var(--neutrals-100);
}

.gazette-card + .gazette-card {
  margin-top: 16px;
}

h3.gazette-card-title {
  margin: 0;
  padding: 16px 0;
  color: var(--heading-color);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

/* نصوص without a جهة: a card with no title */
.gazette-card.is-untitled .gazette-item:first-child {
  border-top: 0;
}

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

.gazette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--neutrals-500);
  scroll-margin-top: 140px;
}

.gazette-item-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gazette-item-ref {
  color: var(--primary-200);
  font-size: var(--font-size-sm);
  /* 400: no theme variable for it (regular is 300, medium 500) */
  font-weight: 400;
  text-decoration: none;
}

p.gazette-item-subject {
  margin: 0;
  color: var(--text-900);
  font-size: var(--font-size-md);
  /* 400: no theme variable for it (regular is 300, medium 500) */
  font-weight: 400;
  line-height: 1.6;
}

.gazette-item-date {
  color: var(--neutrals-900);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-regular);
}

.gazette-item-actions {
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.gazette-item-actions .archive-post-pdf-btn {
  padding: 10px 24px;
}

.gazette-item-actions .archive-post-pdf-btn-download {
  background-color: #fff;
}

/* Long cards: 5 نصوص, then "عرض الكل (N)" */
.gazette-card.is-collapsible:not(.is-expanded) .gazette-item.is-extra {
  display: none;
}

.gazette-show-all {
  display: block;
  margin: 0 auto;
  padding: 12px 0 16px;
  border: 0;
  background: none;
  color: var(--primary-500);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-decoration: underline;
  cursor: pointer;
}

.gazette-card.is-expanded .gazette-show-all {
  display: none;
}

/* ---------- One نص (single-gazette-item.php) ---------- */

.gazette-item-single {
  max-width: 860px;
}

h1.gazette-item-single-title {
  margin: 0 0 32px;
  color: var(--heading-color);
  font-size: var(--font-size-2xl);
  line-height: 1.5;
  font-weight: var(--font-weight-bold);
}

dl.gazette-item-details {
  margin: 0 0 32px;
  border-top: 1px solid var(--neutrals-500);
}

.gazette-item-detail {
  display: flex;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--neutrals-500);
}

.gazette-item-detail dt {
  flex: 0 0 140px;
  color: var(--primary-200);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.gazette-item-detail dd {
  margin: 0;
  color: var(--text-900);
  font-size: var(--font-size-sm);
}

.gazette-item-detail dd a {
  color: var(--primary-500);
}

.gazette-item-single .gazette-item-actions {
  justify-content: flex-start;
}

a.gazette-back {
  display: inline-block;
  margin-top: 32px;
  color: var(--primary-500);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* ---------- Narrow screens (full mobile pass later) ---------- */

@media (max-width: 1000px) {
  .gazette-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .gazette-toc-inner {
    position: static;
    max-height: none;
  }

  .gazette-item {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- Scrollbars of the فهرس and the dropdown lists ----------
   Thin (4px), brown, no up/down arrows. Chrome, Edge and Safari: the
   ::-webkit-scrollbar rules (they stop working as soon as the standard
   scrollbar-width / -color are set, so those are for Firefox only). */

.gazette-toc-inner::-webkit-scrollbar,
.gazette-dropdown-list::-webkit-scrollbar {
  width: 4px;
}

.gazette-toc-inner::-webkit-scrollbar-button,
.gazette-dropdown-list::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.gazette-toc-inner::-webkit-scrollbar-track,
.gazette-dropdown-list::-webkit-scrollbar-track {
  background: transparent;
}

.gazette-toc-inner::-webkit-scrollbar-thumb,
.gazette-dropdown-list::-webkit-scrollbar-thumb {
  border-radius: 2px;
  background-color: var(--primary-100);
}

.gazette-toc-inner::-webkit-scrollbar-thumb:hover,
.gazette-dropdown-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--primary-200);
}

@supports not selector(::-webkit-scrollbar) {
  .gazette-toc-inner,
  .gazette-dropdown-list {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-100) transparent;
  }
}
