/*
Theme Name: CSFree Dev
Theme URI: https://csfree.org
Author: Lokesh
Author URI: https://csfree.org
Description: A dark, IDE-inspired WordPress theme for developer blogs, docs, and project sites. Fixed file-tree sidebar, terminal-style hero, monospace/sans type pairing, and a built-in light/dark toggle persisted with localStorage.
Version: 1.0.0
Requires at least: 5.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: csfree-dev
Tags: dark, developer, blog, custom-menu, custom-logo, translation-ready
*/

/* =========================================================
   DESIGN TOKENS
   ========================================================= */
:root{
  --bg:            #0f1117;
  --bg-elev:       #161923;
  --bg-elev-2:     #1c2030;
  --sidebar-bg:    #12141c;
  --border:        #262b3d;
  --text:          #e6e8ef;
  --text-dim:      #8b92a8;
  --text-faint:    #565d75;
  --accent-amber:  #e8a33d;
  --accent-cyan:   #5fb3b3;
  --accent-rose:   #d9748c;
  --danger:        #e26060;
  --radius:        6px;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w: 300px;
  --topbar-h: 56px;
  --ad-rail-w: 220px;
}

[data-theme="light"]{
  --bg:            #f6f7fb;
  --bg-elev:       #ffffff;
  --bg-elev-2:     #eef0f7;
  --sidebar-bg:    #ffffff;
  --border:        #dde1ec;
  --text:          #1b1e29;
  --text-dim:      #565d75;
  --text-faint:    #8b92a8;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  transition: background .2s ease, color .2s ease;
}

h1,h2,h3,h4,h5,h6{
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}
h1{ font-size: clamp(1.8rem, 3vw, 2.6rem); }
h2{ font-size: 1.6rem; margin-top: 2.2em; }
h3{ font-size: 1.25rem; }

a{ color: var(--accent-cyan); text-decoration: none; }
a:hover{ color: var(--accent-amber); }

code, pre, kbd{ font-family: var(--font-mono); }
pre{
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  overflow-x: auto;
}
code{
  background: var(--bg-elev-2);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
  color: var(--accent-amber);
}
pre code{ background: none; padding: 0; color: var(--text); }

img{ max-width: 100%; height: auto; border-radius: var(--radius); }

