/* ==========================================================================
   Окна сервисов в разделе Open-source: интерактив и небольшая анимация
   ========================================================================== */

/* общий сброс для кнопок внутри окон (низкая специфичность: стили элементов важнее) */
:where(.app) button {
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

html:not(.js) :where(.app) button { cursor: default; }

.ui-caret {
  display: inline-block;
  width: 1px;
  height: 0.9rem;
  margin-left: 1px;
  background: var(--accent);
}

/* ---------- paperless-ngx ---------- */

.app--paperless .app-body { position: relative; }
.pl-query { color: var(--text); font-size: 0.82rem; }

.doc {
  width: 100%;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.doc:hover,
.doc.is-match { background: rgb(79 209 197 / 0.08); box-shadow: inset 0 0 0 1px rgb(79 209 197 / 0.25); }

.pl-view {
  position: absolute;
  inset: 0.5rem;
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #2c353d, #181d22);
  border: 1px solid rgb(79 209 197 / 0.3);
  border-radius: 12px;
  box-shadow: 0 20px 40px -20px rgb(0 0 0 / 0.8);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pl-view.is-open { opacity: 1; transform: none; }

.pl-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 0.8rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
}

.pl-view-title {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pl-view-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--text-2);
  font-size: 1.15rem;
  line-height: 1;
  text-align: center;
  background: rgb(255 255 255 / 0.06);
  border-radius: 50%;
}

.pl-view-body {
  display: flex;
  flex: 1;
  gap: 0.9rem;
  align-items: flex-start;
  min-height: 0;
  padding: 0.8rem;
}

.pl-view-page .thumb {
  width: 5.5rem;
  height: auto;
  filter: drop-shadow(0 8px 14px rgb(0 0 0 / 0.5));
}

.pl-view-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.6rem;
  margin: 0;
  font-size: 0.74rem;
}

.pl-view-meta dt { color: var(--muted); }
.pl-view-meta dd { margin: 0; color: var(--text); }

/* ---------- Vaultwarden ---------- */

.vault-row--key { width: 100%; transition: background-color 0.3s ease, box-shadow 0.3s ease; }
.vault-row--key:hover,
.vault-row--key[aria-expanded="true"] { background: rgb(79 209 197 / 0.08); box-shadow: inset 0 0 0 1px rgb(79 209 197 / 0.25); }
.vault-hint { color: var(--accent); font-size: 0.72rem; }

/* ключ раскрывается поверх нижней строки: высота окна не меняется и страница не прыгает */
.vault-item { position: relative; z-index: 2; }

