/* LBLR Strain Library -- the LBLR chrome around a light stage, so artwork is
   judged on the ground it will actually be seen on. */

:root {
  --bg: #080b12;
  --surface: #121826;
  --surface-2: #1a2130;
  --surface-3: #232c3e;
  --field: #0d121d;
  --border: #212a3a;
  --border-strong: #35415a;
  --border-hover: #46546f;
  --text: #e7ecf7;
  --text-muted: #94a1ba;
  --accent: #22d3ee;
  --accent-2: #a78bfa;
  --accent-soft: rgba(34, 211, 238, 0.13);
  --brand-gradient: linear-gradient(115deg, var(--accent), var(--accent-2));
  --danger: #f87171;
  --stage: #f4f4f5;
  --stage-white: #ffffff;
  --radius: 9px;
  --radius-sm: 7px;
  --control-h: 40px;
  --shadow-pop: 0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 48px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 22px; }
.muted { color: var(--text-muted); font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }
[hidden] { display: none !important; }

/* --- LBLR branding ----------------------------------------------------- */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.app-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: none; }
.app-mark svg { width: 38px; height: 38px; display: block; }
.wordmark {
  font-size: 22px; line-height: 1.1;
  background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* "Strain Library" sits on the LBLR baseline at the same size, in the chrome's
   own white rather than the gradient, so the two read as one name. */
.wordmark-sub { font-weight: 800; color: var(--text); -webkit-text-fill-color: var(--text); margin-left: 8px; letter-spacing: -0.01em; }
.credit {
  margin: 2px 0 0; font-size: 10.5px; letter-spacing: 0.085em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap;
}
.credit strong { font-weight: 700; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.credit-foot { text-align: center; margin: 28px 0 0; }

/* --- buttons and inputs ------------------------------------------------- */
.btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius); padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--brand-gradient); color: #04121a; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 13px; }
input[type="search"], input[type="password"] {
  background: var(--field); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 9px 12px; font: inherit; outline: none; min-width: 0;
}
input:focus { border-color: var(--accent); }
.field { display: grid; gap: 6px; }
.field > label, .control > label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
}

/* --- the gate ----------------------------------------------------------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.gate-card form { display: grid; gap: 10px; }
.gate-card .credit { margin-top: 6px; }

/* --- the library -------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: rgba(8, 11, 18, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar input[type="search"] { flex: 1 1 240px; }
.status { padding: 8px 20px 0; min-height: 1em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 16px 20px 40px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: pointer;
  text-align: left; padding: 0; color: inherit; font: inherit; display: grid;
}
.card:hover { border-color: var(--accent); }
.card-thumb { aspect-ratio: 1; background: var(--stage); display: grid; place-items: center; }
.card-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-thumb .spinner { width: 22px; height: 22px; border: 3px solid #d4d4d8; border-top-color: #71717a; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-body { padding: 10px 12px 12px; display: grid; gap: 2px; }
.card-body strong { font-size: 14px; line-height: 1.25; }

/* --- the views, and the generate form ------------------------------------ */
.views { display: flex; gap: 4px; }
.view-tab {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--text-muted);
  padding: 7px 14px; border-radius: var(--radius); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.view-tab:hover { color: var(--text); }
