/* ==========================================================================
   DaedalMap downloads storefront - local layer
   --------------------------------------------------------------------------
   site.css owns every token, the page shell, nav, footer, hero, catalog
   browser, cards, badges, and buttons this page uses. It is loaded first and
   is a build-time copy of the exact file daedalmap.com serves.

   Only rules that are genuinely specific to the download store belong here.
   If a rule would be useful on any other catalog surface, it belongs in
   site.css instead, not in this file.
   ========================================================================== */

/* One catalog control: the boxed primary switch chooses a product lane, then
   the smaller pills and search narrow that lane. This follows the compact
   three-type picker used by the earlier Try Data flow. */
.downloads-catalog-shell {
  overflow: hidden;
  border: 1px solid rgba(116, 185, 224, 0.18);
  border-radius: var(--radius-md);
  background: rgba(5, 14, 22, 0.58);
}

.downloads-kind-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
  padding: var(--sp-4);
}

.downloads-kind-tab {
  --lane-accent: #72e1b9;
  --lane-line: rgba(114, 225, 185, 0.42);
  --lane-soft: rgba(114, 225, 185, 0.08);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  align-items: center;
  min-height: 78px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-top: 2px solid var(--lane-line);
  border-radius: 10px;
  background: rgba(5, 14, 22, 0.66);
  color: var(--muted-strong);
  font-family: var(--type-base);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.downloads-kind-tab[data-category="data"] {
  --lane-accent: #ffbe5c;
  --lane-line: rgba(255, 190, 92, 0.44);
  --lane-soft: rgba(255, 190, 92, 0.08);
}

.downloads-kind-tab[data-category="programs"] {
  --lane-accent: #ffaaa2;
  --lane-line: rgba(255, 111, 97, 0.4);
  --lane-soft: rgba(255, 111, 97, 0.07);
}

.downloads-kind-tab:hover {
  border-color: var(--lane-line);
  background: var(--lane-soft);
  color: var(--text-strong);
  transform: translateY(-1px);
}

.downloads-kind-tab[aria-selected="true"] {
  border-color: var(--lane-line);
  background: var(--lane-soft);
  color: var(--lane-accent);
  box-shadow: inset 0 2px 0 var(--lane-accent);
}

.downloads-kind-tab strong {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.downloads-kind-tab small {
  grid-column: 1;
  font-size: 0.78rem;
  line-height: 1.4;
}

.downloads-kind-count {
  grid-column: 2;
  grid-row: 1 / span 2;
  color: rgba(167, 191, 206, 0.58);
  font-family: var(--type-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.downloads-catalog-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px 20px;
  border-top: 1px solid var(--line-soft);
  background: rgba(8, 20, 30, 0.42);
}

/* Category panels are switched by the primary tablist. */
.downloads-panel[hidden] {
  display: none;
}

/* A download card title is a heading, not a link to a profile page, so the
   shared whole-card hit area would swallow clicks meant for the card body.
   Only the explicit Download and Manifest links should be clickable. */
.downloads-card .catalog-card-name::before {
  content: none;
}

/* The shared action style is also used on a real button here, because its
   first action opens review details rather than navigating immediately. */
.downloads-review-button {
  border-style: solid;
  font-family: var(--type-base);
  cursor: pointer;
}

/* Downloads use four cards across on desktop. Geometry is selected
   country-first, and package details stay out of its cards. */
.downloads-grid,
.downloads-country-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-5);
}

.geometry-download-country {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(99, 185, 255, 0.07), transparent 48%),
    var(--panel);
  box-shadow: var(--shadow-card);
}

.geometry-download-country-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}

.geometry-download-country-name {
  margin: 0;
  color: var(--text-strong);
  font-size: var(--text-card);
}

