:root{
    --bg:#0a0b0d;
    --panel:#111215;
    --panel-2:#0d0e11;
    --text:#e9e6df;
    --muted:#6f7480;
    --dim:#4b4f58;
    --border:rgba(255,255,255,.09);
    --amber:#ffb454;
    --amber-dim:#8a6a3a;
    --blue:#8fd3ff;
    --red:#ff5f57;
    --yellow:#febc2e;
    --green:#28c840;
}

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

html{
    scroll-behavior:smooth;
}

body{
    min-height:100vh;
    display:flex;
    justify-content:center;
    padding:24px;
    font-family:'JetBrains Mono', ui-monospace, monospace;
    color:var(--text);
    background:var(--bg);
    position:relative;
}

a{
    color:inherit;
}

/* ambient layers */
.vignette{
    position:fixed;
    inset:0;
    pointer-events:none;
    background:radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(0,0,0,.55) 100%);
    z-index:2;
}

.scanlines{
    position:fixed;
    inset:0;
    pointer-events:none;
    background:repeating-linear-gradient(
        to bottom,
        rgba(255,255,255,.02) 0px,
        rgba(255,255,255,.02) 1px,
        transparent 1px,
        transparent 3px
    );
    z-index:2;
    opacity:.5;
}

.glow{
    position:fixed;
    width:640px;
    height:640px;
    top:0;
    left:50%;
    transform:translate(-50%,-30%);
    background:radial-gradient(circle, rgba(255,180,84,.09), transparent 65%);
    filter:blur(10px);
    pointer-events:none;
    z-index:0;
}

.noise-dot{
    position:fixed;
    inset:0;
    pointer-events:none;
    background-image:radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
    background-size:3px 3px;
    z-index:2;
    opacity:.4;
}

/* terminal window */
.wrap{
    position:relative;
    z-index:1;
    width:min(760px,100%);
    margin:auto;
}

.term{
    border-radius:12px;
    background:var(--panel);
    border:1px solid var(--border);
    box-shadow:
        0 30px 80px rgba(0,0,0,.55),
        0 0 0 1px rgba(0,0,0,.3),
        0 0 90px rgba(255,180,84,.05);
    overflow:hidden;
    animation:rise .5s cubic-bezier(.16,1,.3,1) both;
}

@keyframes rise{
    from{opacity:0; transform:translateY(12px) scale(.99);}
    to{opacity:1; transform:translateY(0) scale(1);}
}

.term-bar{
    display:flex;
    align-items:center;
    gap:16px;
    padding:12px 16px;
    background:var(--panel-2);
    border-bottom:1px solid var(--border);
}

.dots{
    display:flex;
    gap:8px;
    flex-shrink:0;
}

.dot{
    width:11px;
    height:11px;
    border-radius:50%;
}

.dot.r{background:var(--red);}
.dot.y{background:var(--yellow);}
.dot.g{background:var(--green);}

