/* Vocabulary page only */
.vocabulary-page {
  --background: #000;
  --card: #101010;
  --panel: #191919;
  --foreground: #fff;
  --muted: #9a9a9a;

  margin: 0;
  padding: 14px;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color-scheme: dark;
}

.vocabulary-page *,
.vocabulary-page *::before,
.vocabulary-page *::after {
  box-sizing: border-box;
}

.vocabulary-page [hidden] {
  display: none !important;
}

.vocabulary-page :where(button, input, select, textarea) {
  font: inherit;
}

.vocabulary-page button {
  cursor: pointer;
}

.vocabulary-page button:disabled {
  cursor: wait;
}

.vocabulary-page :where(button, input, a):focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

/* The page sits inside one rounded card */
.vocabulary-card {
  min-height: calc(100dvh - 28px);
  padding: 30px 40px 48px;
  border-radius: 30px;
  background: var(--card);
}

.vocabulary-page .site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 34px;
  font-size: clamp(0.75rem, 3.4vw, 3.25rem);
}

.vocabulary-page .site-header h1 {
  margin: clamp(36px, 8vh, 96px) 0 0;
  font-family: inherit;
  font-size: 2em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.vocabulary-page .home-link {
  flex-shrink: 0;
  color: var(--foreground);
  font-family: inherit;
  font-size: 1em;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

/* Search, with the Filters button beside it */
.vocabulary-toolbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

#word-search {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-weight: 600;
  color-scheme: light;
}

/* Only the prompt shouts; what you type keeps its own capitalisation. */
#word-search::placeholder {
  color: #4f4f4f;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 1;
}

/* Opens the filters. Bordered like the toggles inside, and filled white
   while open, the way a toggle shows it is on. */
.filter-toggle {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 18px 0 22px;
  border: 2px solid #3a3a3a;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.filter-toggle:hover:not(:disabled) {
  border-color: #fff;
}

.filter-toggle[aria-expanded="true"] {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.filter-toggle:disabled {
  opacity: 0.35;
}

/* How many filters are on, readable at a glance with the panel shut. */
.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  background: #fff;
  color: #000;
  font-size: 0.75rem;
  letter-spacing: 0;
}

.filter-toggle[aria-expanded="true"] .filter-count {
  background: #000;
  color: #fff;
}

.filter-chevron {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.filter-toggle[aria-expanded="true"] .filter-chevron {
  transform: rotate(180deg);
}

/* What is applied: one white tag per filter, as a chosen toggle looks, each
   removed by its cross. The count of matching words sits at the end. */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 14px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.filter-chips:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px 0 14px;
  border: 2px solid #fff;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-size: 0.85rem;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease;
}

.filter-chip:hover {
  background: transparent;
  color: #fff;
}

