/* ==========================================================================
   Apps catalogue + detail sheet
   ========================================================================== */

.catalogue-section {
  padding: 0 0 96px;
  background: var(--bg-secondary);
}

.catalogue-toolbar {
  position: sticky;
  top: 56px;
  z-index: 40;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--toolbar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
}

.toolbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-field {
  position: relative;
  flex: 1 1 260px;
  max-width: 360px;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 980px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.search-field input::placeholder { color: var(--muted-2); }

.search-field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 2px 1px;
}

.filter-chips::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: none;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 980px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
              color 0.2s var(--ease);
}

.filter-chip:hover { border-color: var(--muted-2); }

.filter-chip[aria-pressed="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.results-line {
  margin: 22px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.catalogue-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.catalogue-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.cat-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.cat-icon {
  width: 58px;
  height: 58px;
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--icon-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  object-fit: cover;
}

.cat-label {
  min-width: 0;
  flex: 1;
}

.cat-category {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.cat-price {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 12px;
}

.cat-price--status { color: var(--warn); font-weight: 500; }

.cat-icon--empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  background: var(--chip);
}

.cat-status {
  flex: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.catalogue-card h3 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.catalogue-card p {
  display: -webkit-box;
  min-height: 3.9em;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.cat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  color: var(--link);
  font-size: 13px;
  font-weight: 500;
}

.cat-link .icon { width: 12px; height: 12px; }

.catalogue-empty {
  grid-column: 1 / -1;
  padding: 44px 0;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.catalogue-loading {
  grid-column: 1 / -1;
  padding: 48px 0;
  color: var(--muted-2);
  font-size: 14px;
  text-align: center;
}

.catalogue-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.catalogue-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.catalogue-cta p {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Detail sheet ---------- */
.app-dialog {
  width: min(980px, calc(100vw - 32px));
  max-width: none;
  max-height: 90vh;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

body.modal-open { overflow: hidden; }

.dialog-shell {
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  overscroll-behavior: contain;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.dialog-close:hover { background: var(--line-soft); color: var(--text); }

.dialog-app-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding-right: 36px;
}

.dialog-icon {
  width: 92px;
  height: 92px;
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: 21px;
  background: var(--icon-bg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  object-fit: cover;
}

.dialog-title {
  margin: 2px 0 4px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.dialog-category {
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dialog-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.dialog-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.dialog-facts strong { color: var(--text); font-weight: 500; }

.dialog-shots {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin: 22px -32px 0;
  padding: 4px 32px 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.dialog-shots img {
  width: auto;
  height: 360px;
  flex: none;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  scroll-snap-align: start;
  object-fit: contain;
  background: var(--chip);
}

.dialog-section { margin-top: 26px; }

.dialog-section h3 {
  margin-bottom: 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dialog-description,
.dialog-release {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-line;
}

.dialog-release {
  padding: 16px;
  border-radius: 14px;
  background: var(--chip);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.dialog-error {
  padding: 40px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 980px) {
  .catalogue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-inner { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; max-width: none; }
}

@media (max-width: 700px) {
  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .catalogue-section { padding-bottom: 72px; }
  .catalogue-toolbar { top: 56px; padding: 12px 0; }
  .catalogue-grid { grid-template-columns: 1fr; }
  .catalogue-card p { min-height: 0; }
  .catalogue-cta { align-items: flex-start; flex-direction: column; }

  .dialog-shell { padding: 22px; }
  .dialog-app-head { gap: 13px; padding-right: 30px; }
  .dialog-icon { width: 66px; height: 66px; border-radius: 16px; }
  .dialog-title { font-size: 23px; }
  .dialog-shots { margin: 18px -22px 0; padding: 4px 22px 12px; }
  .dialog-shots img { height: 270px; }
  .app-dialog { width: calc(100vw - 20px); border-radius: 20px; }
}

@media print {
  .app-dialog { display: none !important; }
}
