/* ============================================================
   OpenCrust Documentation — Custom Theme
   Brand: orange #e8651a · blue #2e6db4 · teal #00c4a0
   Inspired by openclaw.ai — deep-space terminal aesthetic
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://api.fontshare.com/v2/css?f[]=clash-display@500,600,700&f[]=satoshi@400,500,700&display=swap');

/* ---------- CSS variables ---------- */
.navy {
    --bg:                   #07111e;
    --fg:                   #e8edf5;
    --sidebar-bg:           #050d18;
    --sidebar-fg:           #b0bccf;
    --sidebar-non-existant: #3d5068;
    --sidebar-active:       #e8651a;
    --sidebar-spacer:       #1a2a3a;
    --links:                #60a5fa;
    --inline-code-color:    #fbd38d;
    --theme-popup-bg:       #0d1f30;
    --theme-popup-border:   #1a2a3a;
    --theme-hover:          #1a2a3a;
    --quote-bg:             #0d1f30;
    --quote-border:         #e8651a;
    --table-border-color:   #1a2a3a;
    --table-header-bg:      #0d1f30;
    --table-alternate-bg:   #0a1826;
    --searchbar-border-color: #1a2a3a;
    --searchbar-bg:         #0d1f30;
    --searchbar-fg:         #e2e8f0;
    --searchresults-header-fg: #e8651a;
    --searchresults-border-color: #1a2a3a;
    --searchresults-li-bg:  #0d1f30;
    --search-mark-bg:       #7c2d12;
}

/* ---------- Animations ---------- */
@keyframes twinkle {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 0.9; }
}

@keyframes nebulaDrift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(20px, -10px) scale(1.05); }
    100% { transform: translate(0, 0) scale(1); }
}

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

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

/* ---------- Star field background ---------- */
.navy body {
    background-color: #07111e;
    position: relative;
}

.navy body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 40% 8%, rgba(232,101,26,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 60%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 25%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 80% 70%, rgba(0,196,160,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 45%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 85%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 35% 55%, rgba(46,109,180,0.6) 0%, transparent 100%);
    background-size: 400px 300px;
    animation: twinkle 8s ease-in-out infinite;
    pointer-events: none;
}

.navy body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 60% 40% at 20% 20%, rgba(232,101,26,0.07) 0%, transparent 70%),
        radial-gradient(ellipse 50% 35% at 80% 80%, rgba(46,109,180,0.08) 0%, transparent 70%),
        radial-gradient(ellipse 40% 30% at 60% 10%, rgba(0,196,160,0.05) 0%, transparent 70%);
    animation: nebulaDrift 30s ease-in-out infinite;
    pointer-events: none;
}

/* ---------- Sidebar ---------- */
.navy .sidebar {
    background: rgba(5, 13, 24, 0.92);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(232,101,26,0.15);
}

/* Logo area — injected by opencrust.js, fallback text */
.navy .sidebar .sidebar-scrollbox::before {
    content: "";
    display: block;
    height: 64px;
    background: url('https://github.com/opencrust-org/opencrust/raw/main/assets/logo.png') no-repeat left center / contain;
    margin: 16px 16px 12px;
    border-bottom: 1px solid rgba(232,101,26,0.2);
    padding-bottom: 14px;
    filter: drop-shadow(0 0 8px rgba(232,101,26,0.3));
}

.navy .sidebar .chapter li a {
    border-radius: 6px;
    margin: 1px 8px;
    padding: 5px 10px;
    transition: background 0.15s, color 0.15s, border-left 0.15s;
    font-family: 'Satoshi', sans-serif;
    font-size: 0.9em;
    border-left: 2px solid transparent;
}

.navy .sidebar .chapter li a:hover {
    background: rgba(232,101,26,0.1);
    color: #e8651a;
    border-left-color: rgba(232,101,26,0.4);
}

.navy .sidebar .chapter li a.active {
    background: rgba(232,101,26,0.15);
    color: #fb923c;
    font-weight: 600;
    border-left-color: #e8651a;
}

/* ---------- Menu bar ---------- */
.navy #menu-bar {
    background: rgba(5, 13, 24, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(232,101,26,0.15);
}

.navy #menu-bar .menu-title {
    font-family: 'Clash Display', sans-serif;
    font-weight: 700;
    color: #e8651a;
    letter-spacing: 0.05em;
    font-size: 1.05rem;
}

.navy #menu-bar i.fa {
    color: #64748b;
    transition: color 0.15s;
}

.navy #menu-bar i.fa:hover {
    color: #e8651a;
}

/* ---------- Main content ---------- */
.navy .content main {
    max-width: 880px;
    animation: fadeInUp 0.6s ease-out both;
    font-family: 'Satoshi', sans-serif;
    line-height: 1.75;
}

