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

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --text: #111111;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent: #111111;
  --radius: 8px;
  --radius-sm: 4px;
  --max-width: 900px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 80px 0 48px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 32px;
}

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

.search-bar input {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

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

.search-bar button {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-bar button:hover {
  opacity: 0.85;
}

.search-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loader svg {
  animation: spin 1s linear infinite;
}

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

.error-msg {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 12px;
}

/* ===== Progress Bar ===== */
.progress-bar {
  max-width: 560px;
  margin: 16px auto 0;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ===== Results ===== */
.results {
  padding-bottom: 48px;
}

.section {
  margin-top: 48px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-count {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ===== Favicons Grid ===== */
.favicons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.favicon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.favicon-preview {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  border-radius: var(--radius-sm);
}

.favicon-preview img {
  max-width: 64px;
  max-height: 64px;
  image-rendering: auto;
}

.favicon-meta {
  text-align: center;
}

.favicon-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.favicon-size {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.favicon-actions {
  display: flex;
  gap: 6px;
}

.favicon-actions button {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.favicon-actions button:hover {
  background: var(--bg);
}

/* ===== Colours Grid ===== */
.colours-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.colour-swatch {
  position: relative;
  cursor: pointer;
  transition: transform 0.15s;
}

.colour-swatch:hover {
  transform: translateY(-2px);
}

.swatch-fill {
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  border: 1px solid rgba(0,0,0,0.08);
}

.swatch-info {
  margin-top: 6px;
  text-align: center;
}

.swatch-hex {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', monospace;
  color: var(--text);
}

.swatch-role {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: capitalize;
  margin-top: 1px;
}

.swatch-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
  line-height: 1.6;
  pointer-events: none;
}

.swatch-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
}

.colour-swatch:hover .swatch-tooltip {
  display: block;
}

.swatch-dimmed .swatch-fill {
  opacity: 0.4;
}

.swatch-dimmed .swatch-hex,
.swatch-dimmed .swatch-role {
  opacity: 0.5;
}

/* ===== Fonts List ===== */
.fonts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.font-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.font-info {
  flex: 1;
}

.font-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.font-source {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.font-source a {
  color: var(--text-secondary);
}

.font-preview-text {
  font-size: 1.4rem;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
  max-width: 50%;
}

/* ===== Export ===== */
.export-section {
  margin-top: 48px;
}

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-btn {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

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

/* ===== Meta Bar ===== */
.meta-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ===== Explainer ===== */
.explainer {
  margin-top: 80px;
  padding: 40px 0;
  border-top: 1px solid var(--border-light);
}

.explainer h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.explainer h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

.explainer p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  max-width: 640px;
}

.explainer ul {
  list-style: none;
  padding: 0;
}

.explainer li {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  padding-left: 16px;
  position: relative;
}

.explainer li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 4px;
  height: 4px;
  background: var(--text-tertiary);
  border-radius: 50%;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 32px 24px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero {
    padding: 48px 0 32px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-bar button {
    justify-content: center;
  }

  .favicons-grid {
    grid-template-columns: 1fr;
  }

  .colours-grid {
    gap: 8px;
  }

  .swatch-fill {
    width: 72px;
    height: 72px;
  }

  .font-card {
    flex-direction: column;
    gap: 12px;
  }

  .font-preview-text {
    text-align: left;
    max-width: 100%;
  }

  .export-buttons {
    flex-direction: column;
  }

  .meta-bar {
    flex-direction: column;
    gap: 4px;
  }
}