.vault-key {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.vault-key.is-open { grid-template-rows: 1fr; }
.vault-key-in { display: grid; gap: 0.2rem; overflow: hidden; }

.vault-key.is-open .vault-key-in {
  padding: 0.45rem 0.6rem;
  background: #161c21;
  border: 1px dashed rgb(79 209 197 / 0.45);
  border-radius: 8px;
  box-shadow: 0 12px 24px -12px rgb(0 0 0 / 0.8);
}

.vault-key-label { color: var(--muted); font-size: 0.68rem; }

.vault-key code {
  color: #a5ece4;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

/* ---------- Sure ---------- */

.fin-bars {
  display: flex;
  gap: 0.35rem;
}

.fin-bar {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.25rem 0.15rem 0.2rem;
  border-radius: 6px;
  transition: background-color 0.3s ease;
}

.fin-bar:hover,
.fin-bar.is-active { background: rgb(255 255 255 / 0.05); }

.fin-plot {
  display: flex;
  align-items: flex-end;
  height: 2.2rem;
}

.fin-col {
  width: 100%;
  height: var(--h);
  background: rgb(110 150 230 / 0.35);
  border-radius: 3px 3px 0 0;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.fin-bar:nth-child(odd) .fin-col { background: rgb(79 209 197 / 0.35); }
.fin-bar.is-active .fin-col { background: var(--accent); box-shadow: 0 0 12px rgb(79 209 197 / 0.6); }

.fin-cap {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.15;
  text-align: center;
}

.fin-bar.is-active .fin-cap { color: var(--text); }

/* ---------- Linkwarden ---------- */

.lw-url {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.1rem;
  padding-inline: 0.7rem;
  overflow: hidden;
  background: rgb(255 255 255 / 0.05);
  border-radius: 9px;
}

.lw-lock {
  position: relative;
  flex: none;
  width: 0.6rem;
  height: 0.5rem;
  margin-top: 0.25rem;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
}

.lw-lock::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.42rem;
  width: 0.36rem;
  height: 0.36rem;
  border: 1.5px solid var(--accent);
  border-bottom: 0;
  border-radius: 0.25rem 0.25rem 0 0;
  transform: translateX(-50%);
}

.lw-url-text {
  overflow: hidden;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.links-grid .link-card {
  align-content: start;
  width: 100%;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.link-card:hover,
.link-card.is-active { background: rgb(79 209 197 / 0.08); box-shadow: inset 0 0 0 1px rgb(79 209 197 / 0.3); }

.links-grid .link-prev { height: 2rem; background-size: 160% 160%; }

.link-title {
  color: var(--text-2);
  font-size: 0.72rem;
  line-height: 1.25;
}

.link-card.is-active .link-title { color: var(--text); }

/* ---------- authentik ---------- */

.auth {
  display: grid;
  padding: 0.7rem;
  background: rgb(255 255 255 / 0.03);
  border-radius: 12px;
}

.auth > * { grid-area: 1 / 1; }

.auth-form,
.auth-2fa {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.45rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.auth-2fa { opacity: 0; transform: translateY(0.4rem); pointer-events: none; }
.auth.is-totp .auth-form { opacity: 0; transform: translateY(-0.4rem); pointer-events: none; }
.auth.is-totp .auth-2fa { opacity: 1; transform: none; }

.auth .ui-input { letter-spacing: normal; }
.auth-user:empty::before,
.auth-pass:empty::before { content: attr(data-ph); color: var(--muted); }
.auth-pass:not(:empty) { letter-spacing: 0.15em; }

.auth-login { font-size: 0.78rem; text-align: center; cursor: pointer; }
.auth-login:disabled { cursor: default; opacity: 0.85; }

.totp-title { color: var(--text-2); font-size: 0.78rem; }

.totp {
  display: flex;
  gap: 0.3rem;
}

.totp span {
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.9rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background: rgb(255 255 255 / 0.06);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 6px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.totp span.is-set { border-color: rgb(79 209 197 / 0.6); background: rgb(79 209 197 / 0.1); }

.totp-ok {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  font-size: 0.76rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.totp-ok svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.auth.is-ok .totp-ok { opacity: 1; }
.auth.is-ok .totp span { border-color: var(--accent); }

/* Mattermost: канал с ботом-агентом */
.mm-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}

.mm-channel { color: var(--text); font-size: 0.88rem; font-weight: 500; }
.mm-count { color: var(--muted); font-size: 0.72rem; }

.mm-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.35rem 0.2rem;
}

.mm-av {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
}

.mm-av--user {
  background:
    radial-gradient(circle at 50% 38%, rgb(255 255 255 / 0.5) 0 0.3rem, transparent 0.32rem),
    radial-gradient(circle at 50% 108%, rgb(255 255 255 / 0.5) 0 0.65rem, transparent 0.67rem),
    rgb(110 150 230 / 0.25);
}

.mm-av--bot {
  background: conic-gradient(from 200deg, #4fd1c5, #3b6fe0, #8a6df0, #4fd1c5);
  box-shadow: 0 0 10px rgb(79 209 197 / 0.5);
}

.mm-text { display: grid; gap: 0.1rem; min-width: 0; }
.mm-name { color: var(--text); font-size: 0.8rem; font-weight: 500; }

.mm-tag {
  margin-left: 0.3rem;
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 400;
  background: rgb(255 255 255 / 0.08);
  border-radius: 4px;
}

.mm-line { color: var(--text-2); font-size: 0.82rem; line-height: 1.4; }
.mm-time { margin-left: 0.4rem; color: var(--muted); font-size: 0.68rem; font-weight: 400; }

.mm-input {
  margin-top: 0.35rem;
  padding: 0.5rem 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
  background: rgb(255 255 255 / 0.04);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 8px;
}

/* «печатает…» и ответ занимают одно место, высота не прыгает */
.mm-swap { display: grid; }
.mm-swap > * { grid-area: 1 / 1; }
.mm-typing { display: flex; align-items: center; gap: 0.2rem; opacity: 0; }

.mm-typing i {
  width: 0.35rem;
  height: 0.35rem;
  background: var(--muted);
  border-radius: 50%;
}

/* ==========================================================================
   Движение
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  .ui-caret { animation: caret 1s steps(1) infinite; }
  .mask { background: linear-gradient(90deg, var(--muted) 35%, #d8fbf6 50%, var(--muted) 65%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 4.5s ease-in-out infinite; }
  .vault-row:last-child .mask { animation-delay: 1.4s; }
  .links-grid .link-prev { animation: drift 9s ease-in-out infinite alternate; }
  .links-grid .link-card:nth-child(2) .link-prev { animation-delay: -3s; }
  .links-grid .link-card:nth-child(3) .link-prev { animation-delay: -6s; }

  /* Mattermost: бот «печатает», потом отвечает */
  .mm-typing { animation: mm-typing 7s ease infinite; }
  .mm-reply { animation: mm-reply 7s ease infinite; }
  .mm-typing i { animation: dot 1.1s ease-in-out infinite; }
  .mm-typing i:nth-child(2) { animation-delay: 0.15s; }
  .mm-typing i:nth-child(3) { animation-delay: 0.3s; }
}

@keyframes caret {
  50% { opacity: 0; }
}

@keyframes shimmer {
  0%, 30% { background-position: 100% 0; }
  70%, 100% { background-position: 0% 0; }
}

@keyframes drift {
  from { background-position: 0% 0%; }
  to { background-position: 100% 100%; }
}

@keyframes mm-typing {
  0%, 8% { opacity: 0; }
  12%, 38% { opacity: 1; }
  42%, 100% { opacity: 0; }
}

@keyframes mm-reply {
  0%, 40% { opacity: 0; }
  46%, 92% { opacity: 1; }
  97%, 100% { opacity: 0; }
}
