/* ==========================================================================
   City Watch News - Mobile Shorts App Stylesheet
   Modern Inshorts / TikTok Style Vertical Swipe News App
   ========================================================================== */

:root {
  --app-bg: #0f172a;
  --app-card-bg: #1e293b;
  --app-card-surface: rgba(30, 41, 59, 0.95);
  --app-text: #f8fafc;
  --app-text-muted: #94a3b8;
  --app-text-subtle: #64748b;
  --app-primary: #ec0000;
  --app-primary-rgb: 236, 0, 0;
  --app-primary-hover: #c40000;
  --app-accent: #f59e0b;
  --app-border: rgba(255, 255, 255, 0.08);
  --app-whatsapp: #25d366;
  --app-font-family: 'Anek Gujarati', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --phone-width: 440px;
  --phone-radius: 36px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light Theme Variables */
[data-theme="light"] {
  --app-bg: #f1f5f9;
  --app-card-bg: #ffffff;
  --app-card-surface: rgba(255, 255, 255, 0.96);
  --app-text: #0f172a;
  --app-text-muted: #475569;
  --app-text-subtle: #94a3b8;
  --app-border: rgba(0, 0, 0, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--app-font-family);
  background: var(--app-bg);
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient Background for Desktop View */
.desktop-ambient {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(var(--app-primary-rgb), 0.15) 0%, transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
              var(--app-bg);
  z-index: 0;
  pointer-events: none;
}

/* Main Outer App Frame Wrapper */
.app-viewport-wrapper {
  position: relative;
  width: 100%;
  height: 100dvh;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

/* Device Shell on Desktop */
.app-device-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  height: 100vh;
  max-width: var(--phone-width);
  background: var(--app-card-bg);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--app-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive Desktop Full-Width Mode */
.app-viewport-wrapper.wide-mode .app-device-shell {
  max-width: 720px;
}

@media (min-width: 769px) {
  .app-device-shell {
    height: calc(100vh - 40px);
    max-height: 920px;
    border-radius: var(--phone-radius);
    border: 8px solid #000000;
  }
}

/* Top Navigation App Header - Compact & Docked */
.app-header {
  position: relative;
  flex-shrink: 0;
  z-index: 30;
  padding: 6px 12px 6px;
  background: var(--app-card-bg);
  border-bottom: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

[data-theme="light"] .app-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--app-text);
}

.app-brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
}

.app-brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.app-brand-badge {
  background: var(--app-primary);
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
}

.header-counter-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--app-accent);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 7px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--app-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

[data-theme="light"] .header-icon-btn {
  background: rgba(0, 0, 0, 0.04);
}

.header-icon-btn:hover, .header-icon-btn:active {
  background: rgba(var(--app-primary-rgb), 0.15);
  color: var(--app-primary);
  border-color: rgba(var(--app-primary-rgb), 0.3);
}

/* Category Horizontal Chips Scroller */
.category-chips-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 1px 0 2px;
}

.category-chips-bar::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 3px 9px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--app-border);
  color: var(--app-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

[data-theme="light"] .category-chip {
  background: rgba(0, 0, 0, 0.04);
}

.category-chip:hover {
  color: var(--app-text);
  background: rgba(255, 255, 255, 0.12);
}

.category-chip.active {
  background: var(--app-primary);
  color: #ffffff;
  border-color: var(--app-primary);
  box-shadow: 0 2px 8px rgba(var(--app-primary-rgb), 0.35);
}

/* Top Progress Indicator Bar */
.feed-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #ec0000, #f59e0b);
  z-index: 40;
  width: 0%;
  transition: width 0.3s ease;
}

/* Feed Container (Vertical Snap Scroll) */
.feed-container {
  flex: 1;
  height: 0;
  min-height: 0;
  width: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  position: relative;
  z-index: 10;
}

.feed-container::-webkit-scrollbar {
  display: none;
}

/* Individual News Card */
.news-card {
  width: 100%;
  height: 100%;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--app-card-bg);
  overflow: hidden;
  user-select: none;
}

/* Card Media / Image Header Area */
.card-media {
  position: relative;
  width: 100%;
  height: 40%;
  min-height: 160px;
  max-height: 300px;
  background: #000000;
  overflow: hidden;
  flex-shrink: 0;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: block;
}

.news-card.active .card-media img {
  transform: scale(1.03);
}

/* Gradient Scrim Over Image: Only lower portion */
.card-media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    transparent 50%,
    rgba(0, 0, 0, 0.4) 80%,
    rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
}

[data-theme="light"] .card-media-overlay {
  background: linear-gradient(180deg,
    transparent 50%,
    rgba(255, 255, 255, 0.3) 80%,
    rgba(255, 255, 255, 0.9) 100%);
}

/* Card Badges (Category & Time) */
.card-badges {
  position: absolute;
  bottom: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
}

.card-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(236, 0, 0, 0.9);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 500;
}

/* Card Content / Body Area */
.card-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 14px 6px;
  overflow: hidden;
  position: relative;
  background: var(--app-card-bg);
}

