/* The portal shell: a panel of apps on the left, the chosen app in a frame on the right.
   Built on ds/tokens.css and ds/bundle.css (the Galebach App Design System). */

:root { --panel-w: 248px; --rail-w: 60px; --bar-h: 52px; }
html, body { height: 100%; }
body { overflow: hidden; }
[hidden] { display: none !important; }

/* ---- the firm mark: wordmark with the client under it ---- */
.mark { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mark b { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.mark span { font-size: 12px; color: var(--mute); white-space: nowrap; }

/* ---- the sign-in gate ---- */
.gate { min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 40px; box-sizing: border-box; overflow: auto; }
.gate-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-4); padding: var(--space-24); box-sizing: border-box; }
.gate-card h1 { font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: var(--space-24) 0 var(--space-6); }
.gate-msg { color: var(--ink2); margin: 0 0 var(--space-16); }
.gate-msg:empty { display: none; }
.gate-slot { display: flex; justify-content: center; gap: var(--space-8); flex-wrap: wrap; }
.gate-slot:empty { display: none; }
/* Clerk's form brings its own card; flatten it into ours. */
.gate-card .cl-cardBox, .gate-card .cl-card { box-shadow: none !important; border: 0 !important; }

/* ---- the shell ---- */
.shell { display: flex; height: 100%; }
.topbar { display: none; }

.panel { flex: 0 0 var(--panel-w); width: var(--panel-w); display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--line); box-sizing: border-box; min-height: 0; transition: flex-basis 160ms cubic-bezier(0.2, 0, 0, 1), width 160ms cubic-bezier(0.2, 0, 0, 1); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); padding: var(--space-14) var(--space-10) var(--space-14) var(--space-16); border-bottom: 1px solid var(--line); min-height: 64px; box-sizing: border-box; }
.panel .ico, .topbar .ico { flex: 0 0 auto; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: none; color: var(--ink2); border-radius: var(--radius-4); cursor: pointer; padding: 0; }
.panel .ico:hover, .topbar .ico:hover { border-color: var(--line); background: var(--page); }

.apps { display: flex; flex-direction: column; gap: 2px; padding: var(--space-10) var(--space-8); flex: 1 1 auto; overflow-y: auto; }
.apps a { position: relative; display: flex; align-items: center; gap: var(--space-12); min-height: 40px; padding: 0 var(--space-10); border-radius: var(--radius-4); color: var(--ink2); font-weight: 500; text-decoration: none; white-space: nowrap; }
.apps a svg { flex: 0 0 auto; color: var(--mute); }
.apps a span { overflow: hidden; text-overflow: ellipsis; }
.apps a:hover { background: var(--page); color: var(--ink); text-decoration: none; }
.apps a[aria-current="page"] { background: var(--blue-bg); color: var(--blue-d); font-weight: 600; }
.apps a[aria-current="page"] svg { color: var(--blue); }
.apps a[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 2px; background: var(--blue); }

.account { border-top: 1px solid var(--line); padding: var(--space-10) var(--space-8) var(--space-12); display: flex; flex-direction: column; gap: 2px; }
.account-who { padding: var(--space-4) var(--space-10); font-size: 12.5px; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who small { display: block; color: var(--gap); font-size: 12px; }
.account-out { display: flex; align-items: center; gap: var(--space-12); min-height: 36px; padding: 0 var(--space-10); border: 0; background: none; color: var(--mute); border-radius: var(--radius-4); cursor: pointer; text-align: left; white-space: nowrap; font-size: 13px; }
.account-out svg { flex: 0 0 auto; }
.account-out:hover { background: var(--page); color: var(--ink); }

/* Collapsed: a rail of icons, the toggle on top. */
.shell.rail .panel { flex-basis: var(--rail-w); width: var(--rail-w); }
.shell.rail .panel-head { padding: var(--space-14) 0; justify-content: center; }
.shell.rail .panel-head .mark,
.shell.rail .apps a span,
.shell.rail .account-who,
.shell.rail .account-out span { display: none; }
.shell.rail .apps a, .shell.rail .account-out { justify-content: center; padding: 0; }

/* The stage: one frame per app, kept once loaded, only the chosen one shown. */
.stage { flex: 1 1 auto; min-width: 0; position: relative; background: var(--page); }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--page); }

/* Phone width: a top bar, and the panel becomes a drawer over the page. */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .topbar { display: flex; align-items: center; gap: var(--space-10); height: var(--bar-h); flex: 0 0 var(--bar-h); padding: 0 var(--space-16) 0 var(--space-8); border-bottom: 1px solid var(--line); background: var(--card); box-sizing: border-box; }
  .topbar .mark { flex: 1 1 auto; overflow: hidden; }
  .bar-now { font-size: 13px; font-weight: 600; color: var(--blue-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
  .panel, .shell.rail .panel { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); flex-basis: auto; transform: translateX(-100%); transition: transform 160ms cubic-bezier(0.2, 0, 0, 1); visibility: hidden; }
  .shell.open .panel { transform: none; visibility: visible; }
  #toggleBtn { display: none; }
  .shell.rail .panel-head { padding: var(--space-14) var(--space-10) var(--space-14) var(--space-16); justify-content: space-between; }
  .shell.rail .panel-head .mark, .shell.rail .account-who { display: flex; }
  .shell.rail .account-who { display: block; }
  .shell.rail .apps a span, .shell.rail .account-out span { display: inline; }
  .shell.rail .apps a, .shell.rail .account-out { justify-content: flex-start; padding: 0 var(--space-10); }
  .scrim { position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
  .stage { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none !important; }
}
