/* Reusable components. Colored elements take their color via a CSS custom
   property override on the element (e.g. style="--topic-color: var(--topic-prob)")
   rather than hardcoded hex values, per the token system. */

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

/* ---- Floating pill nav ----
   Scoped under .nav-floating (not bare .nav-inner/.nav-links/.nav-follow)
   because problem.html keeps the old sticky-bar nav markup and reuses those
   same class names — bare selectors here would bleed into that untouched page. */

.nav-floating {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 1000px;
  z-index: 100;
  border-radius: 999px;
  background: rgba(10, 10, 12, 0.5);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.05) inset,
    0 10px 36px rgba(0, 0, 0, 0.45);
  transition: transform 420ms cubic-bezier(0.65, 0, 0.35, 1), opacity 420ms ease;
}

/* Ducks out of the way for the full duration of the hero scroll sequence
   (hero-scroll-base.js toggles this) so the effect gets the entire screen. */
.nav-floating.is-hidden {
  transform: translateX(-50%) translateY(-140%);
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .nav-floating {
    transition: none;
  }
}

.nav-floating .nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px;
}

.nav-floating .nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-floating .nav-links a {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 200ms ease;
}

.nav-floating .nav-links a:hover,
.nav-floating .nav-links a.active {
  color: var(--text-primary);
}

.nav-floating .nav-follow {
  font-size: 13px;
  font-weight: 600;
  color: var(--bg-base);
  background: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
  padding: 6px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  transition: background 200ms ease;
}

.nav-floating .nav-follow:hover {
  background: var(--accent-dim);
}

.nav-floating ~ main {
  padding-top: 88px;
}

@media (max-width: 640px) {
  .nav-floating {
    width: calc(100% - 24px);
  }

  .nav-floating .nav-follow {
    display: none;
  }

  .nav-floating .nav-links {
    gap: 20px;
  }
}

/* ---- Nav logo ---- */

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo img {
  height: 28px;
  width: auto;
  display: block;
}

.nav-logo span {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 180ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow var(--transition-fast);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-base);
}

.btn-primary:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover {
    transform: none;
  }
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary:disabled:hover {
  background: var(--accent);
}

/* ---- "What it looks like" figure ----
   A live, working miniature of the problem interface (index.html). The
   inner markup is the real problem-page structure and classes verbatim
   (problem.css is loaded here for exactly that), zoomed down by .fig-scale
   — so the demo is the real thing rendered small, and can't drift from it.
   Only the browser frame below is demo-specific. */

.fig-screen {
  max-width: 920px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Deliberately not scaled down (owner call): a true miniature rendered
   type too small to read comfortably, and legibility beats fidelity of
   scale here. At zoom 1 the demo renders at real size inside a narrower
   frame — i.e. exactly the real page viewed in a ~920px browser window.
   zoom (not transform: scale) is the knob because it's layout-aware: the
   frame's height follows the content and clicks/carets stay aligned. */
.fig-scale {
  zoom: 1;
}

/* The only concession to the frame: the real page's tall bottom padding
   (room to scroll) would read as dead space inside a fixed-height card. */
.fig-scale .problem-main {
  padding-bottom: var(--space-8);
}

/* Shared stopwatch toggle (real problem page + this demo). */
.timer-toggle {
  padding: 0;
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.timer-toggle:hover {
  color: var(--text-primary);
}

/* Browser chrome bar: traffic lights + back arrow on the left, a centered
   URL pill — the "you're looking at a page of this site" frame. */
.fig-browser-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.fig-browser-left {
  position: absolute;
  left: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.fig-dots {
  display: flex;
  gap: 6px;
}

.fig-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.fig-back-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.fig-url {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 18px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-muted);
}

.fig-lock {
  width: 12px;
  height: 12px;
}

/* ---- Topic name (.pill, historical name) ----
   Owner call: no pill/chip background anywhere a topic type appears — the
   colored text alone carries it. Used by the about page's topic cards and
   the problem page's toolbar. Don't reintroduce a background/border here. */

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--topic-color);
  white-space: nowrap;
}

