/* =============================================================
   InstaPub UI polish layer (softwarehouse-grade)                
   Loaded AFTER style.css. Adds depth, motion, and micro-        
   interactions on top of the existing app WITHOUT changing      
   markup or layout. Safe: prefers-reduced-motion is respected.  
   ============================================================ */

:root {
  /* richer elevation + motion tokens */
  --sh-card: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -6px rgba(16,24,40,.10);
  --sh-pop: 0 6px 18px -4px rgba(16,24,40,.12), 0 20px 50px -12px rgba(16,24,40,.20);
  --sh-glow: 0 0 0 4px rgba(214,41,118,.12);
  --t-spring: cubic-bezier(.34,1.56,.64,1);
  --t-smooth: cubic-bezier(.22,1,.36,1);
  --ring: 0 0 0 3px rgba(214,41,118,.25);
  --glass: rgba(255,255,255,.65);
  --glass-border: rgba(255,255,255,.6);
  --ease-ripple: cubic-bezier(0,0,.2,1);
}

html[data-theme="dark"] {
  --glass: rgba(18,20,26,.55);
  --glass-border: rgba(255,255,255,.08);
  --sh-card: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -8px rgba(0,0,0,.5);
  --sh-pop: 0 6px 18px -4px rgba(0,0,0,.5), 0 24px 60px -16px rgba(0,0,0,.6);
}

/* ---------- global motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- custom scrollbar ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-2); }

/* soften the whole app's flat look with a calm animated ambient background */
body {
  background-attachment: fixed;
  transition: background-color .5s var(--t-smooth);
}

/* ---------- brand / logo ---------- */
.brand-name, .logo {
  background-size: 300% 300%;
  animation: instapub-brandshift 9s ease infinite;
  -webkit-background-clip: text;
  background-clip: text;
}
@keyframes instapub-brandshift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.brand-logo {
  display: inline-flex;
  filter: drop-shadow(0 10px 28px rgba(214,41,118,.45));
  animation: instapub-float 5s ease-in-out infinite;
  margin-bottom: 10px;
}
.brand-logo svg {
  display: block;
  border-radius: 22px;
  transition: transform .35s var(--t-smooth);
}
.brand-logo:hover svg { transform: rotate(-4deg) scale(1.03); }
@keyframes instapub-float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- auth screen (canvas painted behind) ---------- */
.auth-screen {
  position: relative;
  isolation: isolate;
}
.auth-bg-canvas { position: absolute; inset: 0; z-index: -1; }
/* Auth-card: base supplies the designed surface; here we add a refined, safe
   entrance for motion without replacing the existing visual identity. */
.auth-card { position: relative; animation: instapub-card-in .6s var(--t-smooth) both; }
@keyframes instapub-card-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- form fields: lift the flat look ---------- */
.auth-form input {
  transition: border-color .2s var(--t-smooth), box-shadow .2s var(--t-smooth), background-color .2s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
  background: var(--card);
}

/* ---------- buttons: gradient, lift, ripple-ready ---------- */
/* Ripple containers. The base supplies gradient/shadow; we add only the
   positioning needed to host the ripple ink (and keep it inside rounded
   corners) without changing surface appearance. */
.btn-primary, .btn-outline, .btn-danger, button.btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn-outline, .btn-danger, .btn {
  transition: transform .15s var(--t-spring), box-shadow .2s, background-color .2s, color .2s;
}
.btn-outline:hover { transform: translateY(-1px); box-shadow: var(--sh-card); }

/* generic material-style buttons (added by the app dynamically) get consistency */
button.btn.btn-primary { border: none; }

/* ---------- ripple element (painted by polish.js) ---------- */
.ripple-ink {
  position: absolute;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,.65) 0%, rgba(255,255,255,0) 70%);
  transform: scale(0);
  animation: instapub-ripple .6s var(--ease-ripple) forwards;
  pointer-events: none;
  z-index: 0;
}
@keyframes instapub-ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ---------- post cards: gentle lift + reveal ---------- */
.post-card {
  box-shadow: var(--sh-card);
  transition: transform .3s var(--t-spring), box-shadow .3s var(--t-smooth);
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--sh-pop); }
/* Scroll-reveal only activates when polish.js marks the main container;
   otherwise content stays visible (safe fallback). */
