﻿/* Reset & variables */
* { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #111722;
  --bg-top: #252f3f;
  --bg-deep: #090d16;
  --panel: rgba(17, 24, 37, 0.9);
  --panel-soft: rgba(17, 24, 37, 0.75);
  --line: rgba(168, 188, 219, 0.24);
  --text: #eef3fc;
  --muted: #a9b7cd;
  --accent: #c5d3ea;
  --accent-deep: #1a2438;
  --tag: #314056;
  --success: #8bd8ad;
  --danger: #f0a8a8;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.4);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(136, 151, 175, 0.24), transparent 30%),
    radial-gradient(circle at top right, rgba(106, 121, 146, 0.3), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg));
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.85), transparent 85%);
}

.library-shell {
  position: relative;
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 70px;
}

/* Account button */
.minimal-login-bar {
  position: relative;
  top: 0;
  left: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto 0 auto;
  padding: 18px 0 0 0;
  background: transparent;
  z-index: 100;
  border-radius: 0 0 0 18px;
  box-shadow: none;
  border-bottom: none;
}

.minimal-login-bar .back-home-link {
  margin-right: auto;
  padding: 0;
  min-height: unset;
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  transition: color 0.15s;
}
.minimal-login-bar .back-home-link:hover {
  color: var(--text);
  transform: none;
}

.minimal-login-bar .account-menu-btn {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0 8px 0 0;
  min-width: unset;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.minimal-login-bar .account-menu-btn img {
  filter: brightness(0) invert(1);
  width: 28px;
  height: 28px;
  display: block;
}

.minimal-login-bar .account-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #131c2b;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 16px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(168, 188, 219, 0.2);
  z-index: 200;
}

.minimal-login-bar .home-auth-status {
  margin: 0;
  font-size: 0.86rem;
  color: #d7e2f5;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(168, 188, 219, 0.15);
}

.minimal-login-bar .home-dev-login {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 6px;
}

.minimal-login-bar input[type="text"] {
  width: 80px;
  padding: 2px 6px;
  font-size: 0.97em;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  transition: border 0.15s;
}

.minimal-login-bar input[type="text"]:focus {
  border: 1.5px solid #8bd8ad;
  outline: none;
}

.minimal-login-bar button {
  font-size: 0.97em;
  padding: 3px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  transition: background 0.15s, color 0.15s;
}

.minimal-login-bar button:hover {
  background: #232c3e;
  color: #8bd8ad;
}