/* ---- Topic label ----
   A colored dot + colored text, no badge/pill shape — used in the carousel
   and problems table, where a colored chip on every row read as a stock
   SaaS-dashboard tell. Same "dot + colored value" language as the
   difficulty display right next to it. */

.topic-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--topic-color);
  white-space: nowrap;
}

.topic-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--topic-color);
  flex-shrink: 0;
}

/* ---- Difficulty meter + badge ---- */

/* One continuous bar rather than ten discrete pips, filled to the value.
   The fill ramps from a faded to a full-strength version of the band's own
   color. A spectrum gradient across the whole 1-10 scale was tried first
   and read as "green with a tinted tip" on every single row — a bar filled
   from zero always shows the low end of the scale, so green dominates no
   matter how hard the problem is. Keying the ramp to the band instead
   makes a 9/10 unmistakably red at a glance, while length still carries
   the exact value. */
.diff-meter {
  display: inline-block;
  width: 58px;
  height: 12px;
  border-radius: 3px;
  background: var(--border-default);
  vertical-align: middle;
  /* Clips the fill's square right edge back to the track's rounding at
     10/10, where the two would otherwise collide at the corners. */
  overflow: hidden;
}

.diff-meter-fill {
  display: block;
  height: 100%;
  /* Left cap follows the track; the right end cuts off hard, so the fill
     reads as a level being marked rather than a floating pill. */
  border-radius: 3px 0 0 3px;
  /* Opaque ramp: a deep shade of the band's color into the full-strength
     one. Mixing toward `transparent` instead let the gray track show
     through the fill and muddied it. */
  background-image: linear-gradient(
    90deg,
    color-mix(in srgb, var(--diff-color) 60%, var(--bg-base)),
    var(--diff-color)
  );
}

.badge-difficulty {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--diff-color);
  font-variant-numeric: tabular-nums;
}

/* ---- Form controls ---- */

.search-input,
.select-input {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  min-width: 180px;
  transition: border-color var(--transition-fast);
}

.select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}

.filter-group--search {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.filter-bar .search-input {
  padding-left: 34px;
}

/* The .filter-bar-scoped rule in layout.css sets `background: transparent`
   (shorthand), which wipes out .select-input's chevron background-image
   since they share specificity — restore it here, scoped the same way so
   this wins on source order instead of fighting specificity. */
.filter-bar .select-input {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  background-size: 14px;
}

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

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

.search-input:disabled,
.select-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---- Problems table ----
   Each row carries its topic color as a CSS variable (set inline by
   problems.js) so hover/accent treatments can reference --topic-color
   directly instead of matching on a child element's inline style.
   Fixed layout + explicit widths on every column but Title so the title
   (the thing people are actually scanning for) gets the space, instead of
   the browser's auto-layout guessing from content and starving it. */

.problems-table {
  table-layout: fixed;
}

.problems-table th:nth-child(1),
.problems-table td:nth-child(1) {
  width: 44px;
}

.problems-table th:nth-child(3),
.problems-table td:nth-child(3) {
  width: 130px;
}

.problems-table th:nth-child(4),
.problems-table td:nth-child(4) {
  width: 150px;
}

/* "Luminous Ledger": no header fill, no cell fills — hairlines and type
   only. The hovered row adopts the site's glow language: its underline
   and index numeral light up in the accent. */
.problems-table thead th {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
}

.problems-table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.problems-table tbody tr:hover td {
  background: rgba(var(--accent-rgb), 0.03);
  border-bottom-color: rgba(var(--accent-rgb), 0.4);
}

/* Each row only owns its bottom border, so the "top line" of a hovered row
   is the row above it — light that one's bottom border too. For the first
   row, the line above it is the header's underline. */
.problems-table tbody tr:has(+ tr:hover) td {
  border-bottom-color: rgba(var(--accent-rgb), 0.4);
}

.problems-table:has(tbody tr:first-child:hover) thead th {
  border-bottom-color: rgba(var(--accent-rgb), 0.4);
}

.problems-table tbody tr:hover .cell-index {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.5);
}

