/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: rgb(244, 244, 241);
    color: rgb(10, 9, 7);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
}

/* Dark Theme */
body.dark-theme {
    background-color: rgb(20, 20, 23);
    color: rgb(244, 244, 241);
}

body.dark-theme .header {
    background-color: rgb(20, 20, 23);
    border-bottom-color: rgb(50, 50, 55);
}

body.dark-theme .logo a,
body.dark-theme .nav-list li a,
body.dark-theme .font-preview a,
body.dark-theme .font-preview h3 {
    color: rgb(244, 244, 241);
}

body.dark-theme .search-input,
body.dark-theme .preview-input {
    background-color: rgb(30, 30, 35);
    color: rgb(244, 244, 241);
    border-color: rgb(50, 50, 55);
}

body.dark-theme .font-card {
    border-color: rgb(50, 50, 55);
}

body.dark-theme .footer {
    background-color: rgb(20, 20, 23);
    border-top-color: rgb(50, 50, 55);
}

body.dark-theme .theme-toggle,
body.dark-theme .menu-toggle,
body.dark-theme .layout-toggle {
    background-color: rgb(30, 30, 35);
    color: rgb(244, 244, 241);
}

body.dark-theme .font-badge {
    background-color: rgb(50, 50, 55);
}

/* HEADER */
.header {
    border-bottom: 1px solid rgb(214, 214, 209);
    height: 65px;
    background-color: rgb(244, 244, 241);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 24px;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 16px;
    font-weight: 400;
}

.logo a {
    text-decoration: none;
    color: rgb(10, 9, 7);
    display: flex;
    align-items: center;
    height: 100%;
}

/* Navigation */
.nav {
    display: none;
}

@media (min-width: 1024px) {
    .nav {
        display: flex;
    }
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 0;
    align-items: center;
    height: 100%;
}

.nav-list li a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    text-decoration: none;
    color: rgb(10, 9, 7);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s;
}

.nav-list li a:hover,
.nav-list li a.active {
    border-bottom-color: rgb(10, 9, 7);
}

body.dark-theme .nav-list li a:hover,
body.dark-theme .nav-list li a.active {
    border-bottom-color: rgb(244, 244, 241);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    background-color: rgb(244, 244, 241);
    border-bottom: 1px solid rgb(214, 214, 209);
    padding: 16px 24px;
}

.mobile-nav.active {
    display: block;
}

body.dark-theme .mobile-nav {
    background-color: rgb(20, 20, 23);
    border-bottom-color: rgb(50, 50, 55);
}

.mobile-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-nav-list li a {
    text-decoration: none;
    color: rgb(10, 9, 7);
    font-weight: 500;
    padding: 8px 0;
    display: block;
}

body.dark-theme .mobile-nav-list li a {
    color: rgb(244, 244, 241);
}

@media (min-width: 1024px) {
    .mobile-nav {
        display: none !important;
    }
}

/* Search Form */
.search-form {
    flex: 1;
    max-width: 300px;
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: 1px solid rgb(214, 214, 209);
    border-radius: 4px;
    background-color: rgb(244, 244, 241);
    color: rgb(10, 9, 7);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: rgb(10, 9, 7);
}

.search-input::placeholder {
    color: rgb(85, 83, 77);
}

/* Buttons */
.theme-toggle,
.menu-toggle,
.layout-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background-color: rgb(244, 244, 241);
    color: rgb(10, 9, 7);
    font-size: 18px;
    cursor: pointer;
    border-radius: 2px;
    transition: background-color 0.2s;
}

.theme-toggle:hover,
.menu-toggle:hover,
.layout-toggle:hover {
    background-color: rgb(230, 230, 227);
}

body.dark-theme .theme-toggle:hover,
body.dark-theme .menu-toggle:hover,
body.dark-theme .layout-toggle:hover {
    background-color: rgb(50, 50, 55);
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    .menu-toggle {
        display: none;
    }
}

/* MAIN CONTENT */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Hero Section */
.hero {
    margin-bottom: 32px;
}

.hero-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: rgb(10, 9, 7);
}

body.dark-theme .hero-title {
    color: rgb(244, 244, 241);
}

.hero-description {
    font-size: 16px;
    color: rgb(85, 83, 77);
    line-height: 24px;
}

body.dark-theme .hero-description {
    color: rgb(160, 160, 155);
}