::selection{ background: var(--accent-cyan); color: #0f1117; }

/* focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible{
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* =========================================================
   LAYOUT SHELL
   ========================================================= */
.csfd-shell{
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar: file-tree style nav ---- */
.csfd-sidebar{
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 0 2rem;
}
.csfd-sidebar-brand{
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1.25rem 1.25rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.csfd-sidebar-brand .dot{ width:10px; height:10px; border-radius:50%; background: var(--accent-amber); flex-shrink:0; }
.csfd-sidebar-brand span.site-title{
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.csfd-sidebar-section-label{
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  padding: 1.1rem 1.25rem .4rem;
}
.csfd-tree{ list-style:none; margin:0; padding:0; }
.csfd-tree li{ position: relative; }
.csfd-tree a{
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem 1.25rem .45rem 1.6rem;
  color: var(--text-dim);
  font-size: .92rem;
  border-left: 2px solid transparent;
}
.csfd-tree a::before{ content: "›"; font-family: var(--font-mono); color: var(--text-faint); width: 1em; }
.csfd-tree a:hover{ color: var(--text); background: var(--bg-elev); }
.csfd-tree .current-menu-item > a{
  color: var(--accent-cyan);
  border-left-color: var(--accent-cyan);
  background: var(--bg-elev);
}

.csfd-sidebar-footer{
  padding: 1rem 1.25rem 0;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.csfd-theme-toggle{
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  margin-top: 1rem;
  padding: .5rem .7rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: .82rem;
  cursor: pointer;
}
.csfd-theme-toggle:hover{ color: var(--text); border-color: var(--accent-cyan); }

/* ---- Main column ---- */
.csfd-main-wrap{ display:flex; flex-direction:column; min-height:100vh; }

/* body-grid: [ad-left] [page: topbar+content] [ad-right] */
.csfd-body-grid{
  display: grid;
  grid-template-columns: var(--ad-rail-w) minmax(0,1fr) var(--ad-rail-w);
  flex: 1;
}
.csfd-page{ display:flex; flex-direction:column; min-width:0; }
.csfd-ad-rail{
  display: none;
  padding: 1.5rem 1rem;
}
.csfd-ad-rail-inner{
  position: sticky;
  top: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: .72rem;
  text-align: center;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 1400px){
  .csfd-ad-rail{ display: block; }
}

.csfd-topbar{
  height: var(--topbar-h);
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 20;
}
.csfd-menu-btn{
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); width: 38px; height: 38px; font-family: var(--font-mono); cursor:pointer;
}

.csfd-content{ flex: 1; width: 100%; margin: auto; padding: 2.5rem clamp(1.25rem, 4vw, 3.5rem) 4rem; max-width: 880px; }
.csfd-content.wide{ max-width: 1100px; }

/* ---- Terminal hero ---- */
.csfd-hero{ margin-bottom: 2.5rem; }
.csfd-terminal{
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 60px -30px rgba(0,0,0,.6);
}
.csfd-terminal-bar{
  display:flex; align-items:center; gap:.5rem;
  padding: .6rem .9rem;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
.csfd-terminal-bar .tdot{ width:11px; height:11px; border-radius:50%; }
.csfd-terminal-bar .tdot:nth-child(1){ background:#e26060; }
.csfd-terminal-bar .tdot:nth-child(2){ background:#e8a33d; }
.csfd-terminal-bar .tdot:nth-child(3){ background:#5fb3b3; }
.csfd-terminal-bar .tpath{ margin-left: .5rem; font-family: var(--font-mono); font-size: .78rem; color: var(--text-faint); }
.csfd-terminal-body{ padding: 1.4rem 1.6rem 1.6rem; font-family: var(--font-mono); font-size: .95rem; }
.csfd-terminal-body .line{ color: var(--text-dim); margin-bottom: .35rem; }
.csfd-terminal-body .prompt{ color: var(--accent-cyan); }
.csfd-terminal-body .out{ color: var(--text); }
.csfd-terminal-body h1{ margin: .6rem 0 .3rem; font-size: clamp(1.5rem,3vw,2.1rem); }
.csfd-terminal-body .tagline{ color: var(--text-dim); font-family: var(--font-sans); max-width: 60ch; }
.csfd-cursor{ display:inline-block; width:.55em; height:1.1em; background: var(--accent-amber); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink{ 50%{ opacity:0; } }
@media (prefers-reduced-motion: reduce){ .csfd-cursor{ animation: none; } }

/* ---- Post cards ---- */
.csfd-card-grid{ display:grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); margin: 1.5rem 0; }
.csfd-card{
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  transition: border-color .15s ease, transform .15s ease;
}
.csfd-card:hover{ border-color: var(--accent-cyan); transform: translateY(-2px); }
.csfd-card .eyebrow{ font-family: var(--font-mono); font-size: .72rem; color: var(--accent-amber); text-transform: uppercase; letter-spacing:.06em; }
.csfd-card h3{ margin: .4rem 0 .4rem; font-size: 1.05rem; }
.csfd-card h3 a{ color: var(--text); }
.csfd-card p{ color: var(--text-dim); font-size: .92rem; margin: 0; }
.csfd-card .meta{ margin-top: .8rem; font-family: var(--font-mono); font-size: .76rem; color: var(--text-faint); }

/* ---- Single/page article ---- */
.csfd-article header.entry-header{ margin-bottom: 1.5rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.csfd-article .entry-meta{ font-family: var(--font-mono); font-size: .8rem; color: var(--text-faint); margin-top:.4rem; }
.csfd-article .entry-content > *{ margin-bottom: 1.15em; }
.csfd-breadcrumb{ font-family: var(--font-mono); font-size: .8rem; color: var(--text-faint); margin-bottom: 1rem; }
.csfd-breadcrumb a{ color: var(--text-faint); }
.csfd-breadcrumb a:hover{ color: var(--accent-cyan); }

/* ---- Ad slot ---- */
.csfd-ad-slot{
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin: 1.75rem 0;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: .74rem;
  text-align: center;
  background: var(--bg-elev);
}

/* ---- Pagination / footer ---- */
.csfd-pagination{ display:flex; gap:.5rem; margin-top:2rem; font-family: var(--font-mono); font-size:.85rem; }
.csfd-pagination a, .csfd-pagination span{
  padding: .4rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-dim);
}
.csfd-pagination .current{ color: var(--accent-cyan); border-color: var(--accent-cyan); }

.csfd-site-footer{
  border-top: 1px solid var(--border);
  padding: 1.5rem clamp(1.25rem, 4vw, 3.5rem);
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-faint);
  display:flex; justify-content: space-between; flex-wrap: wrap; gap:.5rem;
}

/* comments */
.csfd-comments{ margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.comment-list{ list-style:none; margin:0; padding:0; }
.comment-list article{ background: var(--bg-elev); border:1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.comment-form input, .comment-form textarea{
  width:100%; background: var(--bg-elev); border:1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: .6rem .8rem; font-family: var(--font-sans); margin-bottom: .8rem;
}
.comment-form button, button.csfd-btn, input[type="submit"]{
  background: var(--accent-cyan); color:#0f1117; border:none; border-radius: var(--radius);
  padding: .6rem 1.1rem; font-family: var(--font-mono); font-weight:600; cursor:pointer;
}
.comment-form button:hover, button.csfd-btn:hover, input[type="submit"]:hover{ background: var(--accent-amber); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 920px){
  .csfd-shell{ grid-template-columns: 1fr; }
  .csfd-sidebar{
    position: fixed; left: 0; top: 0; z-index: 40;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,.4);
  }
  .csfd-sidebar.is-open{ transform: translateX(0); }
  .csfd-topbar{ display:flex; }
  .csfd-content{ padding: 1.75rem 1.1rem 3rem; }
}
