/*
 * Abraj web tools (simple): حاسبة البرج الصيني، ما هو برجي، حساب الجمل.
 * Loaded after /styles.css and uses its tokens (colours, fonts, radii). Logical properties only, so RTL needs no overrides.
 * Every class is prefixed st- (or jm-) so it cannot clash with the site or the sibling astro tools.
 */

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

/* ---------- Top bar ---------- */

.st-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-block: 18px 4px;
}

.st-brand {
  font-size: 2rem;
  text-decoration: none;
}

.st-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--on-dark-3);
  font-size: 0.875rem;
  line-height: 1.6;
}

.st-crumbs li + li::before {
  content: "‹";
  margin-inline-end: 4px;
  color: var(--gold-500);
}

.st-crumbs a {
  color: var(--on-dark-2);
  text-underline-offset: 4px;
}

/* ---------- Page ---------- */

.st-main {
  max-width: 760px;
  padding-block-start: clamp(16px, 4vw, 32px);
}

.st-title {
  color: var(--gold-400);
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.5rem + 2.6vw, 3rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.st-lede {
  max-width: 34rem;
  margin: 8px auto 0;
  color: var(--on-dark-2);
  text-align: center;
}

.st-card,
.st-result {
  margin-block-start: 24px;
  padding: clamp(18px, 5vw, 28px);
  background: var(--surface-dark);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-xl);
}

.st-result {
  display: grid;
  gap: 14px;
  background: linear-gradient(160deg, var(--surface-dark-alt), var(--surface-dark) 55%);
  border-color: #e4bf7c4d;
  scroll-margin-block-start: 16px;
}

.st-result:focus {
  outline: none;
}

/* The result is focused by script so screen readers land on it; it is not a control, so no focus ring. */
.st-result:focus-visible {
  outline: none;
}

.st-result > *,
.st-panel > *,
.st-about > * {
  margin: 0;
}

fieldset {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

legend {
  margin-block-end: 8px;
  padding: 0;
  color: var(--gold-300);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
}

.st-date {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 12px;
}

.st-field {
  display: grid;
  gap: 6px;
  margin-block-end: 16px;
}

.st-date .st-field {
  margin: 0;
}

.st-field label {
  color: var(--on-dark-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.st-field input,
.st-field select {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  color: var(--on-dark);
  font: inherit;
  font-size: 1.125rem;
  background: var(--bg-deep);
  border: 1px solid #e4bf7c66;
  border-radius: var(--r-md);
}

.st-field select {
  padding-inline-end: 8px;
}

.st-field input[dir="ltr"] {
  text-align: center;
}

.st-field input::placeholder {
  color: var(--on-dark-3);
  opacity: 0.7;
}

.st-field input:focus-visible,
.st-field select:focus-visible {
  outline: 3px solid var(--gold-300);
  outline-offset: 2px;
}

.st-hint {
  margin-block-start: 10px;
  color: var(--on-dark-3);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Two-option switch (calendar, method), built on real radio buttons. */
.st-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.st-switch legend {
  flex-basis: 100%;
}

.st-switch label {
  position: relative;
  flex: 1 1 8rem;
}

.st-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.st-switch span {
  display: block;
  min-height: 48px;
  padding: 10px 16px;
  color: var(--on-dark-2);
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  background: var(--bg-deep);
  border: 1px solid var(--line-dark);
  border-radius: 999px;
}

.st-switch input:checked + span {
  color: var(--on-light);
  background: linear-gradient(135deg, var(--gold-from), var(--gold-to));
  border-color: transparent;
}

.st-switch input:focus-visible + span {
  outline: 3px solid var(--gold-300);
  outline-offset: 2px;
}

.st-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-block-start: 8px;
  padding: 12px 24px;
  color: var(--on-light);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-from), var(--gold-to));
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.st-btn:focus-visible {
  outline: 3px solid var(--on-dark);
  outline-offset: 3px;
}

.st-btn-secondary {
  color: var(--gold-300);
  background: transparent;
  border: 1px solid #e4bf7c80;
}

.st-error {
  margin-block-start: 12px;
  padding: 10px 14px;
  color: var(--blush-100);
  background: #e9a3bf26;
  border: 1px solid #e9a3bf66;
  border-radius: var(--r-md);
}

.st-privacy {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-block-start: 14px;
  color: var(--on-dark-3);
  font-size: 0.875rem;
  line-height: 1.7;
}

.st-privacy svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-block-start: 3px;
  color: var(--gold-400);
}

/* ---------- Result ---------- */

.st-eyebrow {
  color: var(--gold-400);
  font-size: 0.9375rem;
  text-align: center;
}

.st-big {
  color: var(--on-dark);
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 2rem + 3vw, 3.5rem);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.st-num {
  color: var(--gold-300);
  font-variant-numeric: tabular-nums;
}

.st-badge {
  justify-self: center;
  padding: 4px 16px;
  color: var(--gold-300);
  font-weight: 700;
  border: 1px solid #e4bf7c66;
  border-radius: 999px;
}

.st-tagline {
  color: var(--gold-300);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
  line-height: 1.7;
  text-align: center;
}

.st-fact {
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
}

.st-label {
  color: var(--on-dark-3);
  font-size: 0.875rem;
}

.st-strong {
  color: var(--on-dark);
  font-weight: 700;
  font-size: 1.125rem;
  text-align: center;
}

.st-muted {
  color: var(--on-dark-3);
  font-size: 0.875rem;
  line-height: 1.7;
}

.st-soft {
  color: var(--on-dark-2);
}

.st-center,
#ws-range,
#ws-converted,
#ws-traits {
  text-align: center;
}

