/* =============================================
   TOKENS
   ============================================= */
:root {
    --bamboo-dark:   #3D6B4F;
    --bamboo-mid:    #5A8F6A;
    --bamboo-light:  #8DBF8D;
    --bamboo-pale:   #C8DFC8;
    --bamboo-mist:   #EBF3EB;

    --bone:          #F5F2EA;
    --bone-warm:     #EDE9DF;
    --white:         #FFFFFF;

    --ink:           #1E2D22;
    --ink-mid:       #3D4F40;
    --ink-soft:      #6B7D6E;
    --ink-faint:     #9EAD9F;

    --sidebar-w:     300px;
    --font-mono:     'DM Mono', monospace;
    --font-body:     'Inter', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bone);
    color: var(--ink);
    line-height: 1.65;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* =============================================
   LAYOUT
   ============================================= */
.layout {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--bamboo-pale);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--bamboo-pale);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.logo-mark {
    color: var(--bamboo-dark);
    font-size: 20px;
    line-height: 1;
}

.logo-text {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 13px;
    color: var(--bamboo-dark);
    letter-spacing: 0.02em;
}

.sidebar-sub {
    font-size: 11px;
    color: var(--ink-faint);
    line-height: 1.4;
}

/* NAV */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--bamboo-pale) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--bamboo-pale); border-radius: 2px; }

.nav-section { border-bottom: 1px solid var(--bamboo-mist); }

.nav-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    transition: color 0.15s;
}

.nav-section-toggle:hover { color: var(--bamboo-dark); }
.nav-section-toggle.active { color: var(--bamboo-dark); }

.nav-count {
    background: var(--bamboo-mist);
    color: var(--bamboo-dark);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 10px;
}

.nav-list {
    list-style: none;
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 2000px;
}

.nav-list.collapsed { max-height: 0; }

.nav-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 8px 24px;
    text-decoration: none;
    color: var(--ink-mid);
    transition: background 0.12s, color 0.12s;
    border-left: 2px solid transparent;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bamboo-mist);
    color: var(--bamboo-dark);
    border-left-color: var(--bamboo-light);
}

.nav-item.active {
    background: var(--bamboo-mist);
    color: var(--bamboo-dark);
    border-left-color: var(--bamboo-dark);
}

.nav-item-id {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--bamboo-mid);
    flex-shrink: 0;
    min-width: 30px;
}

.nav-item.active .nav-item-id { color: var(--bamboo-dark); }

.nav-item-title {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    flex: 1;
}

.nav-item-cat {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    flex-basis: 100%;
    margin-left: 38px;
}

.sidebar-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--bamboo-pale);
    flex-shrink: 0;
}

.sidebar-footer p {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-faint);
    line-height: 1.8;
}

/* =============================================
   CATEGORY COLORS
   ============================================= */
