/* ════════════════════════════════════════════════════════════════
   Spacii — shared cross-cutting CSS
   Loaded by every page. Page-specific CSS still lives in each file.
   ════════════════════════════════════════════════════════════════ */

/* ── Locale visibility primitives ──
   Each piece of localised copy is wrapped in <span class="en">...</span>
   <span class="zh">...</span> etc. The active locale class on <body>
   ('lang-zh', 'lang-ar', 'lang-hi', 'lang-ko') hides the others.
   English is the default — visible when no lang-* class is set.
*/
.zh, .ar, .hi, .ko { display: none !important; }

body.lang-zh .zh, body.lang-ar .ar, body.lang-hi .hi, body.lang-ko .ko { display: inline !important; }
body.lang-zh .en, body.lang-ar .en, body.lang-hi .en, body.lang-ko .en { display: none !important; }

/* Block-level variants */
body.lang-zh div.zh, body.lang-zh p.zh, body.lang-zh h1.zh, body.lang-zh h2.zh,
body.lang-zh h3.zh, body.lang-zh h4.zh, body.lang-zh h5.zh, body.lang-zh li.zh,
body.lang-zh small.zh, body.lang-zh strong.zh, body.lang-zh label.zh, body.lang-zh button.zh { display: block !important; }
body.lang-zh button.zh, body.lang-zh strong.zh, body.lang-zh label.zh { display: inline-block !important; }

body.lang-ar div.ar, body.lang-ar p.ar, body.lang-ar h1.ar, body.lang-ar h2.ar,
body.lang-ar h3.ar, body.lang-ar h4.ar, body.lang-ar h5.ar, body.lang-ar li.ar,
body.lang-ar small.ar, body.lang-ar strong.ar, body.lang-ar label.ar, body.lang-ar button.ar { display: block !important; }
body.lang-ar button.ar, body.lang-ar strong.ar, body.lang-ar label.ar { display: inline-block !important; }

body.lang-hi div.hi, body.lang-hi p.hi, body.lang-hi h1.hi, body.lang-hi h2.hi,
body.lang-hi h3.hi, body.lang-hi h4.hi, body.lang-hi h5.hi, body.lang-hi li.hi,
body.lang-hi small.hi, body.lang-hi strong.hi, body.lang-hi label.hi, body.lang-hi button.hi { display: block !important; }
body.lang-hi button.hi, body.lang-hi strong.hi, body.lang-hi label.hi { display: inline-block !important; }

body.lang-ko div.ko, body.lang-ko p.ko, body.lang-ko h1.ko, body.lang-ko h2.ko,
body.lang-ko h3.ko, body.lang-ko h4.ko, body.lang-ko h5.ko, body.lang-ko li.ko,
body.lang-ko small.ko, body.lang-ko strong.ko, body.lang-ko label.ko, body.lang-ko button.ko { display: block !important; }
body.lang-ko button.ko, body.lang-ko strong.ko, body.lang-ko label.ko { display: inline-block !important; }

/* RTL support for Arabic */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .nav-left, html[dir="rtl"] .nav-right { flex-direction: row-reverse; }

/* ── Spacii common toggle bar ──
   Compact group of language and theme buttons.
   Designed to slot into existing header right-side. */

