/**
 * platform.css — what the platform's own pages need on top of the shared kit:
 * the two-panel auth screen, the home tiles, and the user-management modal.
 */

/* ── Auth screens ────────────────────────────────────────────────────────── */

.auth-body { background: var(--s-surface); }

/* An even split, as the old TMS login had: brand on the left, form on the
   right. The proportions, the deep navy and the placement of the wordmark are
   what people recognise, so they are kept exactly. */
.auth-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-shell-single { grid-template-columns: 1fr; }

.auth-visual {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 60px;
  background: #111827;
  color: #fff;
  overflow: hidden;
}
/* The gradient the old screen used: two coloured pools over a navy diagonal.
   The first pool takes the tenant's own colour, so a second client is not
   wearing this one's blue. */
.auth-visual-wash {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 10% 20%, color-mix(in srgb, var(--sight-primary) 80%, transparent) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, .8) 0%, transparent 40%),
    linear-gradient(135deg, #1e1b4b 0%, #1e3a8a 100%);
  pointer-events: none;
}
.auth-visual-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100%;
}
/* margin-top:auto pushes the words to the foot of the panel, under the logo. */
.auth-visual h1 {
  margin: 0 0 20px; margin-top: auto;
  font-size: 3rem; line-height: 1.1; font-weight: 700; letter-spacing: -.02em;
}
.auth-visual p { margin: 0; max-width: 400px; font-size: 1.1rem; line-height: 1.5; opacity: .8; }

.auth-tailored {
  margin-top: 40px;
  font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; opacity: .5;
}

.auth-logo { display: flex; align-items: center; margin-bottom: 40px; font-size: 20px; font-weight: 680; }
.auth-logo img { width: 220px; max-width: 100%; object-fit: contain; }
/* A logo drawn in dark ink for a white page has to be knocked out to sit on
   the navy. A tenant whose logo is already light sets logoOnDark: "as-is". */
.auth-logo.is-inverted img { filter: brightness(0) invert(1); }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 392px; }
.auth-card h2 { margin: 0 0 5px; font-size: 23px; font-weight: 670; color: var(--s-ink); letter-spacing: -.01em; }
.auth-sub { margin: 0 0 24px; color: var(--s-muted); font-size: 13.5px; }

.auth-mobile-logo { display: none; margin-bottom: 22px; }
.auth-mobile-logo img { max-height: 46px; max-width: 180px; object-fit: contain; }

.auth-password { position: relative; }
.auth-password .s-input { padding-right: 42px; }
.auth-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: none; border: 0; border-radius: 6px;
  color: var(--s-faint); cursor: pointer;
}
.auth-eye:hover { color: var(--s-text); background: var(--s-line-soft); }

.auth-error {
  margin: 0 0 14px; padding: 10px 12px;
  background: var(--s-danger-soft); color: var(--s-danger);
  border: 1px solid #fecaca; border-radius: var(--s-radius-sm);
  font-size: 13px;
}
.auth-note {
  margin: 0 0 14px; padding: 10px 12px;
  background: var(--s-ok-soft); color: var(--s-ok);
  border: 1px solid #bbf7d0; border-radius: var(--s-radius-sm);
  font-size: 13px;
}

.auth-link {
  display: block; width: 100%; margin-top: 14px; padding: 6px;
  background: none; border: 0;
  font: inherit; font-size: 13px; color: var(--s-muted); text-align: center; cursor: pointer;
  border-radius: 6px;
}
.auth-link:hover { color: var(--sight-primary); background: var(--s-line-soft); }

/* Who built it, centred under the form, with their mark — as the old page had
   it. No border: the old one had none, and the rule drew the eye to the least
   important thing on the screen. */
.auth-foot {
  margin-top: 40px;
  text-align: center;
  font-size: .75rem; color: var(--s-faint);
}
.auth-foot p { margin: 0; }
.auth-vendor-logo {
  display: block; margin: 10px auto 0;
  height: 50px; width: auto;
  opacity: .8;
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-mobile-logo { display: block; }
}

/* ── Home ────────────────────────────────────────────────────────────────── */

/* The home page sits in the right-hand panel of the same two-panel shell as
   the sign-in screen, so it is wider than the login card but bounded the same
   way. The tiles stack in one column: two apps side by side in a half-width
   panel are narrower than the words in them. */
.home-panel { align-items: start; padding: 56px 40px; }
.home-card { width: 100%; max-width: 480px; margin: auto 0; }

.home-tiles { display: grid; gap: 14px; }

.home-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 32px; padding-top: 18px;
  border-top: 1px solid var(--s-line);
}
.home-foot-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.home-foot-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.home-foot-meta strong { font-size: 13.5px; color: var(--s-ink); font-weight: 640; }
.home-foot-meta span { font-size: 11.5px; color: var(--s-muted); }

@media (max-width: 900px) {
  .home-panel { padding: 32px 20px; }
  .home-card { max-width: none; }
}

.home-welcome { margin-bottom: 24px; }
.home-welcome h1 { margin: 0 0 4px; font-size: 25px; font-weight: 680; color: var(--s-ink); letter-spacing: -.015em; }
.home-welcome p { margin: 0; color: var(--s-muted); font-size: 14px; }