/* ---------- Headings ---------- */
.navy h1 {
    font-family: 'Clash Display', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e8651a 0%, #fb923c 40%, #fbbf24 70%, #e8651a 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 6s ease infinite;
    border-bottom: 1px solid rgba(232,101,26,0.25);
    padding-bottom: 0.3em;
    margin-bottom: 0.6em;
}

.navy h2 {
    font-family: 'Clash Display', sans-serif;
    color: #fb923c;
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(46,109,180,0.25);
    padding-bottom: 0.2em;
}

.navy h3 {
    font-family: 'Clash Display', sans-serif;
    color: #fdba74;
    font-size: 1.15rem;
}

.navy h4, .navy h5, .navy h6 {
    color: #fed7aa;
    font-family: 'Satoshi', sans-serif;
    font-weight: 600;
}

/* ---------- Links ---------- */
.navy a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.15s;
}

.navy a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

/* ---------- Inline code ---------- */
.navy code {
    background: rgba(232,101,26,0.12);
    color: #fbd38d;
    border-radius: 4px;
    padding: 0.15em 0.45em;
    font-size: 0.87em;
    border: 1px solid rgba(232,101,26,0.2);
}

/* ---------- Code blocks — terminal style ---------- */
.navy pre {
    position: relative;
    background: rgba(5, 13, 24, 0.85) !important;
    border: 1px solid rgba(232,101,26,0.2);
    border-radius: 10px;
    backdrop-filter: blur(8px);
    padding-top: 36px !important;
    box-shadow:
        0 4px 24px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.04);
    overflow: hidden;
}

/* Traffic-light dots via JS — fallback left border */
.navy pre::before {
    content: "● ● ●";
    position: absolute;
    top: 10px;
    left: 14px;
    font-size: 11px;
    letter-spacing: 4px;
    color: #2d3748;
    line-height: 1;
}

.navy pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    font-size: 0.88em;
    border: none;
}

/* Copy button */
.navy .buttons {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 10;
}

.navy .buttons button {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #64748b;
    border-radius: 5px;
    transition: all 0.15s;
    font-size: 0.78em;
    padding: 2px 7px;
}

.navy .buttons button:hover {
    background: rgba(232,101,26,0.15);
    color: #e8651a;
    border-color: rgba(232,101,26,0.3);
}

/* ---------- Tables ---------- */
.navy .table-wrapper {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(46,109,180,0.2);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.navy table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.92em;
    font-family: 'Satoshi', sans-serif;
}

.navy table thead tr {
    background: rgba(46,109,180,0.15);
    color: #fb923c;
}

.navy table thead th {
    padding: 11px 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(232,101,26,0.3);
    font-family: 'Clash Display', sans-serif;
    font-size: 0.85em;
    text-transform: uppercase;
}

.navy table tbody tr {
    border-bottom: 1px solid rgba(26,42,58,0.8);
    transition: background 0.12s;
}

.navy table tbody tr:nth-child(even) {
    background: rgba(10,24,38,0.5);
}

.navy table tbody tr:hover {
    background: rgba(232,101,26,0.07);
}

.navy table td {
    padding: 9px 14px;
    color: #cbd5e0;
}

/* ---------- Blockquotes ---------- */
.navy blockquote {
    border-left: 3px solid #e8651a;
    background: rgba(232,101,26,0.06);
    border-radius: 0 10px 10px 0;
    padding: 14px 20px;
    color: #b0bccf;
    margin: 1.2em 0;
    backdrop-filter: blur(4px);
}

.navy blockquote strong:first-child {
    color: #e8651a;
    text-transform: uppercase;
    font-size: 0.78em;
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 5px;
    font-family: 'Clash Display', sans-serif;
}

/* ---------- Search ---------- */
.navy #searchresults a {
    color: #60a5fa;
}

.navy mark {
    background: rgba(232,101,26,0.35);
    color: #fed7aa;
    border-radius: 3px;
    padding: 0 3px;
}

/* ---------- Page nav ---------- */
.navy .nav-chapters {
    color: #475569;
    transition: color 0.15s, background 0.15s;
    border-radius: 8px;
}

.navy .nav-chapters:hover {
    color: #e8651a;
    background: rgba(232,101,26,0.08);
}

/* ---------- Selection ---------- */
.navy ::selection {
    background: rgba(232,101,26,0.35);
    color: #fff;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #050d18; }
::-webkit-scrollbar-thumb {
    background: rgba(232,101,26,0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(232,101,26,0.5);
}

/* ---------- Focus ring ---------- */
.navy :focus-visible {
    outline: 2px solid #00c4a0;
    outline-offset: 3px;
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
    .navy h1 { font-size: 1.6rem; }
    .navy h2 { font-size: 1.2rem; }
    .navy table { font-size: 0.8em; }
    .navy pre { font-size: 0.82em; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
