/* ── Reset ──────────────────────────────────────────────── */
* {
    border: 0 none;
    font-weight: inherit;
    font-family: inherit;
    font-style: inherit;
    font-size: 100%;
    margin: 0;
    outline: 0;
    padding: 0;
    vertical-align: baseline;
}

/* ── Themes ─────────────────────────────────────────────── */

[data-theme="gruvbox"] {
    --bg:          #282828;
    --text:        #ebdbb2;
    --heading:     #fabd2f;
    --mark:        #928374;
    --link:        #83a598;
    --hover:       #fe8019;
    --strong:      #fe8019;
    --em:          #b8bb26;
    --quote-bg:    #32302f;
    --code-bg:     #3c3836;
    --code-text:   #8ec07c;
    --inline-text: #ebdbb2;
    --border:      #504945;
    --meta:        #928374;
}

[data-theme="nord"] {
    --bg:          #2e3440;
    --text:        #d8dee9;
    --heading:     #e5e9f0;
    --mark:        #4c566a;
    --link:        #88c0d0;
    --hover:       #a3be8c;
    --strong:      #88c0d0;
    --em:          #ebcb8b;
    --quote-bg:    #3b4252;
    --code-bg:     #3b4252;
    --code-text:   #a3be8c;
    --inline-text: #88c0d0;
    --border:      #4c566a;
    --meta:        #4c566a;
}

[data-theme="minimal"] {
    --bg:          #0f0f0f;
    --text:        #d4d4d4;
    --heading:     #ffffff;
    --mark:        #444444;
    --link:        #4ec9b0;
    --hover:       #ffffff;
    --strong:      #ffffff;
    --em:          #4ec9b0;
    --quote-bg:    #1a1a1a;
    --code-bg:     #1e1e1e;
    --code-text:   #9cdcfe;
    --inline-text: #9cdcfe;
    --border:      #333333;
    --meta:        #555555;
}

[data-theme="solarized"] {
    --bg:          #002b36;
    --text:        #839496;
    --heading:     #93a1a1;
    --mark:        #586e75;
    --link:        #268bd2;
    --hover:       #2aa198;
    --strong:      #cb4b16;
    --em:          #b58900;
    --quote-bg:    #073642;
    --code-bg:     #073642;
    --code-text:   #859900;
    --inline-text: #2aa198;
    --border:      #586e75;
    --meta:        #586e75;
}

/* ── Base ───────────────────────────────────────────────── */

html {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Hack', 'Fantasque Sans Mono', monospace;
    font-style: normal;
    font-weight: normal;
}

html, body { height: 100%; width: 100%; }

/* ── Layout ─────────────────────────────────────────────── */

.container {
    display: grid;
    gap: 0.5rem;
}

@media all and (min-width: 960px) {
    .container { grid-template-columns: repeat(8, 1fr); }
    .side  { grid-column-start: 1; grid-column-end: 3; }
    .main  { grid-column-start: 3; grid-column-end: 8; }
}

@media screen and (min-width: 1100px) {
    .container { grid-template-columns: 1fr 2fr; }
    .side  { grid-column-start: 1; grid-column-end: 2; }
    .main  { grid-column-start: 2; grid-column-end: 3; }
}

@media screen and (min-width: 1400px) {
    .container { grid-template-columns: repeat(6, 1fr); }
    .side  { grid-column-start: 2; grid-column-end: 3; }
    .main  { grid-column-start: 3; grid-column-end: 6; }
}

@media all and (max-width: 960px) {
    .container { grid-template-columns: 1fr; }
    .side { grid-row-start: 2; grid-row-end: 3; }
    .main {
        grid-row-start: 1; grid-row-end: 2;
        grid-column-start: 1; grid-column-end: 2;
        padding-left: 1rem;
    }
}

/* ── Sidebar ─────────────────────────────────────────────── */

.side { padding-left: 1rem; }

.side h1 { font-size: inherit; }

.side h1 a,
.side h1 a:visited {
    color: var(--heading);
    border-bottom: none;
    text-decoration: none;
}

.side h1 a:hover,
.side h1 a:focus {
    color: var(--link);
    border-bottom: none;
    outline: none;
}

.side .nav ul { list-style: none; margin: 0; padding: 0; }
.side .nav ul li { line-height: 1.2; margin: 0 0 1em; }

