/*
 * السطح — مدخل منصات الهجده.
 * لوحان: «حبر» داكن (الافتراضي) و«ورق» فاتح، يشتركان في نفس المتغيّرات.
 */

.sath-body {
  --ink: #08080a;
  --ink-raise: rgba(244, 239, 228, 0.035);
  --ink-raise-hover: rgba(244, 239, 228, 0.062);
  --text: #f1ece1;
  --text-soft: #cdc6b8;
  --muted: #8d8981;
  --gold: #b39359;
  --gold-lite: #dcc28c;
  --line: rgba(244, 239, 228, 0.1);
  --line-soft: rgba(244, 239, 228, 0.075);
  --lamp: rgba(179, 147, 89, 0.15);
  --vignette: rgba(0, 0, 0, 0.42);
  --panel: #0e0e11;
  --scrim: rgba(4, 4, 6, 0.72);
  --shadow: 0 34px 90px rgba(0, 0, 0, 0.6);
  --tile-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  --grain: 0.5;

  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Tajawal", system-ui, sans-serif;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s ease, color 0.5s ease;
}

[data-theme="paper"] .sath-body {
  --ink: #efe9dc;
  --ink-raise: rgba(255, 255, 255, 0.66);
  --ink-raise-hover: #fffdf8;
  --text: #22201b;
  --text-soft: #45413a;
  --muted: #6d675c;
  --gold: #8a6c39;
  --gold-lite: #a37f3d;
  --line: rgba(34, 32, 27, 0.14);
  --line-soft: rgba(34, 32, 27, 0.085);
  --lamp: rgba(179, 147, 89, 0.26);
  --vignette: rgba(120, 100, 66, 0.14);
  --panel: #fbf7ef;
  --scrim: rgba(60, 52, 36, 0.32);
  --shadow: 0 30px 70px rgba(74, 61, 38, 0.22);
  --tile-shadow: 0 16px 34px rgba(74, 61, 38, 0.12);
  --grain: 0.28;
  color-scheme: light;
}

.sath-body * {
  box-sizing: border-box;
}

/* ── الخلفية: مصباح، مسطرة ورق، وحبيبات ───────────────────────── */

.sath-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sath-canvas > span {
  position: absolute;
  inset: 0;
  display: block;
}

.sath-canvas__lamp {
  background:
    radial-gradient(150% 105% at 50% -30%, var(--lamp), transparent 58%),
    radial-gradient(85% 62% at 6% 112%, var(--lamp), transparent 72%),
    linear-gradient(180deg, transparent 34%, var(--vignette));
}

.sath-canvas__rules {
  background-image: repeating-linear-gradient(
    to bottom,
    var(--line-soft) 0 1px,
    transparent 1px 34px
  );
  -webkit-mask-image: radial-gradient(110% 78% at 50% 12%, #000 12%, transparent 78%);
  mask-image: radial-gradient(110% 78% at 50% 12%, #000 12%, transparent 78%);
  opacity: 0.75;
}

.sath-canvas__grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: var(--grain);
  mix-blend-mode: overlay;
}

.sath-canvas__arc {
  position: absolute;
  inset-inline: -6%;
  top: -4%;
  height: min(62vh, 560px);
  color: var(--gold);
  opacity: 0.22;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
}

[data-theme="paper"] .sath-canvas__arc {
  opacity: 0.17;
}

/* ── تخطي ──────────────────────────────────────────────────────── */

.sath-skip {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  z-index: 60;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  background: var(--gold);
  color: #14100a;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s ease;
}

.sath-skip:focus-visible {
  top: 1rem;
}

/* ── الترويسة ──────────────────────────────────────────────────── */

.sath-head {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 2vw, 1.2rem);
  padding: clamp(1rem, 2.6vw, 1.7rem) clamp(1.1rem, 5vw, 3.2rem);
}

.sath-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.sath-brand__mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  color: var(--gold);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), color 0.3s ease;
}

.sath-brand:hover .sath-brand__mark,
.sath-brand:focus-visible .sath-brand__mark {
  transform: rotate(45deg);
  color: var(--gold-lite);
}

.sath-brand__text {
  display: grid;
  line-height: 1.35;
  min-width: 0;
}

