/*
 * Download home page styles.
 * Sections: foundation, layout, catalog cards, release modal, access gate,
 * responsive rules.
 */

/* Foundation */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --page-bg: #f5f5f7;
  --text: #1d1d1f;
  --muted: #77777c;
  --muted-2: #a1a1a8;
  --glass: rgba(255, 255, 255, 0.52);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --border: rgba(255, 255, 255, 0.62);
  --line: rgba(29, 29, 31, 0.08);
  --shadow: 0 16px 60px rgba(24, 24, 27, 0.08), 0 2px 8px rgba(24, 24, 27, 0.04);
  --shadow-soft: 0 8px 28px rgba(24, 24, 27, 0.06);
  --blur: blur(36px) saturate(180%);
  --dark: #151518;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --ok: #10b981;
  --warn: #f59e0b;
}

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
button, input { font: inherit; }
[hidden] { display: none !important; }

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 999px;
  opacity: 0.58;
  filter: blur(0);
}

.blob-1 {
  width: 820px;
  height: 820px;
  top: -240px;
  left: -180px;
  background: radial-gradient(circle, #a78bfa 0%, rgba(167,139,250,.55) 18%, rgba(125,211,252,.22) 45%, transparent 70%);
  animation: driftA 18s ease-in-out infinite;
}

.blob-2 {
  width: 720px;
  height: 720px;
  top: 120px;
  right: -220px;
  background: radial-gradient(circle, #5eead4 0%, rgba(94,234,212,.48) 20%, rgba(147,197,253,.22) 45%, transparent 70%);
  animation: driftB 22s ease-in-out infinite;
}

.blob-3 {
  width: 640px;
  height: 640px;
  bottom: -260px;
  left: 24%;
  background: radial-gradient(circle, #f9a8d4 0%, rgba(249,168,212,.46) 20%, rgba(253,230,138,.24) 45%, transparent 70%);
  animation: driftC 24s ease-in-out infinite;
}

@keyframes driftA {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(80px, 70px, 0) scale(1.06); }
}

@keyframes driftB {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-90px, 40px, 0) scale(.96); }
}

@keyframes driftC {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(60px, -90px, 0) scale(1.08); }
}

/* Page layout */
.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.top-link {
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  color: rgba(29,29,31,.72);
  background:
    linear-gradient(135deg, rgba(255,255,255,.66), rgba(255,255,255,.26) 48%, rgba(255,255,255,.54)),
    rgba(255,255,255,.28);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow:
    0 14px 34px rgba(29,29,31,.09),
    inset 0 1px 0 rgba(255,255,255,.82),
    inset 0 -1px 0 rgba(255,255,255,.36);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  transition: transform .2s ease, box-shadow .2s ease, color .2s ease, background .2s ease;
}

.top-link::before {
  content: "";
  position: absolute;
  inset: 1px 2px auto;
  height: 46%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.66), rgba(255,255,255,0));
  pointer-events: none;
}

.top-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 22% 12%, rgba(255,255,255,.74), transparent 34%);
  opacity: .72;
  pointer-events: none;
}

.top-link:hover {
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255,255,255,.76), rgba(255,255,255,.34) 48%, rgba(255,255,255,.62)),
    rgba(255,255,255,.36);
  box-shadow:
    0 18px 42px rgba(29,29,31,.12),
    inset 0 1px 0 rgba(255,255,255,.9),
    inset 0 -1px 0 rgba(255,255,255,.42);
  transform: translateY(-1px);
}

.top-link.admin-link {
  padding: 0 16px;
}

.catalog-shell,
/* Intro/card primitives */
.software-card {
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow), inset 0 .5px 0 rgba(255,255,255,.78);
}

.search-panel {
  flex: 1;
  min-width: 300px;
}

.search-box {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(29,29,31,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow-soft), inset 0 .5px 0 rgba(255,255,255,.88);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
}

.search-box:focus-within {
  transform: translateY(-1px);
  background: rgba(255,255,255,.86);
  box-shadow: 0 16px 40px rgba(29,29,31,.08), inset 0 .5px 0 rgba(255,255,255,.9);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.search-box input::placeholder {
  color: rgba(29,29,31,.36);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  padding: 18px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.48);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow-soft), inset 0 .5px 0 rgba(255,255,255,.78);
}

.stat strong {
  display: block;
  font-size: 22px;
  letter-spacing: -.8px;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.catalog-shell {
  margin-top: 18px;
  border-radius: 32px;
  padding: 18px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 4px 18px;
}

.filter-btn {
  border: 1px solid rgba(29,29,31,.08);
  background: rgba(255,255,255,.46);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .2s ease, color .2s ease, transform .2s ease, border-color .2s ease;
}

.filter-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,.72);
  transform: translateY(-1px);
}

.filter-btn.active {
  color: #fff;
  border-color: var(--dark);
  background: var(--dark);
  box-shadow: 0 10px 24px rgba(29,29,31,.12);
}

