@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,700;1,9..144,400&family=Syne:wght@700;800&family=DM+Mono:wght@400;500&display=swap');

/* ─── Variables ─── */
:root {
  --bg: #f5efe6;
  --surface: #fdf9f5;
  --surface-alt: #ede7dc;
  --border: #ddd5c8;
  --text-primary: #111111;
  --text-secondary: #5a5248;
  --text-muted: #9a8e84;
  --accent: #e63946;
  --accent-light: #fdecea;
  --accent-mid: #f4969c;
  --success: #1db954;
  --warning: #f5a623;
  --danger: #e5484d;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Mono', monospace;
}

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

html, body {
  overflow-x: hidden;
}

/* ─── Base ─── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
header {
  padding: 1rem 2rem;
  background: #111111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 0.35rem;
  border-bottom: 2.5px solid var(--accent);
}

header h1 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

header h1 span {
  color: var(--accent);
}

/* ─── Main ─── */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

/* ─── Hero ─── */
#hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  padding: 3rem 0 1rem;
}

#hero-title {
  font-family: 'Fraunces', serif;
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.05;
  color: var(--text-primary);
}

#hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.7;
}

#hero-suggestions {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.suggestion {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  padding: 0;
  transition: color 0.2s, border-color 0.2s;
}

.suggestion:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* ─── Hero states ─── */
#hero.collapsed #hero-title,
#hero.collapsed #hero-subtitle,
#hero.collapsed #hero-suggestions {
  display: none;
}

#hero.collapsed {
  padding: 1.5rem 0;
  gap: 0.75rem;
}

/* ─── Search ─── */
#search-section {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  max-width: 560px;
}

#search-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  border-color: var(--border);
  box-shadow: 0 0 0 3px rgba(90, 40, 10, 0.08);
}

#search-btn {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.875rem 1.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

#search-btn:hover {
  background: #c1121f;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

#search-btn:active {
  transform: translateY(0);
}

/* ─── Loading ─── */
.loading-pulse {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  padding: 3rem 0;
}

.loading-pulse span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-pulse span:nth-child(2) { animation-delay: 0.2s; }
.loading-pulse span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Error ─── */
#error-message {
  font-size: 0.85rem;
  color: #cc2200;
  background: #fff0ee;
  border: 1.5px solid #ffcccc;
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  text-align: center;
  font-family: var(--font-body);
}

/* ─── Profile Card ─── */
#profile-section {
  flex-direction: column;
  gap: 2rem;
}

#profile-section:not([hidden]) {
  display: flex;
}

#profile-card {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

#profile-avatar-wrapper {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 4px solid var(--border);
  flex-shrink: 0;
  padding: 3px;
  transition: border-color 0.4s ease;
  box-sizing: border-box;
}

#profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

#profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

#profile-name {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.1;
}

#profile-username {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.1rem;
}

#profile-bio {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.7;
  margin-top: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Stats ─── */
#profile-stats {
  display: flex;
  gap: 0.75rem;
  list-style: none;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

#profile-stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.1rem;
  min-width: 80px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#profile-stats li span {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

/* ─── Links ─── */
#profile-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  list-style: none;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

#profile-links li {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.link-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 0.3rem;
}

#profile-links a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}

#profile-links a:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* ─── Languages ─── */
#languages-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-sm);
}

#languages-section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

#languages-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lang-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: 0.75rem;
}

.lang-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-bar-track {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.lang-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

/* ─── Repos ─── */
#repos-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

#repo-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#repos-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 0.5rem;
}

#repos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

#repos-header h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

#repos-toggle {
  display: flex;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
}

.toggle-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.toggle-btn.active {
  background: var(--text-primary);
  color: #fff;
}

#repos-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.repo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  text-decoration: none;
}

.repo-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--accent-mid);
}

.repo-card-name {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.repo-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.repo-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ─── Footer ─── */
footer {
  text-align: center;
  padding: 1.25rem 1.5rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  background: #111111;
  border-top: 2.5px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

footer a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: rgba(255, 255, 255, 0.85);
}

#easter-egg {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ─── Results footer ─── */
#results-footer {
  display: flex;
  justify-content: center;
  padding-top: 1rem;
}

#search-again-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  border-bottom: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}

#search-again-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-secondary);
}

#beginning-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-style: italic;
  transition: color 0.2s;
}

#beginning-btn:hover {
  color: var(--text-secondary);
}

/* ─── Entrance animation ─── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-in:nth-child(1) { animation-delay: 0s; }
.animate-in:nth-child(2) { animation-delay: 0.15s; }
.animate-in:nth-child(3) { animation-delay: 0.35s; }
.animate-in:nth-child(4) { animation-delay: 0.5s; }

@media (max-width: 600px) {
  main {
    padding: 2rem 1rem;
  }

  #search-section {
    flex-direction: column;
  }

  #search-input,
  #search-btn {
    width: 100%;
  }

  #profile-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  #profile-stats {
    justify-content: center;
  }

  #profile-links {
    justify-content: center;
  }

  #repos-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #repos-list {
    grid-template-columns: 1fr;
  }

  .lang-row {
    grid-template-columns: 90px 1fr 40px;
  }
}