.st-panel {
  display: grid;
  gap: 10px;
  padding: clamp(16px, 4vw, 22px);
  background: #0a0e2a99;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
}

.st-panel-alt {
  background: #221f52b3;
}

.st-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-400);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
}

.st-center .st-sub {
  justify-content: center;
}

.st-sub svg {
  width: 16px;
  height: 16px;
}

.st-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.st-chips li {
  padding: 4px 14px;
  color: var(--on-dark);
  font-size: 0.9375rem;
  border: 1px solid #e4bf7c80;
  border-radius: 999px;
}

.st-note {
  padding: 12px 16px;
  color: var(--on-light-2);
  font-size: 0.9375rem;
  line-height: 1.8;
  background: var(--surface-light-alt);
  border-radius: var(--r-md);
}

.st-note ul {
  display: grid;
  gap: 8px;
}

.st-more {
  display: block;
  color: var(--gold-300);
  font-weight: 700;
  text-align: center;
  text-underline-offset: 5px;
}

/* حساب الجمل: one tile per counted letter, in reading order. */
.jm-letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.jm-letters li {
  display: grid;
  min-width: 46px;
  padding: 6px 4px;
  text-align: center;
  background: #0a0e2a99;
  border: 1px solid var(--line-dark);
  border-radius: 12px;
}

.jm-letter {
  color: var(--on-dark);
  font-family: var(--font-display);
  font-size: 1.375rem;
  line-height: 1.5;
}

.jm-value {
  color: var(--gold-300);
  font-size: 0.875rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.st-cta {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-block-start: 8px;
  padding-block-start: 16px;
  color: var(--on-dark-2);
  text-align: center;
  border-block-start: 1px solid var(--line-dark);
}

.st-cta .cta {
  width: 100%;
  max-width: 26rem;
}

/* ---------- Explainer, tables, links ---------- */

.st-about {
  display: grid;
  gap: 12px;
  margin-block-start: clamp(40px, 8vw, 64px);
  color: var(--on-dark-2);
}

.st-about h2,
.st-links h2 {
  color: var(--gold-400);
  font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2rem);
}

.st-ts3a {
  padding: 12px 16px;
  background: var(--surface-dark);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-md);
}

.st-ts3a a,
.st-about a {
  color: var(--gold-300);
  text-underline-offset: 4px;
}

.st-details summary {
  min-height: 44px;
  padding-block: 8px;
  color: var(--gold-300);
  font-weight: 700;
  cursor: pointer;
}

.st-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-md);
}

.st-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.st-table th,
.st-table td {
  padding: 8px 12px;
  text-align: start;
  border-block-end: 1px solid var(--line-dark);
}

.st-table thead th {
  color: var(--gold-400);
  background: var(--surface-dark);
}

.st-table tbody th {
  color: var(--on-dark);
  font-weight: 700;
}

.st-table-num td,
.st-table-num tbody th {
  text-align: center;
}

.st-table-num tbody th {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.st-diff td {
  color: var(--gold-300);
  font-weight: 700;
}

.st-links {
  margin-block-start: clamp(40px, 8vw, 64px);
}

.st-links ul {
  display: grid;
  gap: 10px;
  margin-block-start: 14px;
}

.st-links a {
  display: block;
  min-height: 48px;
  padding: 12px 16px;
  color: var(--on-dark);
  font-weight: 700;
  text-decoration: none;
  background: var(--surface-dark);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-md);
}

.st-links a:hover {
  border-color: #e4bf7c80;
}

@media (min-width: 720px) {
  .st-links ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 359px) {
  .st-date {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .st-field-year,
  .st-field-wide {
    grid-column: 1 / -1;
  }
}

@media (forced-colors: active) {
  .st-switch input:checked + span {
    outline: 2px solid Highlight;
  }
}

.st-date-hijri {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1.3fr);
}
