/* Better Formulas — Library alphabetical index + dedicated search
   New, standalone stylesheet. Only referenced by library.html.
   Does not modify or override anything in theme.css. */

.library-index {
  max-width: 720px;
  margin: 0 auto;
}

/* --- Alphabet grid: 6 letters per row. 26 letters = four full rows of 6
   plus a final row of 2 (Y, Z) — that's just what's left over, so no
   special CSS is needed to force a short last row. Grid auto-placement
   handles it. --- */
.library-index__grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.library-index__letter {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.library-index__letter:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.library-index__letter.is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.library-index__letter.is-empty {
  color: var(--text-muted);
  opacity: 0.55;
}

/* --- Search the Library ---
   The label sits flush with the grid's left edge; the input+button row
   spans the full width of the same container, so its right edge lines up
   with the grid's right edge automatically — both live in one
   .library-index wrapper of identical max-width. */
.library-index__search {
  margin-bottom: 8px;
}
.library-index__search-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.library-index__search-blurb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 10px;
}
.library-index__search-row {
  display: flex;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.library-index__search-row input[type="search"] {
  flex: 1;
  border: none;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.library-index__search-row input[type="search"]:focus {
  outline: 2px solid var(--green-medium);
  outline-offset: -2px;
}
.library-index__search-row button {
  border: none;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 22px;
  cursor: pointer;
  white-space: nowrap;
}
.library-index__search-row button:hover {
  background: var(--green-medium);
  color: #0f151b;
}

/* --- Results: hidden entirely until a letter is clicked or a search runs --- */
.library-index__results {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.library-index__results[hidden] {
  display: none;
}
.library-index__results-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.library-index__results-heading h2 {
  font-size: 1.05rem;
  margin: 0;
}
.library-index__results-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}
.library-index__results-clear:hover { color: var(--text); }

.library-index__result-list {
  display: grid;
  gap: 12px;
}
.library-index__result-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: inherit;
}
a.library-index__result-card:hover {
  border-color: var(--navy);
}
.library-index__result-card p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.library-index__result-card .tag-pill {
  flex-shrink: 0;
}
.library-index__coming-soon {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.library-index__no-results {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .library-index__grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }
  .library-index__letter { font-size: 0.95rem; }
  .library-index__search-row { flex-direction: column; }
  .library-index__search-row button { width: 100%; }
}
