/* Copyright 2026 The Chromium Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

/* #css_wrapper_metadata_start
 * #type=style-lit
 * #import=chrome://resources/cr_elements/cr_icons_lit.css.js
 * #import=//bookmarks-side-panel.top-chrome/shared/sp_shared_style.css.js
 * #scheme=relative
 * #include=cr-icons-lit sp-shared-style
 * #css_wrapper_metadata_end */

#header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  margin: 0 14px;
}

#navigation-container {
  display: grid;
  grid-template-areas: 'left-area';
  flex: 1;
  min-width: 0;
  height: 100%;
}

#actions-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

#root-header {
  grid-area: left-area;
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: translateX(0);
}

#root-header h1 {
  color: var(--cr-primary-text-color);
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#actions-container .metadata {
  color: var(--cr-secondary-text-color);
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 400;
  line-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-inline-end: 8px;
}

#folder-header {
  grid-area: left-area;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  margin: 0;
}

#root-header.active,
#folder-header.active {
  opacity: 1;
  pointer-events: auto;
}

cr-icon-button {
  --cr-icon-button-icon-size: 16px;
  --cr-icon-button-size: 24px;
  margin: 0;
}

#sortMenu cr-icon {
  height: 20px;
  width: 20px;
}

cr-icon[invisible] {
  visibility: hidden;
}

.dropdown-item {
  gap: 4px;
}

#title-container {
  display: grid;
  grid-template-areas: 'title-area';
  position: relative;
  overflow: hidden;
  width: 100%;
  z-index: 2;
  pointer-events: none;
  margin-inline-start: 0;
  padding-inline-start: 0;
}

#title-container[has-back-button] {
  margin-inline-start: -24px;
  padding-inline-start: 24px;
}

#title-container.direction-forward,
#title-container.direction-backward {
  overflow: visible;
}

.title-span {
  grid-area: title-area;
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transform: translateX(0);
}

.title-span.active {
  opacity: 1;
  pointer-events: auto;
}

/*
 * Subfolder-to-Subfolder Navigation (within #title-container):
 * - Forward (deeper folder): Outgoing parent title slides out to the right,
 *   while the incoming child title slides in from the left.
 * - Backward (parent folder): Outgoing child title fades out, while the
 *   incoming parent title slides in from the right.
 */
#title-container.direction-forward .title-span.active.transitioning {
  animation: title-slide-in-from-left 200ms ease-out forwards;
}

#title-container.direction-forward .title-span.transitioning:not(.active) {
  animation: title-slide-out-to-right 200ms ease-out forwards;
}

#title-container.direction-backward .title-span.active.transitioning {
  animation: title-slide-in-from-right 200ms ease-out forwards;
}

#title-container.direction-backward .title-span.transitioning:not(.active) {
  animation: title-fade-out 200ms ease-out forwards;
}

/*
 * Root-to-Folder Navigation Swaps (swapping between #root-header and
 * #folder-header):
 * - Forward (All Bookmarks -> Folder): Outgoing root header ("All Bookmarks")
 *   slides out to the right, while the incoming folder header slides in
 *   from the left.
 * - Backward (Folder -> All Bookmarks): Outgoing folder header fades out
 *   in place, while the incoming root header slides in from the right.
 */
#navigation-container.direction-forward #root-header.transitioning {
  animation: title-slide-out-to-right 200ms ease-out forwards;
}

#navigation-container.direction-forward #folder-header.transitioning {
  animation: title-fade-in 200ms ease-out forwards;
}

#navigation-container.direction-backward #folder-header.transitioning {
  animation: title-fade-out 200ms ease-out forwards;
}

#navigation-container.direction-backward #root-header.transitioning {
  animation: title-slide-in-from-right 200ms ease-out forwards;
}

@keyframes title-slide-in-from-left {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes title-slide-out-to-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes title-slide-in-from-right {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes title-slide-out-to-left {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}
@keyframes title-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes title-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
