/* ============================================================================
   FONT DECLARATIONS
   ============================================================================ */

@font-face {
    font-family: 'ProLisa';
    src: url('fonts/ProLisa-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'ProLisa';
    src: url('fonts/ProLisa-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Input Sans Narrow';
    src: url('fonts/fonnts.com-InputSansNarrow.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Input Sans Narrow';
    src: url('fonts/fonnts.com-InputSansNarrow_Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

/* ============================================================================
   CSS VARIABLES - DARK MODE
   ============================================================================ */

:root {
    /* Colors */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    /*--bg-card: linear-gradient(to bottom, hsla(210, 0%, 23%, 1) 0%, hsla(220, 0%, 18%, 1) 45%, hsla(230, 0%, 16%, 1) 55%, hsla(252, 0%, 0%, 1) 99%);
    --bg-card2: linear-gradient(to top, hsla(210, 0%, 10%, 1) 0%, hsla(220, 0%, 8%, 1) 30%, hsla(230, 0%, 6%, 1) 60%, hsla(252, 0%, 4%, 1) 99%);*/
	--bg-card: black;
	--bg-card2: black;
	
    --text-primary: #ffffff;
    --text-secondary: #dfe6ff;
    --text-muted: #888888;
    --border-primary: #444444;
    --border-light1: hsla(243, 100%, 21%, 0.7);
    --border-light2: hsla(243, 100%, 21%, 0.7);

    /* Accents */
    --accent-blue: hsl(240, 100%, 81%);
    --accent-color: hsl(240, 100%, 70%);
    --accent-color-hover: hsl(240, 100%, 75%);
    --hover-bg: rgba(255, 255, 255, 0.1);
    --hover-scale: 1.05;

    /* Sizing */
    --title-bar-height: 60px;
    --control-bar-height: 90px;
    --content-height: calc(100vh - var(--title-bar-height) - var(--control-bar-height));

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Fonts */
    --font-primary: 'ProLisa', 'Input Sans Narrow', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'ProLisa', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light Mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f5f5f5;
        --bg-card: hsla(240, 10%, 95%, 0.95);
        --text-primary: #000000;
        --text-secondary: #333333;
        --text-muted: #666666;
        --border-primary: #cccccc;
        --border-light: #e0e0e0;
        --accent-blue: hsl(240, 70%, 50%);
        --hover-bg: rgba(0, 0, 0, 0.05);
    }
}

/* ============================================================================
   RESET & BASE STYLES
   ============================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
}

img {
    display: block;
    max-width: 100%;
}

/* ============================================================================
   TITLE BAR
   ============================================================================ */

#item-title-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--title-bar-height);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    gap: 16px;
}

/* Title content wrapper */
#item-title-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#item-title-link {
    transition: opacity var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

#item-title-link:hover {
    opacity: 0.8;
}

#item-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

/* Subtitle styles */
.item-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    opacity: 0.85;
}

.item-subtitle-favicon {
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    border-radius: 2px;
}

.item-subtitle-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.title-bar-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.title-bar-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.title-bar-links a:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

/* ============================================================================
   SWIPE CONTAINER
   ============================================================================ */

#swipe-container {
    position: fixed;
    top: var(--title-bar-height);
    left: 0;
    right: 0;
    bottom: var(--control-bar-height);
    overflow: hidden;
    touch-action: pan-y;
    user-select: none;
    background: var(--bg-card2)
}

#content-wrapper {
    width: 95%;
    height: 100%;
    transition: transform var(--transition-medium);
    will-change: transform;
}

#content-wrapper.swiping {
    transition: none;
}

#content-display {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
#content-display::-webkit-scrollbar {
    display: none;
}

#content-display {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ============================================================================
   PULL TO REFRESH
   ============================================================================ */

.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
    z-index: 10;
}

.pull-to-refresh.pulling {
    opacity: 1;
}

.pull-to-refresh.refreshing {
    opacity: 1;
}

.pull-to-refresh-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   CONTENT TYPES - VIDEO CONTAINERS
   ============================================================================ */

.video-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Invidious thumbnail mode (no iframe) */
.video-container.invidious-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Blurred background fill using the thumbnail */
.invidious-thumb-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.15);
  filter: blur(28px);
  opacity: 0.75;
  z-index: 0;
}

/* Foreground thumbnail (kept sharp) */
.invidious-thumb-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Center play button overlay (click target) */
.invidious-thumb-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
}

/* Visual play icon drawn with CSS (no image file needed) */
.invidious-thumb-play::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.invidious-thumb-play::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-35%, -50%);
  width: 0;
  height: 0;
  border-left: 26px solid rgba(255, 255, 255, 0.92);
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
}


/* Blurred background effect */
.video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    backdrop-filter: blur(40px);
    opacity: 0.8;
    z-index: 0;
}

.video-iframe {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: none;
    z-index: 1;
}

/* Video overlay buttons (Invidious/YouTube) */
.video-overlay-buttons {
    position: absolute;
    bottom: 24px; /* Leave space above player controls */
    right: 24px;
    display: flex;
    filter: drop-shadow(2px 3px 8px hsl(0, 0%, 0%));
    gap: clamp(12px, 5vw, 60px);
    z-index: 10;
    pointer-events: auto;
}

.video-overlay-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(30px, 5vw, 60px);
    height: clamp(30px, 5vw, 60px);
    background: rgba(0, 0, 0, 0);
    border-radius: 50%;
    transition: background var(--transition-fast), transform var(--transition-fast);
    text-decoration: none;
    touch-action: auto;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
}

.video-overlay-btn:hover {
    background: rgba(0, 0, 0, 0);
    transform: scale(1.1);
}