.reveal-on .post-card, .reveal-on .ic-reveal {
  opacity: 0;
  transform: translateY(16px);
}
.reveal-on .post-card.is-visible, .reveal-on .ic-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .5s var(--t-smooth), transform .5s var(--t-smooth);
}

/* ---------- action buttons (like etc): lively micro-interaction ---------- */
.action-btn {
  transition: transform .18s var(--t-spring);
  filter: drop-shadow(0 2px 6px rgba(16,24,40,.12));
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.feed-ico { display: block; flex-shrink: 0; }
.action-btn.liked .feed-ico { animation: instapub-heart .45s var(--t-spring); }
.action-btn:hover { transform: scale(1.18); }
.action-btn:active { transform: scale(.86); }
.action-btn.liked { animation: instapub-heart .45s var(--t-spring); }
@keyframes instapub-heart {
  0% { transform: scale(.6); }
  45% { transform: scale(1.35); }
  70% { transform: scale(.9); }
  100% { transform: scale(1); }
}

/* ---------- nav buttons: hover ring ---------- */
.nav-btn { position: relative; transition: transform .18s var(--t-spring), color .2s; }
.nav-btn:hover { transform: translateY(-2px) scale(1.08); }
.nav-btn:active { transform: translateY(0) scale(.9); }
.nav-ico { display: block; }
/* soft hover tint so icons feel alive */
.nav-btn:hover .nav-ico { filter: drop-shadow(0 0 3px var(--sh-glow, rgba(214,41,118,.5))); }



/* ---------- loading indicator ---------- */
.loading {
  font-weight: 500;
  color: var(--fg-2);
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
  animation: instapub-breathe 1.6s ease-in-out infinite;
}
@keyframes instapub-breathe {
  0%,100% { opacity: .4; }
  50% { opacity: 1; }
}

/* ---------- toast: refined snackbar ---------- */
.toast {
  border-radius: var(--r-full);
  box-shadow: var(--sh-pop);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  background: rgba(23,25,29,.88) !important;
  color: #fff;
  animation: instapub-toast .3s var(--t-smooth);
}
@keyframes instapub-toast {
  from { opacity: 0; transform: translate(-50%, 16px) scale(.9); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ---------- story ring: animated brand ring (additive, reduced-motion safe) ---------- */
.story-ring-img { box-shadow: none; }
/* A soft pulsing gradient ring around the avatar (does not cover the face). */

.story-item { position: relative; }
.story-ring-img:not(.story-ring-empty) {
  animation: none;
}
@keyframes instapub-ring-pulse {
  0%,100% { box-shadow: 0 0 0 3px var(--card), 0 0 0 4px rgba(214,41,118,.45), 0 0 0 7px rgba(214,41,118,.10); }
  50% { box-shadow: 0 0 0 3px var(--card), 0 0 0 4px rgba(214,41,118,.75), 0 0 0 11px rgba(214,41,118,.16); }
}
/* ---------- story/reel viewer: smooth entrance (additive; does not touch display logic) ---------- */
.story-overlay.open { animation: instapub-overlay-in .22s ease-out; }
@keyframes instapub-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; transform: none; }
}

/* ---------- view transition wrapper (added by polish.js around #main) ---------- */
.view-fade { animation: instapub-view .34s var(--t-smooth) both; }
/* ---------- keyboard accessibility: clear focus-visible rings ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand, #d62976);
  outline-offset: 2px;
  border-radius: var(--r-sm, 8px);
}
.btn:focus-visible, .btn-primary:focus-visible, .btn-outline:focus-visible {
  box-shadow: var(--ring, 0 0 0 3px rgba(214,41,118,.25));
}

/* ---------- text selection tint (subtle studio touch) ---------- */
::selection {
  background: rgba(214,41,118,.18);
  color: var(--fg, #17191d);
}
/* ---------- consistent icon sizing across nav (fixes small theme icon) ---------- */
.nav-btn svg, .nav-actions svg { width:21px; height:21px; display:block; flex-shrink:0; }

/* ---------- reels/stories empty frames: themed soft surface ---------- */
.reel-frame { background: var(--surface-2, #e9eaee); }

/* ---------- reduce tap-highlight (mobile) ---------- */
a, button { -webkit-tap-highlight-color: transparent; }

/* ---------- live toolbar button: match brand pill of + New reel ---------- */
.live-toolbar .btn {
  background: linear-gradient(135deg, #feda75, #d62976 35%, #962fbf 70%, #4f5bd5);
  border: none;
  color: #fff;
  border-radius: var(--r-full, 999px);
  padding: 7px 18px;
  font-weight: 600;
  box-shadow: var(--sh-pop);
}
.live-toolbar .btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ---------- glassmorphism on surfaces (theme-aware tokens) ---------- */
.story-ring, .live-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.story-ring { border-radius: var(--r-lg, 14px); }

/* ---------- image loading flourish: subtle fade-in on media ---------- */
.post-img, .avatar-sm, .avatar-lg, .grid-item img, .reel-video, .story-media {
  animation: instapub-media-in .45s var(--t-smooth) both;
}
@keyframes instapub-media-in {
  from { opacity: 0; }
  to { opacity: 1; transform: none; }
}
@keyframes instapub-view {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ---------- skeleton loaders (added by polish.js around .loading) ---------- */
.skeleton-mount { display: block; }
.skeleton-mount .loading { min-height: 40px; text-align: center; padding-top: 12px; }
.sk { position: relative; overflow: hidden; background: var(--surface-2, #e9eaee); border-radius: 8px; }
.sk::after {
  content: '';
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: instapub-shimmer 1.4s infinite;
}
@keyframes instapub-shimmer { 100% { transform: translateX(100%); } }
/* ---------- empty states: intentional, calm, not flat ---------- */
.empty {
  max-width: 420px;
  margin-left: auto; margin-right: auto;
  padding-top: 72px; padding-bottom: 72px;
  line-height: 1.5;
  animation: instapub-empty-in .4s var(--t-smooth) both;
}
.empty h2 {
  font-size: 20px; font-weight: 650;
  color: var(--fg, #17191d);
  letter-spacing: -.2px;
  margin: 14px 0 6px;
}
.empty p {
  color: var(--fg-2, #7a7e87);
  margin: 0 auto;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.55;
}
@keyframes instapub-empty-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
/* ---------- coherent form focus: brand pink, not blue (design-system consistency) ---------- */
.auth-form input:focus, .auth-form textarea:focus,
.search-form input:focus, .explore-form input:focus,
.composer textarea:focus, .input:focus,
.comment-box:focus, .comment-input:focus {
  border-color: #d62976;
  box-shadow: 0 0 0 3px rgba(214,41,118,.15);
}
.sk-card {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e5ea);
  border-radius: var(--r-md, 12px);
  overflow: hidden;
  max-width: 614px; margin: 0 auto 24px;
  box-shadow: var(--sh-card);
}
.sk-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.sk-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.sk-line { height: 11px; border-radius: 6px; }
.sk-title { width: 40%; height: 11px; border-radius: 6px; }
.sk-img { width: 100%; aspect-ratio: 4/3; border-radius: 0; }
.sk-body { padding: 12px 14px; display: flex; gap: 14px; }
.sk-dot { width: 26px; height: 26px; border-radius: 8px; }

/* =============================================================
   Instagram parity layer — values transposed from instagram.com
   ============================================================ */

/* base type size like instagram.com */
body { font-size: 14px; }

/* flat, hairline-separated rows like instagram.com feed column */
.story-ring, .live-card { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; border: none; }

/* story ring: exact instagram.com gradient ring (4-stop brand), hover lift */
.story-ring-img { border-radius: 50%; transition: transform .18s ease; }
/* ring moved: ig-parity.css draws it with ::before (radius-safe) */
.story-item:hover .story-ring-img { transform: scale(1.07); }
.story-item:hover .story-caption { color: var(--accent); }
.story-caption { transition: color .15s ease; }

/* story viewer: linear progress fill + slide between stories */
.story-bar { transition: width .12s linear; }
.story-stage > * { animation: instapub-story-slide .25s ease both; }
@keyframes instapub-story-slide {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}
.story-close { transition: transform .15s ease; }
.story-close:hover { transform: scale(1.12); }

/* like button pops like instagram.com */
.action-btn:hover { transform: scale(1.12); }