/* ── Main ────────────────────────────────────────────────── */

.main { padding-right: 1rem; }

/* ── Typography ──────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6,
p, pre, blockquote, form, ul, ol, dl { margin: 1em 0; }

li, dd, blockquote { margin-left: 2em; }

h1, h2, h3, h4, h5, h6 {
    color: var(--heading);
    font-size: 1rem;
    font-style: normal;
    font-weight: bold;
    margin-top: 2em;
    text-decoration: underline;
}

h1::before { content: "# ";  color: var(--mark); }
h2::before { content: "## "; color: var(--mark); }
h3::before { content: "### "; color: var(--mark); }
h4::before { content: "#### "; color: var(--mark); }
h5::before { content: "##### "; color: var(--mark); }
h6::before { content: "###### "; color: var(--mark); }

blockquote, p, table { margin-top: 0; max-width: 80vw; }
blockquote, p, li     { line-height: 1.5; }

@media screen and (max-width: 960px) {
    blockquote, p, table { max-width: 95vw; }
}

blockquote {
    background-color: var(--quote-bg);
    border-left: 3px solid var(--border);
    margin-left: 0;
    padding: 1rem 1rem 1rem 2rem;
    max-width: 55rem;
}

/* ── Links ───────────────────────────────────────────────── */

a, a:visited {
    border-bottom: 1px dashed;
    color: var(--link);
    font-style: normal;
    font-weight: 400;
    text-decoration: none;
}

a:hover, a:focus {
    border-bottom-style: solid;
    color: var(--hover);
    outline: 1px solid;
    outline-offset: .25em;
}

em     { color: var(--em);     font-style: italic; }
strong { color: var(--strong); font-weight: bold; }

/* ── Post single ─────────────────────────────────────────── */

.post-date {
    display: block;
    color: var(--meta);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.post-content p { max-width: 70vw; }

.post-content pre {
    max-width: 58em;
    overflow-x: auto;
    padding: 1rem;
}

.post-content p code {
    background: var(--code-bg);
    color: var(--inline-text);
    display: inline-block;
    padding: 0.125rem 0.3rem;
}

/* ── Post list ───────────────────────────────────────────── */

#post-list article          { margin-bottom: 1em; }
#post-list article p        { margin-bottom: 0; }
#post-list article p.date   { color: var(--meta); }

/* ── Code ────────────────────────────────────────────────── */

code {
    background: var(--code-bg);
    color: var(--inline-text);
    display: inline-block;
    padding: 0.125rem 0.3rem;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    max-width: 58em;
    overflow-x: auto;
    padding: 1rem;
}

pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* ── Language switcher ───────────────────────────────────── */

.lang-switch {
    margin-top: 1.5em;
    list-style: none;
}

.lang-switch li { margin: 0; }

.lang-switch a,
.lang-switch a:visited {
    color: var(--meta);
    border-bottom-color: var(--meta);
}

/* ── Theme switcher dots ─────────────────────────────────── */

.theme-switcher {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    margin-top: 1.8em;
}

.theme-switcher button {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity 0.15s, transform 0.15s;
    background: none;
}

.theme-switcher button:hover  { opacity: 0.75; transform: scale(1.25); }
.theme-switcher button.active { opacity: 1;    border-color: var(--text); }

.theme-switcher button[data-set-theme="gruvbox"]  { background-color: #fabd2f; }
.theme-switcher button[data-set-theme="nord"]      { background-color: #88c0d0; }
.theme-switcher button[data-set-theme="minimal"]   { background-color: #4ec9b0; }
.theme-switcher button[data-set-theme="solarized"] { background-color: #268bd2; }

/* ── Arabic / RTL ────────────────────────────────────────── */

[dir="rtl"] {
    font-family: 'IBM Plex Sans Arabic', 'Hack', monospace;
}

html[dir="rtl"] { font-size: 1.05rem; }

[dir="rtl"] .side { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .main { padding-right: 0; padding-left: 1rem; }

@media all and (max-width: 960px) {
    [dir="rtl"] .main { padding-left: 0; padding-right: 1rem; }
}

[dir="rtl"] h1::before { content: "# "; }
[dir="rtl"] h2::before { content: "## "; }
[dir="rtl"] h3::before { content: "### "; }