.video-overlay-btn:active {
    background: rgba(0, 0, 0, 0);
    transform: scale(0.95);
}

.video-overlay-btn img {
    width: 48px;
    height: 48px;
    display: block;
    pointer-events: none;
}

/* TikTok videos - vertical format */
.video-container.tiktok {
    /* Uses same fill approach as standard videos */
}

/* Invidious video container */
.invidious-video-wrapper {
    width: 100%;
    height: 100%;
}

/* ============================================================================
   CONTENT TYPES - BLUESKY
   ============================================================================ */

.bluesky-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: transparent;
    backdrop-filter: blur(10px);
}

.bluesky-iframe {
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: calc(100vh - var(--title-bar-height) - var(--control-bar-height) - 32px);
    min-height: 400px;
    border: none;
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    color-scheme: dark;
}

/* ============================================================================
   CONTENT TYPES - BLOG ARTICLES
   ============================================================================ */

.blog-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px;
}

.blog-content article {
    font-family: var(--font-primary);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
}

.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
    font-family: var(--font-display);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
    font-weight: 700;
}

.blog-content h1 { font-size: 28px; }
.blog-content h2 { font-size: 24px; }
.blog-content h3 { font-size: 20px; }

.blog-content p {
    margin-bottom: 1em;
}

.blog-content a {
    color: var(--accent-blue);
    text-decoration: underline;
}

.blog-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em auto;
}

.blog-content blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 16px;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

.blog-content ul,
.blog-content ol {
    margin: 1em 0;
    padding-left: 24px;
}

.blog-content li {
    margin-bottom: 0.5em;
}

.blog-content pre {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 1em 0;
}

.blog-content code {
    font-family: 'Courier New', monospace;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.blog-content pre code {
    background: none;
    padding: 0;
}

/* ============================================================================
   LOADING & EMPTY STATES
   ============================================================================ */

.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.loading-state p,
.empty-state p,
.error-state p {
    font-size: 18px;
    margin-bottom: 16px;
}

/* ============================================================================
   CONTROL BAR
   ============================================================================ */

#control-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--control-bar-height);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-light);
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
    padding-inline: 6vw;
    align-items: center;
}

.control-btn {
    background: transparent;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    transition: background var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
    background: var(--hover-bg);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    pointer-events: none;
}

.nav-btn {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
    user-select: none;
}

/* Disabled navigation button state */
.nav-btn.disabled,
.control-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.nav-btn.disabled img,
.control-btn.disabled img {
    opacity: 0.5;
}

#folder-selector-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   DROP-UP MENU
   ============================================================================ */

.drop-up-menu {
    position: absolute;
    bottom: 80px;
    right: -30%;
    min-width: 200px;
    max-width: 70vw;
    max-height: 450px;
    overflow-y: auto;
    background: var(--bg-card);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid var(--border-light1);
    border-radius: 12px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    padding: 8px;
    z-index: 101;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.drop-up-menu.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.drop-up-menu:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Scrollbar for drop-up menu */
.drop-up-menu::-webkit-scrollbar {
    width: 6px;
}

.drop-up-menu::-webkit-scrollbar-track {
    background: transparent;
}

.drop-up-menu::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

.folder-menu-item {
    padding: 8px 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background var(--transition-fast);
    font-size: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--accent-color);
    margin-bottom: 3px;
}

.folder-menu-item:last-child {
    margin-bottom: 0;
}

.folder-menu-item:hover {
    background: var(--hover-bg);
}

.folder-menu-item.active {
    background: var(--accent-blue);
    color: var(--bg-primary);
    font-weight: 700;
}

/* Header container for toggle and refresh */
.folder-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

/* Toggle button in folder menu */
.folder-menu-toggle {
    flex: 1;
    padding: 8px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.folder-menu-toggle:hover {
    background: var(--hover-bg);
}

/* Nextcloud button */
.folder-menu-nextcloud {
    flex-shrink: 0;
    width: 48px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-menu-nextcloud:hover {
    background: var(--hover-bg);
}

.folder-menu-nextcloud:active {
    transform: scale(0.95);
}

.nextcloud-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Label container (holds icon or text) */
.toggle-label {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

/* Icon for unread mode */
.toggle-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Text for "All" mode */
.toggle-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Toggle switch container */
.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--border-light);
    border-radius: 12px;
    position: relative;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

/* Toggle slider (the moving circle) */
.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

/* Active state (toggle ON - shows unread) */
.folder-menu-toggle.active .toggle-switch {
    background: var(--accent-blue);
}

.folder-menu-toggle.active .toggle-slider {
    transform: translateX(20px);
}

/* Keyboard focus indicator */
.folder-menu-item.keyboard-focus,
.folder-menu-toggle.keyboard-focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Tablet */
@media (min-width: 768px) {
    #item-title {
        font-size: 20px;
    }

    .blog-content {
        padding: 32px 40px;
    }

    .blog-content article {
        font-size: 18px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    #item-title-bar {
        padding: 0 40px;
    }

    #control-bar {
        padding: 12px 40px;
        
    }

    .blog-content {
        padding: 40px;
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================================================
   LOGIN MODAL
   ============================================================================ */

.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-medium);
}

.login-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.login-modal-content h2 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: bold;
    text-align: center;
}

.login-modal-content p {
    margin: 0 0 24px 0;
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.form-buttons {
    text-align: center;
}

.login-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.login-btn:hover {
    background: var(--accent-color-hover);
}

.login-btn:active {
    transform: scale(0.98);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.hidden {
    display: none !important;
}

.cursor-grabbing {
    cursor: grabbing;
}
