:root {
  --teal-950: #063e44;
  --teal-900: #07555d;
  --teal-800: #0c6971;
  --teal-100: #eaf5f4;
  --teal-50: #f4f9f8;
  --navy-950: #0b2638;
  --navy-800: #18394b;
  --slate-600: #61717a;
  --slate-500: #78878e;
  --line: #cfddda;
  --sand-200: #eadcc4;
  --sand-100: #f7f1e8;
  --gold: #bd8a3b;
  --white: #fff;
  --shadow: 0 18px 45px rgba(15, 53, 61, 0.08);
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 50% 6%, rgba(12, 105, 113, 0.055), transparent 30rem),
    #fbfcfc;
  color: var(--navy-950);
  font-family: var(--font);
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  min-height: 62px;
  display: grid;
  place-items: center;
  background: linear-gradient(110deg, var(--teal-900), var(--teal-950));
  color: var(--white);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 1.05rem;
  font-weight: 700;
}

.topbar__line {
  width: 46px;
  height: 2px;
  background: var(--gold);
}

.page-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 68px 0 80px;
}

.hero {
  text-align: center;
}

.hero__eyebrow {
  margin: 0 0 12px;
  color: var(--teal-800);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 1120px;
  margin: 0 auto;
  font-size: clamp(2rem, 3.8vw, 3.35rem);
  line-height: 1.28;
  letter-spacing: -0.035em;
  font-weight: 800;
}

.hero__subtitle {
  margin: 18px auto 36px;
  color: var(--slate-600);
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  line-height: 1.8;
}

.search {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 9px 8px 12px;
  border: 1px solid #bdd0cd;
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(15, 53, 61, 0.04);
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.search:focus-within {
  border-color: var(--teal-800);
  box-shadow: 0 0 0 4px rgba(12, 105, 113, 0.1), var(--shadow);
}

.search__icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--teal-900);
}

.search__icon svg,
.topic__icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search input {
  min-width: 0;
  height: 56px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--navy-950);
  font-size: 1.12rem;
}

.search input::placeholder {
  color: #7b898f;
  opacity: 1;
}

.search__clear {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--teal-50);
  color: var(--teal-900);
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
}

.search__submit {
  min-width: 146px;
  height: 58px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(110deg, var(--teal-900), var(--teal-800));
  color: var(--white);
  cursor: pointer;
  font-size: 1.13rem;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(7, 85, 93, 0.16);
  transition: transform 160ms ease-out, filter 160ms ease-out;
}

.search__submit:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
}

.topics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.topic {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #bfd5d2;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, var(--teal-50));
  color: var(--navy-950);
  cursor: pointer;
  font-size: 1.03rem;
  font-weight: 700;
  transition: transform 160ms ease-out, border-color 160ms ease-out, background 160ms ease-out;
}

.topic:hover,
.topic:focus-visible {
  transform: translateY(-2px);
  border-color: var(--teal-800);
  background: var(--teal-100);
}

.topic__icon {
  width: 37px;
  height: 37px;
  color: var(--teal-800);
  flex: 0 0 auto;
}

.results {
  margin-top: 58px;
  scroll-margin-top: 24px;
  animation: reveal 220ms ease-out both;
}

.results--message {
  width: min(720px, 100%);
  margin-inline: auto;
}

.topic-choices {
  padding: 26px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal-800);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.topic-choices h3 {
  margin: 0 0 16px;
  color: var(--navy-950);
  font-size: 1.2rem;
}

.topic-choices__list {
  display: grid;
  gap: 10px;
}

.topic-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  padding: 13px 16px;
  border: 1px solid #bfd0cd;
  border-radius: 11px;
  background: var(--teal-50);
  color: var(--navy-950);
  text-decoration: none;
  font-weight: 800;
  line-height: 1.65;
}

.topic-choice:hover,
.topic-choice:focus-visible {
  border-color: var(--teal-800);
  background: var(--teal-100);
}