/* Preview Input */
.preview-input {
    width: 100%;
    padding: 16px 20px;
    margin-bottom: 24px;
    border: 1px solid rgb(214, 214, 209);
    background-color: rgb(244, 244, 241);
    color: rgb(10, 9, 7);
    font-size: 20px;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.preview-input:focus {
    outline: none;
    border-color: rgb(10, 9, 7);
}

.preview-input::placeholder {
    color: rgb(85, 83, 77);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.font-count {
    font-size: 14px;
    color: rgb(85, 83, 77);
}

body.dark-theme .font-count {
    color: rgb(160, 160, 155);
}

/* Layout Toggle */
.layout-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Case Filters */
.case-filters {
    display: flex;
    gap: 4px;
    background: rgb(230, 230, 227);
    padding: 4px;
    border-radius: 4px;
}

body.dark-theme .case-filters {
    background: rgb(40, 40, 45);
}

.case-filter {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: rgb(85, 83, 77);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

body.dark-theme .case-filter {
    color: rgb(140, 140, 135);
}

.case-filter:hover {
    color: rgb(10, 9, 7);
}

body.dark-theme .case-filter:hover {
    color: rgb(220, 220, 215);
}

.case-filter.active {
    background: rgb(255, 255, 255);
    color: rgb(10, 9, 7);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

body.dark-theme .case-filter.active {
    background: rgb(60, 60, 65);
    color: rgb(244, 244, 241);
}

/* Hidden case variants */
.font-preview .preview-var.case-hidden {
    display: none !important;
}

/* Fonts Grid */
.fonts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    width: 100%;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .fonts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .fonts-grid {
        grid-template-columns: 1fr;
    }
}

/* List View */
.fonts-grid.list-view {
    grid-template-columns: 1fr;
}

.fonts-grid.list-view .font-card {
    border-right: none;
}

.fonts-grid.list-view .font-preview {
    min-height: 140px;
}

.fonts-grid.list-view .font-preview .preview-var {
    font-size: 18px;
}

.fonts-grid.list-view .font-preview .preview-var.highlighted {
    font-size: 28px;
}

/* Font Card */
.font-card {
    padding: 24px;
    border-right: 1px solid rgb(214, 214, 209);
    border-bottom: 1px solid rgb(214, 214, 209);
    display: block;
    text-align: left;
    transition: background-color 0.2s;
}

.font-card:hover {
    background-color: rgb(250, 250, 247);
}

body.dark-theme .font-card:hover {
    background-color: rgb(30, 30, 35);
}

.font-card:nth-child(3n) {
    border-right: none;
}

@media (max-width: 1024px) {
    .font-card:nth-child(3n) {
        border-right: 1px solid rgb(214, 214, 209);
    }
    .font-card:nth-child(2n) {
        border-right: none;
    }
}

@media (max-width: 640px) {
    .font-card {
        border-right: none;
    }
}

body.dark-theme .font-card:nth-child(3n) {
    border-right: none;
}

@media (max-width: 1024px) {
    body.dark-theme .font-card:nth-child(3n) {
        border-right: 1px solid rgb(50, 50, 55);
    }
    body.dark-theme .font-card:nth-child(2n) {
        border-right: none;
    }
}

.font-card-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.font-label {
    font-size: 14px;
    font-weight: 500;
    color: rgb(85, 83, 77);
    text-align: center;
}

body.dark-theme .font-label {
    color: rgb(160, 160, 155);
}

.font-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 20px 0;
}

.font-preview a {
    text-decoration: none;
    color: rgb(10, 9, 7);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    transition: opacity 0.2s;
}

body.dark-theme .font-preview a {
    color: rgb(244, 244, 241);
}

.font-preview a:hover {
    opacity: 0.7;
}

.font-preview .preview-var {
    display: block;
    font-weight: 400;
    text-align: center;
    line-height: 1.1;
    font-size: 24px;
    opacity: 0.4;
    transition: opacity 0.2s, font-size 0.2s;
}

.font-preview .preview-var.highlighted {
    font-size: 40px;
    opacity: 1;
}

.font-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    color: rgb(85, 83, 77);
    flex-wrap: wrap;
}

body.dark-theme .font-meta {
    color: rgb(160, 160, 155);
}

.font-category {
    font-weight: 400;
}

.font-count-styles {
    font-weight: 400;
}

.font-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: rgb(230, 230, 227);
    border-radius: 2px;
    font-size: 12px;
    color: rgb(85, 83, 77);
}