/* Topic reads as plain colored text in the table — no dot. The label text
   itself is the non-color signal, so nothing is lost for colorblind
   visitors; the dot stays elsewhere (carousel) where rows are sparser. */
.problems-table .topic-label::before {
  content: none;
}

.cell-index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-disabled);
  text-align: right;
  transition: color var(--transition-fast), text-shadow var(--transition-fast);
}

.cell-main {
  max-width: 0;
}

.cell-title {
  display: block;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color var(--transition-fast);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-title:focus-visible {
  color: var(--topic-color);
}

.cell-teaser {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* .cell-difficulty is the <td> itself — never give a table cell
   `display: flex` directly, it stops the cell stretching to the row's
   height (row height is driven by its sibling cells), leaving a gap below
   it that shows the page background through: the "black rectangle" bug.
   The flex layout lives on the inner .diff-display wrapper instead. */
.diff-display {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  white-space: nowrap;
}

/* Narrower topic/difficulty columns + number-only difficulty below 640px —
   the full-size 152px/150px columns would otherwise starve the title
   column on a phone-width screen. Topic stays plain text (no icon to drop
   here), just truncates if "Game Theory" doesn't fit. */
@media (max-width: 640px) {
  .problems-table th:nth-child(3),
  .problems-table td:nth-child(3) {
    width: 92px;
  }

  .problems-table th:nth-child(4),
  .problems-table td:nth-child(4) {
    width: 56px;
  }

  .topic-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .diff-meter {
    display: none;
  }

  .problems-table thead th:nth-child(3),
  .problems-table thead th:nth-child(4) {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.empty-state {
  padding: var(--space-16) var(--space-6);
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---- About page: criteria cards ---- */

.criteria-card {
  padding: 40px 0 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.criteria-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 72px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.15;
  margin-bottom: 20px;
  transition: opacity var(--transition-base);
}

.criteria-card:hover .criteria-number {
  opacity: 0.3;
}

.criteria-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---- About page: topics list ----
   Quiet definition list, not a card grid — no background, no border, no
   pill. Topic name is plain colored text (topics.js fills the live problem
   count from the real data). */

.topics-list {
  margin-top: var(--space-6);
}

.topic-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  margin: 0 calc(-1 * var(--space-4));
  border-top: 1px solid var(--border-subtle);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.topic-row:last-child {
  border-bottom: 1px solid var(--border-subtle);
}

/* Same luminous-hover language as the problems table: a faint white glow,
   not a topic-colored one — border lights up and the topic name gets a
   soft white text-shadow (its own hue is kept, the glow just sits on top). */
.topic-row:hover {
  background: rgba(var(--accent-rgb), 0.03);
  border-top-color: rgba(var(--accent-rgb), 0.4);
}

.topic-row:last-child:hover {
  border-bottom-color: rgba(var(--accent-rgb), 0.4);
}

/* Each row only owns its top border, so the "bottom line" of a hovered row
   is the next row's top border (the last row's own bottom border is
   handled above). */
.topic-row:hover + .topic-row {
  border-top-color: rgba(var(--accent-rgb), 0.4);
}

.topic-row-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--topic-color);
}

.topic-row-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 60ch;
}

.topic-row-count {
  display: inline-block;
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.topic-row-count:hover {
  color: var(--text-primary);
}

.topic-row-count-num {
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .topic-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}

/* Pagination — problems table pager. Same visual language as the filter
   controls above: surface buttons, default borders, mono numerals. The
   active page inverts to the accent fill; arrows disable at the ends. */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.page-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.page-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-base);
  cursor: default;
}

.page-btn:disabled {
  color: var(--text-disabled);
  cursor: default;
}
