/*
Theme Name: Khepri Society Fixed
Theme URI: https://kheprisociety.com/
Author: Khepri Society
Description: A lightweight RTL-first editorial block theme for Khepri Society, with automated latest story, most-read articles, and YouTube video sections.
Version: 1.1.3
Requires at least: 6.5
Requires PHP: 7.4
Text Domain: khepri-society
*/

:root {
  --khepri-teal: #003c34;
  --khepri-teal-deep: #033d35;
  --khepri-gold: #c99544;
  --khepri-ink: #102a32;
  --khepri-warm-white: #faf9f5;
  --khepri-border: #d9dfdd;
  --khepri-muted: #667773;
  --khepri-shadow: 0 12px 34px rgba(0, 60, 52, 0.08);
  --khepri-radius: 2px;
}

html { scroll-behavior: smooth; }
body {
  direction: rtl;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body,
button,
input,
select,
textarea {
  font-family: "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

a { transition: opacity .2s ease, color .2s ease, border-color .2s ease; }
a:hover { opacity: .82; }

/* Header */
.khepri-topbar {
  direction: ltr;
  min-height: 146px;
}
.khepri-topbar > .wp-block-group__inner-container,
.khepri-topbar.wp-block-group {
  align-items: center;
}
.khepri-wordmark {
  direction: ltr;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.khepri-logo-block img { display: block; height: auto; }

.khepri-nav-shell {
  background: var(--khepri-teal);
  color: #fff;
  min-height: 48px;
}
.khepri-nav-inner {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.khepri-primary-nav { flex: 1 1 auto; }
.khepri-primary-nav .wp-block-navigation__container {
  width: 100%;
  justify-content: space-between;
  gap: clamp(16px, 2.4vw, 42px);
}
.khepri-primary-nav a {
  color: #fff !important;
  font-weight: 500;
  font-size: 15.5px;
  text-decoration: none;
  white-space: nowrap;
}
.khepri-primary-nav .wp-block-navigation-item__content:hover { color: var(--khepri-gold) !important; }

.khepri-nav-search {
  direction: ltr;
  width: 150px;
  flex: 0 0 150px;
}
.khepri-nav-search .wp-block-search__inside-wrapper {
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: #fff;
  overflow: hidden;
}
.khepri-nav-search input {
  border: 0 !important;
  min-width: 0;
  padding: 4px 8px !important;
  font-size: 13px;
}
.khepri-nav-search button {
  padding: 5px 8px !important;
  color: var(--khepri-ink) !important;
  background: #fff !important;
}

/* Shared layout */
.khepri-main {
  padding-top: clamp(38px, 4.2vw, 64px);
  padding-bottom: clamp(52px, 6vw, 88px);
}
.khepri-section {
  margin-block: clamp(46px, 5vw, 72px);
}
.khepri-section-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
}
.khepri-section-heading-row::before {
  content: "";
  width: 10px;
  height: 31px;
  flex: 0 0 10px;
  background: var(--khepri-teal);
}
.khepri-section-heading {
  margin: 0;
  color: var(--khepri-teal);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 600;
  line-height: 1.35;
}
.khepri-more-row {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
}
.khepri-more-row::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--khepri-teal);
}
.khepri-more-button,
.khepri-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 38px;
  padding: 5px 18px 7px;
  border: 2px solid var(--khepri-teal);
  border-radius: 5px;
  color: var(--khepri-teal);
  background: #fff;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
}
.khepri-more-button:hover,
.khepri-button:hover {
  opacity: 1;
  color: #fff;
  background: var(--khepri-teal);
}

/* Latest hero */
.khepri-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) minmax(300px, .9fr);
  gap: clamp(30px, 3.2vw, 50px);
  align-items: stretch;
  direction: ltr;
}
.khepri-hero-media {
  min-height: 430px;
  position: relative;
  overflow: hidden;
  background: #e9eeec;
  box-shadow: var(--khepri-shadow);
}
.khepri-hero-media img {
  width: 100%;
  height: 100%;
  min-height: 430px;
  object-fit: cover;
  display: block;
}
.khepri-hero-overlay {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 28px 30px;
  background: linear-gradient(to top, rgba(0, 49, 43, .86), rgba(0, 49, 43, .64), transparent);
  color: #fff;
  direction: rtl;
  text-align: right;
}
.khepri-hero-title {
  margin: 0;
  font-size: clamp(24px, 2.5vw, 38px);
  font-weight: 700;
  line-height: 1.35;
}
.khepri-hero-title,
.khepri-hero-title a,
.khepri-hero-title a:link,
.khepri-hero-title a:visited,
.khepri-hero-title a:hover,
.khepri-hero-title a:focus {
  color: #fff !important;
}
.khepri-hero-title a { text-decoration: none; }

.khepri-hero-copy {
  direction: rtl;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: right;
}
.khepri-hero-kicker {
  margin: 0 0 8px;
  color: var(--khepri-gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}
.khepri-hero-excerpt {
  margin: 0 0 26px;
  color: var(--khepri-ink);
  font-size: clamp(16px, 1.45vw, 19px);
  line-height: 2;
}

/* Article cards */
.khepri-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 36px 26px;
}
.khepri-card { min-width: 0; }
.khepri-card-image {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #edf1ef;
}
.khepri-card-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .3s ease;
}
.khepri-card:hover .khepri-card-image img { transform: scale(1.025); }
.khepri-card-title {
  margin: 11px 0 0;
  color: var(--khepri-ink);
  font-size: clamp(15px, 1.35vw, 18px);
  font-weight: 600;
  line-height: 1.65;
  text-align: right;
}
.khepri-card-title a { color: inherit; text-decoration: none; }
.khepri-card-meta {
  margin-top: 5px;
  color: var(--khepri-muted);
  font-size: 12px;
}

