*, *::before, *::after { box-sizing: border-box; }

:root {
  --page-topbar-h: 3rem;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--page-topbar-h);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--ui-font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg-canvas);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* -------------------------------------------------------
   Language switching
------------------------------------------------------- */
.t-ar { display: none; }
html[lang="ar"] .t-en { display: none; }
html[lang="ar"] .t-ar { display: unset; }

/* -------------------------------------------------------
   App shell — full-width topbar above sidebar+main
------------------------------------------------------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* -------------------------------------------------------
   Topbar — spans full width
------------------------------------------------------- */
.page-topbar {
  height: var(--page-topbar-h);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--color-surface-default) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--color-border-subtle);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.crumbs strong {
  color: var(--color-text-primary);
  font-weight: 500;
}

.crumb-sep { opacity: 0.4; }

.topbar-controls {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.topbar-controls .ctrl-select { width: auto; }

/* -------------------------------------------------------
   Mobile nav — below topbar, hidden on desktop
------------------------------------------------------- */
.mobile-nav {
  display: none;
  flex-shrink: 0;
  overflow-x: auto;
  padding: 0.5rem 1rem;
  gap: 0.375rem;
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-surface-default);
  -webkit-overflow-scrolling: touch;
}

.mobile-nav-item {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.3125rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
  transition: background var(--motion-fast) var(--easing-standard),
              color var(--motion-fast) var(--easing-standard);
}

.mobile-nav-item:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
}

/* -------------------------------------------------------
   App body — sidebar + main
------------------------------------------------------- */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}

/* -------------------------------------------------------
   Sidebar
------------------------------------------------------- */
.side {
  position: sticky;
  top: var(--page-topbar-h);
  height: calc(100vh - var(--page-topbar-h));
  overflow-y: auto;
  border-inline-end: 1px solid var(--color-border-subtle);
  background: var(--color-surface-default);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-action-primary-bg);
  color: var(--color-action-primary-text);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.brand-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Theme select control */
.ctrl-select {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: var(--ui-font-sans);
  color: var(--color-text-primary);
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.4;
}

.ctrl-select:focus {
  outline: 2px solid var(--color-action-primary-bg);
  outline-offset: 1px;
}

.ctrl-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.25rem;
}

/* Toggle controls */
.ctrl-toggle {
  display: inline-flex;
  align-self: flex-start;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 1px;
}

.ctrl-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-family: var(--ui-font-sans);
  color: var(--color-text-secondary);
  cursor: pointer;
  line-height: 1.4;
  font-weight: 400;
  transition: background var(--motion-fast) var(--easing-standard),
              color var(--motion-fast) var(--easing-standard);
}

.ctrl-toggle button[aria-pressed="true"] {
  background: var(--color-surface-default);
  color: var(--color-text-primary);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Nav */
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  transition: background var(--motion-fast) var(--easing-standard),
              color var(--motion-fast) var(--easing-standard);
}

.nav-item:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
}

.side-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  letter-spacing: 0.04em;
}

/* -------------------------------------------------------
   Main column
------------------------------------------------------- */
.main { min-width: 0; }

.content {
  padding: 2rem 2.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* -------------------------------------------------------
   Hero — renamed from .hero to avoid daisyUI conflict
------------------------------------------------------- */
.page-hero {
  padding: 2rem;
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    circle at 1px 1px,
    color-mix(in srgb, var(--color-text-primary) 7%, transparent) 1px,
    transparent 1px
  );
  background-size: 14px 14px;
  pointer-events: none;
  -webkit-mask: linear-gradient(180deg, transparent 0%, black 30%, black 70%, transparent 100%);
  mask: linear-gradient(180deg, transparent 0%, black 30%, black 70%, transparent 100%);
}

.page-hero > * { position: relative; }

.page-hero-copy { max-width: 64ch; }

.page-hero-eyebrow {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin: 0 0 0.5rem;
}

.page-hero-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 0.625rem;
  color: var(--color-text-primary);
}

.page-hero-desc {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin: 0;
}

.page-hero-stats {
  display: flex;
  gap: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border-subtle);
  margin-top: 1.25rem;
}

/* renamed from .stat to avoid daisyUI conflict */
.page-stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.page-stat strong {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.page-stat span {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* -------------------------------------------------------
   Component sections
------------------------------------------------------- */
.component-section {
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5625rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-subtle);
}

.section-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.01em;
}

.section-link {
  font-size: 0.75rem;
  color: var(--color-action-primary-bg);
}

.section-link:hover { text-decoration: underline; }

iframe {
  width: 100%;
  min-height: 400px;
  border: 0;
  display: block;
}

/* -------------------------------------------------------
   Responsive — mobile
------------------------------------------------------- */
@media (max-width: 768px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .side { display: none; }

  .mobile-nav { display: flex; }

  .topbar-controls { display: flex; gap: 0.375rem; }

  .content {
    padding: 1rem 1rem 3rem;
    gap: 1rem;
  }

  .page-hero { padding: 1.25rem; }
  .page-hero-stats { gap: 1.25rem; }
}
