/* Base styles with light/dark mode */
:root {
    --bg: #ffffff;
    --bg-secondary: #f5f5f5;
    --text: #1a1a1a;
    --text-muted: #666666;
    --border: #e0e0e0;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --glyph-bg: #fafafa;
    --shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1a1a;
        --bg-secondary: #262626;
        --text: #f5f5f5;
        --text-muted: #a0a0a0;
        --border: #404040;
        --accent: #60a5fa;
        --accent-hover: #93c5fd;
        --glyph-bg: #2a2a2a;
        --shadow: rgba(0, 0, 0, 0.3);
    }
}

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

/* Unicode glyph font stack - system fonts with emoji support */
.unicode-glyph,
.char-cell .glyph,
.char-hero .glyph,
.search-result .glyph {
    font-family:
        "Apple Color Emoji",
        "Segoe UI Emoji",
        "Segoe UI Symbol",
        "Noto Color Emoji",
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.logo:hover {
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

.search-form {
    margin-left: auto;
    position: relative;
}

.search-form input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    width: 250px;
}

.search-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 4px 12px var(--shadow);
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.search-dropdown:not(:empty) {
    display: block;
}

/* Main content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Narrow page layout for detail pages */
.page-narrow {
    max-width: 800px;
    margin: 0 auto;
}

/* Action links */
.action-link {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.action-link:hover {
    color: var(--accent);
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Character grid */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 4px;
}

.char-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--glyph-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 1.5rem;
    transition: all 0.15s ease;
}

.char-cell:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    text-decoration: none;
    transform: scale(1.05);
}

.char-cell .glyph {
    font-size: 1.75rem;
    line-height: 1;
}

.char-cell .codepoint {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
}

/* Character detail page */
.char-detail {
    display: grid;
    gap: 2rem;
}

.char-hero {
    text-align: center;
    padding: 2rem;
    background: var(--glyph-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.char-hero .glyph {
    font-size: 8rem;
    line-height: 1.2;
}

.char-hero .name {
    font-size: 1.25rem;
    margin-top: 1rem;
    color: var(--text-muted);
}

.char-hero .codepoint {
    font-family: ui-monospace, monospace;
    font-size: 1.5rem;
    margin-top: 0.5rem;
}

.char-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

.char-nav > * {
    flex: 1;
}

.char-nav > *:first-child {
    text-align: left;
}

.char-nav > *:nth-child(2) {
    text-align: center;
}

.char-nav > *:last-child {
    text-align: right;
}

.char-nav a {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.9rem;
}

.copy-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.copy-btn {
    padding: 0.4rem 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.8rem;
    font-family: ui-monospace, monospace;
}

.copy-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Properties table */
.props-table {
    width: 100%;
    border-collapse: collapse;
}

.props-table th,
.props-table td {
    padding: 0.5rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.props-table th {
    font-weight: 500;
    color: var(--text-muted);
    width: 40%;
}

.props-table td {
    font-family: ui-monospace, monospace;
    font-size: 0.9rem;
}

/* Block/script list */
.item-list {
    display: grid;
    gap: 0.5rem;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    transition: background 0.15s;
}

.item-row:hover {
    background: var(--glyph-bg);
}

.item-row .name {
    font-weight: 500;
}

.item-row .count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Featured blocks */
.featured-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.featured-block {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.featured-block:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.featured-block .name {
    font-weight: 500;
    color: var(--text);
}

.featured-block .count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Search results */
.search-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: var(--bg-secondary);
}

.search-result .glyph {
    font-size: 1.5rem;
    width: 2.5rem;
    text-align: center;
}

.search-result .info {
    flex: 1;
}

.search-result .name {
    font-weight: 500;
}

.search-result .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.9rem;
}

.pagination .current {
    background: var(--accent);
    color: white;
}

/* Section */
.section {
    margin-bottom: 3rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Utility classes */
.mt-sm {
    margin-top: 1rem;
}

.mt-md {
    margin-top: 1.5rem;
}

.text-muted {
    color: var(--text-muted);
}

.empty-state {
    padding: 1rem;
    color: var(--text-muted);
}

/* Homepage styles */
.hero-section {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg) 100%);
    border-radius: 16px;
    margin-bottom: 2rem;
}

.hero-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.hero-search-form {
    position: relative;
    max-width: 500px;
    margin: 0 auto 2rem;
}

.hero-search-form input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hero-search-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.hero-search-form input::placeholder {
    color: var(--text-muted);
}

.hero-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.showcase-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.showcase-char {
    font-size: 2.5rem;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glyph-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.showcase-char:hover {
    transform: scale(1.1);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-link {
    text-decoration: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin: -0.5rem -1rem;
    transition: background-color 0.2s ease;
}

.stat-link:hover {
    background: var(--bg);
}

.stat-link:hover .stat-value {
    text-decoration: underline;
}

.featured-blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.block-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.875rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
}

.block-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.block-samples {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.625rem;
    min-height: 2rem;
}

.sample-glyph {
    font-size: 1.5rem;
    opacity: 0.9;
}

.block-card .block-info {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

.block-name {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.125rem;
}

.block-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.browse-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
}

.browse-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.browse-icon {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.browse-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.125rem;
}

.browse-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Blocks list page */
.blocks-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.block-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s ease;
}

.block-row:hover {
    border-color: var(--accent);
    background: var(--bg);
}

.block-row .block-samples {
    min-width: 140px;
    flex-shrink: 0;
    gap: 0.25rem;
    margin-bottom: 0;
}

.sample-char {
    font-size: 1.25rem;
    width: 1.5em;
    text-align: center;
}

.block-row .block-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
    min-width: 0;
    border-top: none;
    padding-top: 0;
}

