/* static/css/earth.css
   =========================================================================
   صفحة «الأرض والفلك» — مسرحٌ بملء الشاشة بين الشريط العلوي والتذييل، القرص في
   وسطه والأدوات عائمة على أطرافه (static/js/earth/controls.js):
     • عمود الطبقات  : جانب نهاية السطر (يسار العربية، يمين الإنجليزية).
     • عمود التنقّل   : جانب بداية السطر (يمين العربية، يسار الإنجليزية).
     • الشريط السفلي : مباشر + بطاقة التاريخ + الفصل + التشغيل + الآن.
   الخصائص المنطقية (inset-inline-*) تعكس الجانبين تلقائياً مع اتجاه اللغة.

   القسمان:
     (١) مكوّنات الأدوات: حبّة القفز، زرّ/مربّع الكوكب، بطاقة التاريخ، زرّا التشغيل/الآن.
     (٢) تخطيط الصفحة: المسرح، العمودان، الشريط، وأوضاع الشاشات (ضيّق/طولي، قصير بالعرض).
   ========================================================================= */

/* لوحة القرص (WebGL للأرض/الليل + 2D للشبكة والعلامات) تملآن المسرح وتتراكبان. */
.earth-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#earth-overlay {
  pointer-events: none; /* التفاعل على المسرح (interactions.js) */
}

/* ###########################################################################
   (١) مكوّنات الأدوات
   ########################################################################### */

/* ---------------------------------------------------------------------------
   أبعاد أزرار الأدوات: خارج نمط الأزرار العام (:where(.astro-ui button) في forms.css)،
   فمظهرها كلّه من هنا.
   --------------------------------------------------------------------------- */

.earth-nav-btn {
  padding: 7px 9px;              /* أسهمٌ مريحة اللمس بلا مزاحمة للنص */
  border-radius: 0;
}
.earth-planet-chip {
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 999px;
}
.earth-planets-btn {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 999px;
}
.earth-speed-btn,
.earth-now-btn {
  padding: 10px 18px;
  font-size: 14px;
  border-radius: 12px;
}
/* شارة «مباشر»: صفٌّ علويّ صغير محاذًى لبداية اللوحة (يمين)، بنقطةٍ نابضة */
.earth-live-slot {
  flex: 0 0 auto;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;   /* rtl: البداية = يمين اللوحة */
  gap: 6px;
}
.earth-live-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5252;
  box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.55);
  animation: earth-live-pulse 1.7s ease-out infinite;
}
.earth-live-badge {
  display: none;
  padding: 3px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ff5252;
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.30);
  border-radius: 999px;
}
.earth-live-slot.is-live .earth-live-dot,
.earth-live-slot.is-live .earth-live-badge {
  display: inline-block;
}
/* نبضة نقطة «مباشر» (يستعملها سطر مباشر داخل بطاقة التاريخ: .tc-live-dot). */
@keyframes earth-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(255, 82, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .earth-datecard .tc-live-dot { animation: none; }
}

/* ===========================================================================
   بطاقة التاريخ القابلة للتحرير (تقويم الخالق + ميلادي + ساعة) — نظير بطاقة صفحة اليوم
   منسّقٌ للوحة الأرض. صفوفٌ (تسمية/قيمة) متحاذية، والقيمة في صفّي التقويمين ثلاث
   خاناتٍ إنلاين تبدو كنصٍّ حتى التركيز. السطر الأوّل: ساعةٌ كبيرة مركزية (عرضٌ فقط).
   =========================================================================== */
.earth-datecard {
  width: 100%;
  direction: rtl;                 /* يوم(يمين) ‑ اسمُ‑الشهر ‑ رقمُ‑الشهر ‑ سنة(يسار) */
}

/* سطر «مباشر» أعلى البطاقة داخلها (النقطتان 1+2): مساحته محجوزةٌ دائماً (min-height)
   فلا يقفز ارتفاع البطاقة عند تبديل الوضع؛ يظهر محتواه في الوضع الحيّ فقط. */
