/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Righteous&display=swap');

/* ── Design Tokens ── */
:root {
  --bg:        #FFF1F2;
  --surface:   #ffffff;
  --surface-2: #FDF2F8;
  --border:    #FECDD3;
  --text:      #881337;
  --text-2:    #4B5563;
  --text-muted:#9CA3AF;
  --primary:   #E11D48;
  --primary-h: #BE123C;
  --accent:    #2563EB;
  --shadow:    rgba(225,29,72,.12);
  --radius:    1rem;
  --nav-h:     60px;
}

[data-theme="dark"] {
  --bg:        #0d0a0b;
  --surface:   #1a1017;
  --surface-2: #231520;
  --border:    #3d1f2b;
  --text:      #f5e6ea;
  --text-2:    #c9aab5;
  --text-muted:#7a5062;
  --primary:   #FB7185;
  --primary-h: #f43f5e;
  --shadow:    rgba(0,0,0,.4);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text-2);
  min-height: 100dvh;
  transition: background 0.3s, color 0.3s;
}

h1,h2,h3 { font-family: 'Righteous', sans-serif; }

/* ── Nav ── */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  display: flex; align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  transition: background 0.3s, border-color 0.3s;
}

.nav-logo {
  font-family: 'Righteous', sans-serif;
  font-size: 1.4rem;
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -.5px;
}

.nav-search {
  flex: 1;
  max-width: 400px;
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s;
}
.nav-search::placeholder { color: var(--text-muted); }
.nav-search:focus { border-color: var(--primary); }

.theme-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Tags bar ── */
.tags-bar {
  padding: .5rem 1rem;
  display: flex; gap: .5rem;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}
.tags-bar::-webkit-scrollbar { display: none; }
.tags-bar { scrollbar-width: none; }

/* ── Masonry Grid ── */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: 10px;
  gap: 10px;
  align-items: start;
}

/* ── Pin Card ── */
.pin-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface-2);
  break-inside: avoid;
  transition: transform .25s ease, box-shadow .25s ease;
}
.pin-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px var(--shadow);
}

.pin-img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 80px;
  background: var(--surface-2);
}

.pin-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(0,0,0,.82) 0%,
    rgba(0,0,0,.35) 55%,
    transparent 100%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: .75rem;
  opacity: 0;
  transition: opacity .22s ease;
}
.pin-card:hover .pin-overlay,
.pin-card.tapped  .pin-overlay { opacity: 1; }

.pin-overlay-title {
  color: #fff;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 5px;
}

.pin-overlay-tags { display: flex; flex-wrap: wrap; gap: 3px; }

.pin-overlay .tag-pill {
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
  font-size: .625rem;
  padding: 2px 7px;
}

/* ── Tag Pills ── */
.tag-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s;
  cursor: pointer;
}
.tag-pill:hover { opacity: .75; }

.tag-artist    { background: #DBEAFE; color: #1D4ED8; }
.tag-character { background: #DCFCE7; color: #15803D; }
.tag-copyright { background: #EDE9FE; color: #6D28D9; }
.tag-meta      { background: #F3F4F6; color: #4B5563; }
.tag-general   { background: #FFE4E6; color: #BE123C; }

[data-theme="dark"] .tag-artist    { background: #1e3a5f; color: #93C5FD; }
[data-theme="dark"] .tag-character { background: #1a3d26; color: #86EFAC; }
[data-theme="dark"] .tag-copyright { background: #2e1a5c; color: #C4B5FD; }
[data-theme="dark"] .tag-meta      { background: #1f2937; color: #9CA3AF; }
[data-theme="dark"] .tag-general   { background: #4c0519; color: #FDA4AF; }

/* ── Tag group label ── */
.tag-group-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

/* ── Surface card (pin detail / admin) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .3s, border-color .3s;
}

/* ── Admin inputs ── */
.admin-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: .5rem;
  padding: .45rem .75rem;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s;
}
.admin-input:focus { border-color: var(--primary); }
.admin-input::placeholder { color: var(--text-muted); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: .6rem;
  padding: .55rem 1rem;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-h); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ── Misc ── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-primary  { color: var(--primary); }
.bg-surface    { background: var(--surface); }
.border-muted  { border-color: var(--border); }

/* ── Loading spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

/* ── Related pins section ── */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

/* ── Mobile safe-area ── */
@media (max-width: 640px) {
  .masonry-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .pin-card, .pin-overlay, .theme-btn, .btn-primary { transition: none !important; }
}
