/* ==========================================================================
 * GIFDOM — styles (a loving study of GIPHY's look & feel)
 * ========================================================================== */
:root {
  --bg: #121212;
  --bg-2: #1a1a1f;
  --bg-3: #212121;
  --grey: #2b2b31;
  --fg: #ffffff;
  --muted: #a6a6a6;
  --pink: #ff6666;
  --magenta: #e646b6;
  --blue: #00ccff;
  --blue2: #3191ff;
  --green: #00ff99;
  --purple: #9933ff;
  --indigo: #6157ff;
  --yellow: #fff35c;
  --grad-primary: linear-gradient(45deg, #e646b6 0%, #ff6666 100%);
  --grad-blue: linear-gradient(135deg, #00ccff, #3191ff);
  --grad-purple: linear-gradient(90deg, #6157ff, #9933ff);
  --grad-brand: linear-gradient(90deg, #00ff99, #00ccff 40%, #9933ff 75%, #ff6666);
  --radius: 4px;
  --hd-h: 64px;
  --maxw: 1360px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  overflow-y: scroll;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.grad {
  background: var(--grad-brand);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: gradShift 6s linear infinite;
}
@keyframes gradShift { to { background-position: 200% center; } }

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #000;
}
.hd-inner {
  max-width: var(--maxw); margin: 0 auto; height: var(--hd-h);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand .crown {
  font-size: 24px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
  display: inline-block; transform-origin: 50% 60%; cursor: pointer;
}
@keyframes crownSpin {
  0%   { transform: rotate(0deg)    scale(1);    }
  50%  { transform: rotate(180deg)  scale(1.25); }
  100% { transform: rotate(360deg)  scale(1);    }
}
.brand .crown:hover { animation: crownSpin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.brand-txt { font-weight: 900; font-size: 26px; letter-spacing: -0.5px; }
.brand.small .brand-txt { font-size: 20px; }

.search {
  position: relative; flex: 1; max-width: 720px; display: flex; align-items: center;
  background: #fff; border-radius: var(--radius); overflow: visible;
}
.search-ic { position: absolute; left: 14px; font-size: 15px; opacity: .6; pointer-events: none; }
.search input {
  flex: 1; border: 0; outline: 0; background: transparent; color: #121212;
  font-size: 16px; padding: 14px 96px 14px 40px; border-radius: var(--radius); min-width: 0;
  font-family: inherit;
}
.search input::placeholder { color: #a6a6a6; }
.search::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 56px;
  background: var(--grad-primary); border-radius: 0 var(--radius) var(--radius) 0;
  pointer-events: none;
}
.search::before {
  content: '🔍'; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  z-index: 1; font-size: 18px; filter: grayscale(1) brightness(3);
}

.suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-3); border-radius: 8px; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); display: none; z-index: 50;
  border: 1px solid #333;
}
.suggest.open { display: block; }
.suggest-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px; font-size: 15px; border-bottom: 1px solid #2a2a2a;
}
.suggest-item:hover { background: var(--grey); }
.suggest-item em { color: var(--muted); font-style: normal; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.hd-nav { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hd-nav a[data-nav] {
  padding: 8px 12px; border-radius: 20px; font-weight: 700; font-size: 15px; color: #eee;
  transition: background .15s, color .15s;
}
.hd-nav a[data-nav]:hover { background: var(--grey); }
.hd-nav a.active { background: var(--grad-purple); color: #fff; }
.nav-create { background: linear-gradient(90deg, var(--green), var(--blue)); color: #08131a !important; }
.nav-fav .fav-count {
  background: var(--pink); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; margin-left: 2px;
}
.nav-gear { background: none; border: 0; font-size: 20px; padding: 6px; border-radius: 50%; }
.nav-gear:hover { background: var(--grey); }
.hd-burger { display: none; background: none; border: 0; color: #fff; font-size: 24px; }

/* ---------------- app shell ---------------- */
#app { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 48px; }

/* hero */
.hero {
  position: relative; margin: 18px 0 8px; padding: 26px 26px;
  border-radius: 16px; overflow: hidden;
  background: radial-gradient(1200px 300px at 10% -30%, rgba(153,51,255,.35), transparent),
              radial-gradient(900px 280px at 90% 130%, rgba(0,204,255,.30), transparent),
              linear-gradient(120deg, #1c1030, #101a2b);
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
}
.hero-inner h2 { margin: 0 0 6px; font-size: 30px; font-weight: 900; }
.hero-inner p { margin: 0 0 14px; color: #d9d9e3; max-width: 560px; }
.hero-terms { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-term {
  padding: 6px 14px; border-radius: 20px; background: rgba(255,255,255,.1);
  font-weight: 600; font-size: 14px; transition: background .15s;
}
.hero-term:hover { background: rgba(255,255,255,.22); }
.hero-strip { display: flex; gap: 8px; flex-shrink: 0; }
.hero-gif { width: 96px; height: 96px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.hero-gif:nth-child(even) { transform: translateY(14px); }

/* type tabs (GIFs / Stickers / Clips) */
.type-tabs {
  position: relative; display: flex; width: 360px; max-width: 100%;
  margin: 16px 0; background: var(--grey); border-radius: 30px; overflow: hidden; font-weight: 700;
}
.tab-slider {
  position: absolute; top: 0; bottom: 0; width: 33.3333%;
  background: var(--grad-primary); border-radius: 30px; transition: left .25s cubic-bezier(.165,.84,.44,1);
}
.type-tab { position: relative; z-index: 1; flex: 1; text-align: center; padding: 11px 0; color: #fff; }

/* trending pills */
.pills-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.pills-row::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: linear-gradient(180deg, #2c2c33, #232329); border-radius: 24px;
  padding: 10px 16px; font-weight: 700; font-size: 15px; white-space: nowrap;
  transition: opacity .15s, transform .15s;
}
.pill svg { flex-shrink: 0; }
.pill:hover { transform: translateY(-1px); }

/* category strip */
.cat-strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 12px; scrollbar-width: none; }
.cat-strip::-webkit-scrollbar { display: none; }
.cat-pill {
  --pill: #444; display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 8px 14px; border-radius: 22px; background: var(--bg-3); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: border-color .15s, background .15s;
}
.cat-pill .cp-ic { font-size: 16px; }
.cat-pill:hover { background: var(--grey); }
.cat-pill.active { border-color: var(--pill); box-shadow: inset 0 0 0 1px var(--pill); }

/* page head */
.page { margin-top: 8px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin: 14px 0 14px; gap: 12px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 24px; font-weight: 900; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.sugg-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

/* ---------------- masonry grid (JS row-first, shortest-column) ---------------- */
.masonry { display: flex; gap: 12px; align-items: flex-start; }
.mcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.tile {
  margin: 0; position: relative;
}
.tile-media {
  position: relative; display: block; width: 100%; border-radius: var(--radius);
  overflow: hidden; background: linear-gradient(135deg, #26262e, #1b1b22);
}
.tile-media img { width: 100%; height: auto; display: block; }
.tile-media.loading { min-height: 140px; }
.tile-media.loading::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, #22222a 30%, #2e2e38 50%, #22222a 70%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.tile-media.broken { min-height: 160px; background: linear-gradient(135deg, #3a2a4a, #23303f); }
.tile-ph {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 160px; padding: 16px; font-weight: 800; font-size: 15px; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.mh-tip { color: #cfc6ff; font-size: 14px; margin: 10px 0 0; }

.tile-ov {
  position: absolute; inset: 0; opacity: 0; transition: opacity .18s;
  background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 26%, transparent 62%, rgba(0,0,0,.6) 100%);
  display: flex; flex-direction: column; justify-content: space-between; padding: 8px;
}
.tile-media:hover .tile-ov { opacity: 1; }
.tile-top { display: flex; justify-content: flex-end; }
.tile-bot { display: flex; justify-content: space-between; align-items: center; }
.tile-user { font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.ic-btn {
  background: rgba(0,0,0,.35); border: 0; border-radius: 50%; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
  transition: transform .12s, background .12s;
}
.ic-btn:hover { transform: scale(1.12); background: rgba(0,0,0,.55); }
.ic-btn svg { display: block; }

/* scroll sentinel / spinner */
.scroll-sentinel { display: flex; justify-content: center; padding: 30px 0; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty state */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-emoji { font-size: 64px; margin-bottom: 10px; }
.empty h3 { color: #fff; margin: 0 0 6px; font-size: 22px; }

/* chips */
.chip {
  display: inline-block; padding: 6px 12px; border-radius: 18px; background: var(--grey);
  font-size: 13px; font-weight: 600; transition: background .15s;
}
.chip:hover { background: #3a3a42; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--grey); color: #fff; border: 0; border-radius: 24px;
  padding: 11px 16px; font-weight: 700; font-size: 15px; transition: background .15s, transform .1s;
}
.btn:hover { background: #3a3a42; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad-purple); }
.btn.primary:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: .7; cursor: default; }

/* ---------------- detail modal ---------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(6px);
  z-index: 200; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--bg-2); border-radius: 14px; width: 100%; max-width: 1000px;
  position: relative; padding: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.modal.small { max-width: 460px; }
.modal-x {
  position: absolute; top: 12px; right: 12px; background: var(--grey); border: 0; color: #fff;
  width: 34px; height: 34px; border-radius: 50%; font-size: 15px; z-index: 3;
}
.modal-x:hover { background: #3a3a42; }
.modal-main { display: flex; gap: 22px; }
.modal-stage {
  flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: center;
  min-width: 260px;
}
.stage-img { border-radius: 10px; max-width: 520px; width: auto; height: auto; max-height: 60vh; box-shadow: 0 12px 40px rgba(0,0,0,.5); background: #14141a; }
.modal-stage { image-rendering: auto; }
.modal-side { flex: 1; min-width: 0; }
.mh-title { font-size: 22px; font-weight: 900; }
.mh-user { color: var(--muted); margin-top: 4px; font-size: 14px; }
.mh-user a { color: var(--blue); }
.modal-stats { display: flex; gap: 16px; margin: 14px 0; color: #ddd; font-weight: 700; font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.modal-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-related { margin-top: 24px; }
.modal-related h3 { margin: 0 0 12px; font-size: 18px; }
.related-grid { column-count: 4; column-gap: 12px; }
@media (max-width: 700px) { .related-grid { column-count: 2; } }

/* settings */
.settings h2 { margin: 0 0 8px; }
.settings .muted { color: var(--muted); font-size: 14px; }
.settings .muted.small { font-size: 12px; }
.settings label { display: block; margin: 14px 0 6px; font-weight: 700; font-size: 14px; }
.settings input[type=text], .settings input:not([type]) , .settings input {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid #3a3a42;
  background: var(--bg-3); color: #fff; font-size: 15px; font-family: inherit;
}
.settings .toggle { display: flex; align-items: center; gap: 10px; }
.settings .toggle input { width: auto; }
.settings-btns { display: flex; gap: 8px; margin-top: 16px; }
.settings hr { border: 0; border-top: 1px solid #333; margin: 18px 0; }

/* ---------------- studio ---------------- */
.studio-grid { display: flex; gap: 26px; flex-wrap: wrap; }
.studio-preview { flex: 0 0 auto; }
#studio-canvas { border-radius: 12px; box-shadow: 0 16px 50px rgba(0,0,0,.5); background: #000; }
.studio-controls { flex: 1; min-width: 280px; max-width: 460px; }
.studio-controls label { display: block; font-weight: 700; margin: 12px 0 6px; font-size: 14px; }
.studio-controls input, .studio-controls select {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid #3a3a42;
  background: var(--bg-3); color: #fff; font-size: 15px; font-family: inherit;
}
.pal-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pal-swatch { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; padding: 0; }
.pal-swatch.active { border-color: #fff; transform: scale(1.08); }
.studio-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ---------------- toast ---------------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #000; color: #fff; padding: 12px 18px; border-radius: 26px; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(16px); transition: opacity .25s, transform .25s;
  border: 1px solid #2a2a2a;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------- footer ---------------- */
.site-footer { border-top: 1px solid #000; background: #0d0d0d; margin-top: 40px; }
.ft-inner { max-width: var(--maxw); margin: 0 auto; padding: 36px 16px; display: flex; gap: 40px; flex-wrap: wrap; }
.ft-col { flex: 1; min-width: 200px; }
.ft-col h4 { margin: 0 0 12px; font-size: 15px; }
.ft-col .muted { color: var(--muted); font-size: 14px; }
.ft-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.ft-links a { color: var(--muted); font-size: 14px; }
.ft-links a:hover { color: #fff; }
.ft-bottom { text-align: center; color: #666; font-size: 12px; padding: 16px; border-top: 1px solid #1a1a1a; }

/* ---------------- responsive ---------------- */
@media (max-width: 780px) {
  .hd-nav { display: none; position: absolute; top: var(--hd-h); left: 0; right: 0; flex-direction: column; background: var(--bg-2); padding: 12px; gap: 6px; border-bottom: 1px solid #000; }
  .site-header.open .hd-nav { display: flex; }
  .hd-burger { display: block; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-strip { display: none; }
  .modal-main { flex-direction: column; }
  .modal-stage { justify-content: center; width: 100%; }
  .stage-canvas, .stage-img { max-width: 100%; }
}