.earth-datecard .tc-live-slot {
  display: flex;
  align-items: center;
  justify-content: flex-start;    /* rtl: البداية = يمين البطاقة */
  gap: 6px;
  min-height: 16px;
  margin-bottom: 2px;
}
.earth-datecard .tc-live-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5252;
  box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.55);
  animation: earth-live-pulse 1.7s ease-out infinite;
}
.earth-datecard .tc-live-badge {
  display: none;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ff5252;
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.30);
  border-radius: 999px;
}
.earth-datecard .tc-live-slot.is-live .tc-live-dot { display: inline-block; }
.earth-datecard .tc-live-slot.is-live .tc-live-badge { display: inline-block; }
.earth-datecard .tc-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 4px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.earth-datecard .tc-row:not(:first-child):focus-within,
.earth-datecard .tc-row:not(:first-child):hover {
  background: color-mix(in srgb, var(--accent, #2a6df4) 7%, transparent);
}
.earth-datecard .tc-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary, rgba(112, 108, 108, 0.7));
  white-space: nowrap;
  flex: 0 0 auto;
}
.earth-datecard .tc-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
  white-space: nowrap;
  flex: 1 1 auto;
}
/* صفّ الساعة: أفقيٌّ — التسمية (محلي/خالق) يميناً والساعة يساراً على الطرفين
   (النقطة 4)، بحدٍّ سفليّ خفيف يفصله عن صفّي التاريخ. */
.earth-datecard .tc-clockrow {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px clamp(8px, 1.4vh, 14px);
  margin-bottom: 2px;
  border-bottom: 1px solid #8aa0d033;
  border-radius: 0;
}
.earth-datecard .tc-clockrow .tc-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.8;
  align-self: center;
}
.earth-datecard .tc-clockrow .tc-value {
  text-align: left;
  flex: 0 0 auto;
}
/* الساعة: أرقام متساوية العرض فلا يهتزّ العرض مع كل دقيقة، وحجمٌ بارز عصريّ */
.earth-datecard .tc-clock {
  font-variant-numeric: tabular-nums;
  font-size: clamp(26px, 4.2vh, 38px);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--text-main), var(--accent, #2a6df4));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* محرّر التقاويم: تدفّقٌ نصّيّ ثابت الاتجاه (RTL) بلا انعكاس */
.earth-datecard .tc-editor {
  direction: rtl;
  unicode-bidi: isolate;
}
/* الخانة: تصفير تنسيق النموذج العامّ (forms.css: width:100% + padding/‏font/‏bg/‏color)
   الذي كان سيُضخّمها ويقصّها؛ ثم إطارٌ داخليّ (inset) يوحي بقابلية
   الكتابة دون تغيير حجم الصندوق. */
.earth-datecard .tc-cell {
  all: unset;
  box-sizing: content-box;
  display: inline-block;
  vertical-align: baseline;
  text-align: center;
  line-height: inherit;
  font: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(120, 150, 200, 0.5);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  min-width: 0;
  height: auto;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  direction: ltr;            /* أرقام الخانة LTR داخلياً (1404 لا 4041) */
  unicode-bidi: isolate;     /* والخانة كوحدةٍ تتبع ترتيب المحرّر RTL */
  cursor: text;
  transition: background 0.15s, box-shadow 0.15s;
}
.earth-datecard .tc-cell-num  { width: 2.6ch; }
.earth-datecard .tc-cell-year { width: 5.0ch; }
.earth-datecard .tc-cell:hover {
  box-shadow: inset 0 0 0 1px rgba(120, 150, 200, 0.75);
  background: rgba(120, 150, 200, 0.10);
}
.earth-datecard .tc-cell:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(120, 150, 200, 1);
  background: rgba(120, 150, 200, 0.13);
}
.earth-datecard .tc-monthname { direction: rtl; }
/* خطأ الإدخال: تلوينٌ لحظيّ للخانة (نصّاً وإطاراً) بلا تغييرٍ في القياس */
.earth-datecard .tc-row.has-error .tc-cell {
  color: #e53935;
  box-shadow: inset 0 0 0 1px rgba(229, 57, 53, 0.7);
}