.card-heading {
  font-size: 1.12rem;
  line-height: 1.35;
  font-weight: 800;
  color: var(--app-text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.card-summary-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.card-summary {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--app-text-muted);
  font-weight: 400;
  text-align: justify;
  letter-spacing: 0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 4px;
  font-size: 0.7rem;
  color: var(--app-text-subtle);
  border-top: 1px dashed var(--app-border);
}

.card-meta-author {
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-meta-counter {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

[data-theme="light"] .card-meta-counter {
  background: rgba(0, 0, 0, 0.06);
}

/* Swipe Up Hint Banner */
.swipe-up-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 2px 0;
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--app-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}

.swipe-up-hint i {
  animation: bounce-up 1.6s infinite ease-in-out;
}

@keyframes bounce-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Card Footer / Actions Bar */
.card-footer {
  padding: 8px 12px calc(var(--safe-bottom) + 8px);
  background: var(--app-card-surface);
  border-top: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 20;
}

.btn-read-full {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--app-primary) 0%, #b91c1c 100%);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(var(--app-primary-rgb), 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-read-full:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--app-primary-rgb), 0.45);
  color: #ffffff;
}

.card-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--app-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

[data-theme="light"] .action-btn {
  background: rgba(0, 0, 0, 0.04);
}

.action-btn:hover, .action-btn:active {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

.action-btn.whatsapp-btn {
  color: var(--app-whatsapp);
  border-color: rgba(37, 211, 102, 0.3);
}

.action-btn.whatsapp-btn:hover {
  background: rgba(37, 211, 102, 0.15);
}

.action-btn.tts-btn.playing {
  color: var(--app-accent);
  border-color: var(--app-accent);
  background: rgba(245, 158, 11, 0.15);
  animation: pulse-audio 1.2s infinite ease-in-out;
}

@keyframes pulse-audio {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.action-btn.bookmark-btn.saved {
  color: #f59e0b;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

/* Floating Navigation Controls (Desktop Only) */
.floating-nav {
  position: absolute;
  right: -55px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .floating-nav {
    display: none !important;
  }
}

body.webview-mode .floating-nav {
  display: none !important;
}

.nav-pill-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: var(--app-card-surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--app-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.nav-pill-btn:hover {
  background: var(--app-primary);
  color: #ffffff;
  transform: scale(1.08);
}

.nav-counter-pill {
  padding: 4px 8px;
  border-radius: 12px;
  background: var(--app-card-surface);
  border: 1px solid var(--app-border);
  color: var(--app-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* End of Feed Screen Card */
.feed-end-card {
  width: 100%;
  height: 100dvh;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  background: var(--app-card-bg);
}

.feed-end-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 20px;
}

.feed-end-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--app-text);
}

.feed-end-desc {
  font-size: 0.95rem;
  color: var(--app-text-muted);
  max-width: 300px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.feed-end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 260px;
}

/* Skeleton Loading Shimmer */
.skeleton-card {
  width: 100%;
  height: 100dvh;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--app-card-bg);
  overflow: hidden;
}

.skeleton-media {
  width: 100%;
  height: 44%;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-content {
  flex: 1;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-line {
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Toast Notification */
.app-toast {
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--app-border);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: nowrap;
}

.app-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Saved News Drawer / Modal */
.app-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.app-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.app-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80%;
  background: var(--app-card-bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  z-index: 95;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.app-drawer.active {
  transform: translateY(0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--app-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--app-border);
  text-decoration: none;
  color: var(--app-text);
  transition: background 0.2s ease;
}

.drawer-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.drawer-item-img {
  width: 70px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.drawer-item-title {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Desktop Controls Helper */
.desktop-controls-hint {
  position: absolute;
  left: -200px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--app-card-surface);
  border: 1px solid var(--app-border);
  border-radius: 16px;
  padding: 16px;
  width: 170px;
  color: var(--app-text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: none;
}

@media (min-width: 1100px) {
  .desktop-controls-hint {
    display: block;
  }
}

.desktop-controls-hint .hint-title {
  font-weight: 800;
  color: var(--app-text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kbd-key {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-family: monospace;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  border: 1px solid var(--app-border);
  color: var(--app-text);
  margin: 1px;
}

/* ==========================================================================
   Flutter WebView & Native Mobile App Optimizations
   ========================================================================== */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .desktop-ambient,
  .desktop-controls-hint,
  #viewModeBtn {
    display: none !important;
  }

  .app-viewport-wrapper {
    height: 100dvh;
    height: 100vh;
  }

  .app-device-shell {
    max-width: 100% !important;
    width: 100% !important;
    height: 100dvh !important;
    height: 100vh !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
}

/* Explicit WebView Mode class */
body.webview-mode .desktop-ambient,
body.webview-mode .desktop-controls-hint,
body.webview-mode #viewModeBtn {
  display: none !important;
}

body.webview-mode .app-viewport-wrapper {
  height: 100dvh;
  height: 100vh;
}

body.webview-mode .app-device-shell {
  max-width: 100% !important;
  width: 100% !important;
  height: 100dvh !important;
  height: 100vh !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Disable unwanted mobile WebView long-press context popups */
.news-card, .card-media, .card-content, .card-heading, .card-summary {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* Offline Status Banner */
.app-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  padding: calc(var(--safe-top) + 6px) 12px 6px;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
  animation: slide-down 0.3s ease;
}

.app-offline-banner.active {
  display: flex;
}

@keyframes slide-down {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

