/* ==========================================================================
   Heimdall Application Database - static gallery
   Palette lifted from the Heimdall aesthetic:
     green  #47918a   deep blue #0b3161   info panels rgb(36,87,113)
     button #458e89 -> #356d69   tile dark #161b1f   tile light #fafbfc
   ========================================================================== */

:root {
  --grad-1: #47918a;
  --grad-2: #0b3161;
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.7);
  --text-faint: rgba(255, 255, 255, 0.45);
  --info-bg: rgb(36, 87, 113);
  --info-accent: rgba(63, 132, 131, 0.7);
  --btn-1: #458e89;
  --btn-2: #356d69;
  --btn-border: #458e88;
  --tile-dark: #161b1f;
  --tile-light: #fafbfc;
  --panel: #0f2540;
  --panel-2: rgba(255, 255, 255, 0.06);
  --focus: #7fd3cc;
  --enhanced: #47918a;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--grad-2);
}

/* Fixed brand gradient behind everything. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at center, var(--grad-1) 0%, var(--grad-2) 100%);
}

a {
  color: var(--text);
}

/* Accessibility helpers ---------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--info-bg);
  color: #fff;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Home badge (top-left) ---------------------------------------------------- */
.home {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  padding: 5px 15px;
  color: #fff;
  background: rgba(63, 132, 131, 0.7);
  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}
.home-logo {
  height: 30px;
  width: auto;
}

/* Stat pills (top-right, vertical stack) ------------------------------------
   Values replicate ul.menu / .info from the old site's _app.scss. The column
   container's default align-items: stretch gives every pill the width of the
   widest one, so left and right edges align into one uniform block. Square
   corners, flat, near-touching. */
.stats {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}
.stat {
  display: flex;
  align-items: stretch;
  font-size: 12px;
  text-transform: lowercase;
  text-align: right;
  text-decoration: none;
  color: #fff;
  border: 0;
  padding: 0;
  /* Kill the UA button background so the translucent count chip composites
     over the page gradient identically on <button> and <a> pills. */
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.4);
  font-family: inherit;
}
.stat-label {
  flex: 1;
  padding: 5px 10px;
  background: var(--info-bg);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.stat-count {
  padding: 5px 4px;
  min-width: 40px;
  background: var(--info-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat:hover .stat-label,
.stat:focus-visible .stat-label {
  background: #2c6a8b;
}

/* Hero --------------------------------------------------------------------- */
.hero {
  max-width: 900px;
  margin: 0 auto;
  padding: 15vh 20px 30px;
  text-align: center;
}

/* H1 logotype lockup */
.lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 0 0 30px;
  font-weight: 200;
  text-transform: uppercase;
}
.lockup-word {
  font-weight: 200;
  font-size: clamp(30px, 7vw, 52px);
  letter-spacing: 2px;
  line-height: 1;
}
.lockup-sub {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding-left: 16px;
  border-left: 1px solid #fff;
  text-align: left;
}
.lockup-line1 {
  font-size: clamp(14px, 2.6vw, 19px);
  letter-spacing: 2px;
  line-height: 1.2;
}
.lockup-line2 {
  font-size: clamp(11px, 2vw, 14px);
  letter-spacing: 10px;
  line-height: 1.2;
  color: var(--text-dim);
}

/* Hero search pill */
.search {
  max-width: 360px;
  margin: 0 auto;
}
#search-input {
  width: 100%;
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
#search-input::placeholder {
  color: #9aa0a6;
}

/* "Or" divider with double-line pseudo elements */
.or-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 360px;
  margin: 22px auto;
  color: var(--text-dim);
}
.or-divider span {
  font-size: 12px;
  font-weight: 200;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  /* Darker line with a lighter line offset 1px below. */
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.25) 0 1px,
    rgba(255, 255, 255, 0.25) 1px 2px
  );
}