.home-tile {
  display: flex; flex-direction: column;
  background: var(--s-surface);
  border: 1px solid var(--s-line); border-radius: var(--s-radius);
  box-shadow: var(--s-shadow);
  overflow: hidden;
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
.home-tile:hover { box-shadow: var(--s-shadow-lg); transform: translateY(-1px); border-color: #d7dbe0; }

.home-tile-main {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 18px; text-decoration: none; color: inherit; flex: 1;
}
.home-tile-icon {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 10px;
  background: var(--sight-primary-soft); color: var(--sight-primary);
}
.home-tile-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.home-tile-name { font-size: 15.5px; font-weight: 660; color: var(--s-ink); }
.home-tile-blurb { font-size: 12.5px; color: var(--s-muted); line-height: 1.5; }

.home-tile-actions {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 9px 12px;
  border-top: 1px solid var(--s-line-soft);
  background: #fcfcfd;
}
.home-tile-actions a {
  padding: 5px 9px; border-radius: 6px;
  font-size: 12.5px; color: var(--s-muted); text-decoration: none;
}
.home-tile-actions a:hover { background: var(--s-line-soft); color: var(--sight-primary); }

.home-tile-admin .home-tile-icon { background: var(--s-line-soft); color: var(--s-text); }

.home-skeleton {
  height: 138px; border-radius: var(--s-radius);
  background: linear-gradient(90deg, #f1f3f5 25%, #e9ecef 37%, #f1f3f5 63%);
  background-size: 400% 100%;
  animation: home-shimmer 1.3s ease infinite;
}
@keyframes home-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── Users ───────────────────────────────────────────────────────────────── */

.user-name { font-weight: 570; color: var(--s-ink); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--s-surface);
  border-radius: 12px; box-shadow: var(--s-shadow-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 40px);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--s-line);
}
.modal-head h2 { margin: 0; flex: 1; font-size: 16px; font-weight: 660; color: var(--s-ink); }
.modal-head .s-linkbtn { font-size: 21px; line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px; border-top: 1px solid var(--s-line); background: #fcfcfd;
  border-radius: 0 0 12px 12px;
}

.access-set { margin: 4px 0 0; padding: 14px; border: 1px solid var(--s-line); border-radius: var(--s-radius-sm); }
.access-set legend { padding: 0 6px; font-size: 12px; font-weight: 620; color: var(--s-muted); text-transform: uppercase; letter-spacing: .04em; }
.access-set .s-field:last-of-type { margin-bottom: 0; }
#app-rows.is-dimmed { opacity: .45; pointer-events: none; }

.link-box {
  margin-top: 18px; padding: 14px;
  background: var(--sight-primary-soft);
  border: 1px solid var(--s-line); border-radius: var(--s-radius-sm);
}
.link-box strong { display: block; font-size: 13px; color: var(--s-ink); margin-bottom: 3px; }
.link-box .s-hint { display: block; margin-bottom: 9px; }
.link-row { display: flex; gap: 8px; }
.link-row .s-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

/* ── Moving between the sign-in screen and home ──────────────────────────── */
/*
 * These are two separate documents that happen to be drawn the same way: the
 * brand panel on the left, something on the right. Signing in used to be a
 * white flash and a new page. A cross-document view transition makes the left
 * panel persist — the browser matches it by name across the navigation — while
 * the right side hands over from the form to your apps.
 *
 * Browsers without view transitions navigate exactly as they did before. There
 * is no script behind this and nothing to fall back to.
 */
@view-transition { navigation: auto; }

.auth-visual { view-transition-name: sight-brand; }
.auth-panel { view-transition-name: sight-panel; }

/* The brand panel must not move at all — it is the fixed thing the right side
   changes against. Naming it means the browser matches it across the two
   documents; the rest of this stops it being animated once matched.
   Hiding the outgoing image rather than cross-fading is what keeps it from
   flickering: with both images present and neither animated, they sit on top
   of each other. */
::view-transition-group(sight-brand) { animation-duration: 0s; }
::view-transition-image-pair(sight-brand) { isolation: none; }
::view-transition-old(sight-brand) { display: none; }
::view-transition-new(sight-brand) { animation: none; opacity: 1; }

::view-transition-old(sight-panel) { animation: sight-panel-out .22s ease both; }
::view-transition-new(sight-panel) { animation: sight-panel-in .36s cubic-bezier(.22, 1, .36, 1) both; }

@keyframes sight-panel-out {
  to { opacity: 0; transform: translateY(-8px) scale(.985); }
}
@keyframes sight-panel-in {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to { opacity: 1; transform: none; }
}

/* ── Arriving at the sign-in screen ──────────────────────────────────────── */

/* Only on the sign-in document. The home page shares this markup, and without
   the scope its brand panel re-animated on arrival — which is the opposite of
   the left side holding still. */
.is-signin .auth-visual-inner > * { animation: sight-rise .5s cubic-bezier(.22, 1, .36, 1) both; }
.is-signin .auth-visual-inner > *:nth-child(1) { animation-delay: .04s; }
.is-signin .auth-visual-inner > *:nth-child(2) { animation-delay: .10s; }
.is-signin .auth-visual-inner > *:nth-child(3) { animation-delay: .15s; }
.is-signin .auth-visual-inner > *:nth-child(4) { animation-delay: .19s; }

.is-signin .auth-card { animation: sight-rise .45s cubic-bezier(.22, 1, .36, 1) .06s both; }

@keyframes sight-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Someone who has asked for less movement gets none of this — the page simply
   appears, which is what they asked for. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .is-signin .auth-visual-inner > *,
  .is-signin .auth-card { animation: none; }
}
