/* =============================================================================
   Refera — mock sign-in screen + account chip (SHELL chrome, js/auth.js)
   -----------------------------------------------------------------------------
   The app's front door, at the marketing site's bar: dot-grid paper (the body
   already wears it), one centred white window — hairline border, macOS window
   chrome, the deep overlay shadow — carrying the wordmark, a mono eyebrow, a
   Operational sans headline, two crafted fields, the ink-pill primary and the ghost
   demo path. Everything here is DEMONSTRATION-ONLY: the amber mono line on
   the card says so in as many words.

   html.is-auth hides the app shell while the front door is up (set inline in
   index.html before first paint, so neither state ever flashes).
   ========================================================================== */

/* ------------------------------------------------- shell visibility switch */
html.is-auth .topbar,
html.is-auth .tabbar,
html.is-auth .more-scrim,
html.is-auth .more-sheet,
html.is-auth #view,
html.is-auth .foot { display: none !important; }

/* ------------------------------------------------------------- the screen */
.login-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px var(--gutter) calc(32px + var(--safe-bottom));
}
.login-card-wrap { width: min(400px, 100%); }

/* the sign-in window — the site's .appwin frame */
.login-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-glass);
  overflow: hidden;
  box-shadow: var(--overlay-shadow);
}
@media (prefers-reduced-motion: no-preference) {
  .login-card { animation: rise-in var(--dur-slow) var(--ease-out) both; }
  .login-foot { animation: rise-in var(--dur-slow) var(--ease-out) both; animation-delay: 90ms; }
}

/* window bar: traffic lights + centred mono title (site .appwin-bar) */
.login-bar {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  padding: 12px 16px; min-height: 40px;
  background: var(--bar);
  border-bottom: 1px solid var(--hair);
}
.login-bar .tl { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.login-bar .tl-r { background: #FF5F57; }
.login-bar .tl-y { background: #FEBC2E; }
.login-bar .tl-g { background: #28C840; }
.login-bar-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em;
  color: var(--ink3); white-space: nowrap;
}

/* ------------------------------------------------------------------- body */
.login-body { padding: 30px 30px 26px; }

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-mark { display: flex; flex: none; }
.login-mark svg { border-radius: 8px; }
.login-wordmark {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  letter-spacing:0; line-height: 1;
}

.login-eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink3); margin-bottom: 8px;
}
.login-title {
  font-size: 23px; font-weight: 500; letter-spacing:0; line-height: 1.2;
  margin-bottom: 22px;
}

/* ------------------------------------------------------------------ fields */
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink3);
}
.login-input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  font: 400 14px/1.4 var(--font); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair-dark); border-radius: var(--r-input);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.login-input::placeholder { color: var(--ink3-decor); }
.login-input:hover { border-color: var(--ink3); }
.login-input:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .13);
}

.login-submit { width: 100%; margin-top: 6px; min-height: 44px; }
.login-passkey { width: 100%; min-height: 44px; margin-top: 10px; }

/* mono "or" divider between the two paths */
.login-or {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink3);
}
.login-or::before, .login-or::after {
  content: ''; flex: 1; height: 1px; background: var(--hair);
}

/* the one-click demo path — prominent ghost pill with a travelling arrow */
.login-demo { width: 100%; min-height: 44px; gap: 8px; }
.login-demo-arrow { display: flex; }
.login-demo-arrow svg { transition: transform var(--dur-fast) var(--ease-out); }
.login-demo:hover .login-demo-arrow svg { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) {
  .login-demo:hover .login-demo-arrow svg { transform: none; }
}

/* demonstration posture, in as many words (amber mono — the demo-chip voice).
   NO text-transform: the line must render exactly as written. */
.login-demo-note {
  margin-top: 18px; text-align: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--amber);
}

/* quiet footer under the window */
.login-foot {
  margin-top: 20px; text-align: center;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
}
.login-foot a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 8px; color: var(--ink3);
}
.login-foot a:hover { color: var(--teal); }

/* ------------------------------------------------------------------- 390px */
@media (max-width: 719px) {
  .login-screen { padding: 20px 16px calc(24px + var(--safe-bottom)); }
  .login-body { padding: 26px 22px 22px; }
}

/* ==================================================== WORKSPACE SWITCHER */
/* Top-left: the Refera R mark + current practice name + chevron, opening a
   menu to switch/add a practice (js/workspace.js). This is the primary
   identity in the console (Attio-style), so the account chip on the right
   carries the PERSON, not a duplicate practice name. */