/* Hero CTA + quiet build link */
.hero-cta {
  text-transform: uppercase;
}
.build-link {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.build-link a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.build-link a:hover {
  color: #fff;
}

/* Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
}
.btn-primary {
  color: #fff;
  background: radial-gradient(ellipse at center, var(--btn-1) 0%, var(--btn-2) 100%);
  border-color: var(--btn-border);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.btn-primary:hover {
  filter: brightness(1.08);
}

/* Quiet filter control (above grid) ---------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0 0 10px;
}
.filter {
  border: 0;
  padding: 5px 14px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  text-transform: lowercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.18s ease, background 0.18s ease;
}
.filter:hover {
  color: #fff;
}
.filter.is-active {
  color: #fff;
  background: rgba(63, 132, 131, 0.7);
  font-weight: 600;
}

/* Grid --------------------------------------------------------------------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 20px 60px;
}
.result-count {
  color: var(--text-faint);
  font-size: 11px;
  margin: 0 0 14px;
  text-align: center;
  min-height: 14px;
}
.status {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
}
.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  outline: none;
}

/* App tile — values replicate .item in Heimdall's compiled app.css ---------- */
.tile {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  height: 90px;
  flex: 0 0 280px;
  padding: 15px;
  padding-right: 55px;
  border-radius: 6px;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  border: 1px solid rgba(76, 76, 76, 0.4);
  background-clip: padding-box;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.25)
  );
  transition: transform 0.25s ease-in-out, box-shadow 0.25s ease-in-out;
}
/* The signature half-circle cut off by the tile's right edge. */
.tile::after {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  right: -48px;
  top: 0;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 40px 0 rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.tile:hover,
.tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tile--dark {
  background-color: var(--tile-dark);
  color: #fff;
}
.tile--light {
  background-color: var(--tile-light);
  color: #161b1f;
}

/* Arrow-into-bar glyph (Font Awesome arrow-alt-to-right stand-in), 24px,
   10px from the right edge, above the circle, currentColor. */
.tile-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  z-index: 1;
}

.tile-icon {
  flex: 0 0 60px;
  width: 60px;
  height: 60px;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-icon img {
  max-width: 60px;
  max-height: 60px;
  display: block;
}
.tile-fallback {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  background: rgba(127, 211, 204, 0.18);
  color: #7fd3cc;
}
.tile-body {
  min-width: 0;
  position: relative;
  z-index: 1;
}
.tile-name {
  display: block;
  font-size: 16px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 3px;
  background: var(--enhanced);
  color: #fff;
}

/* Footer ------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 18px 20px 30px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: center;
  margin-bottom: 8px;
}
.site-footer a {
  color: var(--text-faint);
  text-decoration: none;
}
.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}
.footer-note {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
}
.footer-note a {
  color: var(--text-faint);
  text-decoration: underline;
}

/* Detail modal ------------------------------------------------------------- */
.modal[hidden] {
  display: none;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 28px;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-right: 30px;
}
.detail-icon {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px;
}
.detail-icon img {
  max-width: 100%;
  max-height: 100%;
}
.detail-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
}
.detail-description {
  color: var(--text-dim);
  margin: 0 0 18px;
}
.detail-meta {
  display: grid;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}
.detail-meta li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.detail-meta .k {
  flex: 0 0 90px;
  color: var(--text-faint);
}
.detail-meta .v {
  color: #fff;
  word-break: break-word;
}
.detail-meta a {
  color: #9fdcd6;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.detail-actions .btn {
  flex: 1 1 auto;
  text-align: center;
}

/* Light mode --------------------------------------------------------------- */
@media (prefers-color-scheme: light) {
  :root {
    --grad-1: #cfe4e1;
    --grad-2: #9fbcd6;
    --text: #10233b;
    --text-dim: rgba(16, 35, 59, 0.78);
    --text-faint: rgba(16, 35, 59, 0.55);
    --panel: #ffffff;
    --panel-2: rgba(16, 35, 59, 0.05);
    --focus: #1f6f68;
  }
  body {
    background: var(--grad-2);
  }
  .lockup-sub {
    border-left-color: var(--text);
  }
  .filter.is-active {
    color: #fff;
  }
  .modal-card {
    border-color: rgba(16, 35, 59, 0.14);
  }
  .modal-close {
    background: rgba(16, 35, 59, 0.08);
    color: #10233b;
  }
  .detail-icon {
    background: rgba(16, 35, 59, 0.05);
  }
  .detail-meta li {
    border-bottom-color: rgba(16, 35, 59, 0.1);
  }
  .detail-meta .v {
    color: #10233b;
  }
  .detail-meta a {
    color: #1f6f68;
  }
  #search-input {
    box-shadow: 0 2px 10px rgba(16, 35, 59, 0.15);
  }
  .site-footer a:hover {
    color: #10233b;
  }
}

/* Motion preference -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
    transition: none !important;
  }
}

/* Small screens ------------------------------------------------------------ */
@media (max-width: 600px) {
  .stats {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin: 66px 15px 0;
  }
  .stat-label {
    padding: 2px 10px;
  }
  .stat-count {
    padding: 2px 4px;
  }
  .hero {
    padding-top: 20px;
  }
  .lockup {
    gap: 12px;
  }
  .search,
  .or-divider {
    max-width: none;
  }
  .modal {
    padding: 0;
  }
  .modal-card {
    max-height: 100vh;
    border-radius: 0;
  }
}