.term-title{
    flex:1;
    text-align:center;
    font-size:.78rem;
    color:var(--muted);
    letter-spacing:.02em;
    padding-right:43px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.term-body{
    padding:30px 30px 26px;
    font-size:.92rem;
    line-height:1.7;
}

.ln{
    white-space:pre-wrap;
    word-break:break-word;
    margin-bottom:4px;
}

.ln a.breadcrumb{
    text-decoration:none;
}

.ln a.breadcrumb:hover .cmd{
    color:var(--amber);
}

.prompt{color:var(--amber);}
.path{color:var(--blue);}
.cmd{color:var(--text);}

/* home: directory listing */
.listing{
    display:flex;
    flex-direction:column;
    border:1px solid var(--border);
    border-radius:8px;
    overflow:hidden;
    margin:16px 0 8px;
}

.entry{
    text-decoration:none;
    color:var(--text);
    display:flex;
    align-items:baseline;
    gap:14px;
    padding:13px 16px;
    border-bottom:1px solid var(--border);
    transition:background .15s ease, padding-left .15s ease;
    font-size:.86rem;
}

.entry:last-child{border-bottom:none;}

.entry:hover{
    background:rgba(255,180,84,.06);
    padding-left:20px;
}

.entry:hover .entry-title{color:var(--amber);}

.entry-date{
    color:var(--dim);
    flex-shrink:0;
    width:96px;
}

.entry-title{
    color:var(--text);
    flex:1;
    min-width:0;
    unicode-bidi:plaintext; /* auto-detects RTL for Persian titles, no flag needed */
}

.entry-tags,.entry-meta{
    color:var(--amber-dim);
    flex-shrink:0;
    font-size:.8rem;
    display:none;
}

@media (min-width:560px){
    .entry-tags,.entry-meta{display:block;}
}

/* tags archive page */
.tag-group{margin-bottom:26px;}

.tag-heading{
    font-size:1rem;
    font-weight:700;
    color:var(--amber);
    margin:0 0 10px;
    scroll-margin-top:20px;
}

.tag-count{
    color:var(--dim);
    font-weight:400;
    font-size:.82rem;
}

.empty{
    color:var(--muted);
    padding:18px 4px 6px;
}

/* post article typography */
.post-meta{
    color:var(--muted);
    font-size:.82rem;
    margin:2px 0 22px;
}

.post-meta .tag{
    color:var(--amber-dim);
    text-decoration:none;
}

.post-meta .tag:hover{
    color:var(--amber);
    text-decoration:underline;
}

article.post h1.post-title{
    font-size:1.7rem;
    font-weight:800;
    letter-spacing:-.5px;
    margin:6px 0 4px;
    line-height:1.25;
    unicode-bidi:plaintext;
}

/* prev/next post navigation */
.post-nav{
    display:flex;
    gap:16px;
    margin-top:36px;
    border-top:1px solid var(--border);
    padding-top:20px;
}

.post-nav-link{
    flex:1;
    min-width:0;
    text-decoration:none;
    padding:14px 16px;
    border:1px solid var(--border);
    border-radius:8px;
    transition:background .15s ease, border-color .15s ease;
}

.post-nav-link:hover{
    background:rgba(255,180,84,.06);
    border-color:rgba(255,180,84,.3);
}

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

.post-nav-label{
    display:block;
    color:var(--amber-dim);
    font-size:.75rem;
    margin-bottom:4px;
}

.post-nav-title{
    display:block;
    color:var(--text);
    font-size:.85rem;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    unicode-bidi:plaintext;
}

/* ---------------------------------------------------------- */
/* RTL support (Persian posts): set `rtl: true` in front matter */
/* ---------------------------------------------------------- */

article.post[dir="rtl"]{
    font-family:'Vazirmatn', 'JetBrains Mono', sans-serif;
}

.prose.rtl{
    font-family:'Vazirmatn', sans-serif;
    line-height:2;
}

/* code always stays LTR and monospace, even inside RTL articles */
.prose.rtl pre,
.prose.rtl code{
    direction:ltr;
    unicode-bidi:isolate;
    text-align:left;
    font-family:'JetBrains Mono', monospace;
}

/* mirror list indent and blockquote rule to the correct side */
.prose.rtl ul,
.prose.rtl ol{
    margin:0 1.3em 20px 0;
}

.prose.rtl blockquote{
    border-left:none;
    border-right:2px solid var(--amber-dim);
    padding:2px 16px 2px 0;
}

/* the "## " prefix is a nod to markdown syntax in Latin script —
   skipped for Persian headings so it doesn't sit awkwardly against RTL text */
.prose.rtl h2::before,
.prose.rtl h3::before{
    content:"";
}

.prose{
    font-size:.95rem;
    line-height:1.85;
    color:var(--text);
}

.prose p{margin:0 0 20px;}

.prose h1,.prose h2,.prose h3{
    color:var(--text);
    font-weight:700;
    margin:34px 0 14px;
    letter-spacing:-.3px;
}

.prose h2{font-size:1.25rem;}
.prose h3{font-size:1.05rem;}

.prose h2::before{
    content:"## ";
    color:var(--amber-dim);
}

.prose h3::before{
    content:"### ";
    color:var(--amber-dim);
}

.prose ul,.prose ol{
    margin:0 0 20px 1.3em;
    color:var(--text);
}

.prose li{margin-bottom:6px;}

.prose a{
    color:var(--blue);
    text-decoration:underline;
    text-decoration-color:rgba(143,211,255,.35);
    text-underline-offset:3px;
}

.prose a:hover{
    color:var(--amber);
    text-decoration-color:var(--amber);
}

.prose blockquote{
    border-left:2px solid var(--amber-dim);
    padding:2px 0 2px 16px;
    margin:0 0 20px;
    color:var(--muted);
}

.prose code{
    font-family:'JetBrains Mono', monospace;
    background:rgba(255,255,255,.06);
    padding:2px 6px;
    border-radius:4px;
    font-size:.85em;
    color:var(--amber);
}

.prose pre{
    background:var(--panel-2);
    border:1px solid var(--border);
    border-radius:8px;
    padding:16px 18px;
    overflow-x:auto;
    margin:0 0 22px;
}

.prose pre code{
    background:none;
    padding:0;
    color:var(--text);
    font-size:.83rem;
    line-height:1.6;
}

.prose img{
    max-width:100%;
    border-radius:8px;
    border:1px solid var(--border);
    margin:8px 0 20px;
}

.prose hr{
    border:none;
    border-top:1px dashed var(--border);
    margin:30px 0;
}

/* cursor / EOF line */
.cursor-line{
    display:flex;
    align-items:center;
    gap:8px;
    color:var(--muted);
    margin-top:26px;
}

.cursor{
    display:inline-block;
    width:8px;
    height:16px;
    background:var(--amber);
    animation:blink 1s steps(1) infinite;
}

@keyframes blink{
    0%,49%{opacity:1;}
    50%,100%{opacity:0;}
}

.footer{
    margin-top:22px;
    text-align:center;
    color:var(--dim);
    font-size:.76rem;
    letter-spacing:.02em;
    position:relative;
    z-index:1;
}

.footer a{
    color:var(--dim);
    text-decoration:underline;
    text-decoration-color:var(--border);
}

.footer a:hover{color:var(--amber);}

@media (max-width:600px){
    .term-body{padding:22px 18px 20px;}
    article.post h1.post-title{font-size:1.4rem;}
    .entry-date{width:78px; font-size:.78rem;}
}

@media (prefers-reduced-motion:reduce){
    *, *::before, *::after{
        animation-duration:.001ms !important;
        animation-iteration-count:1 !important;
        transition-duration:.001ms !important;
    }
}
