/* Design tokens */
:root {
  --bg: #0d1321;
  --panel: #111827;
  --panel-2: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22d3ee;
  --accent-2: #60a5fa;
  --danger: #f87171;
  --warn: #f59e0b;
  --ok: #34d399;
  --focus: 2px dotted #22d3ee;
  --fun-1: #fde047;
  --fun-2: #a78bfa;
  --fun-3: #7dd3fc;
  --ticker-duration: 60s; /* slower ticker */
}

* { box-sizing: border-box; }
  :root {
    /* Slightly brighter, still dark theme */
    --bg: #121a2f;
    --panel: #182238;
    --panel-2: #14253f;
    --text: #e7eaf0;
    --muted: #aeb6c2;
    --accent: #22d3ee;
    --accent-2: #60a5fa;
    --danger: #f87171;
    --warn: #f59e0b;
    --ok: #34d399;
    --focus: 2px dotted #22d3ee;
    --fun-1: #fde047;
    --fun-2: #a78bfa;
    --fun-3: #7dd3fc;
    --ticker-duration: 60s; /* slower ticker */
  }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  .site-header {
    background: var(--panel);
    border-bottom: 1px solid #2a3750;
  }
  background: var(--bg);
  .result-item { display: flex; justify-content: space-between; align-items: center; padding: .6rem .75rem; border: 1px solid #2a3750; border-radius: .5rem; background: #1b2f4d; }
  .results .result-item:hover { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(96,165,250,.25) inset; }
  .results .result-item:focus-within { outline: var(--focus); outline-offset: 2px; }
  color: var(--text);
  .details { margin-top: .75rem; }
  line-height: 1.55;
}
  .tile { background: #14253f; border: 1px solid #2a3750; border-radius: .5rem; padding: .75rem; }

  .meter { display: flex; align-items: center; justify-content: space-between; background: #14253f; border: 1px solid #2a3750; border-radius: .5rem; padding: .6rem .75rem; gap: .75rem; }
.container {
  .site-footer { background: var(--panel); border-top: 1px solid #2a3750; margin-top: 2rem; }
  width: min(1100px, 92vw);
  .lb-card { background: #1b2f4d; border: 1px solid #2a3750; border-radius: .5rem; padding: .75rem; border-top-width: 3px; border-top-color: transparent; box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
  .lb-grid .lb-card:nth-child(1) { border-top-color: var(--accent); }
  .lb-grid .lb-card:nth-child(2) { border-top-color: var(--fun-2); }
  .lb-grid .lb-card:nth-child(3) { border-top-color: var(--fun-3); }
  margin: 0 auto;
  .details-aside { background: #14253f; border: 1px solid #2a3750; border-radius: .5rem; padding: .6rem .75rem; }
}

  .alias-chip { display: inline-block; padding: .2rem .5rem; border-radius: 999px; background: #1b2f4d; border: 1px solid #2a3750; font-size: .9rem; color: var(--text); }
.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 1000;
  background: #fff;
  color: #000;
  padding: .5rem .75rem;
  #suggest-form input[type="text"],
  #suggest-form input[type="url"],
  #suggest-form input[type="email"],
  #suggest-form textarea {
    width: 100%;
    padding: .7rem .9rem;
    border-radius: .5rem;
    border: 1px solid #2a3750;
    background: #14253f;
    color: var(--text);
  }
  border-radius: .25rem;
  .fun .card { border-color: #2b3b58; box-shadow: 0 0 0 1px #14253f, 0 6px 18px rgba(0,0,0,0.25); }
}
  .ticker { position: relative; overflow: hidden; border-radius: .5rem; border: 1px solid #2a3750; background: #14253f; }

.site-header {
  .ticker .pill { display: inline-flex; align-items: center; gap: .35rem; background: #1b2f4d; border: 1px solid #2a3750; color: var(--text); border-radius: 999px; padding: .25rem .6rem; margin-right: .5rem; }
  background: var(--panel);
  .modal-dialog { position: relative; margin: 8vh auto; width: min(680px, 92vw); background: var(--panel-2); border: 1px solid #2a3750; border-radius: .75rem; padding: 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
  border-bottom: 1px solid #1f2937;
  .quiz .q-card { background: #14253f; border: 1px solid #2a3750; border-radius: .5rem; padding: .75rem; }
}
  .quiz .choices button { text-align: left; background: #1b2f4d; border: 1px solid #2a3750; color: var(--text); border-radius: .5rem; padding: .5rem .6rem; cursor: pointer; }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 0;
}
.brand { display: flex; align-items: center; gap: .5rem; }
.brand .logo { display: block; height: 50px; width: auto; }
.brand .logo-wordmark { height: 70px; width: auto; max-width: min(50vw, 420px); }
.brand-name, .brand-link { color: var(--text); text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem; }
.site-nav ul { list-style: none; display: flex; gap: 1rem; margin: 0; padding: 0; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a:focus { color: var(--text); }
.nav-btn { padding: .35rem .6rem; font-size: .95rem; }

.hero { padding: 2rem 0 1rem; }
.hero h1 { margin: 0 0 .25rem; font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.2rem); }
.tagline { margin: 0 0 .5rem; color: var(--muted); }
.disclaimer { font-size: .9rem; color: var(--muted); }
.hero-actions { margin-top: .75rem; }

.card { background: var(--panel-2); border: 1px solid #1f2937; border-radius: .75rem; padding: 1rem; margin: 1rem 0; }
.card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.card h2 { margin: 0; font-size: 1.25rem; }
.muted { color: var(--muted); }

#lookup-input {
  width: 100%;
  padding: .75rem 1rem;
  border-radius: .5rem;
  border: 1px solid #374151;
  background: #0b1220;
  color: var(--text);
}
#lookup-input:focus { outline: var(--focus); outline-offset: 2px; }

.results { margin-top: .75rem; display: grid; gap: .5rem; }
.result-item { display: flex; justify-content: space-between; align-items: center; padding: .6rem .75rem; border: 1px solid #1f2937; border-radius: .5rem; background: #0b1220; }
.result-item button { background: transparent; color: var(--accent); border: 1px solid #134e4a; padding: .35rem .6rem; border-radius: .35rem; cursor: pointer; }
.result-item button:focus { outline: var(--focus); }

/* Inline details shown directly after a result item */
.inline-details { margin-top: .25rem; background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .75rem; }

.details { margin-top: .75rem; }
.timeline { font-size: .95rem; }
.badge { display: inline-block; padding: .15rem .45rem; border-radius: .35rem; font-size: .8rem; margin-left: .5rem; }
.badge.deprecated { background: #3f1d1d; color: #fecaca; border: 1px solid #7f1d1d; }
.badge.merged { background: #1f2437; color: #bfdbfe; border: 1px solid #1e3a8a; }
.badge.active { background: #0f2b23; color: #a7f3d0; border: 1px solid #065f46; }

/* Details two-column layout */
.details-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.details-main { min-width: 0; }
.details-aside { background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .6rem .75rem; }
.alias-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.alias-chip { display: inline-block; padding: .2rem .5rem; border-radius: 999px; background: #0a1528; border: 1px solid #1f2937; font-size: .9rem; color: var(--text); }
@media (min-width: 820px) {
  .details-grid { grid-template-columns: 1fr minmax(220px, 30%); }
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.tile { background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .75rem; }
.tile .title { font-weight: 600; margin: 0 0 .25rem; }
.tile .subtle { color: var(--muted); font-size: .9rem; }

.stack { display: grid; gap: .5rem; }
.meter { display: flex; align-items: center; justify-content: space-between; background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .6rem .75rem; gap: .75rem; }
.meter .emoji { font-size: 1.1rem; }
.meter .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.meter .score[data-level="high"] { color: var(--danger); }
.meter .score[data-level="medium"] { color: var(--warn); }
.meter .score[data-level="low"] { color: var(--ok); }
/* Make leaderboard rows that act like buttons keyboard accessible */
.meter[role="button"] { cursor: pointer; }
.meter[role="button"]:focus { outline: var(--focus); outline-offset: 2px; }

.generator-controls { display: flex; gap: .5rem; margin-bottom: .5rem; }
.btn { background: var(--accent-2); color: #06090f; border: none; padding: .5rem .75rem; border-radius: .5rem; cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid #155e75; }
.btn:focus { outline: var(--focus); }
.generator-output { display: block; font-size: 1.15rem; min-height: 1.8rem; }

.site-footer { background: var(--panel); border-top: 1px solid #1f2937; margin-top: 2rem; }
.footer-inner { padding: 1rem 0; font-size: .95rem; }
/* Footer links */
.site-footer a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.site-footer a:hover {
  color: var(--accent-2);
  text-decoration-thickness: 2px;
}
.site-footer a:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
  border-radius: .25rem;
}
.site-footer a:visited { color: var(--accent); }
.site-footer a[aria-disabled="true"] {
  color: var(--muted);
  text-decoration: none;
  cursor: not-allowed;
  pointer-events: none;
  opacity: .85;
}

/* Leaderboard */
.lb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.lb-card { background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .75rem; }
.rank-list { margin: .5rem 0 0; padding-left: 1.25rem; }
.rank-list li { margin: .25rem 0; }

/* Leaderboard: trophy + honorable mention */
.rank-list li.meter { list-style: none; padding-left: .6rem; }
.rank-list { padding-left: 0; }
.trophy { font-size: 1.1rem; }
.trophy[data-rank="1"] { filter: drop-shadow(0 0 2px rgba(253, 224, 71, 0.5)); }
.trophy[data-rank="2"] { filter: drop-shadow(0 0 2px rgba(203, 213, 225, 0.5)); }
.trophy[data-rank="3"] { filter: drop-shadow(0 0 2px rgba(234, 179, 8, 0.5)); }
.hm { display: inline-block; padding: .1rem .4rem; border-radius: .35rem; font-size: .8rem; color: var(--muted); border: 1px dashed #334155; }

/* Forms */
.form-row { display: grid; gap: .35rem; }
#suggest-form label { font-weight: 600; }
#suggest-form input[type="text"],
#suggest-form input[type="url"],
#suggest-form input[type="email"],
#suggest-form textarea {
  width: 100%;
  padding: .7rem .9rem;
  border-radius: .5rem;
  border: 1px solid #374151;
  background: #0b1220;
  color: var(--text);
}
#suggest-form textarea { resize: vertical; min-height: 6rem; }
#suggest-form input::placeholder,
#suggest-form textarea::placeholder { color: #6b7280; }
#suggest-form input:focus,
#suggest-form textarea:focus { outline: var(--focus); outline-offset: 2px; border-color: #2563eb; }
#suggest-form input:invalid:focus { border-color: var(--danger); }
.form-actions { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; }
#suggest-status { display: block; min-height: 1.25rem; margin-top: .25rem; }

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

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* Mobile header fixes: wrap nav and avoid horizontal scroll */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  /* Keep brand and login button on a single line */
  .header-inner { flex-wrap: nowrap; gap: .5rem; align-items: center; justify-content: space-between; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand .logo-wordmark { height: 48px; max-width: 55vw; }
  .site-nav { flex: 0 0 auto; width: auto; margin-left: .5rem; }
  /* Show only the Login button in the nav */
  .site-nav ul { flex-wrap: nowrap; gap: 0; justify-content: flex-end; }
  /* Hide anchor links; leave the Login button visible */
  .site-nav a { display: none !important; }
}

/* Fun Mode accents */
.fun .site-header { background: linear-gradient(90deg, var(--panel) 0%, #1b2437 100%); }
.fun .brand .logo { filter: drop-shadow(0 0 6px var(--fun-2)); }
.fun .card { border-color: #23324f; box-shadow: 0 0 0 1px #0b1220, 0 6px 18px rgba(0,0,0,0.25); }

/* Rename ticker */
.ticker { position: relative; overflow: hidden; border-radius: .5rem; border: 1px solid #1f2937; background: #0b1220; }
.ticker-track { display: inline-block; white-space: nowrap; padding: .6rem .75rem; animation: ticker-scroll var(--ticker-duration) linear infinite; }
.ticker .pill { display: inline-flex; align-items: center; gap: .35rem; background: #0a1528; border: 1px solid #1f2937; color: var(--text); border-radius: 999px; padding: .25rem .6rem; margin-right: .5rem; }
.ticker .arrow { color: var(--accent-2); }
.ticker .when { color: var(--muted); font-size: .85rem; }
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.paused .ticker-track { animation-play-state: paused; }

/* Confetti canvas */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 999; }

/* Modal */
.modal[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-dialog { position: relative; margin: 8vh auto; width: min(680px, 92vw); background: var(--panel-2); border: 1px solid #1f2937; border-radius: .75rem; padding: 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.modal-close { position: absolute; top: .5rem; right: .5rem; background: transparent; color: var(--text); border: 1px solid #334155; border-radius: .35rem; padding: .2rem .45rem; cursor: pointer; }
.modal-close:focus { outline: var(--focus); }

/* Make the details modal wider and constrain height for large content */
#details-modal .modal-dialog {
  width: min(1040px, 96vw);
  max-height: 88vh;
  overflow: auto;
}

/* Quiz */
.quiz { display: grid; gap: .75rem; }
.quiz .q-header { display: flex; align-items: baseline; justify-content: space-between; }
.quiz .q-card { background: #0b1220; border: 1px solid #1f2937; border-radius: .5rem; padding: .75rem; }
.quiz .choices { display: grid; gap: .5rem; margin-top: .5rem; }
.quiz .choices button { text-align: left; background: #0a1528; border: 1px solid #1f2937; color: var(--text); border-radius: .5rem; padding: .5rem .6rem; cursor: pointer; }
.quiz .choices button:focus { outline: var(--focus); }
.quiz .choices button.correct { border-color: #065f46; box-shadow: 0 0 0 1px #065f46 inset; }
.quiz .choices button.incorrect { border-color: #7f1d1d; box-shadow: 0 0 0 1px #7f1d1d inset; }
.quiz .footer { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }
.quiz .progress { color: var(--muted); }
.quiz .result { font-weight: 700; }
