/* Application layout, landing split view, shell, and navigation. */

/* Define the root application frame and its custom type scale. */
#app {
  display: flex;
  flex-direction: row;
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--ks-text-default);
  background-size: cover;
  background-position: center;
  --ks-text-xs: 0.85rem;
  --ks-text-sm: 1rem;
  --ks-text-base: 1.1rem;
  --ks-text-lg: 1.25rem;
  --ks-text-xl: 1.4rem;
  --ks-text-2xl: 1.65rem;
  --ks-text-3xl: 2rem;
  --ks-text-4xl: 2.4rem;
  --ks-density-scale: 1;

  /* Keystone derives these at :root, so they never saw the scale above;
     declaring them again here makes tables, labels, and headings use it. */
  --ks-type-h1-size: var(--ks-text-4xl);
  --ks-type-h2-size: var(--ks-text-3xl);
  --ks-type-h3-size: var(--ks-text-2xl);
  --ks-type-h4-size: var(--ks-text-xl);
  --ks-type-h5-size: var(--ks-text-lg);
  --ks-type-h6-size: var(--ks-text-base);
  --ks-type-body-lg-size: var(--ks-text-lg);
  --ks-type-body-size: var(--ks-text-base);
  --ks-type-body-sm-size: var(--ks-text-sm);
  --ks-type-label-size: var(--ks-text-sm);
  --ks-type-caption-size: var(--ks-text-xs);
  --ks-type-code-size: var(--ks-text-sm);
  --ks-density-font: var(--ks-text-sm);
  --ks-density-font-xs: var(--ks-text-xs);
  --ks-density-font-lg: var(--ks-text-base);
}

/* Center the brand and supporting content in the landing-page rail. */
#app div#left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40%;
  height: 100%;
  margin: 0;
  padding: 40px;
  position: relative;
  background-color: var(--color-background-dark);
  color: rgb(255 255 255 / 90%);
}

/* Center the sign-in and sign-up forms in the landing-page content rail. */
#app div#right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 60%;
  height: 100%;
  margin: 0;
  padding: 8%;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(270deg, #4a5a7099 25%, #000000fe 155%),
    linear-gradient(45deg, #0d6efdf0 -5%, #3fa9ff99 75%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: darken;
}

/* Remove unnecessary label decoration inside the landing form. */
#app #right .ks-label {
  text-shadow: none;
}

/* Make the authenticated shell fill the viewport independently of the landing view. */
#app #app-shell {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Keep the shell row and its columns at a stable desktop split. */
#app .app-shell-row {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 0;
}

/* Reserve a fixed proportion for the application menu. */
#app .app-menu-col {
  width: 21%;
  flex: 0 0 auto;
}

/* Allow the page column to consume the remaining horizontal space. */
#app .app-page-col {
  min-width: 0;
  flex: 1 1 auto;
}

/* Style the dark application navigation rail. */
#app #app-menu {
  min-width: 100px;
  height: 100%;
  padding: 2rem 1.25rem 1.5rem;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgb(16 18 22 / 96%) 0%, rgb(25 28 34 / 94%) 100%);
  border-right: 1px solid rgb(255 255 255 / 8%);
  box-shadow: inset -1px 0 0 rgb(255 255 255 / 3%);
}

/* Provide a strong heading treatment for optional menu headings. */
#app #app-menu .ks-h2 {
  margin: 0 0 1.5rem;
  color: rgb(255 255 255 / 94%);
  font-size: clamp(2.4rem, 2vw, 4rem);
  line-height: 1;
  letter-spacing: -0.06em;
  font-weight: 700;
}

/* Present the workspace brand at the top of the navigation rail. */
#app .app-menu-brand {
  display: flex;
  align-items: center;
  margin: 0 0 1.75rem;
  padding: 0 0.25rem 1.35rem;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
}

/* Keep the brand mark legible against the dark navigation rail. */
#app .app-menu-logo,
#app .landing-logo {
  width: 16.5rem;
  max-width: 100%;
  height: auto;
}

/* Stack navigation items with a small, consistent rhythm. */
#app #nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Hide the mobile menu trigger until the responsive breakpoint. */
#app .mobile-menu-toggle {
  display: none;
}

/* Normalize navigation item list behavior. */
#app .ks-nav-item {
  margin: 0;
  list-style: none;
}

/* Create a readable, keyboard-friendly navigation link. */
#app .ks-nav-link {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.88rem 0.9rem;
  border-radius: 2px;
  color: rgb(255 255 255 / 80%);
  text-decoration: none;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

/* Align navigation icons with their text labels. */
#app .ks-nav-link i {
  width: 1.25rem;
  margin-top: 0.18rem;
  color: rgb(188 209 231 / 90%);
  font-size: 1.15rem;
  filter: drop-shadow(0 0 0.15rem rgb(255 255 255 / 18%));
}

/* Stack each navigation label and subtitle. */
#app .nav-link-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

/* Emphasize the primary navigation label. */
#app .nav-link-title {
  display: block;
  color: inherit;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 500;
}

/* Reduce the visual weight of supporting navigation text. */
#app .nav-link-subtitle {
  display: block;
  color: rgb(255 255 255 / 62%);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Give hover and keyboard focus a clear, subtle navigation affordance. */
#app .ks-nav-link:hover,
#app .ks-nav-link:focus-visible {
  background: rgb(255 255 255 / 5%);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%);
  transform: translateX(2px);
  outline: none;
}

/* Brighten navigation details while a link is active or focused. */
#app .ks-nav-link:hover i,
#app .ks-nav-link:focus-visible i {
  color: #ffffff;
}

/* Brighten navigation descriptions while a link is active or focused. */
#app .ks-nav-link:hover .nav-link-subtitle,
#app .ks-nav-link:focus-visible .nav-link-subtitle {
  color: rgb(255 255 255 / 78%);
}

/* Mark the current navigation location without changing Keystone classes. */
#app .ks-nav-link.active {
  background: rgb(118 151 196 / 15%);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #3fa9ff;
}

/* Brighten navigation icons for the active destination. */
#app .ks-nav-link.active i {
  color: #ffffff;
}

/* Keep the page viewport independently scrollable inside the shell. */
#app #page-container {
  display: flex;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--ks-canvas);
  color: var(--ks-text-default);
}

/* Only the tab panel cross-fades when a tab changes. The rest of the
   page (menu, header, everything around the panel) holds still instead of
   fading out and back in with Keystone's whole-page snapshot. */
::view-transition-group(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { display: none; }
