/* =========================
   Universe Home - Part-like styling (uses part-bg-wrap fallback)
   ========================= */

/* full width container like part.css */
main.site-container {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.universe-page {
  width: 100%;
  max-width: none;
  margin: 0;
}

/* =========================
   DEFAULT TOKENS (work even if theme class is missing)
   ========================= */
:root {
  --bg: #0b0b0b;

  --panel-bg: rgba(15, 15, 15, .72);
  --panel-border: rgba(255, 255, 255, .10);

  --card-bg: rgba(20, 20, 20, .72);
  --card-border: rgba(255, 255, 255, .10);

  --text: #fff;
  --muted: rgba(255, 255, 255, .80);

  --btn-surface: rgba(0, 0, 0, .35);
  --btn-surface-hover: rgba(0, 0, 0, .50);
  --btn-border: rgba(255, 255, 255, .16);

  /* IMPORTANT: fallback exactly like part */
  --part-bg-fallback: url("/static/main_img/NoIMG/NoIMG_bg_NIGHT.webp");
}

/* base */
html {
  background: var(--bg);
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* =========================
   Theme tokens (support multiple theme mechanisms)
   ========================= */

/* DARK */
body.theme-dark,
body.dark,
html[data-theme="dark"] body {
  --bg: #0b0b0b;

  --panel-bg: rgba(15, 15, 15, .72);
  --panel-border: rgba(255, 255, 255, .10);

  --card-bg: rgba(20, 20, 20, .72);
  --card-border: rgba(255, 255, 255, .10);

  --text: #fff;
  --muted: rgba(255, 255, 255, .80);

  --btn-surface: rgba(0, 0, 0, .35);
  --btn-surface-hover: rgba(0, 0, 0, .50);
  --btn-border: rgba(255, 255, 255, .16);

  --part-bg-fallback: url("/static/main_img/NoIMG/NoIMG_bg_NIGHT.webp");
}

/* LIGHT */
body.theme-light,
body.light,
html[data-theme="light"] body {
  --bg: #f3f4f6;

  --panel-bg: rgba(255, 255, 255, .84);
  --panel-border: rgba(0, 0, 0, .12);

  --card-bg: rgba(255, 255, 255, .88);
  --card-border: rgba(0, 0, 0, .12);

  --text: #111;
  --muted: rgba(0, 0, 0, .70);

  --btn-surface: rgba(255, 255, 255, .78);
  --btn-surface-hover: rgba(255, 255, 255, .94);
  --btn-border: rgba(0, 0, 0, .14);

  --part-bg-fallback: url("/static/main_img/NoIMG/NoIMG_bg_LIGHT.webp");
}

/* =========================
   Fullscreen background wrap (EXACT like part-bg-wrap)
   ========================= */
.part-bg-wrap {
  min-height: 100vh;
  position: relative;
  width: 100%;

  background-color: #0b0b0b;
  background-image: var(--part-bg-url, var(--part-bg-fallback));
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;

  overflow-x: hidden;
}

.part-bg-wrap.bg-single {
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

/* на мобілах fixed інколи лагує */
@media (max-width: 900px) {
  .part-bg-wrap {
    background-attachment: scroll;
  }
}

/* =========================
   Header (part-like)
   ========================= */
.part-header {
  width: min(1200px, 94vw);
  margin: 14px auto 0;
  border-radius: 18px;
  overflow: hidden;
  position: relative;

  box-shadow: 0 10px 26px rgba(0, 0, 0, .18);
}

.part-header img.bg {
  width: 100%;
  height: 38vh;
  min-height: 260px;
  max-height: 420px;
  object-fit: cover;
  filter: none;
  display: block;
}

/* dark theme: затемнюємо */
body.theme-dark .part-header img.bg,
body.dark .part-header img.bg,
html[data-theme="dark"] body .part-header img.bg {
  filter: brightness(60%);
}

.part-header .overlay {
  position: absolute;
  left: 5%;
  bottom: 10%;
  right: 5%;
  color: #fff;
}

.part-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 2.8rem);
  font-weight: 800;
  letter-spacing: .2px;
}

.part-header p.sub {
  margin-top: 6px;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  color: rgba(255, 255, 255, .90);
}

.part-header p.desc {
  margin-top: 10px;
  font-size: 1rem;
  max-width: 760px;
  color: rgba(255, 255, 255, .85);
}

/* back links (pills) */
.header-back {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 8;
}

.hdr-pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: .95rem;

  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color .2s ease, border-color .2s ease, transform .08s ease;
}

.hdr-pill-link:hover {
  background: rgba(0, 0, 0, .72);
  border-color: rgba(255, 255, 255, .30);
}

