/* ================================================================
   MATRIX SAHAM — User Guide
   White theme, book-like, professional typography
   ================================================================ */

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-page:       #FFFFFF;
    --bg-hero:       #F0FDF4;
    --bg-card:       #F9FAFB;
    --bg-card-hover: #F3F4F6;
    --bg-toc:        #FAFAFA;
    --bg-search:     #F3F4F6;
    --bg-badge-pro:  #10B981;
    --bg-badge-free: #E5E7EB;
    --bg-badge-info: #EFF6FF;
    --bg-location:   #EFF6FF;

    /* Text */
    --text-primary:   #1A1A2E;
    --text-secondary: #4B5563;
    --text-muted:     #6B7280;
    --text-light:     #9CA3AF;
    --text-inverse:   #FFFFFF;

    /* Accent */
    --accent:       #10B981;
    --accent-dark:  #059669;
    --accent-light: #D1FAE5;

    /* Brand */
    --brand-green:  #10B981;
    --brand-red:    #EF4444;
    --brand-gold:   #C79A3D;

    /* Borders */
    --border:       #E5E7EB;
    --border-light: #F3F4F6;
    --border-focus: #10B981;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.05);

    /* Spacing */
    --container-max: 1120px;
    --sidebar-w:     240px;
    --gap:           48px;
    --section-gap:   64px;

    /* Type */
    --font-sans:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'IBM Plex Mono', ui-monospace, Menlo, monospace;
    --font-display: 'Fraunces', Georgia, serif;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

ul, ol { padding-left: 1.5em; }
li { margin-bottom: 0.35em; }
li:last-child { margin-bottom: 0; }

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: #F3F4F6;
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--accent-dark);
}

strong { font-weight: 600; }

img { max-width: 100%; height: auto; }

/* ── Container & Layout ───────────────────────────────────────── */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    gap: var(--gap);
    align-items: start;
}

/* ── Header ───────────────────────────────────────────────────── */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.header-brand:hover { text-decoration: none; }

.header-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

.header-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

.header-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
    background: var(--bg-hero);
    border-bottom: 1px solid var(--border);
    padding: 56px 0 48px;
    text-align: center;
}

.hero-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-dark);
    background: var(--accent-light);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.hero-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    line-height: 1.2;
}

.hero-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ── Search ───────────────────────────────────────────────────── */
.search-section {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-page);
    position: sticky;
    top: 64px;
    z-index: 90;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    color: var(--text-light);
    pointer-events: none;
}

.search-field {
    width: 100%;
    height: 48px;
    padding: 0 44px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-search);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field::placeholder { color: var(--text-light); }

.search-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background: var(--bg-page);
}

.search-clear {
    position: absolute;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--border);
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s;
}

.search-clear:hover { background: #D1D5DB; }

.search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.btn-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 5px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-toggle:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

/* ── TOC Sidebar ──────────────────────────────────────────────── */
.toc {
    position: sticky;
    top: 160px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}

.toc-link.active {
    background: var(--accent-light);
    color: var(--accent-dark);
    border-left-color: var(--accent);
    font-weight: 600;
}

.toc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.6;
}

.toc-link.active .toc-icon { opacity: 1; }

/* ── Feature Sections ─────────────────────────────────────────── */
.feature-section {
    margin-bottom: var(--section-gap);
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--text-inverse);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.section-intro {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ── Feature Cards (Accordion) ────────────────────────────────── */
.feature-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--bg-page);
    transition: border-color 0.2s, box-shadow 0.15s;
    overflow: hidden;
}

.feature-card:hover {
    border-color: #D1D5DB;
}

.feature-card[open] {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.feature-card summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--text-primary);
    list-style: none;
    transition: background 0.15s;
    gap: 12px;
    -webkit-user-select: none;
    user-select: none;
}

.feature-card summary::-webkit-details-marker { display: none; }

.feature-card summary::before {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.2s;
}

.feature-card[open] summary::before {
    transform: rotate(90deg);
}

.feature-card summary:hover {
    background: var(--bg-card);
}

.feature-name {
    flex: 1;
}

.feature-body {
    padding: 4px 18px 20px 50px;
}

.feature-part {
    margin-bottom: 16px;
}

.feature-part:last-child { margin-bottom: 0; }

.feature-part h4 {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.feature-part p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.feature-part ul, .feature-part ol {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.feature-location {
    display: inline-block;
    margin-top: 12px;
    padding: 5px 12px;
    background: var(--bg-location);
    color: #1D4ED8;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    white-space: nowrap;
}

.badge-pro {
    background: var(--bg-badge-pro);
    color: var(--text-inverse);
}

.badge-free {
    background: var(--bg-badge-free);
    color: var(--text-secondary);
}

.badge-info {
    background: var(--bg-badge-info);
    color: #1D4ED8;
}

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 48px;
}

/* ── Search Highlight ─────────────────────────────────────────── */
.feature-card.search-hidden { display: none; }

.feature-section.section-hidden { display: none; }

.search-highlight {
    background: #FEF08A;
    padding: 0 2px;
    border-radius: 2px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .toc {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        background: var(--bg-page);
        border-right: 1px solid var(--border);
        padding: 80px 16px 24px;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: none;
    }

    .toc.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .toc-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 190;
    }

    .toc-overlay.open { display: block; }

    .toc-nav { padding-top: 8px; }

    .sections { padding-top: 8px; }

    .hero-title { font-size: 1.7rem; }
    .hero { padding: 40px 0 32px; }

    .feature-body { padding-left: 18px; }

    .header-subtitle { display: none; }
    .header-divider { display: none; }
}

@media (min-width: 901px) {
    .toc-overlay { display: none !important; }
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
    .site-header,
    .search-section,
    .toc,
    .site-footer { display: none; }

    .layout { grid-template-columns: 1fr; }

    .feature-card { break-inside: avoid; }
    .feature-card[open] .feature-body,
    .feature-card:not([open]) .feature-body { display: block !important; }
    .feature-card { border: 1px solid #ddd; }
    .feature-card summary { cursor: default; }
    .feature-card summary::before { display: none; }

    body { font-size: 11pt; }
    .hero { padding: 24px 0; background: #f0f0f0; }
}

/* ── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .toc-link,
    .feature-card,
    .search-field,
    .btn-toggle { transition: none; }
    .feature-card summary::before { transition: none; }
}