.sath-brand__text strong {
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.sath-brand__text small {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.sath-clock {
  margin-inline-start: auto;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--ink-raise);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.sath-clock[hidden] {
  display: none;
}

.sath-clock__time {
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  direction: ltr;
  color: var(--text);
}

.sath-clock__date {
  display: grid;
  line-height: 1.3;
  text-align: start;
}

.sath-clock__date span {
  font-size: 0.78rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.sath-clock__date em {
  font-style: normal;
  font-size: 0.66rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.sath-theme {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--ink-raise);
  color: var(--text-soft);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.sath-theme:hover,
.sath-theme:focus-visible {
  color: var(--gold-lite);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  transform: translateY(-1px);
}

.sath-theme__icon svg {
  width: 17px;
  height: 17px;
  display: block;
}

.sath-head .alhajda-account {
  margin-inline-start: 0.15rem;
}

/* ── المحتوى ───────────────────────────────────────────────────── */

main {
  position: relative;
  z-index: 4;
  flex: 1;
  width: min(100% - 2.2rem, 1120px);
  margin-inline: auto;
  padding: clamp(1.6rem, 5vw, 4rem) 0 clamp(2.5rem, 6vw, 4.5rem);
}

.sath-hero {
  max-width: 46rem;
  margin-bottom: clamp(2.2rem, 6vw, 4rem);
}

.sath-eyebrow {
  margin: 0 0 0.7rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.sath-hero h1 {
  margin: 0 0 1.1rem;
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-weight: 700;
  font-size: clamp(2.05rem, 6.2vw, 3.6rem);
  line-height: 1.28;
  letter-spacing: -0.01em;
}

.sath-lead {
  margin: 0;
  max-width: 40rem;
  color: var(--text-soft);
  font-size: clamp(0.98rem, 2.2vw, 1.08rem);
}

.sath-section__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: clamp(1rem, 3vw, 1.6rem);
}

.sath-section__head h2 {
  margin: 0;
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.sath-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(
    to left,
    color-mix(in srgb, var(--gold) 45%, transparent),
    transparent
  );
}

.sath-section__count {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.sath-section__count [data-count] {
  direction: ltr;
  display: inline-block;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* ── البلاطات ──────────────────────────────────────────────────── */

/* ثلاثة أعمدة تُبقي المنصات الستّ صفّين مكتملين بلا فراغ أعرج */
.sath-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.8vw, 1.15rem);
}

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

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: clamp(1rem, 2.4vw, 1.45rem);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--ink-raise);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.35s ease,
    background 0.35s ease,
    box-shadow 0.35s ease;
}

.tile[hidden] {
  display: none;
}

.tile::before {
  content: "";
  position: absolute;
  inset-inline: 18%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-lite), transparent);
  opacity: 0;
  transition: opacity 0.35s ease, inset-inline 0.5s ease;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--gold) 42%, transparent);
  background: var(--ink-raise-hover);
  box-shadow: var(--tile-shadow);
  outline: none;
}

.tile:focus-visible {
  border-color: var(--gold-lite);
  box-shadow: var(--tile-shadow), 0 0 0 2px color-mix(in srgb, var(--gold) 55%, transparent);
}

.tile:hover::before,
.tile:focus-visible::before {
  opacity: 0.75;
  inset-inline: 6%;
}

.tile:active {
  transform: translateY(-1px);
}

.tile__glyph {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: radial-gradient(
    100% 100% at 50% 0%,
    color-mix(in srgb, var(--gold) 14%, transparent),
    transparent 70%
  );
  color: var(--gold);
  transition: color 0.35s ease, border-color 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.tile__glyph svg {
  width: 30px;
  height: 30px;
  display: block;
}

.tile:hover .tile__glyph,
.tile:focus-visible .tile__glyph {
  color: var(--gold-lite);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent);
  transform: translateY(-1px) scale(1.04);
}

.tile__body {
  display: grid;
  gap: 0.3rem;
  flex: 1;
}

.tile__name {
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.4;
}

.tile__desc {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.tile__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-soft);
}

.tile__host {
  direction: ltr;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile__go {
  flex: 0 0 auto;
  padding: 0.16rem 0.6rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
  transition: color 0.35s ease, border-color 0.35s ease;
}

.tile:hover .tile__go,
.tile:focus-visible .tile__go {
  color: var(--gold-lite);
  border-color: color-mix(in srgb, var(--gold) 38%, transparent);
}

/* ── ملاحظة الصدق ─────────────────────────────────────────────── */

.sath-note {
  margin-top: clamp(2.4rem, 6vw, 4rem);
  padding: clamp(1.2rem, 3vw, 2rem);
  max-width: 46rem;
  border: 1px solid var(--line-soft);
  border-inline-start: 2px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: 16px;
  background: var(--ink-raise);
}

.sath-note h2 {
  margin: 0 0 0.6rem;
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1.1rem;
  color: var(--gold);
}

.sath-note p {
  margin: 0 0 0.6rem;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.sath-note__small {
  margin-bottom: 0 !important;
  color: var(--muted) !important;
  font-size: 0.82rem !important;
}

/* ── التذييل ───────────────────────────────────────────────────── */

.sath-foot {
  position: relative;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem clamp(0.9rem, 3vw, 1.8rem);
  width: min(100% - 2.2rem, 1120px);
  margin-inline: auto;
  padding: clamp(1.2rem, 3vw, 1.8rem) 0 clamp(1.6rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.8rem;
}

.sath-foot__brand {
  color: var(--text-soft);
  font-weight: 600;
}

.sath-foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(0.8rem, 2.4vw, 1.4rem);
}

.sath-foot__links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.sath-foot__links a:hover,
.sath-foot__links a:focus-visible {
  color: var(--gold-lite);
  border-bottom-color: color-mix(in srgb, var(--gold) 50%, transparent);
}

.sath-foot__meta {
  margin-inline-start: auto;
  direction: rtl;
}

.sath-foot__meta [data-year] {
  direction: ltr;
  display: inline-block;
}

/* ── نافذة خفيفة (لصفحات الهجده نفسها فقط) ───────────────────── */

.sath-win {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.4rem);
}

.sath-win[hidden] {
  display: none;
}

.sath-win__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: sath-fade 0.28s ease both;
}