body.dark-theme .font-badge {
    background-color: rgb(50, 50, 55);
    color: rgb(160, 160, 155);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 32px;
    padding: 24px 0;
    border-top: 1px solid rgb(214, 214, 209);
}

body.dark-theme .pagination {
    border-top-color: rgb(50, 50, 55);
}

.pagination-info {
    font-size: 14px;
    color: rgb(85, 83, 77);
}

body.dark-theme .pagination-info {
    color: rgb(160, 160, 155);
}

.pagination-links {
    display: flex;
    gap: 16px;
}

.pagination-prev,
.pagination-next {
    color: rgb(10, 9, 7);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

body.dark-theme .pagination-prev,
body.dark-theme .pagination-next {
    color: rgb(244, 244, 241);
}

.pagination-prev:hover,
.pagination-next:hover {
    color: rgb(85, 83, 77);
}

.pagination-prev.disabled,
.pagination-next.disabled {
    color: rgb(180, 180, 175);
    pointer-events: none;
}

/* FOOTER */
.footer {
    background-color: rgb(244, 244, 241);
    border-top: 1px solid rgb(214, 214, 209);
    padding: 32px 24px;
    text-align: center;
    margin-top: 48px;
}

.footer-content {
    font-size: 14px;
    color: rgb(85, 83, 77);
    margin-bottom: 16px;
}

body.dark-theme .footer-content {
    color: rgb(160, 160, 155);
}

.footer-content a {
    color: rgb(10, 9, 7);
    text-decoration: none;
    font-weight: 500;
}

body.dark-theme .footer-content a {
    color: rgb(244, 244, 241);
}

.footer-links {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.footer-links a {
    font-size: 14px;
    color: rgb(85, 83, 77);
    text-decoration: none;
    transition: color 0.2s;
}

body.dark-theme .footer-links a {
    color: rgb(160, 160, 155);
}

.footer-links a:hover {
    color: rgb(10, 9, 7);
}

body.dark-theme .footer-links a:hover {
    color: rgb(244, 244, 241);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 24px;
    color: rgb(85, 83, 77);
}

body.dark-theme .no-results {
    color: rgb(160, 160, 155);
}

.no-results h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: rgb(10, 9, 7);
}

body.dark-theme .no-results h3 {
    color: rgb(244, 244, 241);
}

/* Loading state */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Loading Indicator for Infinite Scroll */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: rgb(85, 83, 77);
    font-size: 14px;
}

body.dark-theme .loading-indicator {
    color: rgb(160, 160, 155);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgb(214, 214, 209);
    border-top-color: rgb(10, 9, 7);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

body.dark-theme .loading-spinner {
    border-color: rgb(50, 50, 55);
    border-top-color: rgb(244, 244, 241);
}

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

/* Legal Pages (Privacy, Terms) */
.legal-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 0;
}

.legal-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.legal-updated {
    font-size: 14px;
    color: rgb(85, 83, 77);
    margin-bottom: 32px;
}

body.dark-theme .legal-updated {
    color: rgb(160, 160, 155);
}

.legal-content {
    line-height: 1.7;
}

.legal-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 32px 0 12px 0;
}

.legal-content p {
    margin-bottom: 16px;
    color: rgb(50, 50, 45);
}

body.dark-theme .legal-content p {
    color: rgb(200, 200, 195);
}

.legal-content ul {
    margin: 0 0 16px 24px;
    color: rgb(50, 50, 45);
}

body.dark-theme .legal-content ul {
    color: rgb(200, 200, 195);
}

.legal-content li {
    margin-bottom: 8px;
}

.legal-nav {
    display: flex;
    gap: 24px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgb(214, 214, 209);
}

body.dark-theme .legal-nav {
    border-top-color: rgb(50, 50, 55);
}

.legal-nav a {
    color: rgb(10, 9, 7);
    text-decoration: none;
    font-weight: 500;
}

body.dark-theme .legal-nav a {
    color: rgb(244, 244, 241);
}

.legal-nav a:hover {
    text-decoration: underline;
}

/* Font Face Definitions - Generated dynamically via PHP */