.ws-switch {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 38px; max-width: min(44vw, 340px);
  margin-left: -3px; padding: 4px 8px 4px 5px;
  background: none; color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.ws-switch:hover { background: var(--surface); border-color: var(--hair); }
.ws-switch[aria-expanded="true"] { background: var(--surface); border-color: var(--hair-dark); }
.ws-switch .brand-mark { flex: none; border-radius: 8px; }
.ws-clinic-mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; overflow: hidden; border-radius: 7px;
  border: 1px solid var(--tenant-brand-edge, var(--hair));
  background: var(--surface); color: var(--tenant-brand, var(--teal));
  font-family: var(--mono); font-size: 9px; font-weight: 700;
}
.ws-clinic-mark img, .ws-item-avatar img {
  width: 100%; height: 100%; display: block; object-fit: contain;
}
.ws-brand-cross {
  flex: none; color: var(--ink3); font-size: 12px; line-height: 1;
}
.ws-name {
  font-family: var(--display); font-size: 16px; font-weight: 600;
  letter-spacing:0; line-height: 1; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.ws-chev {
  flex: none; color: var(--ink3);
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ws-switch:hover .ws-chev { color: var(--ink2); }
.ws-switch[aria-expanded="true"] .ws-chev { transform: rotate(180deg); color: var(--ink2); }

.ws-menu {
  position: fixed; z-index: 80;
  top: calc(var(--safe-top) + var(--topbar-h) + 8px);
  left: var(--gutter);
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-card); box-shadow: var(--overlay-shadow);
  padding: 8px;
}
.ws-menu:not([hidden]) { animation: account-pop var(--dur) var(--spring-in); }
.ws-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 12px; border-bottom: 1px solid var(--hair);
}
.ws-head-mark, .ws-item-avatar {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--teal); color: #fff;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}
.ws-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-head-name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-head-sub {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink3);
}
.ws-group-label {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink3);
  margin: 10px 10px 4px;
}
.ws-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-input);
  background: none; text-align: left; color: var(--ink); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.ws-item:hover { background: var(--paper); text-decoration: none; }
.ws-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.ws-item-name {
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-sub {
  font-size: 11.5px; color: var(--ink2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-item-tick { flex: none; color: var(--teal); display: flex; }
.ws-ico {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--paper); color: var(--ink2); border: 1px solid var(--hair);
}
.ws-item-action:hover .ws-ico { color: var(--teal); border-color: var(--tone-teal-border); }
.ws-div { height: 1px; background: var(--hair); margin: 6px 4px; }

/* =========================================================== ACCOUNT CHIP */
/* Signed-in state on the topbar (right): initials avatar + the person, mono. */
.account-slot { display: contents; }

.account-chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 4px 12px 4px 5px;
  background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--r-pill);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
.account-chip:hover { border-color: var(--hair-dark); background: var(--bar); }
.account-chip[aria-expanded="true"] { border-color: var(--ink); }
.account-avatar {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--pill-bg); color: var(--pill-fg);
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.06em;
}
.account-name {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

/* the small account menu (fixed under the topbar's right edge) */
.account-menu {
  position: fixed; z-index: 80;
  top: calc(var(--safe-top) + var(--topbar-h) + 8px);
  right: var(--gutter);
  width: min(280px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--r-card);
  box-shadow: var(--overlay-shadow);
  padding: 8px;
}
.account-menu:not([hidden]) { animation: account-pop var(--dur) var(--spring-in); }
@keyframes account-pop { from { transform: translateY(-8px); opacity: 0; } }
.account-who {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--hair);
}
.account-who-label {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink3);
}
.account-who-name { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.account-who-practice {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em;
  color: var(--ink2); margin-top: 1px;
}
.account-signout {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; text-align: left;
  font: 500 13.5px/1.2 var(--font); color: var(--ink);
  background: none; border: 0; border-radius: var(--r-input); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.account-signout:hover { background: var(--paper); }

@media (max-width: 719px) {
  .account-name { display: none; }
  .account-chip {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 4px;
    border-color: transparent;
    background: none;
  }
  .account-menu { right: 12px; top: calc(var(--safe-top) + var(--topbar-h) + 6px); }
  /* mobile: the switcher shrinks to the mark + chevron (tap target); the
     practice name lives in the menu and the Today header where there is room */
  .ws-name { display: none; }
  .ws-switch { gap: 5px; min-height: 44px; padding: 4px 6px; }
  .ws-menu { left: 12px; top: calc(var(--safe-top) + var(--topbar-h) + 6px); }
}