.cat-caché,
.nav-item-cat.cat-caché { background: #E8F5E0; color: #2D6A1E; }

.cat-arquitectura,
.nav-item-cat.cat-arquitectura { background: #E3EEF8; color: #1A4A72; }

.cat-base-de-datos,
.nav-item-cat.cat-base-de-datos { background: #FDF0E0; color: #7A4510; }

.cat-monitoreo-y-observabilidad,
.nav-item-cat.cat-monitoreo-y-observabilidad { background: #F0E8F8; color: #4A1A72; }

.cat-escalado-horizontal-vertical,
.nav-item-cat.cat-escalado-horizontal-vertical { background: #E0F5F5; color: #0E5A5A; }

.cat-tolerancia-a-fallos,
.nav-item-cat.cat-tolerancia-a-fallos { background: #FDEAEA; color: #7A1A1A; }

.cat-balanceo-de-carga,
.nav-item-cat.cat-balanceo-de-carga { background: #FFF8E0; color: #6B5010; }

.cat-ci-cd-y-despliegue,
.nav-item-cat.cat-ci-cd-y-despliegue { background: #EAF0E8; color: #2A4A1E; }

.cat-diseño-de-apis,
.nav-item-cat.cat-diseño-de-apis { background: #EEE8F0; color: #3A1A5A; }

.cat-frontend-cliente,
.nav-item-cat.cat-frontend-cliente { background: #F0EEE0; color: #4A4010; }

/* =============================================
   MAIN CONTENT
   ============================================= */
.content {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* VIEW SYSTEM */
.view {
    display: none;
    min-height: 100vh;
}

.view.active {
    display: block;
}

/* =============================================
   HOME VIEW
   ============================================= */
.home-hero {
    padding: 64px 72px 48px;
    border-bottom: 1px solid var(--bamboo-pale);
    background: var(--white);
}

.home-hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--bamboo-mid);
    margin-bottom: 18px;
}

.home-title {
    font-size: 38px;
    font-weight: 300;
    line-height: 1.2;
    color: var(--ink);
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.home-title strong { font-weight: 600; }

.home-desc {
    font-size: 15px;
    color: var(--ink-mid);
    line-height: 1.7;
    max-width: 600px;
    margin-bottom: 40px;
}

.home-stats {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 32px;
    background: var(--bone);
    border: 1px solid var(--bamboo-pale);
    border-radius: 10px;
    padding: 24px 32px;
    width: fit-content;
}

.stat { text-align: center; padding: 0 28px; }
.stat:first-child { padding-left: 0; }
.stat:last-child { padding-right: 0; }

.stat-num {
    display: block;
    font-family: var(--font-mono);
    font-size: 36px;
    font-weight: 500;
    color: var(--bamboo-dark);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 12px;
    color: var(--ink-soft);
    line-height: 1.4;
}

.stat-label small {
    display: block;
    font-size: 11px;
    color: var(--ink-faint);
}

.stat-divider {
    width: 1px;
    height: 48px;
    background: var(--bamboo-pale);
    flex-shrink: 0;
}

.home-cta-hint {
    font-size: 13px;
    color: var(--ink-faint);
    font-style: italic;
}

.home-categories {
    padding: 48px 72px 64px;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 20px;
}

.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.cat-card {
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}

.cat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.cat-card-name {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
}

.cat-card-count {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 500;
    opacity: 0.7;
}

/* Cat card colors */
.cat-card-caché { background: #E8F5E0; color: #2D6A1E; border-color: #C5E0B0; }
.cat-card-arquitectura { background: #E3EEF8; color: #1A4A72; border-color: #B0CCDF; }
.cat-card-base-de-datos { background: #FDF0E0; color: #7A4510; border-color: #E8D0AA; }
.cat-card-monitoreo-y-observabilidad { background: #F0E8F8; color: #4A1A72; border-color: #D0B8E8; }
.cat-card-escalado-horizontal-vertical { background: #E0F5F5; color: #0E5A5A; border-color: #A8DADA; }
.cat-card-tolerancia-a-fallos { background: #FDEAEA; color: #7A1A1A; border-color: #F0BABA; }
.cat-card-balanceo-de-carga { background: #FFF8E0; color: #6B5010; border-color: #E8DC9A; }
.cat-card-ci-cd-y-despliegue { background: #EAF0E8; color: #2A4A1E; border-color: #B8D0B0; }
.cat-card-diseño-de-apis { background: #EEE8F0; color: #3A1A5A; border-color: #C8B0D8; }
.cat-card-frontend-cliente { background: #F0EEE0; color: #4A4010; border-color: #D8D0A0; }

/* =============================================
   DETAIL VIEW
   ============================================= */
.detail-header {
    padding: 52px 72px 40px;
    background: var(--white);
    border-bottom: 1px solid var(--bamboo-pale);
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.detail-id {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--bamboo-dark);
    background: var(--bamboo-mist);
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--bamboo-pale);
}

.detail-cat {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 3px 9px;
    border-radius: 4px;
}

.detail-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bamboo-dark);
    background: var(--bamboo-pale);
    padding: 3px 9px;
    border-radius: 4px;
}

.detail-badge-sec {
    color: var(--ink-soft);
    background: var(--bone-warm);
}

.detail-title {
    font-size: 28px;
    font-weight: 400;
    color: var(--ink);
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
    max-width: 720px;
}

.detail-summary {
    font-size: 16px;
    color: var(--ink-mid);
    line-height: 1.7;
    max-width: 680px;
    margin-bottom: 32px;
}

/* CONSENSUS BAR */
.consensus-bar-wrap {
    max-width: 520px;
}

.consensus-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--ink-soft);
    font-family: var(--font-mono);
}

.consensus-val {
    font-size: 15px;
    font-weight: 500;
    color: var(--bamboo-dark);
}

.consensus-track {
    height: 6px;
    background: var(--bamboo-mist);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.consensus-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bamboo-mid), var(--bamboo-dark));
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.consensus-fill-sec {
    background: linear-gradient(90deg, var(--ink-faint), var(--ink-soft));
}

.consensus-sources {
    font-size: 11px;
    color: var(--ink-faint);
    font-family: var(--font-mono);
}

.src-acad { color: #1A4A72; }
.src-ind  { color: #2D6A1E; }

/* DETAIL BODY */
.detail-body {
    padding: 48px 72px;
    max-width: 820px;
}

.detail-section {
    margin-bottom: 44px;
}

.detail-section h2 {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bamboo-mid);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bamboo-mist);
}

.detail-section p {
    font-size: 15px;
    color: var(--ink-mid);
    line-height: 1.8;
}

.example-block {
    background: var(--bone);
    border: 1px solid var(--bamboo-pale);
    border-left: 3px solid var(--bamboo-mid);
    border-radius: 0 8px 8px 0;
    padding: 20px 24px;
}

.example-block p {
    font-size: 14px;
    color: var(--ink-mid);
    line-height: 1.75;
}

/* DETAIL NAV */
.detail-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 72px 48px;
    border-top: 1px solid var(--bamboo-mist);
    gap: 16px;
}

.nav-btn {
    background: var(--white);
    border: 1px solid var(--bamboo-pale);
    color: var(--bamboo-dark);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
    max-width: 320px;
    text-align: left;
    line-height: 1.4;
}

.nav-btn:hover {
    background: var(--bamboo-mist);
    border-color: var(--bamboo-mid);
    transform: translateY(-1px);
}

.nav-btn-next {
    margin-left: auto;
    text-align: right;
}

/* =============================================
   MOBILE MENU
   ============================================= */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bamboo-dark);
    color: var(--white);
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(61,107,79,0.35);
    transition: transform 0.2s;
}

.mobile-menu-btn:hover { transform: scale(1.08); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
    :root { --sidebar-w: 260px; }
    .home-hero, .detail-header { padding: 40px 36px 32px; }
    .home-categories { padding: 36px 36px 48px; }
    .detail-body { padding: 36px 36px; }
    .detail-nav { padding: 20px 36px 36px; }
    .home-title { font-size: 28px; }
}

@media (max-width: 680px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 50;
        height: 100%;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.12);
    }

    .sidebar.open { left: 0; }

    .content { width: 100%; }
    .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

    .home-hero, .detail-header { padding: 32px 24px 28px; }
    .home-categories { padding: 28px 24px 40px; }
    .detail-body { padding: 28px 24px; }
    .detail-nav { padding: 16px 24px 32px; flex-direction: column; }
    .nav-btn-next { margin-left: 0; text-align: left; }
    .home-title { font-size: 22px; }
    .home-stats { flex-direction: column; gap: 16px; }
    .stat-divider { width: 80px; height: 1px; }
}

/* =============================================
   FOCUS & ACCESSIBILITY
   ============================================= */
:focus-visible {
    outline: 2px solid var(--bamboo-dark);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}