.hdr-pill-link:active {
  transform: translateY(1px);
}

body.theme-light .hdr-pill-link,
body.light .hdr-pill-link,
html[data-theme="light"] body .hdr-pill-link {
  background: rgba(255, 255, 255, .70);
  border-color: rgba(0, 0, 0, .18);
  color: #111;
}

body.theme-light .hdr-pill-link:hover,
body.light .hdr-pill-link:hover,
html[data-theme="light"] body .hdr-pill-link:hover {
  background: rgba(255, 255, 255, .88);
}

/* admin block */
.header-admin {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 9;
}

/* =========================
   Glass panel
   ========================= */
.part-panel {
  width: min(1100px, 94vw);
  margin: 18px auto 28px;
  padding: 14px;
  box-sizing: border-box;

  border-radius: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);

  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  overflow-x: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .16);
}

body.theme-light .part-panel,
body.light .part-panel,
html[data-theme="light"] body .part-panel {
  box-shadow: 0 10px 24px rgba(0, 0, 0, .10);
}

/* inner column */
.universe-panel>* {
  width: min(980px, 94vw);
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* =========================
   Buttons (.btn)
   ========================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;

  background: var(--btn-surface);
  border: 1px solid var(--btn-border);
  color: var(--text);

  font-size: .92rem;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: background-color .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease, transform .08s ease;
}

.btn:hover {
  background: var(--btn-surface-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* =========================
   Top actions row
   ========================= */
.actions {
  margin: 8px auto 10px;
  padding: 0 6px;

  display: flex;
  align-items: center;
  gap: 12px;
}

.actions-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions-left>.btn {
  white-space: nowrap;
}

/* =========================
   Titles / groups
   ========================= */
.universe-title {
  margin: 10px 6px 6px;
  font-size: 1.25rem;
  font-weight: 850;
  color: var(--text);
}

.universe-group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

.universe-group-head {
  padding: 0 6px;
  margin-bottom: 10px;
}

.universe-group-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 850;
  color: var(--text);
}

.universe-group-note {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 8px;
}

.universe-empty {
  padding: 10px 6px 2px;
  color: var(--muted);
}

/* =========================
   Parts cards grid
   ========================= */
:root {
  --grid-gap: 12px;
}

@media (max-width: 480px) {
  :root {
    --grid-gap: 8px;
  }
}

.parts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--grid-gap);
  padding: 0 6px;
}

@media (max-width: 600px) {
  .parts-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.part-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;

  border-radius: 14px;
  overflow: hidden;

  background: var(--card-bg);
  border: 1px solid var(--card-border);

  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

body.theme-light .part-card,
body.light .part-card,
html[data-theme="light"] body .part-card {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.10);
}

.part-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  border-color: rgba(37, 99, 235, 0.28);
}

.part-card.is-admin-only {
  outline: 2px dashed rgba(255, 255, 255, .18);
  outline-offset: -6px;
}

body.theme-light .part-card.is-admin-only,
body.light .part-card.is-admin-only,
html[data-theme="light"] body .part-card.is-admin-only {
  outline-color: rgba(0, 0, 0, .14);
}

.part-card-image-wrapper {
  position: relative;
}

.part-card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: rgba(0, 0, 0, .20);
  overflow: hidden;
}

body.theme-light .part-card-image,
body.light .part-card-image,
html[data-theme="light"] body .part-card-image {
  background: rgba(0, 0, 0, .06);
}

.part-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* stats pill (♥ / ✓) */
.part-card-stats {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;

  padding: 6px 8px;
  border-radius: 999px;

  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5;
}

body.theme-light .part-card-stats,
body.light .part-card-stats,
html[data-theme="light"] body .part-card-stats {
  background: rgba(255, 255, 255, .70);
  border-color: rgba(0, 0, 0, .18);
  color: #111;
}

.part-card-stats-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .82rem;
  line-height: 1.1;
  font-weight: 800;
}

.part-card-stats-icon {
  font-size: .9rem;
}

/* body text */
.part-card-body {
  padding: 10px 10px 12px;
}

.part-card-title {
  font-size: .95rem;
  font-weight: 800;
  display: flex;
  align-items: baseline;
  gap: 8px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  color: var(--text);
}

.part-card-badge {
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 800;
  opacity: .85;
  color: var(--muted);
}

.part-card-sub {
  margin-top: 4px;
  font-size: .82rem;
  color: var(--muted);

  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* =========================
   Mobile tweaks
   ========================= */
@media (max-width: 760px) {
  .part-header img.bg {
    height: 34vh;
  }
}

@media (max-width: 640px) {
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}