.geometry-download-country-code,
.geometry-download-section-label,
.downloads-dialog-kicker {
  font-family: var(--type-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.geometry-download-country-code {
  color: var(--blue);
}

.geometry-download-families {
  flex: 1;
  padding: var(--sp-5) 0 var(--sp-6);
}

.geometry-download-section-label {
  display: block;
  margin-bottom: var(--sp-3);
  color: var(--muted);
}

.geometry-download-family-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.geometry-download-family {
  padding: 5px 9px;
  border: 1px solid rgba(99, 185, 255, 0.18);
  border-radius: var(--radius-pill);
  background: var(--blue-faint);
  color: var(--blue-bright);
  font-size: 12px;
  line-height: 1.2;
}

.geometry-download-family-muted {
  color: var(--muted-strong);
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
}

.geometry-download-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.geometry-download-choice {
  min-height: 42px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--blue-line);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(99, 185, 255, 0.18), rgba(41, 111, 164, 0.13));
  color: var(--blue-bright);
  font: 700 12px/1 var(--type-base);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.geometry-download-choice:hover:not(:disabled),
.geometry-download-choice:focus-visible {
  border-color: rgba(157, 224, 255, 0.78);
  background: linear-gradient(180deg, rgba(116, 205, 255, 0.28), rgba(48, 128, 189, 0.22));
  transform: translateY(-1px);
}

.geometry-download-choice:disabled {
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  color: rgba(167, 191, 206, 0.42);
  cursor: not-allowed;
}

/* Native dialog keeps keyboard, focus, and Escape behavior in the browser.
   Its contents are populated only from the hydrated release manifests. */
.downloads-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--panel-elevated);
  color: var(--text);
  box-shadow: var(--shadow), var(--glow-cyan);
}

.downloads-dialog::backdrop {
  background: rgba(1, 5, 9, 0.78);
  backdrop-filter: blur(5px);
}

.downloads-dialog-shell {
  position: relative;
  padding: var(--sp-8);
}

.downloads-dialog-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted-strong);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.downloads-dialog-kicker {
  display: block;
  padding-right: var(--sp-10);
  color: var(--blue);
}

.downloads-dialog h2 {
  margin: var(--sp-2) 0 var(--sp-3);
  color: var(--text-strong);
}

.downloads-dialog-summary {
  margin: 0 0 var(--sp-6);
  color: var(--muted-strong);
  line-height: 1.6;
}

.downloads-dialog-meta {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(2, 10, 17, 0.38);
}

.downloads-dialog-meta .catalog-meta-row {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}

.downloads-dialog-meta .catalog-meta-row:last-child {
  border-bottom: 0;
}

.downloads-dialog-meta .catalog-meta-row strong {
  max-width: 70%;
  overflow-wrap: anywhere;
  text-align: right;
  font-family: var(--type-mono);
  font-size: 11px;
}

.downloads-dialog-warning {
  margin: var(--sp-4) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid rgba(255, 190, 92, 0.32);
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  line-height: 1.5;
}

.downloads-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.downloads-dialog-cancel {
  min-height: 42px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted-strong);
  font-weight: 700;
  cursor: pointer;
}

.downloads-dialog-download {
  min-height: 42px;
}

.downloads-dialog-manifest {
  display: block;
  width: max-content;
  margin: var(--sp-4) 0 0 auto;
  color: var(--muted-strong);
  font-size: 12px;
}

@media (max-width: 1200px) {
  .downloads-grid,
  .downloads-country-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .downloads-kind-switch { grid-template-columns: 1fr; }
  .downloads-kind-tab {
    min-height: 72px;
  }

  .downloads-grid,
  .downloads-country-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .geometry-download-choices {
    grid-template-columns: 1fr;
  }

  .downloads-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    margin-bottom: 8px;
  }

  .downloads-dialog-shell {
    padding: var(--sp-6);
  }

  .downloads-dialog-actions {
    flex-direction: column-reverse;
  }

  .downloads-dialog-actions > * {
    justify-content: center;
    width: 100%;
  }
}