/* Videos */
.khepri-video-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px 24px;
}
.khepri-video-thumb {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #0f2528;
}
.khepri-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease;
}
.khepri-video-thumb iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.khepri-video-card:not(.is-playing):hover img { transform: scale(1.03); }
.khepri-video-card.is-playing .khepri-video-thumb { background: #000; }
.khepri-play {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 68px;
  height: 68px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 50%;
  background: rgba(0,0,0,.34);
  display: grid;
  place-items: center;
}
.khepri-play::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 5px;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 20px solid #fff;
}
.khepri-video-title {
  margin: 11px 0 0;
  color: var(--khepri-ink);
  font-size: clamp(15px, 1.35vw, 18px);
  font-weight: 600;
  line-height: 1.65;
}
.khepri-video-title a { color: inherit; text-decoration: none; }

/* Empty/editor states */
.khepri-empty {
  padding: 28px;
  border: 1px dashed var(--khepri-border);
  background: var(--khepri-warm-white);
  color: var(--khepri-muted);
  text-align: center;
}

/* Footer */
.khepri-footer {
  margin-top: 0;
  padding-block: 64px;
  background: var(--khepri-teal-deep);
  color: #fff;
}
.khepri-footer-inner {
  direction: ltr;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 54px;
}
.khepri-footer-brand { justify-self: start; }
.khepri-footer-copy {
  direction: rtl;
  justify-self: end;
  text-align: right;
}
.khepri-footer-copy p {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 600;
}
.khepri-footer .wp-social-link { background: transparent !important; }
.khepri-footer .wp-social-link a { color: #fff !important; }
.khepri-footer .wp-social-link:hover a { color: var(--khepri-gold) !important; }

/* Single article */
.khepri-single-header { margin-bottom: 32px; }
.khepri-single-title {
  max-width: 920px;
  margin-inline: auto;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.3;
  text-align: center;
}
.khepri-single-meta {
  text-align: center;
  color: var(--khepri-muted);
}
.khepri-single-featured img { width: 100%; max-height: 660px; object-fit: cover; }
.khepri-article-content {
  font-size: 18px;
  line-height: 2;
}
.khepri-article-content p { margin-block: 0 1.4em; }

/* Archive / query loop */
.khepri-archive-title {
  margin-bottom: 36px;
  color: var(--khepri-teal);
  font-size: clamp(32px, 5vw, 54px);
}
.khepri-query-grid.wp-block-post-template {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 36px 26px;
}
.khepri-query-grid .wp-block-post-featured-image { margin-bottom: 12px; }
.khepri-query-grid .wp-block-post-featured-image img { aspect-ratio: 4/3; object-fit: cover; }
.khepri-query-grid .wp-block-post-title { font-size: 20px; line-height: 1.55; }

/* v1.1 proportional refinements based on the approved homepage mock-up */
.khepri-topbar.alignwide,
.khepri-nav-inner.alignwide,
.khepri-main > .wp-block-group.alignwide,
.khepri-footer-inner.alignwide {
  width: min(92vw, 1500px);
  max-width: none;
  margin-inline: auto;
}
.khepri-main > .wp-block-group.alignwide {
  box-sizing: border-box;
}
.khepri-empty {
  min-height: 76px;
  display: grid;
  place-items: center;
  font-size: 15px;
}
.khepri-hero > .khepri-empty {
  min-height: 118px;
}
.khepri-section-heading-row {
  border-top: 1px solid var(--khepri-teal);
  padding-top: 18px;
}
.khepri-hero + .khepri-section .khepri-section-heading-row {
  margin-top: 8px;
}

@media (max-width: 1000px) {
  .khepri-nav-inner { gap: 16px; }
  .khepri-nav-search { display: none; }
  .khepri-hero { grid-template-columns: minmax(0, 1.45fr) minmax(250px, .8fr); }
  .khepri-card-grid,
  .khepri-video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .khepri-topbar { min-height: 94px; }
  .khepri-wordmark { font-size: 14px; }
  .khepri-nav-shell { min-height: 48px; }
  .khepri-nav-inner { min-height: 48px; justify-content: flex-end; }
  .khepri-primary-nav { flex: 0 0 auto; }
  .khepri-primary-nav .wp-block-navigation__responsive-container-open { color: #fff; }
  .khepri-primary-nav .wp-block-navigation__responsive-container.is-menu-open {
    padding: 28px;
    background: var(--khepri-teal);
    color: #fff;
  }
  .khepri-primary-nav .wp-block-navigation__responsive-container-content,
  .khepri-primary-nav .wp-block-navigation__container { align-items: stretch; }
  .khepri-hero {
    grid-template-columns: 1fr;
    gap: 24px;
    direction: rtl;
  }
  .khepri-hero-media,
  .khepri-hero-media img { min-height: 300px; }
  .khepri-hero-copy { align-items: stretch; }
  .khepri-hero-excerpt { font-size: 16px; }
  .khepri-button { align-self: flex-start; }
  .khepri-card-grid,
  .khepri-video-grid { gap: 28px 14px; }
  .khepri-footer-inner { grid-template-columns: 1fr; text-align: center; }
  .khepri-footer-brand,
  .khepri-footer-copy { justify-self: center; }
  .khepri-footer-copy { text-align: center; }
  .khepri-footer .wp-block-social-links { justify-content: center; }
  .khepri-query-grid.wp-block-post-template { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 480px) {
  .khepri-main { padding-top: 24px; }
  .khepri-card-grid,
  .khepri-video-grid { grid-template-columns: 1fr 1fr; }
  .khepri-card-title,
  .khepri-video-title { font-size: 14px; }
  .khepri-play { width: 54px; height: 54px; }
  .khepri-query-grid.wp-block-post-template { grid-template-columns: 1fr; }
}
