/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0f14;
    --bg-secondary: #111820;
    --bg-card: #161e28;
    --bg-card-hover: #1c2532;
    --text-primary: #e0e8f0;
    --text-secondary: #8899aa;
    --text-muted: #556677;
    --accent: #7eb8da;
    --accent-bright: #a0d4f0;
    --border: #1e2a36;
    --border-light: #2a3848;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 10px;
    --radius-sm: 6px;
    --font-heading: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-weight: 400;
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright));
    z-index: 1000;
    transition: width 0.15s ease;
    width: 0%;
}

/* ========== HEADER ========== */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 2px;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-content {
    text-align: center;
    margin-bottom: 1rem;
}

.header-content h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.header-content h1 span {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
    font-size: 1.3rem;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.3rem;
    font-family: var(--font-body);
    font-weight: 400;
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========== SEARCH ========== */
.search-container {
    position: relative;
}

#searchInput {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    width: 220px;
    font-family: var(--font-body);
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-color: var(--accent);
    width: 280px;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow);
    z-index: 200;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

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

.search-result-item strong {
    font-size: 0.85rem;
    font-weight: 500;
}

.search-result-item small {
    font-size: 0.7rem;
    color: var(--accent);
}

/* ========== CATEGORY NAVIGATION ========== */
.category-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.category-nav-inner {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    justify-content: flex-start;
    padding: 0 0.25rem;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font-body);
    font-weight: 400;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

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

.nav-btn.active {
    background: var(--bg-card);
    border-color: var(--accent);
    color: var(--accent-bright);
}

.nav-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    padding: 1.5rem 1rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* ========== CATEGORY GRID ========== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.category-card .card-icon {
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.category-card .card-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.category-card .card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    font-family: var(--font-body);
    font-weight: 400;
}

.category-card .card-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* ========== CATEGORY VIEW ========== */
.category-view {
    animation: fadeIn 0.4s ease;
    scroll-margin-top: 80px;
    padding-bottom: 3rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-view.hidden {
    display: none;
}

.category-view-header {
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
}

.category-view-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--accent-bright);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-view-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.3rem;
    font-family: var(--font-body);
    font-weight: 400;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-body);
    margin-bottom: 2rem;
    transition: all 0.2s ease;
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--accent-bright);
}

.back-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ========== ACCORDION ========== */
.accordion {
    margin-bottom: 1rem;
}

.accordion:last-of-type {
    margin-bottom: 0.5rem;
}

.accordion-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    user-select: none;
}

.accordion-header:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.accordion-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.accordion-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
}

.accordion-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.accordion.open .accordion-arrow {
    transform: rotate(180deg);
}

.accordion-body {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

.accordion.open .accordion-body {
    max-height: 4000px;
    padding: 1.2rem;
}

/* ========== SECTION CONTENT BLOCKS ========== */
.block {
    margin-bottom: 1.2rem;
}

.block h4 {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.block p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-family: var(--font-body);
    font-weight: 400;
}

.block ul {
    margin: 0.4rem 0 0.4rem 1.2rem;
    color: var(--text-secondary);
}

.block li {
    margin-bottom: 0.25rem;
}

.insight-box {
    background: rgba(126, 184, 218, 0.08);
    border-left: 3px solid var(--accent);
    padding: 0.8rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-top: 1rem;
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--accent-bright);
    animation: insightGlow 2s ease 0.5s 1;
}

@keyframes insightGlow {
    0% { border-left-color: var(--accent); }
    50% { border-left-color: var(--accent-bright); }
    100% { border-left-color: var(--accent); }
}

/* ========== SPECS LINK ========== */
.specs-link {
    display: inline-block;
    margin-top: 0.8rem;
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.specs-link:hover {
    color: var(--accent-bright);
    border-bottom-style: solid;
}

/* ========== FOOTER ========== */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1.2rem 1rem;
    text-align: center;
}

footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    font-family: var(--font-body);
}

/* ========== PROTOCOL FOOTER ========== */
.protocol-footer {
    padding: 1.5rem 1.5rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

.footer-rule {
    display: none;
}

.footer-note {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
    font-weight: 400;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.footer-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    letter-spacing: 0.02em;
}

.footer-link:hover {
    color: var(--text-primary);
}

.footer-link .link-label {
    border-bottom: 1px dotted transparent;
    transition: border-color 0.2s ease;
}

.footer-link:hover .link-label {
    border-bottom-color: var(--text-muted);
}

.footer-link .link-arrow {
    font-size: 0.6rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.footer-link:hover .link-arrow {
    opacity: 0.9;
}

.footer-sep {
    display: inline-block;
    width: 1px;
    height: 10px;
    background: var(--border);
    margin: 0 0.5rem;
    opacity: 0.4;
}

.footer-close {
    font-family: var(--font-body);
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.4;
}

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 14, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: modalFadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

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

.modal-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    animation: panelSlideIn 0.25s ease;
}

@keyframes panelSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 0.8rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    transition: color 0.2s ease;
    font-family: var(--font-body);
}

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

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    letter-spacing: -0.01em;
}

.modal-text {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.2rem;
}

.address-container {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    word-break: break-all;
}

.kaspa-address {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    overflow-wrap: anywhere;
    background: transparent;
    padding: 0;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.copy-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

.copied-feedback {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.5rem;
    text-align: right;
    transition: opacity 0.3s ease;
}

.copied-feedback.hidden {
    opacity: 0;
}

.modal-github-link {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent);
    transition: all 0.2s ease;
    margin-top: 0.3rem;
}

.modal-github-link:hover {
    color: var(--accent-bright);
    border-bottom-style: solid;
}

/* ========== RESPONSIVE FOOTER ========== */
@media (max-width: 500px) {
    .protocol-footer {
        padding: 2.5rem 1rem 1.5rem;
    }
    
    .footer-links {
        gap: 0.2rem;
    }
    
    .footer-link {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
    }
    
    .footer-sep {
        margin: 0 0.3rem;
        height: 10px;
    }
    
    .modal-panel {
        padding: 1.5rem;
    }
    
    .address-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .copy-btn {
        justify-content: center;
    }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .category-view {
        animation: none;
    }
    
    .insight-box {
        animation: none;
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
    .header-content h1 {
        font-size: 1.6rem;
    }
    
    .category-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
    
    .category-card {
        padding: 1rem;
    }
    
    .category-card .card-title {
        font-size: 1rem;
    }
    
    #searchInput {
        width: 180px;
    }
    
    #searchInput:focus {
        width: 230px;
    }
    
    .search-results {
        width: 280px;
        right: -20px;
    }
}

@media (max-width: 380px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #searchInput,
    #searchInput:focus {
        width: 100%;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    header, nav, footer, .search-container, .back-btn, .progress-bar {
        display: none;
    }
    
    .accordion-body {
        max-height: none;
        padding: 1rem;
    }
    
    body {
        background: white;
        color: black;
    }
}

#backButton {
    margin-bottom: 1.5rem;
}

#categoryView {
    padding-top: 0.5rem;
}