.sp-toggles {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.sp-lang-sw {
  display: inline-flex;
  gap: 1px;
  background: var(--camel, #EDE6DC);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid var(--border, #DDD4C8);
}

.sp-lang-sw button {
  padding: 4px 9px;
  border: none;
  background: none;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  color: var(--brown-light, #A0907E);
  transition: all 0.18s ease;
  font-family: inherit;
  min-width: 28px;
  white-space: nowrap;
}

.sp-lang-sw button.active,
.sp-lang-sw button[aria-pressed="true"] {
  background: var(--cream, #FDFBF7);
  color: var(--brown, #2C2016);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.sp-lang-sw button:hover:not(.active) { color: var(--brown, #2C2016); }
.sp-lang-sw button:focus-visible { outline: 2px solid var(--accent, #8B5E3C); outline-offset: 2px; }

.sp-theme-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border, #DDD4C8);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--brown-mid, #6B5C4D);
  font-size: 0.95rem;
  transition: all 0.18s ease;
  padding: 0;
  font-family: inherit;
}
.sp-theme-btn:hover { border-color: var(--accent, #8B5E3C); color: var(--accent, #8B5E3C); }
.sp-theme-btn:focus-visible { outline: 2px solid var(--accent, #8B5E3C); outline-offset: 2px; }
.sp-theme-btn[data-theme-icon="sun"] .icon-sun { display: inline; }
.sp-theme-btn[data-theme-icon="sun"] .icon-moon { display: none; }
.sp-theme-btn[data-theme-icon="moon"] .icon-sun { display: none; }
.sp-theme-btn[data-theme-icon="moon"] .icon-moon { display: inline; }

/* ── Spacii back button ──
   Small icon button placed inside the page header.
   Uses history.back() but falls back to a configured page if no history. */
.sp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border, #DDD4C8);
  color: var(--brown-mid, #6B5C4D);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.sp-back:hover { border-color: var(--accent, #8B5E3C); color: var(--accent, #8B5E3C); }
.sp-back:focus-visible { outline: 2px solid var(--accent, #8B5E3C); outline-offset: 2px; }
.sp-back svg { width: 14px; height: 14px; }

/* ── Spacii common footer ──
   Visible on every page. */
.sp-footer {
  background: var(--cream, #FDFBF7);
  border-top: 1px solid var(--border, #DDD4C8);
  padding: 2.5rem 2rem 1.75rem;
  margin-top: 4rem;
  font-family: var(--sans, 'Inter', sans-serif);
  color: var(--brown-mid, #6B5C4D);
}
.sp-footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
}
.sp-footer-col h4 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brown, #2C2016);
  margin-bottom: 0.85rem;
}
.sp-footer-col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.sp-footer-col a { color: var(--brown-mid, #6B5C4D); font-size: 0.85rem; transition: color 0.18s ease; }
.sp-footer-col a:hover { color: var(--accent, #8B5E3C); }
.sp-footer-brand { font-family: var(--serif, 'DM Serif Display', serif); font-size: 1.2rem; color: var(--brown, #2C2016); margin-bottom: 0.5rem; }
.sp-footer-tag { font-size: 0.85rem; line-height: 1.6; max-width: 320px; }
.sp-footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border, #DDD4C8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--brown-light, #A0907E);
  flex-wrap: wrap;
  gap: 0.75rem;
}
@media (max-width: 768px) {
  .sp-footer-grid { grid-template-columns: 1fr 1fr; gap: 1.75rem; }
  .sp-footer { padding: 2rem 1.25rem 1.25rem; }
  .sp-footer-bottom { flex-direction: column; align-items: flex-start; }
}

/* ── Toast for ephemeral notifications ── */
.sp-toast-host {
  position: fixed;
  top: 80px;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1100;
  pointer-events: none;
}
.sp-toast {
  background: var(--brown, #2C2016);
  color: var(--cream, #FDFBF7);
  padding: 0.65rem 0.95rem;
  border-radius: 8px;
  font-size: 0.82rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  pointer-events: auto;
  animation: sp-toast-in 0.22s ease-out;
}
@keyframes sp-toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes sp-toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }
.sp-toast.leaving { animation: sp-toast-out 0.22s ease-in forwards; }

/* ── Skip-to-content link (accessibility) ── */
.sp-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brown, #2C2016);
  color: var(--cream, #FDFBF7);
  padding: 0.5rem 1rem;
  z-index: 9999;
  border-radius: 0 0 6px 6px;
  font-size: 0.82rem;
}
.sp-skip:focus { left: 0; }