.sath-win__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 1080px);
  height: min(84vh, 780px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translate(var(--win-dx, 0px), var(--win-dy, 0px));
  animation: sath-rise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sath-win__panel.is-max {
  width: min(100%, 1600px);
  height: min(94vh, 1200px);
}

.sath-win__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--gold) 9%, transparent),
    transparent
  );
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.sath-win__bar.is-dragging {
  cursor: grabbing;
}

.sath-win__id {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
}

.sath-win__dot {
  align-self: center;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent);
}

.sath-win__id strong {
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1rem;
  white-space: nowrap;
}

.sath-win__id small {
  direction: ltr;
  color: var(--muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sath-win__acts {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.sath-win__btn {
  appearance: none;
  padding: 0.32rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.sath-win__btn:hover,
.sath-win__btn:focus-visible {
  color: var(--gold-lite);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 9%, transparent);
}

.sath-win__btn--close:hover,
.sath-win__btn--close:focus-visible {
  color: #e08b8b;
  border-color: rgba(224, 139, 139, 0.5);
  background: rgba(224, 139, 139, 0.1);
}

.sath-win__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--ink);
}

.sath-win__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.sath-win__load,
.sath-win__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--ink);
}

.sath-win__load[hidden],
.sath-win__fallback[hidden] {
  display: none;
}

.sath-win__bar-load {
  width: 120px;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}

.sath-win__bar-load::after {
  content: "";
  position: absolute;
  inset-block: 0;
  width: 42%;
  background: linear-gradient(90deg, transparent, var(--gold-lite), transparent);
  animation: sath-sweep 1.15s ease-in-out infinite;
}

.sath-win__cta {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-lite), var(--gold));
  color: #17120a;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}

@keyframes sath-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sath-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translate(var(--win-dx, 0px), var(--win-dy, 0px)); }
}

@keyframes sath-sweep {
  from { inset-inline-start: -45%; }
  to { inset-inline-start: 100%; }
}

/* ── الجوال: شبكة بيت جميلة، بلا استعارة سطح مكتب ────────────── */

@media (max-width: 720px) {
  .sath-head {
    flex-wrap: wrap;
    row-gap: 0.7rem;
  }

  .sath-clock {
    order: 3;
    margin-inline-start: 0;
    width: 100%;
    justify-content: space-between;
  }

  .sath-theme {
    margin-inline-start: auto;
  }

  .sath-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .tile {
    gap: 0.65rem;
    padding: 0.95rem 0.85rem;
    border-radius: 16px;
  }

  .tile__glyph {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .tile__glyph svg {
    width: 25px;
    height: 25px;
  }

  .tile__name {
    font-size: 1.05rem;
  }

  .tile__desc {
    font-size: 0.8rem;
  }

  .tile__foot {
    padding-top: 0.55rem;
  }

  .tile__go {
    display: none;
  }

  .sath-foot__meta {
    margin-inline-start: 0;
  }
}

/* عمودان حتى على الشاشات الضيقة — الشبكة تبقى شبكة، لا قائمة طويلة */
@media (max-width: 400px) {
  main,
  .sath-foot {
    width: min(100% - 1.5rem, 1120px);
  }

  .tile {
    padding: 0.85rem 0.7rem;
  }

  .tile__desc {
    font-size: 0.76rem;
    line-height: 1.6;
  }

  /* الاسم يبقى في aria-label — إخفاؤه يجمع الترويسة في صفّين بدل ثلاثة */
  .sath-theme__label {
    display: none;
  }

  .sath-theme {
    padding: 0.45rem 0.55rem;
  }
}

@media (max-width: 320px) {
  .sath-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sath-body *,
  .sath-body *::before,
  .sath-body *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* في لوح الورق يصبح زر الحساب المحقون من site-shell فاتحًا */
[data-theme="paper"] .alhajda-account__login,
[data-theme="paper"] .alhajda-account__signup {
  color: #22201b;
  border-color: rgba(34, 32, 27, 0.16);
  background: rgba(255, 255, 255, 0.7);
}

[data-theme="paper"] .alhajda-account__signup {
  background: linear-gradient(135deg, #d4b87a, #b39359);
}