.view-tab.is-on { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.generate { padding: 20px; }
.generate-card { max-width: 560px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; display: grid; gap: 12px; }
.generate-card .strain-name { font-size: 28px; margin: 0; }
.form { display: grid; gap: 14px; }
.form input[type="text"], .form textarea {
  width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; font: inherit; outline: none; resize: vertical;
}
.form input[type="text"]:focus, .form textarea:focus { border-color: var(--accent); }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- the detail: a square stage, exactly the 4 x 4 ----------------------- */
.detail { min-height: 100vh; padding: 16px 20px 40px; }
.detail-inner { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; max-width: 1040px; margin: 0 auto; align-items: start; }
.stage-top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
/* The strain's name, large and in the LBLR gradient: the point of the page. */
.strain-name {
  font-size: clamp(30px, 4.2vw, 44px); font-weight: 900; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 10px;
  padding: 0 0 0.08em; display: inline-block; max-width: 100%;
  background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stage { background: var(--stage-white); border-radius: 16px; aspect-ratio: 1; width: 100%; max-width: 640px; padding: 0; overflow: hidden; }
.stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.stage canvas.is-draggable { cursor: grab; }
.stage canvas.is-dragging { cursor: grabbing; }
.slider { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.slider input { width: 100%; min-width: 0; accent-color: var(--accent); }
.stage-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.controls { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: grid; gap: 16px; align-content: start; min-width: 0; }
/* A long brand name must shorten with an ellipsis, not push the column wider. */
.controls > *, .field, .picker { min-width: 0; }
.picker-button { min-width: 0; max-width: 100%; }
.control { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 6px 11px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.versions { display: flex; flex-wrap: wrap; gap: 6px; }
.version {
  width: 64px; height: 64px; border-radius: 10px; border: 2px solid var(--border-strong); background: var(--stage);
  padding: 0; cursor: pointer; overflow: hidden; display: grid; place-items: center;
}
.version img { width: 100%; height: 100%; object-fit: contain; display: block; }
.version.is-on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* --- picker: LBLR's dropdown, as in the tool ---------------------------- */
.picker { position: relative; width: 100%; }
.picker-button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--control-h); padding: 5px 10px 5px 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--field); color: var(--text);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.picker-button:hover:not(:disabled) { border-color: var(--border-hover); }
.picker-button:focus-visible, .picker-button[aria-expanded="true"] { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.picker-button:disabled { opacity: 0.55; cursor: not-allowed; }
.picker-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-text.is-placeholder { color: var(--text-muted); }
.picker-chevron { color: var(--text-muted); display: inline-flex; transition: transform 0.15s ease; }
.picker-button[aria-expanded="true"] .picker-chevron { transform: rotate(180deg); }
.picker-visual { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; overflow: hidden; }
.picker-visual.is-image {
  background-color: var(--stage-white);
  background-image: linear-gradient(45deg, #d9dde5 25%, transparent 25%, transparent 75%, #d9dde5 75%), linear-gradient(45deg, #d9dde5 25%, transparent 25%, transparent 75%, #d9dde5 75%);
  background-size: 8px 8px; background-position: 0 0, 4px 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.picker-visual.is-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-visual.is-swatch { width: 16px; height: 16px; margin: 0 4px; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.4); }
.picker-visual.is-blank { width: 16px; height: 16px; margin: 0 4px; border: 1.5px dashed var(--border-strong); }
.picker-menu {
  position: fixed; z-index: 120; display: flex; flex-direction: column; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-pop); overflow: hidden; animation: picker-in 0.12s ease-out;
}
.picker-menu.is-above { animation-name: picker-in-above; }
@keyframes picker-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes picker-in-above { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.picker-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
.picker-search-icon { color: var(--text-muted); display: inline-flex; }
.picker-search { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; padding: 4px 0; }
.picker-search:focus { outline: none; }
.picker-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.picker-list { overflow-y: auto; padding: 6px; outline: none; }
.picker-group { padding: 8px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text); }
.picker-item .picker-visual { width: 28px; height: 28px; }
.picker-item .picker-visual.is-swatch, .picker-item .picker-visual.is-blank { width: 16px; height: 16px; margin: 0 6px; }
.picker-item-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item-hint { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.picker-item.is-active { background: var(--surface-3); }
.picker-item.is-selected { color: var(--accent); font-weight: 600; }
.picker-tick { color: var(--accent); display: inline-flex; }
.picker-empty { padding: 18px 10px; text-align: center; color: var(--text-muted); font-size: 13px; }

@media (max-width: 860px) {
  .detail-inner { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 12px 14px 30px; }
  .topbar { padding: 12px 14px; }
}
