@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans-latin.61bdf7ac.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/ibm-plex-mono-latin.bb1b581a.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Black & white, dark because this is used in badly-lit tournament halls
     and at night. */
  --bg: #000000;
  --surface: #191919;
  --surface-2: #333333;
  --text: #f5f5f5;
  --muted: #929292;
  --accent: #ffffff; /* focus & active states only */

  /* Provenance colors - encode ruling source reliability, not decoration.
     Kept in color (unlike the rest of the b&w UI) so sections stay
     distinguishable at a glance. */
  --src-faq: #4fa3d1;
  --src-netrep: #57b87f;
  --src-qa: #c972a8;
  --src-judge: #e8b33c;
  --src-cardruling: #7e9cc7;
  --src-other: var(--muted);
  --src-notes: var(--muted);

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

[data-view='home'] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

[hidden] {
  display: none !important;
}

/* ---- Home view ---- */

.search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 16px) 16px 8px;
}

.search-field {
  position: relative;
}

#search-input {
  width: 100%;
  height: 48px;
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 20px;
  letter-spacing: 0.04em;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-2);
  padding: 14px 40px 14px 16px;
  -webkit-appearance: none;
  appearance: none;
}

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

/* Native clear icon is unstyleable in a reliable, cross-browser way (Chrome
   silently drops background-image/mask-image on this UA shadow pseudo-
   element) - hidden in favor of the custom .clear-search button below. */
#search-input::-webkit-search-cancel-button {
  display: none;
}

.clear-search {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.clear-search svg {
  width: 18px;
  height: 18px;
}

.muted {
  color: var(--muted);
}

.empty-state {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 32px;
  gap: 12px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  color: var(--muted);
  opacity: 0.6;
}

.empty-state-title {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  font-size: 17px;
  font-weight: 400;
  margin: 0;
  color: var(--text);
}

.empty-state-text {
  font-size: 14px;
  color: var(--muted);
  max-width: 32ch;
  margin: 0;
}

.empty-state-links {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.empty-state-links a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  overscroll-behavior-y: contain;
}

.result-row {
  display: block;
}

.result-row a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  text-decoration: none;
  color: var(--text);
  transition: background-color 80ms;
}

.result-row a:active,
.result-row a:hover {
  background: var(--surface);
}

.result-name {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-chevron {
  display: inline-flex;
  color: var(--muted);
  flex: none;
}

.result-chevron svg {
  width: 18px;
  height: 18px;
}

#no-results {
  padding: 16px;
}

#no-results .hint {
  display: block;
  margin-top: 4px;
}

.recent-heading {
  margin: 8px 16px 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Card / page view ---- */

.card-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 16px) 16px 8px;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 20px;
  letter-spacing: 0.04em;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-2);
  padding: 14px 16px;
  text-decoration: none;
}

.nameplate {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  font-size: 22px;
  font-weight: 400;
  margin: 8px 16px 16px;
}

.card-text-block {
  margin: -8px 16px 20px;
}

.card-text-block .section-label {
  margin-bottom: 8px;
}

.card-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.card-text p {
  margin: 0 0 8px;
}

.card-text ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-text li {
  position: relative;
  margin: 0 0 6px;
  padding-left: 1.25em;
}

.card-text p:last-child,
.card-text li:last-child {
  margin-bottom: 0;
}

.card-text li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--muted);
}

.page-content {
  margin: 0 16px 24px;
  font-size: 15px;
  line-height: 1.6;
}

.page-content h2 {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 8px;
}

.page-content h2:first-child {
  margin-top: 0;
}

.page-content h3 {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 6px;
}

.page-content p {
  margin: 0 0 12px;
}

.page-content ul,
.page-content ol {
  margin: 0 0 12px;
  padding-left: 1.25em;
}

.page-content li {
  margin-bottom: 6px;
}

.page-content strong {
  font-weight: 600;
}

.section {
  border-left: 3px solid var(--src-other);
  padding: 4px 16px 16px 13px;
  margin: 0 16px 16px 0;
}

.section[data-kind='faq'] {
  border-color: var(--src-faq);
}
.section[data-kind='netrep'] {
  border-color: var(--src-netrep);
}
.section[data-kind='qa'] {
  border-color: var(--src-qa);
}
.section[data-kind='judge'] {
  border-color: var(--src-judge);
}
.section[data-kind='cardruling'] {
  border-color: var(--src-cardruling);
}
.section[data-kind='other'] {
  border-color: var(--src-other);
}
.section[data-kind='notes'] {
  border-color: var(--src-notes);
}

.section-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.section li {
  position: relative;
  margin: 0 0 10px;
  padding-left: 1.25em;
}

.section li:last-child {
  margin-bottom: 0;
}

.section li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--muted);
}

.qa-q,
.qa-a,
.qa-attr {
  margin: 0;
}

.qa-q {
  font-weight: 600;
  margin-bottom: 4px;
}

.qa-attr {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ---- Footer / toasts ---- */

.site-footer {
  margin-top: auto;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  opacity: 0.6;
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  font-size: 14px;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.toast button {
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  margin-left: 4px;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  .result-row a {
    transition: none;
  }
}

@media (min-width: 480px) {
  .nameplate {
    font-size: 26px;
  }
}
