/* ============================================
   KURZ — Component Styles
   ============================================ */

/* ---------- App Shell ---------- */
#app {
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ---------- Header / Navbar ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    /* Ensure it's above the card deck */
    padding: calc(var(--safe-top) + var(--space-2)) var(--space-4) 0 var(--space-4);
    background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
    pointer-events: none;
    /* Allow swipe through background */
}

.navbar * {
    pointer-events: all;
    /* Icons must be clickable */
}

.navbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    margin-bottom: var(--space-2);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.navbar-logo {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.navbar-tagline {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    align-items: center;
    border-radius: var(--radius-full);
    padding: var(--space-1);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
}

.lang-btn {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.5px;
    transition: all var(--duration-normal) var(--ease-smooth);
    color: var(--text-tertiary);
}

.lang-btn.active {
    background: var(--brand-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

/* Icon Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) var(--ease-spring);
    color: var(--text-secondary);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    transform: scale(1.1);
}

.icon-btn:active {
    transform: scale(0.9);
}

/* Ensure Sun/Moon contrast */
.theme-btn {
    color: var(--brand-primary) !important;
}

[data-theme="light"] .navbar {
    border-bottom: 1px solid var(--border-subtle);
}

[data-theme="light"] .icon-btn {
    color: var(--bg-primary);
    /* High contrast in light mode */
}

.icon-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--brand-accent);
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}

/* Theme Toggle */
.theme-btn {
    position: relative;
    overflow: hidden;
}

.theme-btn .icon-sun,
.theme-btn .icon-moon {
    position: absolute;
    transition: all var(--duration-normal) var(--ease-spring);
}

[data-theme="light"] .theme-btn .icon-moon {
    transform: translateY(100%) rotate(90deg);
    opacity: 0;
}

[data-theme="dark"] .theme-btn .icon-sun,
:root:not([data-theme]) .theme-btn .icon-sun {
    transform: translateY(100%) rotate(-90deg);
    opacity: 0;
}

/* ---------- Category Bar ---------- */
.category-bar {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

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

.category-chip {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    transition: all var(--duration-normal) var(--ease-smooth);
    scroll-snap-align: start;
    white-space: nowrap;
    cursor: pointer;
}

.category-chip:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-active);
    color: var(--text-primary);
}

.category-chip.active {
    background: var(--brand-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(108, 92, 231, 0.3);
}

.category-chip .chip-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: var(--space-2);
    vertical-align: middle;
}

/* ---------- News Card Deck ---------- */
.card-deck {
    flex: 1;
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.card-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    transition: transform var(--duration-slow) var(--ease-out);
    will-change: transform;
    perspective: 1200px;
    /* Enable 3D space */
}

/* ---------- News Card ---------- */
.news-card {
    width: 100%;
    height: 100dvh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    /* 3D Premium Look */
    transform-style: preserve-3d;
    backface-visibility: hidden;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-3d), var(--shadow-glow);
}

.card-image-container {
    position: relative;
    height: 45%;
    overflow: hidden;
    background: var(--bg-glass);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-slow) var(--ease-smooth), opacity 0.3s ease;
}

/* Blur-up placeholder effect */
.card-image[loading="lazy"] {
    opacity: 0;
    animation: imageReveal 0.4s ease forwards;
    animation-delay: 0.1s;
}

@keyframes imageReveal {
    from { opacity: 0; filter: blur(10px); transform: scale(1.02); }
    to { opacity: 1; filter: blur(0); transform: scale(1); }
}

.card-image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
            transparent 0%,
            rgba(10, 10, 15, 0.4) 50%,
            var(--bg-primary) 100%);
    transform: translateZ(2px);
    /* Slight lift */
}

.card-source-badge {
    position: absolute;
    top: calc(var(--safe-top) + 100px);
    /* Pushed down to clear navbar */
    left: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.card-source-badge img {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-5) var(--space-5) var(--space-4);
    position: relative;
    z-index: 1;
    transform: translateZ(20px);
    /* Parallax depth */
    transform-style: preserve-3d;
}

.card-category-tag {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 1px;
    width: fit-content;
    margin-bottom: var(--space-3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateZ(10px);
    /* Extra pop */
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-3);
    color: var(--text-primary);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    /* Title pop */
}

.card-summary {
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
    flex: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-4);
    padding-bottom: var(--space-8);
    /* Extra padding for swipe indicator */
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.card-time {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.card-action-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) var(--ease-smooth);
    color: var(--text-tertiary);
}

.card-action-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.card-action-btn.bookmarked {
    color: var(--brand-accent);
}

.card-action-btn svg {
    width: 18px;
    height: 18px;
}

