/* ==========================================================================
   materials.css — "تصفّح المواد" section on the home page (.mat, .mtabs)
   and the reusable material card (.mcard) + card grid (.mgrid), which the
   arabic page list uses as well.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card grid — 3 / 2 / 1 columns, fades in when its content changes
   -------------------------------------------------------------------------- */
.mgrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

@media (min-width: 760px) {
  .mgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .mgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   Material card
   -------------------------------------------------------------------------- */
.mcard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  background: var(--color-white);
  border: 1px solid var(--color-blue-line);
  border-radius: 16px;
  transition: border-color .2s ease, background-color .25s ease, box-shadow .3s ease;
}

/* hover: the card stands out — light blue tint, a soft shadow under it and a
   bluer edge; colour and shadow only, no lift (the site's rule) */
.mcard:hover {
  background: var(--color-sky-50);
  border-color: var(--color-blue-300);
  box-shadow: 0 22px 40px -24px rgba(26, 43, 69, .45);
}

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

/* Cover + text */
.mcard__body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.mcard__cover {
  flex: none;
  display: flex;
}

.mcard__img {
  display: block;
  height: 136px;
  width: auto;
  max-width: 100%;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 10px 20px -12px rgba(26, 43, 69, 0.55), 0 0 0 1px rgba(26, 43, 69, 0.06);
}

.mcard__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.mcard__title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 18px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mcard__title a {
  color: var(--color-navy-700);
  text-decoration: none;
}

.mcard__author {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-blue-500);
}

.mcard__author svg {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  fill: none;
  stroke: var(--color-blue-500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mcard__author-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mcard__desc {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-ink-600);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer bar: details link + QR / share buttons */
.mcard__foot {
  margin: auto -16px -16px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-cream-200);
  border-top: 1px solid var(--color-blue-line);
  border-radius: 0 0 15px 15px;
}

.mcard__link,
.mcard__icon {
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
}

.mcard__link svg,
.mcard__icon svg {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .2s ease;
}

.mcard__link {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 40px;
  box-sizing: border-box;
  padding: 0 14px;
  margin-inline-start: 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-blue-500);
  text-decoration: none;
}

.mcard__link svg {
  stroke: currentColor;
}

.mcard__actions {
  display: flex;
  gap: 4px;
}

.mcard__icon {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
}

.mcard__icon svg {
  stroke: var(--color-navy-700);
}

.mcard__link:hover,
.mcard__icon:hover {
  background: var(--color-blue-500);
  border-color: var(--color-blue-500);
  color: var(--color-white);
}

.mcard__link:hover svg,
.mcard__icon:hover svg {
  stroke: var(--color-white);
}

.mcard__link:focus-visible,
.mcard__icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(59, 117, 150, .25);
}

/* Card — small screens */
@media (max-width: 640px) {
  .mcard__link {
    font-size: 14px;
    padding: 0 8px;
  }
}

@media (max-width: 400px) {
  .mcard {
    padding: 14px;
    gap: 12px;
  }

  .mcard__body {
    gap: 12px;
  }

  .mcard__img {
    height: 112px;
  }

  .mcard__foot {
    margin: auto -14px -14px;
    padding: 10px;
  }

  .mcard__icon {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 350px) {
  .mcard__link {
    font-size: 13px;
    gap: 4px;
  }

  .mcard__icon {
    width: 34px;
    height: 34px;
  }

  .mcard__title {
    font-size: 16px;
  }

  .mcard__desc {
    font-size: 14px;
  }
}

/* --------------------------------------------------------------------------
   Home section "تصفّح المواد"
   -------------------------------------------------------------------------- */
.mat {
  background: var(--color-mist-100);
  padding: 80px 24px;
}

@media (max-width: 900px) {
  .mat {
    padding-top: 88px;
    padding-bottom: 88px;
  }
}

@media (max-width: 640px) {
  .mat {
    padding-top: 72px;
    padding-bottom: 72px;
  }
}

@media (max-width: 400px) {
  .mat {
    padding-left: 12px;
    padding-right: 12px;
  }
}

.mat__wrap {
  max-width: var(--cww, 1320px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.mat__head {
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  text-align: center;
}

.mat__title {
  margin: 0;
  font-family: 'Almarai', 'Cairo', sans-serif;
  font-weight: 800;
  font-size: var(--fs-section-title);
  line-height: 1.2;
  color: var(--color-navy-700);
}

.mat__title-accent {
  color: var(--color-blue-500);
}

.mat__shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mat__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 24px;
}

@media (max-width: 760px) {
  .mat__bar {
    flex-direction: column;
    align-items: stretch;
  }
}

.mat__inner {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* "Browse all" button under the grid */
.mat__more {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10px;
}

.mat__more-link {
  display: inline-flex;
  white-space: nowrap;
  gap: 8px;
  align-items: center;
  height: 44px;
  box-sizing: border-box;
  padding: 0 12px 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--color-blue-500);
  background: transparent;
  color: var(--color-blue-500);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mat__more-link svg {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mat__more-link:hover {
  background: var(--color-blue-500);
  border-color: var(--color-blue-500);
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   Type tabs — a pill bar on every screen (at ≤760px across the width, the
   tabs sharing it; their icons go where they no longer fit, ≤520px)
   -------------------------------------------------------------------------- */
.mtabs {
  --tpx: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 5px;
  background: var(--color-white);
  border: 1px solid var(--color-line);
  border-radius: 999px;
}

.mtabs__tab {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-navy-700);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}

.mtabs__tab svg {
  flex: none;
  fill: none;
  stroke: var(--color-blue-500);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mtabs__tab:hover {
  background: var(--color-blue-100);
  color: var(--color-blue-500);
}

.mtabs__tab[aria-selected="true"] {
  background: var(--color-blue-500);
  color: var(--color-white);
  border-color: var(--color-blue-500);
}

.mtabs__tab[aria-selected="true"] svg {
  stroke: var(--color-white);
}

/* Phones & small tablets: the same bar, across the width (at most 560px):
   equal tabs, except one whose label needs more (never cut) */
@media (max-width: 760px) {
  .mtabs {
    --tpx: 14px;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 560px;
    margin-inline: auto;
    box-sizing: border-box;
    padding: 4px;
  }

  .mtabs__tab {
    flex: 1 1 0;
    min-width: max-content;
    justify-content: center;
    gap: 6px;
    padding: 0 var(--tpx);
  }
}

@media (max-width: 520px) {
  .mtabs {
    --tpx: 10px;
  }

  .mtabs__tab {
    gap: 0;
  }

  .mtabs__tab svg {
    display: none;
  }
}

@media (max-width: 400px) {
  .mtabs {
    --tpx: 6px;
  }
}

@media (max-width: 360px) {
  .mtabs {
    --tpx: 4px;
    padding: 3px;
  }

  .mtabs__tab {
    font-size: 13.5px;
  }
}