.topic-choice__arrow {
  color: var(--teal-800);
  flex: 0 0 auto;
  font-size: 1.25rem;
}

.results__heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.results__label {
  margin-bottom: 4px;
  color: var(--teal-800);
  font-size: 0.88rem;
  font-weight: 800;
}

.results h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
}

.results__count {
  margin-bottom: 3px;
  color: var(--slate-600);
  font-size: 0.95rem;
}

.results__list {
  display: grid;
  gap: 18px;
}

.result-card {
  overflow: hidden;
  border: 1px solid #bfd0cd;
  border-top: 3px solid var(--teal-800);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.result-card__body {
  padding: 26px 30px 24px;
}

.result-card__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  color: var(--teal-800);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-card__tag::before {
  content: "";
  width: 3px;
  height: 18px;
  border-radius: 99px;
  background: var(--gold);
}

.result-card h3 {
  margin: 0 0 12px;
  color: var(--navy-950);
  font-size: clamp(1.24rem, 2.25vw, 1.65rem);
  line-height: 1.55;
}

.result-card__excerpt,
.result-card__fulltext {
  direction: rtl;
  unicode-bidi: plaintext;
  color: var(--navy-800);
  font-size: 1rem;
  line-height: 2;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: pre-line;
}

.bidi-number {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.result-card__excerpt {
  margin-bottom: 0;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #fff0b8;
  color: inherit;
}

.result-card__details {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e6ecea;
}

.result-card__details summary {
  width: fit-content;
  color: var(--teal-900);
  cursor: pointer;
  font-weight: 800;
}

.result-card__fulltext {
  max-height: 380px;
  overflow: auto;
  margin: 15px 0 0;
  padding: 16px;
  border-radius: 10px;
  background: #f7faf9;
  font-size: 0.93rem;
}

.result-card__reference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 30px;
  border-top: 1px solid var(--sand-200);
  background: var(--sand-100);
}

.reference-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--navy-950);
  font-size: 0.9rem;
  font-weight: 700;
}

.reference-list li {
  unicode-bidi: isolate;
}

.reference-key {
  color: var(--slate-600);
  font-weight: 700;
}

.reference-list li:not(:last-child)::after {
  content: "•";
  margin-inline-start: 14px;
  color: var(--gold);
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--teal-900);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.source-link:hover {
  text-decoration: underline;
}

.source-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state {
  padding: 38px 28px;
  border: 1px dashed #b8cbc8;
  border-radius: 16px;
  background: var(--white);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--slate-600);
  line-height: 1.8;
}

.footer {
  padding: 24px 20px 34px;
  border-top: 1px solid #e1e9e7;
  background: #f7f9f9;
  color: var(--slate-600);
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.8;
}

.footer p {
  margin-bottom: 2px;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(12, 105, 113, 0.28);
  outline-offset: 3px;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 54px;
  }

  .page-shell {
    width: min(100% - 28px, 660px);
    padding: 45px 0 58px;
  }

  h1 {
    font-size: clamp(1.85rem, 8vw, 2.6rem);
  }

  .hero__subtitle {
    margin-bottom: 26px;
  }

  .search {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 7px;
  }

  .search__icon {
    width: 32px;
    height: 32px;
  }

  .search input {
    height: 50px;
    font-size: 0.98rem;
  }

  .search__submit {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    height: 50px;
  }

  .topics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
  }

  .topic {
    min-height: 72px;
    gap: 9px;
    padding: 10px;
    font-size: 0.9rem;
  }

  .topic__icon {
    width: 29px;
    height: 29px;
  }

  .results {
    margin-top: 42px;
  }

  .topic-choices {
    padding: 18px;
  }

  .topic-choice {
    min-height: 62px;
    padding: 12px 14px;
    font-size: 0.94rem;
  }

  .results__heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .result-card__body {
    padding: 21px 20px;
  }

  .result-card__reference {
    align-items: start;
    flex-direction: column;
    padding: 16px 20px;
  }

  .reference-list li {
    width: 100%;
  }

  .reference-list li::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
