/* Kulturpool Partner-Portal design system (../partner-portal/DESIGN-SYSTEM.md);
   dark roles follow prefers-color-scheme. */

:root {
  --zinc-50:#fafafa;  --zinc-100:#f4f4f5; --zinc-200:#e4e4e7; --zinc-300:#d4d4d8;
  --zinc-400:#9f9fa9; --zinc-500:#71717b; --zinc-600:#52525c; --zinc-700:#3f3f46;
  --zinc-800:#27272a; --zinc-900:#18181b;
  --indigo-500:#615fff;
  --red-400:#ff6467;    --red-500:#fb2c36;
  --yellow-400:#fdc700; --yellow-500:#f0b100;

  --bg:#ffffff;
  --bg-muted:var(--zinc-50);
  --bg-elevated:var(--zinc-100);

  --text-dimmed:var(--zinc-400);
  --text-muted:var(--zinc-500);
  --text-toned:var(--zinc-600);
  --text-default:var(--zinc-700);
  --text-highlighted:var(--zinc-900);
  --text-inverted:#ffffff;

  --border:var(--zinc-200);
  --border-muted:var(--zinc-200);
  --border-accented:var(--zinc-300);

  --primary:var(--indigo-500);
  --error:var(--red-500);
  --warning:var(--yellow-500);

  --radius:2px;
  --radius-md:calc(var(--radius) * 1.5);
  --radius-lg:calc(var(--radius) * 2);
  --radius-xl:calc(var(--radius) * 3);

  --font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
              "Liberation Mono", "Courier New", monospace;
  --text-xs:.75rem;
  --text-sm:.875rem;  --text-sm-lh:1.4286;
  --text-base:1rem;
  --text-lg:1.125rem; --text-lg-lh:1.5556;
  --fw-medium:500; --fw-semibold:600; --fw-bold:700;

  --space-1:4px;  --space-2:8px;  --space-3:12px; --space-4:16px;
  --space-5:20px; --space-6:24px; --space-8:32px; --space-12:48px;

  --shadow-lg:0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --header-height:64px;
  --transition-colors:color .15s, background-color .15s, border-color .15s;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:var(--zinc-900);
    --bg-muted:var(--zinc-800);
    --bg-elevated:var(--zinc-800);

    --text-dimmed:var(--zinc-500);
    --text-muted:var(--zinc-400);
    --text-toned:var(--zinc-300);
    --text-default:var(--zinc-200);
    --text-highlighted:#ffffff;
    --text-inverted:var(--zinc-900);

    --border:var(--zinc-800);
    --border-muted:var(--zinc-700);
    --border-accented:var(--zinc-700);

    --primary:#d7e5ff;
    --error:var(--red-400);
    --warning:var(--yellow-400);
  }
}

* {
  box-sizing: border-box;
}

/* Elements with their own `display` would otherwise ignore `hidden`. */
[hidden] {
  display: none !important;
}

html {
  font-family: var(--font-sans);
}

body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  color: var(--text-default);
  background: var(--bg);
  font-size: var(--text-sm);
  line-height: var(--text-sm-lh);
}

/* ---------- design-system components ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-md);
  transition: var(--transition-colors);
  cursor: pointer;
  border: 0;
}

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

.btn--solid {
  background: var(--primary);
  color: var(--text-inverted);
}

.btn--solid:hover {
  background: color-mix(in oklab, var(--primary) 75%, transparent);
}

.btn--solid:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--outline {
  background: var(--bg);
  color: var(--text-default);
  box-shadow: inset 0 0 0 1px var(--border-accented);
}

.btn--outline:hover {
  background: var(--bg-elevated);
}

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

.btn--ghost:hover {
  background: var(--bg-elevated);
}

.input {
  width: 100%;
  padding: 6px 10px;
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.25;
  color: var(--text-highlighted);
  background: var(--bg);
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border-accented);
  transition: var(--transition-colors);
}

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

.input--inline {
  width: auto;
  font-size: var(--text-sm);
}

.input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}

.alert {
  display: flex;
  gap: 10px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
}

.alert--error {
  color: var(--error);
  background: color-mix(in oklab, var(--error) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--error) 25%, transparent);
}

/* Yellow text is unreadable on its own wash, so only the icon is coloured. */
.alert--warning {
  align-items: center;
  padding: 10px var(--space-4);
  color: var(--text-default);
  background: color-mix(in oklab, var(--warning) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warning) 25%, transparent);
}

