/* The Apps page (views/apps.ejs). The platform palette (client/src/styles.css),
   scoped under .apps-body so mainUI.css's generic selectors stay out. */

.apps-body {
  --ground: #F3F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FA;
  --ink: #1B232C;
  --ink-2: #3E4954;
  --muted: #5B6672;
  --line: #D9DEE4;
  --line-soft: #EDF0F3;
  --field-line: #C5CCD4;
  --bar: #1F262E;
  --accent: #F2B705;
  --link: #1F5FAD;
  --link-hover: #163F73;
  --good: #2E7D4F;
  --good-ink: #24653F;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.45 var(--sans);
}
.ap a { color: var(--link); }
.ap a:hover { color: var(--link-hover); }

.ap {
  max-width: 1200px; margin: 0 auto; padding: 105px 24px 64px;
  display: flex; flex-direction: column; gap: 20px;
}
.ap *, .ap *::before, .ap *::after { box-sizing: border-box; }
.ap-mono { font-family: var(--mono); font-weight: 500; }
.ap-muted { color: var(--muted); }

/* ---- heading ---- */
.ap-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.ap-head-text { display: flex; flex-direction: column; gap: 6px; max-width: 68ch; }
.ap h1 { margin: 0; font: 600 28px/1.2 var(--sans); letter-spacing: -0.01em; color: var(--ink); }
.ap-lede { margin: 0; color: var(--ink-2); font-size: 15px; }
.ap-summary {
  display: flex; align-items: center; gap: 16px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--ink-2);
}
.ap-summary strong { font-weight: 600; color: var(--ink); }
.ap .ap-summary a { font-weight: 500; font-size: 13px; }

/* ---- filters and search ---- */
.ap-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ap-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-filter {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font: 500 13px var(--sans); cursor: pointer;
}
.ap-filter:hover { border-color: var(--field-line); color: var(--ink); }
.ap-filter[aria-pressed="true"] { background: var(--bar); border-color: var(--bar); color: #FFFFFF; }
.ap-count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ap-filter[aria-pressed="true"] .ap-count { color: #C9D1D9; }
.ap-search {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; margin: 0;
  flex: 0 1 280px; background: var(--surface); border: 1px solid var(--field-line); border-radius: 6px; color: var(--muted);
}
.ap-search:focus-within { outline: 2px solid var(--link); outline-offset: 1px; border-color: transparent; }
.ap-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 14px var(--sans); color: var(--ink); padding: 0; height: 36px; }

/* ---- cards ---- */
.ap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ap-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden; min-height: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.ap-card[hidden] { display: none; }
.ap-card.is-soon { background: var(--surface-2); border-style: dashed; border-color: var(--field-line); }
.ap-card.is-subscribed { border-color: var(--good); }
.ap-card-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; flex: 1 1 auto; }
.ap-card-top { display: flex; align-items: center; gap: 12px; }
.ap-icons { display: flex; flex: none; }
.ap-icons .app-icon + .app-icon { margin-left: -12px; box-shadow: 0 0 0 3px var(--surface); }
.ap-card.is-soon .ap-icons .app-icon + .app-icon { box-shadow: 0 0 0 3px var(--surface-2); }
.app-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ap svg { margin: 0; flex: none; }   /* mainUI.css centers svg with auto margins */
.ap-titles { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.ap h2 { margin: 0; font: 600 15px/1.3 var(--sans); color: var(--ink); }
.ap-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ap-opens { color: var(--muted); font-size: 12px; }
.ap .ap-free { align-self: flex-start; font-size: 13px; font-weight: 500; }
.ap-chip { flex: none; background: #E3E7EC; color: var(--ink-2); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.ap-blurb { margin: 0; color: var(--ink-2); font-size: 13px; }
.ap-card-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  min-height: 57px; padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 13px;
}
.ap-price { color: var(--muted); font-size: 12px; }
.ap-price .ap-mono { color: var(--ink); font-size: 15px; }

.ap-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px;
  border-radius: 6px; border: 1px solid transparent; font: 600 13px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.ap-btn:hover { text-decoration: none; }
.apps-body .ap-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.apps-body .ap-btn--primary:hover { background: #FFC926; border-color: #FFC926; color: var(--ink); }
.apps-body .ap-btn--ghost { background: var(--surface); border-color: var(--field-line); color: var(--ink-2); font-weight: 500; }
.apps-body .ap-btn--ghost:hover { border-color: var(--muted); color: var(--ink); }
.apps-body .ap-btn--dark { background: var(--bar); border-color: var(--bar); color: #FFFFFF; }
.apps-body .ap-btn--dark:hover { background: #343E49; color: #FFFFFF; }
.ap a:focus-visible, .ap button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* subscribed: the message covers the card */
.ap-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center; background: #F1F7F3;
}
.ap-check { width: 36px; height: 36px; border-radius: 50%; background: var(--good); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.ap-overlay-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.ap-overlay-sub { color: var(--ink-2); font-size: 12px; }
.ap-overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }

.ap-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 16px; border: 1px dashed var(--field-line); border-radius: 8px; background: var(--surface); }
.ap-empty p { margin: 0; color: var(--ink-2); }
.ap-note { margin: 0; color: var(--muted); font-size: 13px; }

@media (max-width: 600px) {
  .ap { padding: 89px 16px 48px; }
  .ap h1 { font-size: 24px; }
  .ap-search { flex: 1 1 100%; }
  .ap-summary { width: 100%; justify-content: space-between; }
}
