:root {
    /* Light mode colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #ebebeb;
    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-tertiary: #86868b;
    --accent-color: #0071e3;
    --accent-hover: #0077ed;
    --border-color: #d2d2d7;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
}

.dark-mode {
    /* Dark mode colors */
    --bg-primary: #1d1d1f;
    --bg-secondary: #2d2d2f;
    --bg-tertiary: #3d3d3f;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --accent-color: #2997ff;
    --accent-hover: #148eff;
    --border-color: #424245;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: #2d2d2f;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-top: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-bottom: 0;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.theme-toggle button {
    border: none;
    background: transparent;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.theme-toggle button:hover {
    background-color: var(--bg-tertiary);
}

.light-mode .moon {
    display: block;
}

.light-mode .sun {
    display: none;
}

.dark-mode .moon {
    display: none;
}

.dark-mode .sun {
    display: block;
}

/* Navigation */
nav {
    background-color: var(--bg-secondary);
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 3px 0;
    transition: color 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent-color);
}

/* Main content */
main {
    padding: 20px 0 40px;
    min-height: calc(100vh - 180px);
}

.section {
    display: none;
    animation: fadeIn 0.3s ease;
    padding: 20px 0;
}

.section.active {
    display: block;
}

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

.section h2 {
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 1.75rem;
}

.section-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 15px;
}

/* Search */
.search-container {
    position: relative;
    width: 300px;
}

.search-container input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

/* Tags */
.tag-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.tag-item {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.tag-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.tag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.tag-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-color);
}

.tag-count {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-content {
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
    white-space: normal;
    padding: 5px 0;
    overflow: hidden;
    position: relative;
}

/* Markdown styling for preview */
.tag-content p, 
.tag-content ul, 
.tag-content ol {
    margin-bottom: 0.5em;
}

.tag-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.tag-content a:hover {
    text-decoration: underline;
}

.tag-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.tag-content pre {
    background-color: var(--bg-tertiary);
    padding: 8px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 0.5em;
    font-size: 0.9em;
}

.tag-content pre code {
    background-color: transparent;
    padding: 0;
}

.tag-content img {
    max-width: 100%;
    border-radius: 4px;
    margin: 0.5em 0;
}

.tag-content h1, 
.tag-content h2, 
.tag-content h3 {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.tag-content h1 {
    font-size: 1.3em;
}

.tag-content h2 {
    font-size: 1.2em;
}

.tag-content h3 {
    font-size: 1.1em;
}

.tag-preview-image {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
    max-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-loading-indicator {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    padding: 15px;
    text-align: center;
}

.tag-image-preview {
    max-width: 100%;
    max-height: 200px;
    display: block;
    object-fit: contain;
}

.tag-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.tag-author {
    font-style: italic;
}

.tag-image-indicator {
    display: flex;
    align-items: center;
    color: var(--accent-color);
}

/* Permalink button */
.permalink-button {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 5px;
    margin-left: 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.permalink-button:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

/* Leaderboard */
.leaderboard-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    margin-top: 20px;
}

.leaderboard-table-container {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 8px 4px;
    font-size: 0.85rem;
    vertical-align: middle;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 500;
}

.rank-badge {
    display: none;
}

/* Loader */
.loader {
    border: 3px solid var(--bg-tertiary);
    border-radius: 50%;
    border-top: 3px solid var(--accent-color);
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No results */
.no-results {
    text-align: center;
    color: var(--text-tertiary);
    padding: 20px;
}

.hidden {
    display: none;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-tertiary);
    font-size: 0.9rem;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .search-container {
        width: 100%;
    }
    .tag-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }
    .podium-container {
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }
    .user-name {
        font-size: 0.9rem;
    }
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 4px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    .leaderboard-table th:nth-child(2),
    .leaderboard-table td:nth-child(2) {
        padding-left: 2px;
        padding-right: 2px;
    }
    .podium-wrapper {
        flex-direction: row;
        align-items: flex-start;
        gap: 5px;
    }
    .podium-column {
        flex: 1;
        margin-bottom: 0;
        min-width: 60px;
    }
    .gold-block, .silver-block, .bronze-block {
        font-size: 1.5rem;
    }
    .gold-block { height: 100px; }
    .silver-block { height: 75px; }
    .bronze-block { height: 50px; }
    .user-podium-card {
        padding: 8px;
        min-height: auto;
    }
    .podium-avatar-container {
        width: 35px;
        height: 35px;
        margin: 10px auto 5px;
    }
    .podium-avatar {
        width: 35px;
        height: 35px;
    }
    .podium-username {
        font-size: 0.75rem;
        word-break: break-all;
    }
    .podium-level, .podium-xp {
        font-size: 0.7rem;
    }
    .podium-medal {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
        top: 3px;
        right: 3px;
    }
}

/* Podium styles */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 30px;
    padding: 0 10px;
}

.podium-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    width: 100%;
    max-width: 600px;
    justify-content: center;
}

