/* Shortzz Web – Blue is the Action (DesignTokens) */
:root {
  --brand: #2563EB;
  --brand-light: #3B82F6;
  --brand-dark: #1D4ED8;
  --brand-subtle: #DBEAFE;
  --like: #2563EB;
  --error: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;

  --bg: #000000;
  --surface: #0A0A0A;
  --surface-elevated: #141414;
  --surface-overlay: #1C1C1E;
  --border: #2C2C2E;

  --text-primary: #FFFFFF;
  --text-secondary: #AAAAAA;
  --text-tertiary: #666666;
  --text-disabled: #444444;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --avatar-sm: 32px;
  --avatar-md: 40px;
  --avatar-lg: 56px;
  --avatar-xl: 80px;

  --top-bar-h: 56px;
  --bottom-nav-h: 64px;

  /* Responsive: full viewport below this (phones, tablets, small laptops) */
  --viewport-full-bleed: 1024px;
  --viewport-short: 600px;
}

* { box-sizing: border-box; }
html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--surface-elevated);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Default: responsive frame – never overflow viewport (any size) */
#root {
  position: relative;
  z-index: 1;
  width: min(390px, 100vw);
  max-width: min(390px, 100vw);
  height: min(844px, 90vh, 100dvh);
  max-height: min(844px, 90vh, 100dvh);
  min-height: 0;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border), 0 8px 32px rgba(0,0,0,0.4);
  display: block;
  overflow: hidden;
}

/* Desktop: full width for Sidebar | Feed | Context layout */
@media (min-width: 1025px) {
  #root {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    box-shadow: none !important;
  }
}

/* Full viewport: tablets, phones, small laptops, short screens – תואם לכל גודל/צורה */
@media (max-width: 1024px), (max-height: 600px) {
  html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
  }
  body {
    justify-content: stretch !important;
    align-items: stretch !important;
    background: var(--bg) !important;
  }
  #root {
    max-width: none !important;
    max-height: none !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100vh !important;
    height: var(--vvh, 100dvh) !important;
    min-height: 100vh !important;
    min-height: var(--vvh, 100dvh) !important;
    box-shadow: none !important;
    overflow: hidden !important;
    /* מניעת חיתוך הלחצנים (בית, חיפוש וכו') במכשירים עם home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    box-sizing: border-box !important;
  }
  #root,
  #root > * {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* Screens */
.app-screen {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  padding: var(--space-md);
}
.app-screen--centered {
  max-width: 400px;
  margin: 0 auto;
  padding: 50px 20px;
  text-align: center;
}

/* Typography */
.app-title { color: var(--brand); font-size: 24px; font-weight: 600; margin: 0; }
.app-subtitle { color: var(--text-secondary); font-size: 16px; margin: 8px 0 24px; }
.app-text { color: var(--text-secondary); }

/* Buttons */
.btn {
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  width: 100%;
}
.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--brand);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

/* Inputs */
.input {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--surface);
  color: var(--text-primary);
}
.input::placeholder { color: var(--text-tertiary); }

/* Cards / Lang selection */
.lang-option {
  padding: var(--space-md);
  margin: var(--space-sm) 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-primary);
}
.lang-option:hover { border-color: var(--brand); }

/* Top bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

/* Bottom nav – כמו באפליקציה */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-sizing: border-box;
}
.bottom-nav a, .bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
}
.bottom-nav a:hover, .bottom-nav button:hover { color: var(--text-primary); }
.bottom-nav a.active, .bottom-nav button.active { color: var(--brand); }

/* Feed */
.feed-container {
  padding-bottom: calc(var(--bottom-nav-h) + var(--space-lg));
  max-width: 600px;
  margin: 0 auto;
}
.post-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  overflow: hidden;
}
.post-media {
  aspect-ratio: 9 / 16;
  max-height: min(400px, 70vh, 70dvh);
  width: 100%;
  background: #000;
  position: relative;
  overflow: hidden;
}
.post-media video, .post-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.post-body {
  padding: var(--space-sm);
}
.post-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}
.post-avatar {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  border-radius: 50%;
  object-fit: cover;
  margin-inline-end: 8px;
}
.post-username {
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}
.post-desc { color: var(--text-secondary); font-size: 14px; margin: 0 0 8px; }
.post-actions {
  display: flex;
  gap: 16px;
}
.post-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.post-action.liked { color: var(--like); }

/* Reel (Web DOM overlay – 9:16, responsive, no distortion) */
.reel-container {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  z-index: 999;
  background: var(--bg);
  display: none;
  aspect-ratio: 9 / 16;
  box-sizing: border-box;
}

/* מובייל: כופים מסך מלא – דורס inline מ־JS (שיכול לתת 828px מהקנבס). */
@media (max-width: 1024px), (max-height: 600px) {
  .reel-container[style*="display: block"],
  .reel-container[style*="display:block"] {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: calc(100dvh - 64px) !important;
    max-height: calc(100dvh - 64px) !important;
    aspect-ratio: unset !important;
  }
}

.reel-container video {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  z-index: 0;
  pointer-events: none;
}
.reel-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 30%), linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 40%);
}
.reel-mute {
  position: absolute;
  left: var(--space-sm, 12px);
  bottom: var(--space-sm, 12px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
}
.reel-mute:hover {
  background: var(--surface-elevated);
}
.reel-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-primary);
}
.reel-heart {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  color: var(--like);
  pointer-events: none;
}
.reel-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  padding-bottom: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-sm);
  z-index: 1;
}
.reel-left {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  font-size: 14px;
}
.reel-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: center;
}
.reel-action-btn {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-primary);
}
.reel-action-btn.reel-action-liked {
  color: var(--like);
}
.reel-action-btn span:first-child { font-size: 24px; }
.reel-action-btn span:last-child { font-size: 12px; }
.reel-left .reel-avatar {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  border-radius: 50%;
  object-fit: cover;
}
.reel-follow-btn {
  margin-left: var(--space-xs);
  padding: 4px var(--space-sm);
  border-radius: 999px;
  background: var(--brand);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

/* Profile */
.profile-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-lg);
}
.profile-avatar {
  width: var(--avatar-xl);
  height: var(--avatar-xl);
  border-radius: 50%;
  object-fit: cover;
  margin-inline-end: var(--space-md);
}
.profile-info h2 { margin: 0 0 4px; }
.profile-meta { color: var(--text-secondary); font-size: 14px; }

/* Search */
.search-input {
  margin-bottom: var(--space-md);
}
.search-results, .recent-searches { margin-top: var(--space-lg); }
.user-row {
  display: flex;
  align-items: center;
  padding: var(--space-sm) 0;
  cursor: pointer;
  color: var(--text-primary);
}
.user-row:hover { background: var(--surface-elevated); }
.user-row img {
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: 50%;
  margin-inline-end: 12px;
}

/* Empty / Loading / Error */
.state-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
}
.state-message.error { color: var(--error); }

/* Links */
.link { color: var(--brand); text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-muted { color: var(--text-tertiary); font-size: 14px; }