.catalog-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  padding: 0 6px 18px;
}

.catalog-meta strong {
  color: var(--text);
}

/* Catalog cards */
.software-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.software-card {
  min-height: 300px;
  border-radius: 26px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform .26s ease, box-shadow .26s ease, background .26s ease;
}

.software-card:hover {
  transform: translateY(-5px);
  background: var(--glass-strong);
  box-shadow: 0 22px 70px rgba(24,24,27,.11), 0 2px 8px rgba(24,24,27,.05);
}

.software-card::before {
  content: "";
  position: absolute;
  inset: 0 8px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.8), transparent);
}

.card-top {
  display: flex;
  gap: 14px;
  align-items: center;
}

.app-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 760;
  font-size: 20px;
  letter-spacing: -.8px;
  box-shadow: 0 14px 28px rgba(24,24,27,.12);
}

.app-title {
  min-width: 0;
}

.app-title h3 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.app-desc {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  flex: 1;
}

.tag-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(29,29,31,.05);
  font-size: 11px;
  font-weight: 600;
}

.package-line {
  margin-top: 18px;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.48);
  border: 1px solid rgba(255,255,255,.64);
}

.package-line span {
  display: block;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.package-line strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr .52fr;
  gap: 10px;
  margin-top: 18px;
}

.download-btn,
.info-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .2s ease, opacity .2s ease, background .2s ease;
}

.download-btn {
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255,255,255,.66);
  border: 1px solid rgba(29,29,31,.08);
}

.info-btn {
  color: #fff;
  background: linear-gradient(135deg, #1d1d1f, #312e81);
}

.download-btn:hover,
.info-btn:hover {
  transform: translateY(-1px);
  opacity: .9;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  border-radius: 24px;
  border: 1px dashed rgba(29,29,31,.16);
  background: rgba(255,255,255,.35);
}

.footer {
  margin-top: 34px;
  padding: 22px 0 8px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
}

.footer p {
  margin-top: 14px;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  max-width: min(420px, calc(100% - 32px));
  padding: 13px 16px;
  border-radius: 18px;
  color: #fff;
  background: rgba(22,22,24,.9);
  box-shadow: 0 18px 48px rgba(0,0,0,.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Release selector */
.release-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.release-modal {
  width: min(620px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: 0 28px 90px rgba(24,24,27,.18), inset 0 .5px 0 rgba(255,255,255,.86);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

.release-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.release-head h2 {
  font-size: 22px;
  letter-spacing: -.5px;
}

.release-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.release-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(29,29,31,.06);
  color: var(--text);
  font-size: 20px;
}

.release-list {
  display: grid;
  gap: 10px;
}

.release-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border-radius: 18px;
  background: rgba(255,255,255,.48);
  border: 1px solid rgba(255,255,255,.66);
}

.release-item strong {
  font-size: 14px;
}

.release-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.release-download {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  color: #fff;
  background: var(--dark);
  cursor: pointer;
  font-weight: 700;
}

/* Access gate */
.access-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(245,245,247,.44);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.access-card {
  width: min(520px, 100%);
  padding: 44px 40px;
  border-radius: 32px;
  text-align: center;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 28px 90px rgba(24,24,27,.13), inset 0 .5px 0 rgba(255,255,255,.85);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  margin-bottom: 22px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.42);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}

.access-card h1 {
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -.8px;
  margin-bottom: 12px;
}

.access-hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.access-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.access-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
}

.access-input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(29,29,31,.1);
  outline: none;
  color: var(--text);
  background: rgba(255,255,255,.56);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.access-input:focus {
  border-color: rgba(29,29,31,.26);
  background: rgba(255,255,255,.78);
  box-shadow: 0 12px 34px rgba(29,29,31,.08);
}

.access-note {
  margin-top: 8px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.55;
}

.access-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.access-deny,
.access-allow {
  height: 50px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .2s ease, opacity .2s ease, background .2s ease;
}

.access-deny {
  color: var(--text);
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(29,29,31,.08);
}

.access-allow {
  color: #fff;
  background: var(--dark);
}

.access-deny:hover,
.access-allow:hover {
  transform: translateY(-1px);
  opacity: .9;
}

.access-error {
  min-height: 20px;
  color: #ef4444;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.access-blocked {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

/* Responsive rules */
@media (max-width: 980px) {
  .software-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 28px, 1180px);
    padding-top: 16px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .search-panel {
    width: 100%;
    min-width: 0;
  }
  .top-links {
    justify-content: flex-start;
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
  .catalog-shell {
    border-radius: 26px;
  }
  .software-grid {
    grid-template-columns: 1fr;
  }
  .access-card {
    padding: 36px 24px;
    border-radius: 26px;
  }
  .access-card h1 {
    font-size: 26px;
  }
  .access-actions {
    grid-template-columns: 1fr;
  }
}