.minimal-login-bar .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.minimal-login-bar .button:hover { transform: none; }
.minimal-login-bar .button-primary { background: linear-gradient(135deg, #e8edf6, #c4cfde); color: #111722; border-color: transparent; }
.minimal-login-bar .button-primary:hover { background: linear-gradient(135deg, #f0f4fc, #d0daea); }
.minimal-login-bar .button-secondary { border-color: rgba(168, 188, 219, 0.22); background: rgba(255,255,255,0.04); color: var(--text); }
.minimal-login-bar .button-secondary:hover { background: rgba(255,255,255,0.09); }

/* Typography */
h1, h2, h3 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  letter-spacing: 0.05em;
}

h1 {
  margin-top: 8px;
  font-size: clamp(2.8rem, 7vw, 4.4rem);
  line-height: 0.92;
}

.eyebrow, .kicker, .meta-list dt {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Hero */
.library-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.hero-copy, .upload-card, .filters, .results-header, .library-card, .empty-state {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy { padding: 28px; }

.hero-copy p {
  margin: 14px 0 0;
  line-height: 1.65;
  color: #d7e2f5;
}

.hero-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Upload card */
.upload-card {
  padding: 24px;
  border-top-right-radius: 0 !important;
}

.upload-card h2 { font-size: 2rem; }

.upload-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.upload-note { font-size: 0.92rem; color: #d7e2f5; }

.upload-signup-prompt {
  margin: 10px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}
.upload-signup-prompt a {
  color: #8bd8ad;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.upload-signup-prompt a:hover { color: #b2edcc; }

.upload-drop {
  margin-top: 14px;
  display: grid;
  gap: 6px;
  padding: 24px 18px;
  border: 1px dashed rgba(187, 208, 243, 0.42);
  border-radius: 18px;
  background: var(--panel-soft);
  cursor: pointer;
}

.upload-drop input { display: none; }
.upload-title { font-weight: 700; }
.upload-sub { color: var(--muted); font-size: 0.9rem; }

.upload-status {
  min-height: 22px;
  margin-top: 10px;
  color: var(--success);
  font-size: 0.92rem;
}

/* Filters */
.filters {
  margin-top: 22px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 0.8fr 0.8fr;
  gap: 12px;
}

.filter-field { display: grid; gap: 7px; }

.filter-field label {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

input, select {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(180, 201, 236, 0.25);
  border-radius: 12px;
  background: #10192a;
  color: var(--text);
  font: inherit;
}

/* Results */
.results-header { margin-top: 16px; padding: 14px 18px; }
.results-header h2 { font-size: 2rem; }

/* Library grid */
.library-grid {
  margin-top: 14px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.library-card {
  padding: 16px;
  display: grid;
  gap: 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(17,25,39,0.95), rgba(11,17,29,0.9));
}

.card-top { display: grid; gap: 2px; }

.card-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.library-card h3 { font-size: 1.6rem; line-height: 0.95; }

.summary {
  margin: 0;
  color: #d6e2f4;
  line-height: 1.6;
  min-height: 84px;
}

.meta-list { margin: 0; display: grid; gap: 8px; }
.meta-list div { display: grid; gap: 5px; }
.meta-list dd { margin: 0; color: var(--text); }
.profile { font-weight: 700; }

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

.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--tag);
  color: #e8effb;
  font-size: 0.83rem;
}

.tag-pill-more {
  position: relative;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: default;
}

.tag-overflow-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: #151b24;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  z-index: 50;
  min-width: 140px;
  max-width: 260px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.tag-pill-more:hover .tag-overflow-popover,
.tag-pill-more:focus .tag-overflow-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.library-card .card-actions { gap: 6px; align-self: start; }
.library-card .btn { min-height: 28px; max-height: 28px; padding: 0 10px; font-size: 0.82rem; white-space: nowrap; }
.library-card .open-tool.btn-primary {
  border-color: rgba(220, 232, 250, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.btn:hover, .btn:focus-visible { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #e7eefb); color: var(--accent-deep); }
.btn-secondary { border-color: var(--line); background: rgba(255,255,255,0.03); color: var(--text); }

/* Star ratings */
.card-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  min-height: 20px;
}

.star-rating-ui {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  font-size: 1.2em;
  cursor: pointer;
  user-select: none;
  gap: 1px;
  line-height: 1;
}

.star-input {
  color: #444a5a;
  transition: color 0.15s;
  font-size: 1.2em;
  padding: 0 1px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.star-input.filled { color: #ffd700; }
.star-input.hovered { color: #ffe066; }
.star-input.half-filled {
  background: linear-gradient(90deg, #ffd700 50%, #444a5a 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.star-rating-ui.readonly { cursor: default; }
.star-rating-ui.readonly .star-input { cursor: default; }

.owner-name { font-size: 0.8rem; color: var(--muted); }

.rating-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.avg-rating,
.review-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1;
}

/* Empty state */
.empty-state { margin-top: 14px; padding: 28px; text-align: center; }
.empty-state h3 { font-size: 1.8rem; }
.empty-state p { color: var(--muted); }

/* Responsive */
@media (max-width: 980px) {
  .library-hero, .filters { grid-template-columns: 1fr; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .library-shell { width: min(100vw - 20px, 1160px); padding-top: 0; }
  .library-grid { grid-template-columns: 1fr; }
}