.filter-chip svg {
  display: block;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.match-count {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Filters, when open: a panel in the same tone as the word details. */
.word-filters {
  margin-top: 14px;
  padding: 24px;
  background: var(--panel);
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 22px 52px;
}

.filter-groups fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-groups legend {
  margin-bottom: 12px;
  padding: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Filter values are words, so they keep their own case. */
.option-toggle {
  display: inline-grid;
  grid-template-columns: 40px auto;
  align-items: stretch;
  height: 40px;
  cursor: pointer;
}

.option-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
}

.option-filter {
  position: relative;
  border: 2px solid #3a3a3a;
  transition: background 0.2s ease, border-color 0.2s ease;
}

/* The tick is drawn rather than typed, so it never depends on a font. */
.option-filter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 7px;
  border-left: 3px solid #000;
  border-bottom: 3px solid #000;
  opacity: 0;
  transform: translate(-50%, -65%) rotate(-45deg);
  transition: opacity 0.2s ease;
}

.option-body {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 2px solid #3a3a3a;
  border-left: 0;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.option-toggle input:checked ~ .option-filter {
  border-color: #fff;
  background: #fff;
}

.option-toggle input:checked ~ .option-filter::after {
  opacity: 1;
}

.option-toggle input:checked ~ .option-body {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.option-toggle:hover .option-filter,
.option-toggle:hover .option-body {
  border-color: #fff;
}

.option-toggle input:focus-visible ~ .option-filter {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.option-toggle input:disabled ~ .option-filter,
.option-toggle input:disabled ~ .option-body {
  opacity: 0.35;
}

.additional-filter-groups {
  display: contents;
}

.text-button {
  min-height: 40px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.text-button:hover {
  color: var(--foreground);
}

.page-status,
.no-matches {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Jump to a letter */
.alphabet-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 30px;
}

.alphabet-link {
  min-width: 34px;
  height: 34px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: background 0.15s ease, color 0.15s ease;
}

.alphabet-link:hover:not(:disabled) {
  background: #fff;
  color: #000;
}

.alphabet-link:disabled {
  color: #3e3e3e;
  cursor: default;
}

/* Words on the left, details on the right */
.vocabulary-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 24rem);
  gap: 48px;
  margin-top: 36px;
  align-items: start;
}

.letter-group {
  scroll-margin-top: 20px;
}

.letter-group + .letter-group {
  margin-top: 30px;
}

/* The letter bookends its words. */
.letter-heading {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #2b2b2b;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.letter-words {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 40px;
}

.word-item {
  break-inside: avoid;
}

/* Vocabulary keeps its own capitalisation. */
.word-trigger {
  display: block;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--foreground);
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-align: left;
  overflow-wrap: anywhere;
  transition: opacity 0.15s ease;
}

/* Only shown where two words share a spelling; a meaning, so it keeps its
   own capitalisation and sits quietly beside the word. */
.word-sense {
  margin-left: 10px;
  color: var(--muted);
  font-size: 0.68em;
  font-weight: 600;
  letter-spacing: 0;
}

.word-trigger:hover,
.word-trigger[aria-pressed="true"] {
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

.word-list:hover .word-trigger:not(:hover) {
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  .vocabulary-page {
    scroll-behavior: auto;
  }
}

.word-trigger[aria-pressed="true"] {
  opacity: 1 !important;
}

/* Details panel */
.detail-column {
  position: sticky;
  top: 14px;
}

.word-details {
  padding: 28px;
  border-radius: 0;
  background: var(--panel);
}

.details-placeholder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.details-placeholder span {
  color: #5c5c5c;
  font-size: 0.72rem;
}

.details-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.details-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.25rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

/* Listen and unpin sit together at the right of the heading. */
.details-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

/* A square icon button, bordered like the filters and filling on hover. */
.icon-button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid #3a3a3a;
  background: transparent;
  color: var(--foreground);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
  border-color: #fff;
  background: #fff;
  color: #000;
}

/* The pin is drawn, so it never depends on an icon font loading. */
.icon-button svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.details-meaning {
  margin: 14px 0 26px;
  color: var(--muted);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.details-title {
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.details-table th,
.details-table td {
  padding: 9px 0;
  border-top: 1px solid #2b2b2b;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

/* Field names are interface; their values are vocabulary. */
.details-table th {
  width: 46%;
  padding-right: 14px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.details-table td {
  font-weight: 700;
}

.details-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .letter-words {
    columns: 1;
  }
}

/* On a phone the search keeps the whole row; Filters drops beneath it. */
@media (max-width: 480px) {
  .vocabulary-toolbar {
    flex-wrap: wrap;
  }

  #word-search {
    flex-basis: 100%;
  }

  .filter-toggle {
    height: 44px;
  }
}

@media (max-width: 860px) {
  .vocabulary-page {
    padding: 10px;
  }

  .vocabulary-card {
    min-height: calc(100dvh - 20px);
    padding: 22px 20px 40px;
    border-radius: 22px;
  }

  .vocabulary-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  /* On a narrow screen the panel belongs above the list, where a tap can
     be seen without scrolling back up. */
  .detail-column {
    position: static;
    order: -1;
  }


}
