/* ==========================================================================
   XYZICON - Google-style minimal cloud icon search
   ========================================================================== */

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

:root {
  --blue: #4285f4;
  --blue-dark: #1a73e8;
  --green: #34a853;
  --red: #ea4335;
  --yellow: #fbbc05;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dfe1e5;
  --border-hover: #dadce0;
  --bg: #fff;
  --bg-secondary: #f8f9fa;
  --shadow-sm: 0 1px 6px rgba(32, 33, 36, 0.18);
  --shadow-md: 0 2px 10px rgba(32, 33, 36, 0.2);
  --shadow-lg: 0 4px 20px rgba(32, 33, 36, 0.15);
  --radius: 24px;
  --radius-sm: 8px;
  --transition: 200ms ease;
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

html {
  font-size: 16px;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img {
  display: block;
  max-width: 100%;
}

/* --- App Root --- */
.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Hero (Google-style centering) --- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14vh 1.5rem 2rem;
  transition: padding 260ms ease;
}

.has-results .hero {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  transition: all var(--transition);
}

.logo-icon {
  font-size: 3rem;
  line-height: 1;
  transition: font-size var(--transition);
}

.has-results .logo-icon {
  font-size: 1.75rem;
}

.logo-text {
  font-size: 2.75rem;
  font-weight: 400;
  letter-spacing: -1px;
  color: var(--text);
  transition: font-size var(--transition);
}

.logo-accent {
  color: var(--blue);
  font-weight: 600;
}

.has-results .logo-text {
  font-size: 1.5rem;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
  transition: opacity 180ms ease;
}

.has-results .tagline {
  opacity: 0;
  margin-bottom: 0;
  max-height: 0;
  overflow: hidden;
}

/* --- Search Bar --- */
.search-bar {
  position: relative;
  width: 100%;
  max-width: 584px;
  margin-bottom: 1.25rem;
  transition: max-width var(--transition);
}

.has-results .search-bar {
  max-width: 520px;
}

.search-bar-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 44px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition:
    box-shadow var(--transition),
    border-color var(--transition);
  outline: none;
}

.search-input:hover {
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  box-shadow: var(--shadow-md);
  border-color: transparent;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px;
  color: var(--text-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

/* --- Filters --- */
.search-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.search-toolbar .result-count {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin: 0;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all var(--transition);
}

.toolbar-btn:hover {
  background: var(--bg-secondary);
}

.toolbar-btn.active {
  background: #e8f0fe;
  color: var(--blue-dark);
  border-color: #d2e3fc;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.reset-pill {
  color: var(--red) !important;
  border-color: var(--red) !important;
  background: #fff !important;
}

.pill {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  transition: all var(--transition);
  white-space: nowrap;
}

.pill:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.pill.active {
  background: #e8f0fe;
  color: var(--blue-dark);
  border-color: #d2e3fc;
}

.format-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.fmt-btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.fmt-btn:hover {
  background: var(--bg-secondary);
}

.fmt-btn.active {
  background: var(--blue);
  color: #fff;
}

.result-count {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* --- State messages --- */
.state-msg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
  text-align: center;
  gap: 0.5rem;
}

.state-big {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
}

.btn-reset {
  margin-top: 0.75rem;
  padding: 8px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--blue-dark);
  transition: all var(--transition);
}

.btn-reset:hover {
  background: #e8f0fe;
  border-color: #d2e3fc;
}

/* --- Spinner --- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Results Grid --- */
.results {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

/* --- Card --- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition:
    box-shadow var(--transition),
    border-color var(--transition),
    transform 150ms ease;
}

.card.active,
.card:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: transparent;
  transform: translateY(-2px);
}

.card-img {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 1rem;
}

.icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-width: 100%;
}

.card-body {
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 36px;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-provider {
  display: none;
}

/* Card actions - visible on hover */
.card-actions {
  display: flex;
  gap: 2px;
  padding: 0 0.5rem 0.5rem;
  opacity: 0;
  transition: opacity 150ms ease;
}

.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--blue-dark);
  background: #e8f0fe;
  border-radius: 4px;
  transition: background var(--transition);
  white-space: nowrap;
}

.action-btn:hover {
  background: #d2e3fc;
}

.action-btn:focus-visible,
.search-clear:focus-visible,
.pill:focus-visible,
.fmt-btn:focus-visible,
.toolbar-btn:focus-visible,
.btn-reset:focus-visible,
.search-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.match {
  background: rgba(251, 188, 5, 0.28);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.action-btn svg {
  flex-shrink: 0;
}

/* --- Infinite scroll sentinel --- */
.sentinel {
  height: 1px;
}

.loading-more {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 2rem;
}

.loading-results {
  padding-top: 2rem;
}

.loading-label {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.skeleton-grid--inline {
  width: 100%;
}

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--bg);
}

.skeleton-image,
.skeleton-line {
  background: linear-gradient(
    90deg,
    rgba(223, 225, 229, 0.7) 25%,
    rgba(223, 225, 229, 0.35) 50%,
    rgba(223, 225, 229, 0.7) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
}

.skeleton-line {
  height: 10px;
  margin-top: 0.65rem;
  border-radius: 999px;
}

.skeleton-line.short {
  width: 58%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* --- Initial explore grid --- */
.explore {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0.5rem 1.5rem 3rem;
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.25rem;
  max-width: 840px;
  width: 100%;
}

.explore-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 120ms ease;
  aspect-ratio: 1;
}

.explore-card:hover {
  background: var(--bg-secondary);
  transform: scale(1.08);
}

.explore-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

/* --- Footer --- */
.site-footer {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  margin-top: auto;
}

.site-footer a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: none;
}

.dot {
  margin: 0 0.5rem;
}

.footer-note {
  font-weight: 500;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  pointer-events: auto;
  animation: toastIn 0.25s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.toast.removing {
  animation: toastOut 0.2s ease-in forwards;
}

.toast-icon {
  font-size: 1rem;
  flex-shrink: 0;
}
.toast-message {
  flex: 1;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero {
    padding-top: 10vh;
  }
  .has-results .hero {
    padding: 1rem 1rem 0.75rem;
  }

  .logo-icon {
    font-size: 2.25rem;
  }
  .has-results .logo-icon {
    font-size: 1.5rem;
  }

  .logo-text {
    font-size: 2rem;
  }
  .has-results .logo-text {
    font-size: 1.25rem;
  }

  .tagline {
    font-size: 0.85rem;
  }

  .search-bar {
    max-width: 100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .card-actions {
    opacity: 1;
  }

  .explore-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
}

@media (max-width: 480px) {
  .hero {
    padding-top: 6vh;
  }

  .pill {
    font-size: 0.72rem;
    padding: 4px 10px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .explore-grid {
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 0.15rem;
  }

  .card-img {
    padding: 0.75rem;
  }
  .card-body {
    padding: 0.4rem;
    min-height: 32px;
  }
  .card-title {
    font-size: 0.72rem;
  }
}

/* --- Hide nav/blazor chrome --- */
#blazor-error-ui {
  display: none;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-size: 1rem;
  color: var(--text-secondary);
}

.valid.modified ~ .validation-message {
  display: none;
}