.alert--warning svg {
  flex: 0 0 auto;
  color: var(--warning);
}

.alert--warning strong {
  font-weight: var(--fw-semibold);
  color: var(--text-highlighted);
}

.card-title {
  font-size: 20px;
  font-weight: var(--fw-bold);
  color: var(--text-highlighted);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.choice-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}

.native-control {
  accent-color: var(--primary);
}

.text-link {
  font-weight: var(--fw-medium);
  text-decoration: underline;
  color: var(--text-toned);
  transition: color 150ms;
}

.text-link:hover {
  color: var(--text-highlighted);
}

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: var(--space-3) var(--space-6);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.bar h1 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-highlighted);
}

.bar-note {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dimmed);
}

.bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}

/* ---------- toolbar: text query, image, vector field, threshold ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.search {
  display: flex;
  gap: var(--space-2);
  flex: 1 1 380px;
}

.search .input {
  flex: 1;
  font-size: var(--text-sm);
}

.input--number {
  width: 5.5rem;
}

/* ---------- dropping a picture ---------- */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  box-shadow: inset 0 0 0 2px var(--primary);
  pointer-events: none;
}

.dropzone p {
  margin: 0;
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-lg);
  font-weight: var(--fw-medium);
  color: var(--text-highlighted);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ---------- messages ---------- */

.message {
  margin: var(--space-4) var(--space-6) 0;
}

.empty {
  margin: var(--space-12) var(--space-6);
  color: var(--text-dimmed);
  text-align: center;
}

.empty--lead {
  margin-bottom: var(--space-5);
  font-size: var(--text-lg);
  line-height: var(--text-lg-lh);
  color: var(--text-muted);
}

/* ---------- the start screen's call to action ---------- */

.start-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin: 0 var(--space-6) var(--space-12);
}

.btn--lg {
  padding: 10px 18px;
  font-size: var(--text-base);
}

.start-hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-dimmed);
  text-align: center;
}

/* ---------- reference panel ---------- */

.reference-panel {
  padding: var(--space-5) var(--space-6) 0;
}

.back {
  margin-bottom: var(--space-4);
}

.reference {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  padding: var(--space-4);
}

.reference-thumb {
  flex: 0 0 180px;
  height: 180px;
  border-radius: var(--radius-xl);
}

.reference-meta h2 {
  margin: 0;
}

.reference-meta .id {
  margin: var(--space-3) 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dimmed);
}

.reference-meta .link {
  display: inline-block;
  margin-top: var(--space-3);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  align-items: center;
  margin-top: var(--space-5);
}

.segmented {
  display: inline-flex;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border-accented);
  overflow: hidden;
}

.segmented button {
  border-radius: 0;
  padding: 6px 16px;
}

.segmented button + button {
  box-shadow: inset 1px 0 0 0 var(--border-accented);
}

.segmented button.active,
.segmented button.active:hover {
  background: var(--primary);
  color: var(--text-inverted);
  font-weight: var(--fw-semibold);
}

.segmented button:disabled,
.segmented button:disabled:hover {
  background: transparent;
  color: var(--text-dimmed);
}

.summary {
  margin: 0;
  padding: var(--space-4) var(--space-6) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.reference-panel + .summary {
  padding-top: var(--space-4);
}

.summary strong {
  font-weight: var(--fw-semibold);
  color: var(--text-highlighted);
}

.summary code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 1px 5px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-toned);
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
}

.result {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: var(--transition-colors);
}

.result:hover {
  box-shadow: inset 0 0 0 1px var(--border-accented);
  background: var(--bg-muted);
}

.thumb {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.15s;
}

/* Dim the previous answer while a search runs; 0.45 because prints on white
   barely change at gentler values. */
.grid--loading .thumb {
  opacity: 0.45;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb.broken img {
  display: none;
}

.thumb.broken::after {
  content: "kein Bild";
  font-size: var(--text-xs);
  color: var(--text-dimmed);
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border-top: 1px solid var(--border-muted);
}

.card-title--result {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  line-height: var(--text-sm-lh);
  color: var(--text-highlighted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.provider {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* The reference object's own institution. */
.provider.same {
  color: var(--text-highlighted);
  font-weight: var(--fw-medium);
}

.distance {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-dimmed);
}
