/*
 * Hub (Rail) og startmenu (Proceslinje). Samme panel, placeret forskelligt.
 */

.launcher {
  position: fixed;
  top: calc(12px + var(--safe-top));
  bottom: calc(12px + var(--safe-bottom));
  left: calc(var(--rail-width) + 24px + var(--safe-left));
  z-index: var(--z-launcher);
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, calc(100vw - var(--rail-width) - 48px));
  padding: 20px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-raised);
  transform-origin: left center;
  animation: pop-in 0.18s ease-out;
}

.launcher__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.launcher__subtitle {
  margin: -10px 0 0;
  color: var(--color-ink-2);
}

.launcher__search {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-ink);
}

.launcher__heading {
  font-size: 13px;
  font-weight: 600;
}

.launcher__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

/* Overskrifter og seneste filer hører kun til startmenuen. */
.launcher__heading,
.launcher__recent {
  display: none;
}

.launcher__recent-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.launcher__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--color-line);
}

.launcher__user {
  flex: 1;
  min-width: 0;
}

.launcher__plan {
  display: block;
  color: var(--color-ink-2);
}

/* ---------- App i gitteret ---------- */

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}

.app-tile:hover,
.app-tile:focus-visible {
  background: var(--color-surface-2);
}

/* ---------- Seneste fil ---------- */

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.recent-item:hover {
  background: var(--color-surface-2);
}

.recent-item .app-icon {
  --app-icon-size: 32px;
  --app-icon-glyph: 16px;
}

.recent-item .app-icon::after {
  display: none;
}

.recent-item__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item__meta {
  display: block;
  color: var(--color-ink-2);
}

/* ---------- Skift layout ---------- */

.layout-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.layout-switch__text {
  flex: 1;
  min-width: 0;
}

.layout-switch__hint {
  display: block;
  color: var(--color-ink-2);
}

/* ---------- Som startmenu i Proceslinje ---------- */

:root[data-layout='bar'] .launcher {
  top: auto;
  bottom: calc(64px + var(--safe-bottom));
  left: 50%;
  gap: 14px;
  width: min(620px, calc(100vw - 24px));
  height: auto;
  max-height: calc(100% - 90px);
  padding: 24px;
  border-radius: var(--radius-md);
  transform: translateX(-50%);
  animation: rise-in 0.2s ease-out;
  backdrop-filter: blur(30px);
}

:root[data-layout='bar'] .launcher__title,
:root[data-layout='bar'] .launcher__subtitle {
  display: none;
}

:root[data-layout='bar'] .launcher__heading,
:root[data-layout='bar'] .launcher__recent {
  display: block;
}

:root[data-layout='bar'] .launcher__recent {
  min-height: 0;
  overflow: auto;
}

:root[data-layout='bar'] .launcher__recent .launcher__heading {
  margin-bottom: 8px;
}

:root[data-layout='bar'] .launcher__grid {
  flex: none;
  grid-template-columns: repeat(6, 1fr);
  max-height: 230px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translate(-50%, 18px);
  }
}

/* ---------- Mobil ---------- */

@media (width <= 640px) {
  .launcher {
    right: calc(10px + var(--safe-right));
    bottom: calc(84px + var(--safe-bottom));
    left: calc(10px + var(--safe-left));
    width: auto;
  }

  :root[data-layout='bar'] .launcher {
    right: 10px;
    bottom: calc(62px + var(--safe-bottom));
    left: 10px;
    width: auto;
    height: auto;
    transform: none;
    animation: none;
  }

  :root[data-layout='bar'] .launcher__grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .launcher__recent-list {
    grid-template-columns: 1fr;
  }
}
