/* التخطيط: العتبة (شاشة البدء) والمكتب ذو اللوحات الثلاث */

/* ═══════════════ العتبة ═══════════════ */
.threshold {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
}

/* حلقات متّحدة المركز تستعيد شكل الشعار في الخلفية */
.threshold-rings { position: absolute; inset: 0; pointer-events: none; z-index: -1; }
.threshold-rings span {
  position: absolute; left: 50%; top: 212px;
  border-radius: 50%;
  border: 1px solid var(--ring-line);
  transform: translate(-50%, -50%);
}
.threshold-rings span:nth-child(1) { width: 420px; height: 420px; }
.threshold-rings span:nth-child(2) { width: 780px; height: 780px; border-style: dashed; animation: slow-turn 180s linear infinite; }
.threshold-rings span:nth-child(3) { width: 1240px; height: 1240px; }
.threshold::after {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 212px;
  width: 520px; height: 520px; transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--logo-gold) 16%, transparent) 0%, transparent 62%);
  pointer-events: none;
}
@keyframes slow-turn { to { transform: translate(-50%, -50%) rotate(360deg); } }

.threshold-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "menu pill tools";
  align-items: center;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 32px);
}
.threshold-bar .menu-btn { grid-area: menu; justify-self: start; }
.threshold-bar .preview-pill { grid-area: pill; }
.threshold-bar .bar-tools { grid-area: tools; justify-self: end; }

.threshold-main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.threshold-main:focus { outline: none; }

.threshold-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 16px clamp(16px, 3vw, 32px) 22px;
  font-size: 12.5px; color: var(--faint);
}

/* ═══════════════ المكتب ═══════════════ */
.desk {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr) var(--status-h);
}

.desk-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "menu search tools";
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.desk-search { grid-area: search; justify-self: center; width: min(100%, 720px); }
.desk-bar .menu-btn { grid-area: menu; }
.desk-bar .bar-tools { grid-area: tools; }

.desk-body {
  --a-w: 360px;
  --l-w: 292px;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--a-w) minmax(0, 1fr) var(--l-w);
  gap: 12px;
  padding: 12px;
  transition: grid-template-columns .35s var(--ease-out);
}
.desk-body > * { grid-row: 1; min-height: 0; }
.pane-assistant, .rail-assistant { grid-column: 1; }
.pane-work { grid-column: 2; }
.pane-library, .rail-library { grid-column: 3; }

.pane-rail { display: none; }
.desk-body.no-assistant { --a-w: 48px; }
.desk-body.no-library { --l-w: 48px; }
.desk-body.no-assistant .pane-assistant,
.desk-body.no-library .pane-library { display: none; }
.desk-body.no-assistant .rail-assistant,
.desk-body.no-library .rail-library { display: flex; }

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
  overflow: hidden;
}

.status-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap; overflow: hidden;
}

.mobile-nav { display: none; }

/* ═══════════════ الاستجابة ═══════════════ */
@media (max-width: 1280px) {
  .desk-body { --a-w: 320px; --l-w: 264px; }
}

@media (max-width: 1080px) {
  .desk .conn { display: none; }
}

@media (max-width: 860px) {
  :root { --bar-h: auto; }

  .threshold-bar { grid-template-columns: 1fr auto; grid-template-areas: "menu tools"; }
  .threshold-bar .preview-pill { display: none; }
  .threshold-rings span, .threshold::after { top: 170px; }

  .desk { grid-template-rows: auto minmax(0, 1fr) auto; }
  .desk-bar {
    grid-template-columns: auto 1fr;
    grid-template-areas: "menu tools" "search search";
    row-gap: 10px;
    padding: 10px 12px 12px;
  }
  .desk-bar .bar-tools { grid-area: tools; justify-self: end; }
  .desk-search { grid-area: search; width: 100%; }

  .desk-body,
  .desk-body.no-assistant,
  .desk-body.no-library { grid-template-columns: minmax(0, 1fr); padding: 8px 8px 0; gap: 0; }
  .desk-body > * { grid-column: 1 !important; }
  .desk-body .pane { display: none !important; border-radius: var(--radius) var(--radius) 0 0; }
  .desk-body[data-mpane="assistant"] .pane-assistant,
  .desk-body[data-mpane="work"] .pane-work,
  .desk-body[data-mpane="library"] .pane-library { display: flex !important; }
  .desk-body .pane-rail { display: none !important; }
  .collapse-btn { display: none; }

  .status-bar { display: none; }

  .mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
}