.podium-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-width: 80px;
}

.first-place {
    order: 2;
}

.second-place {
    order: 1;
}

.third-place {
    order: 3;
}

.podium-block {
    width: 100%;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    transition: height 0.3s ease, margin-top 0.3s ease;
    margin-top: 10px;
}

.second-place .podium-block {
    margin-top: calc(10px + (150px - 120px));
}

.third-place .podium-block {
    margin-top: calc(10px + (150px - 90px));
}

.gold-block {
    background: linear-gradient(45deg, #ffd700, #f0c400);
    height: 150px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.silver-block {
    background: linear-gradient(45deg, #c0c0c0, #a8a8a8);
    height: 120px;
    box-shadow: 0 0 10px rgba(192, 192, 192, 0.4);
}

.bronze-block {
    background: linear-gradient(45deg, #cd7f32, #b8732e);
    height: 90px;
    box-shadow: 0 0 8px rgba(205, 127, 50, 0.4);
}

.user-podium-card {
    width: 100%;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    padding: 15px;
    border: 1px solid var(--border-color);
    position: relative;
    text-align: center;
}

.podium-medal {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1d1d1f;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.gold {
    background: linear-gradient(to bottom right, #ffd700, #ffcc33);
}

.silver {
    background: linear-gradient(to bottom right, #c0c0c0, #e6e6e6);
}

.bronze {
    background: linear-gradient(to bottom right, #cd7f32, #daa06d);
}

.podium-avatar-container {
    margin: 15px auto 10px;
    width: 70px;
    height: 70px;
    overflow: hidden;
    border-radius: 50%;
    box-shadow: 0 2px 5px var(--shadow-color);
    border: 2px solid var(--bg-secondary);
}

.podium-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-username {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-level, .podium-xp {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Responsive podium */
@media (max-width: 768px) {
    .podium-wrapper {
        gap: 10px;
        flex-direction: row;
        align-items: flex-start;
    }
    .gold-block {
        height: 120px;
    }
    .silver-block {
        height: 100px;
    }
    .bronze-block {
        height: 80px;
    }
    .user-podium-card {
        padding: 15px;
    }
    .second-place .podium-block {
        margin-top: calc(10px + (120px - 100px));
    }
    .third-place .podium-block {
        margin-top: calc(10px + (120px - 80px));
    }
}

@media (max-width: 480px) {
    .podium-wrapper {
        flex-direction: row;
        align-items: flex-start;
        gap: 5px;
    }
    .podium-column {
        flex: 1;
        margin-bottom: 0;
        min-width: 60px;
    }
    .gold-block {
        height: 100px;
        font-size: 1.5rem;
    }
    .silver-block {
        height: 75px;
        font-size: 1.5rem;
    }
    .bronze-block {
        height: 50px;
        font-size: 1.5rem;
    }
    .user-podium-card {
        padding: 8px;
        min-height: auto;
    }
    .podium-avatar-container {
        width: 35px;
        height: 35px;
        margin: 10px auto 5px;
    }
    .podium-avatar {
        width: 35px;
        height: 35px;
    }
    .podium-username {
        font-size: 0.75rem;
        word-break: break-all;
    }
    .podium-level, .podium-xp {
        font-size: 0.7rem;
    }
    .podium-medal {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
        top: 3px;
        right: 3px;
    }
    .podium-block {
        margin-top: 5px;
    }
    .second-place .podium-block {
        margin-top: calc(5px + (100px - 75px));
    }
    .third-place .podium-block {
        margin-top: calc(5px + (100px - 50px));
    }
}

/* Add modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 20px;
    width: 100%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#back-to-list, #close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#back-to-list:hover, #close-modal:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

#modal-tag-image-container {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
}

#modal-tag-image {
    max-width: 100%;
    height: auto;
    display: block;
}

#modal-tag-content {
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Markdown styling */
#modal-tag-content h1,
#modal-tag-content h2,
#modal-tag-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}

#modal-tag-content p {
    margin-bottom: 1em;
}

#modal-tag-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

#modal-tag-content pre {
    background-color: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
}

#modal-tag-content pre code {
    background-color: transparent;
    padding: 0;
}

#modal-tag-content a {
    color: var(--accent-color);
    text-decoration: none;
}

#modal-tag-content a:hover {
    text-decoration: underline;
}

#modal-tag-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

#modal-tag-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
    margin-left: 0;
    margin-right: 0;
    color: var(--text-secondary);
}

#modal-tag-content ul,
#modal-tag-content ol {
    padding-left: 2em;
    margin-bottom: 1em;
}

.modal-footer {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .modal-content {
        width: 90%;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
} 