/* سطر الخطأ المحجوز: مساحةٌ ثابتةٌ أسفل البطاقة تمتلئ عند الخطأ فقط (بلا قفز) */
.earth-datecard .tc-errline {
  margin-top: 6px;
  min-height: 1.1em;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: #e53935;
  direction: rtl;
  text-align: center;
}

/* مؤشّر الانتظار (يُبدِّل نصَّ الساعة أثناء التحويل/الهبوط) */
.earth-datecard .tc-busy {
  display: none;
  align-items: center;
  gap: 6px;
}
.earth-datecard .tc-value.is-busy .tc-timetext { display: none; }
.earth-datecard .tc-value.is-busy .tc-busy { display: inline-flex; }
.earth-datecard .tc-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(150, 170, 220, 0.35);
  border-top-color: var(--primary, #9db4ff);
  display: inline-block;
  animation: earth-tc-spin 0.7s linear infinite;
}
.earth-datecard .tc-busy-text {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--primary, #9db4ff);
}
@keyframes earth-tc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .earth-datecard .tc-spinner { animation-duration: 1.6s; }
}

/* ===========================================================================
   زرّ إظهار الكواكب (في لوحتها المنبثقة) + مربّعات الكواكب
   =========================================================================== */
.earth-planets-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  background: transparent;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.18));
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.earth-planets-btn:hover {
  background: var(--card-bg, rgba(0, 0, 0, 0.04));
  transform: translateY(-1px);
}
.earth-planets-btn i {
  font-size: 12px;
  opacity: 0.75;
}
/* مُفعّل: تعبئة بلون التمييز */
.earth-planets-btn.is-on {
  color: #fff;
  background: var(--accent, #2a6df4);
  border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent, #2a6df4) 35%, transparent);
}
.earth-planets-btn.is-on i {
  opacity: 1;
}

/* شبكة مربعات الكواكب: ٣ أعمدة متساوية × عدّة صفوف (لون+رمز+اسم)، مضغوطة */
.earth-planet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 100%;
  transition: opacity 0.15s ease;
}
.earth-planet-grid.is-dimmed {
  opacity: 0.4; /* الطبقة مُطفأة: مُعتَّمة لكنها تبقى قابلةً للاختيار */
}
.earth-planet-chip {
  width: 100%;
  min-width: 0;                    /* يسمح بالانكماش داخل الخلية دون فيضان */
  display: inline-flex;
  align-items: center;
  justify-content: center;         /* المحتوى في وسط الخلية */
  gap: 5px;
  font-family: inherit;
  color: var(--text-main);
  background: transparent;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.18));
  cursor: pointer;
  opacity: 0.5; /* غير مُفعّل افتراضياً */
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.earth-planet-chip:hover {
  transform: translateY(-1px);
}
.earth-planet-chip .earth-planet-swatch {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: transparent; /* مجوّف عند الإطفاء */
}
.earth-planet-chip .earth-planet-sym {
  flex: 0 0 auto;
  color: var(--planet-color);
  font-size: 12px;
  line-height: 1;
}
.earth-planet-chip .earth-planet-name {
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* مُفعّل: تعبئة اللون بالمربّع وحدٌّ بلونه ووضوحٌ كامل */
.earth-planet-chip.is-on {
  opacity: 1;
  border-color: var(--planet-color);
  background: color-mix(in srgb, var(--planet-color) 14%, transparent);
}
.earth-planet-chip.is-on .earth-planet-swatch {
  background: var(--planet-color);
  border-color: var(--planet-color);
}

/* ===========================================================================
   حبّة القفز: سهم سابق + الاسم + سهم تالٍ (الأسهم تتبع اللغة — controls.js)
   =========================================================================== */
.earth-nav {
  flex: 1 1 0;
  min-width: 0;                    /* يسمح بالانكماش داخل الصف دون فيضان */
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--card-bg, rgba(0, 0, 0, 0.05)) 100%, transparent);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.14));
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.earth-nav:hover {
  border-color: var(--accent, #2a6df4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 42, 74, 0.10);
}
.earth-nav-label {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.earth-nav-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  color: var(--text-main);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.earth-nav-btn:hover:not(:disabled) {
  background: var(--accent, #2a6df4);
  color: #fff;
}
.earth-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.earth-nav-btn i {
  font-size: 10px;
  opacity: 0.7;
}
.earth-nav-btn:hover:not(:disabled) i {
  opacity: 1;
}

/* ===========================================================================
   زرّا التشغيل و«الآن»
   =========================================================================== */
.earth-speed-btn,
.earth-now-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.earth-speed-btn {
  color: var(--text-main);
  background: var(--card-bg, rgba(0, 0, 0, 0.06));
  border: 1px solid transparent;
}
.earth-speed-btn:hover {
  transform: translateY(-1px);
}
.earth-speed-btn.is-active {
  color: #fff;
  background: var(--accent, #2a6df4);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent, #2a6df4) 40%, transparent);
}
.earth-now-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent, #2a6df4), color-mix(in srgb, var(--accent, #2a6df4) 70%, #7c4dff));
  border: 1px solid transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent, #2a6df4) 35%, transparent);
}
.earth-now-btn:hover {
  transform: translateY(-1px);
}

:root[data-theme='dark'] .earth-nav,
:root[data-theme='dark'] .earth-now-btn,
:root[data-theme='dark'] .earth-planet-chip:not(.is-on),
:root[data-theme='dark'] .earth-planets-btn:not(.is-on) {
  border-color: rgba(255, 255, 255, 0.18);
}
:root[data-theme='dark'] .earth-planets-btn:not(.is-on):hover {
  background: rgba(255, 255, 255, 0.06);
}
:root[data-theme='dark'] .earth-speed-btn {
  background: rgba(255, 255, 255, 0.08);
}

/* الوضع الليلي: الوقت والتقاويم أقرب للأبيض كي تظهر بوضوح على الخلفية الداكنة. */
:root[data-theme='dark'] .earth-datecard .tc-label {
  color: rgba(255, 255, 255, 0.86);
}
:root[data-theme='dark'] .earth-datecard .tc-value {
  color: #fff;
}
/* الساعة: أبيض صريح بلا تدرّجٍ لونيّ (أوضح ليلاً) — نُلغي قصّ الخلفية النصّي. */
:root[data-theme='dark'] .earth-datecard .tc-clock {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #fff;
  color: #fff;
}

/* الشاشات الضيّقة: أسماء وحدات القفز وبطاقة التاريخ أضيق. */
@media (max-width: 600px) {
  .earth-nav-label {
    font-size: 12px;                /* span غير متأثّر بقاعدة button، فيسري هنا */
  }
}
@media (max-width: 480px) {
  .earth-live-slot {
    height: 15px;
  }
  /* بطاقة التاريخ: تضييق الخطوط/الخانات كي لا يفيض صفٌّ عريض. */
  .earth-datecard .tc-row {
    gap: 8px;
    padding: 3px 2px;
  }
  .earth-datecard .tc-label {
    font-size: 12px;
  }
  .earth-datecard .tc-value {
    font-size: 15px;
    min-width: 0;                 /* يسمح بالانكماش بدل فرض عرض المحتوى الكامل */
  }
  .earth-datecard .tc-cell-num  { width: 2.2ch; }
  .earth-datecard .tc-cell-year { width: 4.2ch; }
  /* اسم الشهر: أطول جزءٍ متغيّر الطول في السطر (مثل «جمادى الآخرة»)؛ حدٌّ أقصى للعرض
     + قصّ أنيق (…) بدل دفع بقيّة الصفّ خارج الشاشة. */
  .earth-datecard .tc-monthname {
    max-width: 30vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
  }
  .earth-datecard .tc-clock {
    font-size: clamp(20px, 7.5vw, 28px);
  }
  .earth-planet-grid {
    gap: 5px;
  }
  .earth-nav-label {
    font-size: 11px;
  }
  .earth-speed-btn,
  .earth-now-btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}
@media (max-width: 360px) {
  .earth-datecard .tc-row {
    gap: 6px;
  }
  .earth-datecard .tc-label {
    font-size: 11px;
  }
  .earth-datecard .tc-value {
    font-size: 13px;
  }
  .earth-datecard .tc-cell-num  { width: 1.9ch; }
  .earth-datecard .tc-cell-year { width: 3.6ch; }
  .earth-datecard .tc-monthname {
    max-width: 26vw;
  }
}

/* دعمٌ احتياطي للمتصفحات بلا color-mix(): ساعةٌ بلونٍ مصمت بدل التدرّج. */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .earth-datecard .tc-clock {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--accent, #2a6df4);
  }
}

/* ###########################################################################
   (٢) تخطيط الصفحة
   ########################################################################### */

/* الصفحة بارتفاع النافذة بالضبط بلا تمرير: عمودٌ مرن — حشو الشريط العلوي (body padding-top
   يضبطه topbar.js) ثم المسرح يأخذ ما تبقّى، ثم التذييل (الخصوصية + مبدّل اللغة) ظاهرٌ دائماً
   أسفل الشاشة. العناصر الثابتة (الشريطان، النوافذ) خارج التدفّق فلا يمسّها العمود. */
body.page-earth {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* غلاف المحتوى عمودٌ مرن بدوره (يحوي main وحده هنا — لا header في هذه الصفحة). */
body.page-earth > .page-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* الحاوية العامة بلا حشوٍ ولا حدّ عرض: المسرح يصل لحوافّ المنطقة المتاحة. */
body.page-earth > .page-shell > main.container {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;          /* responsive.css يجعل .container بعرض 99% على الشاشات ≤900px */
  max-width: none;
  padding: 0 !important; /* يغلب !important في style.css (.container ≤600px) */
  overflow: visible;    /* وoverflow-x:auto ≤600px — لا تمرير داخليّ هنا */
  border-radius: 0;
}
/* التذييل عنصرٌ ثابت في عمود الصفحة هنا (لا تمرير ولا شيء يمرّ تحته). */
body.page-earth > footer {
  flex: 0 0 auto;
  position: static;
}

/* المسرح: يملأ ما بين الشريط العلوي والتذييل. ما خارج دائرة القرص شفّاف (night_gl.js)،
   فخلفية المسرح هي خلفية الفضاء حول القرص: بيضاء في الوضع الفاتح، سوداء في الليلي. */
.astro-page {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
  font-family: var(--font-main);
  color: var(--text-main);
}

.astro-map {
  position: absolute;
  inset: 0;
  touch-action: none;   /* إيماءات تكبير/تنقّل مخصّصة (interactions.js) */
  cursor: grab;
}
.astro-map.is-grabbing { cursor: grabbing; }

/* طبقة الأدوات: لا تعترض المؤشّر إلا على عناصرها نفسها. */
.astro-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.astro-ui > * { pointer-events: auto; }

/* أزرار الأدوات خارج نمط الأزرار العام في forms.css: بلا هامشٍ افتراضيّ. */
.astro-ui button { margin: 0; }

/* سطح زجاجيّ موحّد للأدوات العائمة. */
.astro-rail-btn,
.astro-flyout,
.astro-bar,
.astro-rail--jumps .earth-nav {
  background: var(--main-bg-glass);
  border: 1px solid rgba(120, 140, 185, 0.22);
  box-shadow: 0 6px 22px rgba(30, 42, 74, 0.14);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}

/* =======================================================================
   عمود الطبقات (نهاية السطر)
   ======================================================================= */
.astro-rail {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.astro-rail--layers { inset-inline-end: 16px; }

.astro-rail-item { position: relative; }

.astro-rail-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
/* أيقونات SVG (rail_icons.js): خطٌّ بلون الزرّ، والنقاط المصمتة بالون نفسه. */
.astro-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.astro-icon .astro-icon-fill { fill: currentColor; }
.astro-rail-btn:hover { transform: scale(1.06); }
.astro-rail-btn:focus-visible { outline: 2px solid var(--accent, #2a6df4); outline-offset: 2px; }
.astro-rail-btn.is-on {
  color: #fff;
  background: var(--accent, #2a6df4);
  border-color: transparent;
}

/* التلميح: يظهر نحو القرص (جهة بداية السطر من العمود) عند التحويم/التركيز. */
.astro-tip {
  position: absolute;
  inset-inline-end: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  background: rgba(15, 20, 32, 0.88);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.astro-rail-btn:hover .astro-tip,
.astro-rail-btn:focus-visible .astro-tip {
  opacity: 1;
  visibility: visible;
}
/* لا تلميح للزرّ إن كانت لوحته مفتوحة (تغطيه). */
.astro-rail-btn[aria-expanded="true"] .astro-tip { display: none; }

/* لوحة الكواكب المنبثقة بجوار زرّها نحو القرص. */
.astro-flyout {
  position: absolute;
  inset-inline-end: calc(100% + 12px);
  top: 0;
  width: 300px;
  padding: 12px;
  border-radius: 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}
.astro-flyout.is-open { display: flex; }
.astro-flyout .earth-planets-btn { width: 100%; }

/* =======================================================================
   عمود التنقّل الزمني (بداية السطر) — حبّاتٌ مضغوطة
   ======================================================================= */
.astro-rail--jumps {
  inset-inline-start: 16px;
  width: 124px;
  gap: 6px;
}
.astro-rail--jumps .earth-nav {
  flex: 0 0 auto;
  border-radius: 10px;
}
.astro-rail--jumps .earth-nav-btn { padding: 5px 8px; }
.astro-rail--jumps .earth-nav-btn i { font-size: 9px; }
.astro-rail--jumps .earth-nav-label { font-size: 12px; }

/* =======================================================================
   الشريط السفلي
   ======================================================================= */
.astro-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 20px;
  white-space: nowrap;
}

/* «مباشر»: عمودٌ صغير ثابت العرض في بداية الشريط (يظهر محتواه في الوضع الحيّ). */
.astro-live {
  flex: 0 0 auto;
  min-width: 62px;
  justify-content: center;
}

/* بطاقة التاريخ أفقية: الساعة في عمود، والتقويمان فوق بعضهما في العمود التالي. */
.astro-bar .astro-datecard {
  width: auto;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: center;
  position: relative;
}
.astro-bar .astro-datecard > .tc-row:first-child {
  grid-column: 1;
  grid-row: 1 / 3;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  padding-inline-end: 14px;
  border-inline-end: 1px solid #8aa0d033;
  border-radius: 0;
  background: none;
}
.astro-bar .astro-datecard > .tc-row:first-child .tc-label {
  font-size: 11px;
  opacity: 0.8;
}
.astro-bar .astro-datecard > .tc-row:first-child .tc-value { text-align: center; }
.astro-bar .astro-datecard .tc-clock {
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 800;
}
.astro-bar .astro-datecard > .tc-row:not(:first-child) {
  grid-column: 2;
  gap: 12px;
  padding: 2px 6px;
}
.astro-bar .astro-datecard .tc-label { font-size: 12px; }
.astro-bar .astro-datecard .tc-value { font-size: 16px; }
/* ترتيب أعمدة البطاقة يتبع لغة الصفحة (الساعة في بداية السطر) — .earth-datecard أعلاه RTL؛
   محرّر التاريخ نفسه (.tc-editor) يبقى RTL صراحةً كما في كل الموقع. */
html[dir="ltr"] .astro-bar .astro-datecard { direction: ltr; }
/* سطر الخطأ تحت الشريط بلا تغيير ارتفاعه. */
.astro-bar .astro-datecard .tc-errline {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  margin-top: 6px;
  font-size: 12px;
}

.astro-season {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary, rgba(60, 70, 90, 0.75));
}

.astro-actions {
  display: flex;
  gap: 10px;
}
.astro-actions .earth-speed-btn,
.astro-actions .earth-now-btn {
  flex: 0 0 auto;
  min-width: 112px;
}

/* =======================================================================
   أثناء التشغيل: لا تمويه خلفية ولا انتقالات (تتنافس مع رسم القرص فتُسقط إطارات).
   ======================================================================= */
.astro-ui.is-animating .astro-rail-btn,
.astro-ui.is-animating .astro-flyout,
.astro-ui.is-animating .astro-bar,
.astro-ui.is-animating .astro-rail--jumps .earth-nav {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.astro-ui.is-animating * { transition: none; }

/* =======================================================================
   الوضع الليلي
   ======================================================================= */
:root[data-theme='dark'] .astro-page { background: #000; }
:root[data-theme='dark'] .astro-rail-btn,
:root[data-theme='dark'] .astro-flyout,
:root[data-theme='dark'] .astro-bar,
:root[data-theme='dark'] .astro-rail--jumps .earth-nav {
  border-color: rgba(90, 120, 175, 0.18);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
:root[data-theme='dark'] .astro-season { color: rgba(220, 230, 250, 0.75); }

/* =======================================================================
   شاشات متوسطة: شريطٌ أضيق
   ======================================================================= */
@media (max-width: 1100px) {
  .astro-bar { gap: 12px; padding: 8px 12px; }
  .astro-actions .earth-speed-btn,
  .astro-actions .earth-now-btn { min-width: 0; }
  .astro-bar .astro-datecard .tc-clock { font-size: 24px; }
  .astro-rail--jumps { width: 116px; }
}

/* =======================================================================
   الجوال والشاشات الطولية (الجهاز اللوحي عمودياً): القرص بعرض المسرح؛ الطبقات صفٌّ
   أفقيّ أعلى المسرح، والتنقّل والشريط يرسوان أسفله — فلا تتراكب الأدوات على القرص.
   الاستعلام نفسه في controls.js (NARROW_QUERY) — يُعدَّلان معاً.
   ======================================================================= */
@media (max-width: 600px), (max-aspect-ratio: 5/6) {
  .astro-ui {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px;
  }

  .astro-rail--layers {
    top: 8px;
    inset-inline-end: auto;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 8px;
  }
  .astro-rail-btn {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }
  .astro-icon { width: 19px; height: 19px; }
  .astro-tip { display: none; }
  /* لوحة الكواكب تنسدل أسفل صفّ الطبقات متوسّطةً تحته (الصفّ نفسه متوسّط المسرح)، فلا
     تخرج عن حافّة الشاشة مهما ضاقت. */
  .astro-rail--layers .astro-rail-item { position: static; }
  .astro-flyout {
    inset-inline-start: auto;
    inset-inline-end: auto;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 8px);
    width: min(300px, calc(100vw - 24px));
  }

  .astro-rail--jumps {
    position: static;
    transform: none;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .astro-rail--jumps .earth-nav-btn { padding: 5px 7px; }
  .astro-rail--jumps .earth-nav-label { font-size: 11px; }

  .astro-bar {
    position: static;
    transform: none;
    max-width: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 12px;
    padding: 8px 10px;
    border-radius: 16px;
    white-space: normal;
  }
  .astro-bar .astro-datecard { order: 1; flex: 1 1 100%; justify-content: center; }
  .astro-live { order: 2; min-width: 0; }
  .astro-season { order: 3; font-size: 13px; }
  .astro-actions { order: 4; }
  .astro-bar .astro-datecard { column-gap: 10px; }
  .astro-bar .astro-datecard > .tc-row:first-child { padding-inline-end: 10px; }
  .astro-bar .astro-datecard > .tc-row:not(:first-child) { gap: 8px; padding: 2px 4px; }
  .astro-bar .astro-datecard .tc-clock { font-size: 20px; }
  .astro-bar .astro-datecard .tc-value { font-size: 14px; }
  /* تسميتا التقويمين تلتفّان بدل أن تدفعا البطاقة خارج الشريط (الإنجليزية أطول). */
  .astro-bar .astro-datecard > .tc-row:not(:first-child) .tc-label {
    white-space: normal;
    max-width: 6.5em;
    line-height: 1.15;
  }
}

/* الهواتف الصغيرة جداً (≤360px): شريطٌ أضيق كي تتّسع بطاقة التاريخ وزرّاها في العرض. */
@media (max-width: 360px) {
  .astro-bar .astro-datecard { column-gap: 8px; }
  .astro-bar .astro-datecard > .tc-row:first-child { padding-inline-end: 8px; }
  .astro-bar .astro-datecard > .tc-row:not(:first-child) { gap: 6px; padding: 2px; }
  .astro-bar .astro-datecard .tc-clock { font-size: 18px; }
  .astro-bar .astro-datecard .tc-label { font-size: 10px; }
  .astro-bar .astro-datecard .tc-value { font-size: 12px; }
  .astro-actions .earth-speed-btn,
  .astro-actions .earth-now-btn {
    padding: 7px 12px;
    font-size: 13px;
  }
}

/* =======================================================================
   الشاشات القصيرة بالعرض (الهاتف أفقياً): المسرح قصير، فالعمودان يبدآن من أعلى بأزرارٍ
   أصغر، والشريط السفلي سطرٌ واحد مضغوط بينهما.
   ======================================================================= */
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {

  .astro-rail { top: 8px; transform: none; }
  .astro-rail--layers { inset-inline-end: 10px; gap: 5px; }
  .astro-rail-btn { width: 32px; height: 32px; font-size: 13px; }
  .astro-icon { width: 17px; height: 17px; }
  .astro-flyout { max-height: 70vh; overflow-y: auto; }

  .astro-rail--jumps { inset-inline-start: 10px; width: 100px; gap: 4px; }
  .astro-rail--jumps .earth-nav-btn { padding: 3px 6px; }
  .astro-rail--jumps .earth-nav-label { font-size: 11px; }

  .astro-bar {
    bottom: 8px;
    gap: 10px;
    padding: 6px 10px;
    max-width: calc(100% - 2 * 124px);   /* بين العمودين (عرض عمود التنقّل + هامشه) */
  }
  .astro-bar .astro-datecard > .tc-row:not(:first-child) .tc-label { display: none; }
  .astro-bar .astro-datecard .tc-clock { font-size: 18px; }
  .astro-bar .astro-datecard .tc-value { font-size: 13px; }
  .astro-live { min-width: 0; }
  .astro-live .earth-live-badge { display: none; }   /* النقطة الحمراء تكفي هنا */
  .astro-season { font-size: 12px; }
  .astro-actions .earth-speed-btn,
  .astro-actions .earth-now-btn {
    min-width: 0;
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* أضيق الهواتف (≤340px): تُخفى تسميتا التقويمين — التاريخان مميَّزان بأسماء أشهرهما. */
@media (max-width: 340px) {
  .astro-bar .astro-datecard > .tc-row:not(:first-child) .tc-label { display: none; }
}