.block-row .block-info .name {
    font-weight: 500;
}

.block-row .block-info .range {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Fonts page */
.font-family-section {
    margin-bottom: 1.5rem;
}

.font-family-section h2 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.font-variant-list {
    display: flex;
    flex-direction: column;
}

.font-variant {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    padding: 0.2rem 0;
}

.font-variant:hover .variant-name {
    color: var(--accent);
}

.variant-name {
    font-size: 1.75rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.variant-sample {
    font-size: 1.1rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#fonts-status {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Font detail page */
.font-hero {
    text-align: center;
    padding: 2rem;
    background: var(--glyph-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.font-hero h1 {
    margin-bottom: 0.25rem;
}

.font-family {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.font-sample {
    margin: 2rem 0;
}

.sample-large {
    font-size: 4rem;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.sample-text {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.font-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--accent);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    color: white;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

.font-char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
}

.font-char-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--glyph-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s ease;
}

.font-char-cell:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    text-decoration: none;
}

.font-char-cell .glyph {
    font-size: 2rem;
    line-height: 1;
}

.font-char-cell .codepoint {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
    margin-top: 4px;
}

code {
    background: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
}

.glyph-filters {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.glyph-filters label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.glyph-filters input[type="checkbox"] {
    cursor: pointer;
}

#glyph-status {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-link {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.page-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    text-decoration: none;
}

.page-current {
    padding: 0.4rem 0.75rem;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    font-size: 0.9rem;
}

.page-ellipsis {
    color: var(--text-muted);
    padding: 0 0.25rem;
}

/* Variations page */
.variations-header {
    margin-bottom: 2rem;
}

.back-link {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.variations-header h1 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.variations-header .glyph {
    font-size: 3rem;
    line-height: 1;
}

.char-info {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.variations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.variation-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: var(--glyph-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    min-height: 100px;
}

.variation-glyph {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.variation-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    word-break: break-word;
    max-width: 100%;
    text-decoration: none;
}

.variation-name:hover {
    color: var(--accent);
    text-decoration: underline;
}

.variation-cell.unsupported {
    opacity: 0.4;
}

.variation-cell.unsupported .variation-glyph {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 640px) {
    nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .nav-links {
        justify-content: center;
    }

    .search-form {
        margin-left: 0;
    }

    .search-form input {
        width: 100%;
    }

    .char-hero .glyph {
        font-size: 5rem;
    }

    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }

    /* Homepage responsive */
    .hero-section h1 {
        font-size: 1.75rem;
    }

    .hero-search-form input {
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }

    .showcase-char {
        font-size: 2rem;
        width: 52px;
        height: 52px;
    }

    .stats-bar {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    /* Blocks list responsive */
    .block-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .block-row .block-samples {
        min-width: auto;
    }
}