/* Read More Link */
.card-read-more {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-accent);
    transition: all var(--duration-normal) var(--ease-smooth);
    width: fit-content;
    margin-top: var(--space-3);
}

.card-read-more:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-active);
    transform: translateX(4px);
}

.card-read-more svg {
    width: 14px;
    height: 14px;
}

/* ---------- Swipe Indicators ---------- */
.swipe-indicator {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-overlay);
    pointer-events: none;
}

.swipe-indicator-bottom {
    bottom: calc(var(--safe-bottom) + var(--space-8));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    animation: bounceDown 2s infinite;
}

.swipe-indicator-text {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--weight-medium);
}

/* ---------- Card Counter ---------- */
.card-counter {
    position: fixed;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    pointer-events: none;
}

.counter-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-tertiary);
    opacity: 0.3;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.counter-dot.active {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--brand-primary);
    opacity: 1;
}

/* ---------- Loading State ---------- */
.loading-skeleton {
    position: relative;
    overflow: hidden;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
}

.loading-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.04),
            transparent);
    animation: shimmer 1.5s infinite;
}

.skeleton-image {
    height: 45%;
    border-radius: 0;
}

.skeleton-tag {
    width: 80px;
    height: 24px;
    margin-bottom: var(--space-3);
}

.skeleton-title {
    width: 90%;
    height: 28px;
    margin-bottom: var(--space-2);
}

.skeleton-title-2 {
    width: 60%;
    height: 28px;
    margin-bottom: var(--space-3);
}

.skeleton-text {
    width: 100%;
    height: 16px;
    margin-bottom: var(--space-2);
}

.skeleton-text-short {
    width: 75%;
    height: 16px;
}

/* ---------- Bookmarks Panel ---------- */
.bookmarks-panel {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    transform: translateX(100%);
    transition: transform var(--duration-slow) var(--ease-out);
}

.bookmarks-panel.open {
    transform: translateX(0);
}

.bookmarks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-top) + var(--space-4)) var(--space-4) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.bookmarks-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.bookmark-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    transition: all var(--duration-normal) var(--ease-smooth);
    cursor: pointer;
}

.bookmark-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-active);
}

.bookmark-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.bookmark-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.bookmark-info h3 {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.bookmark-info p {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.bookmarks-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    color: var(--text-tertiary);
    text-align: center;
    padding: var(--space-8);
}

.bookmarks-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.bookmarks-empty p {
    font-size: var(--text-sm);
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: calc(var(--safe-bottom) + var(--space-8));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: var(--z-toast);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-elevated);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    opacity: 0;
    transition: all var(--duration-slow) var(--ease-spring);
    white-space: nowrap;
}

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

/* ---------- Error State ---------- */
.error-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8);
    text-align: center;
}

.error-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.error-state h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
}

.error-state p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    max-width: 280px;
}

.error-state button {
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    background: var(--brand-gradient);
    color: white;
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.error-state button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--ease-smooth);
    padding: var(--space-4);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-elevated);
    transform: scale(0.9);
    transition: transform var(--duration-normal) var(--ease-spring);
    overflow: hidden;
    position: relative;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-subtle);
}

.modal-header {
    padding: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
}

.setting-group {
    margin-bottom: var(--space-6);
}

.setting-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

.setting-group input {
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-base);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.btn-primary {
    background: var(--brand-gradient);
    color: white;
    padding: var(--space-3) var(--space-8);
    border-radius: var(--radius-full);
    font-weight: var(--weight-bold);
    transition: transform var(--duration-fast), opacity var(--duration-fast);
}

.btn-primary:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    font-weight: var(--weight-semibold);
    border: 1px solid var(--border-subtle);
}

.close-btn {
    font-size: 1.5rem;
    color: var(--text-tertiary);
    transition: color var(--duration-fast);
}

.close-btn:hover {
    color: var(--text-primary);
}

/* --- Offline Indicator --- */
.offline-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--warning-color);
    color: #1A1A2E;
    text-align: center;
    padding: 8px 16px;
    font-size: var(--text-sm);
    font-weight: 600;
    z-index: var(--z-toast);
    transform: translateY(100%);
    transition: transform 0.3s var(--ease-smooth);
}

.offline-bar.visible {
    transform: translateY(0);
    display: block;
}

/* --- Focus Indicators for Accessibility --- */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.category-chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* --- Reading Time Badge --- */
.card-read-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-left: 12px;
}

/* --- Streak Badge --- */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 12px;
    cursor: help;
}

.streak-count {
    font-weight: 700;
    color: var(--warning-color);
    font-size: var(--text-sm);
}

.streak-fire {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(255, 159, 67, 0.5));
    animation: pulse 2s infinite;
}