@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600&display=swap');

/* ─── THEMES ─────────────────────────────────────────────────── */
:root, .theme-light {
  --bg:       #EFF3F3;
  --primary:  #027474;   /* teal — commands, items */
  --secondary:#d97706;   /* amber — user@host, role */
  --bright:   #0f172a;   /* near-black — name, headings */
  --text:     #334155;   /* body text */
  --muted:    #94a3b8;   /* dim — descriptions */
  --error:    #dc2626;
  --scroll:   #C1C1C1;
}
.theme-dark {
  --bg:       #1a1f2e;
  --primary:  #4ade80;   /* green */
  --secondary:#fbbf24;   /* amber */
  --bright:   #f1f5f9;   /* near-white */
  --text:     #cbd5e1;
  --muted:    #64748b;
  --error:    #f87171;
  --scroll:   #2d3748;
}
.theme-blue-matrix {
  --bg:       #0a0e1a;
  --primary:  #00e5ff;
  --secondary:#00ff9c;
  --bright:   #ffffff;
  --text:     #e2f0ff;
  --muted:    #4a7fa5;
  --error:    #ff5555;
  --scroll:   #1a2a3a;
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre { margin: 0; }
h1,h2,h3,h4,h5,h6 { font-size: inherit; font-weight: inherit; }
img,svg,video,canvas,audio,iframe,embed,object { display: block; }
ul,ol { margin: 0; padding: 0; list-style: none; }

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

body {
  font-family: 'Fira Code', 'JetBrains Mono', 'Fira Mono', monospace;
  font-weight: 500;
  font-size: 1rem;
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.25s, color 0.25s;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scroll); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── TOP-LEVEL LAYOUT ───────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── TERMINAL WRAPPER ───────────────────────────────────────── */
/* column-reverse: input first in DOM = bottom visually */
.terminal-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  height: 100vh;
  overflow: hidden;
  padding: 1.25rem;
  padding-top: 0.75rem;
}

/* ─── ASCII PANEL (right) ────────────────────────────────────── */
.ascii-panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  border-left: 1px solid var(--scroll);
  overflow: hidden;
}
.ascii-portrait-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
#ascii-name {
  margin-top: 1rem;
  font-size: 0.58rem;
  text-align: left;
}
.ascii-subname {
  color: var(--primary);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  margin-top: 0.15rem;
  text-align: center;
}
@media (max-width: 800px) {
  .ascii-panel { display: none; }
}

/* ─── INPUT FORM ─────────────────────────────────────────────── */
/* Lives at top of DOM but appears at bottom via column-reverse */
.input-form {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
}

@media (max-width: 549px) {
  .input-form { flex-wrap: wrap; }
}

.input-prompt-wrap {
  display: inline-flex;
  align-items: center;
  margin-right: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

input[type=text] {
  flex-grow: 1;
  min-width: 4ch;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  caret-color: var(--primary);
}
input[type=text]:focus-visible { outline: none; }

/* ─── OUTPUT HISTORY ─────────────────────────────────────────── */
/* content sticks to bottom like a real terminal */
.terminal-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* each command block */
.cmd-block { margin-bottom: 0.25rem; }

/* ─── PROMPT ─────────────────────────────────────────────────── */
.prompt-wrap {
  display: inline-flex;
  align-items: center;
  margin-right: 0.75rem;
  white-space: nowrap;
}
.t-user   { color: var(--secondary); }
.t-at     { color: var(--text); }
.t-host   { color: var(--primary); }
.t-sep    { color: var(--muted); }
.t-path   { color: var(--secondary); }
.t-dollar { color: var(--text); }
.t-cmd    { color: var(--text); }

/* ─── OUTPUT LINES ───────────────────────────────────────────── */
.out        { line-height: 1.5rem; }
.out.primary{ color: var(--primary); }
.out.secondary{ color: var(--secondary); }
.out.muted  { color: var(--muted); }
.out.error  { color: var(--error); }
.out.bright { font-weight: 600; }
.out-link   { color: var(--primary); text-decoration: none; border-bottom: 1px dashed var(--primary); line-height: 1.5rem; }
.out-link:hover { border-bottom-style: solid; }

/* ─── SEPARATOR ──────────────────────────────────────────────── */
.sep { margin-top: 0.3rem; margin-bottom: 0.3rem; }

/* ─── HERO / ABOUT LAYOUT ────────────────────────────────────── */
/* mirrors HeroContainer from terminal-portfolio */
.hero {
  display: flex;
  flex-wrap: wrap-reverse;
}
.hero-text {
  flex: 1;
  min-width: 280px;
  padding-right: 2rem;
}
.hero-img {
  flex-shrink: 0;
  width: 220px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

@media (max-width: 932px) {
  .hero { margin-bottom: 1.5rem; }
}
@media (max-width: 549px) {
  .hero-img { width: 100%; margin-bottom: 1rem; }
  .hero-text { padding-right: 0; }
}

/* name ASCII art */
.name-art {
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--primary);
  margin-bottom: 1rem;
  white-space: pre;
}
@media (max-width: 549px) { .name-art { display: none; } }

/* ASCII portrait */
.ascii-portrait {
  font-size: 5.5px;
  line-height: 1.15;
  color: var(--primary);
  white-space: pre;
  font-family: 'IBM Plex Mono', monospace;
  opacity: 0.85;
}

/* ─── ABOUT BLOCK ────────────────────────────────────────────── */
.about-block { max-width: 72ch; }
.about-para  { margin-top: 0.5rem; line-height: 1.7; white-space: normal; word-break: break-word; }

/* ─── HELP TABLE ─────────────────────────────────────────────── */
.help-row { display: flex; line-height: 1.5rem; gap: 0.5rem; }
.h-cmd    { color: var(--primary); min-width: 22ch; flex-shrink: 0; }
.h-sep    { color: var(--muted); flex-shrink: 0; }
.h-desc   { color: var(--muted); }

/* ─── BLOG LIST ──────────────────────────────────────────────── */
.blog-row  { display: flex; align-items: baseline; line-height: 1.8rem; gap: 0.75rem; }
.b-n       { color: var(--muted); min-width: 2ch; }
.b-title   { color: var(--primary); cursor: pointer; border-bottom: 1px dashed var(--primary); }
.b-title:hover { border-bottom-style: solid; }
.b-date    { color: var(--muted); font-size: 0.85rem; }

/* ─── POST OVERLAY ───────────────────────────────────────────── */
.post-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.post-overlay.hidden { display: none; }

.overlay-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--scroll);
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}
.overlay-topbar .o-title { color: var(--text); font-weight: 600; margin-right: 0.5rem; }
.overlay-close {
  background: none;
  border: 1px solid var(--scroll);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 2px 10px;
  cursor: pointer;
}
.overlay-close:hover { border-color: var(--primary); }

.reading-bar {
  height: 2px;
  background: var(--primary);
  width: 0%;
  transition: width 0.1s;
  flex-shrink: 0;
}

.post-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 3rem;
}

/* ─── POST CONTENT ───────────────────────────────────────────── */
.post-content { max-width: 760px; margin: 0 auto; line-height: 1.8; }
.post-content h1 { font-size: 1.5rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.post-content h2 { font-size: 1.1rem; font-weight: 600; color: var(--primary); margin-top: 1.5rem; margin-bottom: 0.4rem; }
.post-content h3 { font-size: 1rem; font-weight: 600; color: var(--secondary); margin-top: 1rem; margin-bottom: 0.3rem; }
.post-content p  { margin-top: 0.6rem; }
.post-content a  { color: var(--primary); }
.post-content code { font-family: inherit; font-size: 0.9em; color: var(--primary); background: rgba(0,0,0,0.07); padding: 1px 5px; border-radius: 3px; }
.theme-dark .post-content code { background: rgba(255,255,255,0.08); }
.post-content pre { background: rgba(0,0,0,0.07); border-left: 3px solid var(--primary); padding: 1rem; overflow-x: auto; margin: 0.8rem 0; border-radius: 0 4px 4px 0; }
.theme-dark .post-content pre { background: rgba(0,0,0,0.3); }
.post-content pre code { background: none; padding: 0; }
.post-content blockquote { border-left: 3px solid var(--secondary); padding: 0.25rem 1rem; color: var(--muted); margin: 0.8rem 0; }
.post-content ul,
.post-content ol { padding-left: 1.5rem; margin-top: 0.4rem; list-style: disc; }
.post-content ol { list-style: decimal; }
.post-content li { margin: 0.2rem 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 0.8rem 0; font-size: 0.9rem; }
.post-content th { background: rgba(0,0,0,0.08); color: var(--primary); padding: 0.4rem 0.75rem; text-align: left; border: 1px solid var(--scroll); }
.post-content td { padding: 0.4rem 0.75rem; border: 1px solid var(--scroll); }
.post-content strong { font-weight: 600; }
.post-meta { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--scroll); padding-bottom: 0.75rem; }

/* ─── NON-TERMINAL PAGES (blog.html, bookshelf.html, post pages) ── */
.page-body {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-y: auto;
}
.page-inner { max-width: 820px; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }
.page-nav { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 2.5rem; font-size: 0.875rem; }
.page-nav .brand { color: var(--secondary); margin-right: 0.75rem; font-weight: 600; }
.page-nav a { color: var(--muted); padding: 2px 8px; }
.page-nav a:hover { color: var(--primary); text-decoration: none; }
.page-nav .active { color: var(--primary); }

.post-list-item { padding: 1.25rem 0; border-bottom: 1px solid var(--scroll); }
.post-list-item .date { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.25rem; }
.post-list-item .title a { font-size: 1rem; font-weight: 600; color: var(--primary); }
.post-list-item .title a:hover { text-decoration: underline; }
.post-list-item .excerpt { font-size: 0.875rem; color: var(--muted); margin-top: 0.25rem; line-height: 1.5; }

.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.bk-card { padding: 1rem; border: 1px solid var(--scroll); border-radius: 4px; }
.bk-card:hover { border-color: var(--primary); }
.bk-card .bk-title { color: var(--primary); font-weight: 600; display: block; margin-bottom: 0.15rem; font-size: 0.9rem; }
.bk-card .bk-author { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.35rem; }
.bk-card .bk-stars { color: var(--secondary); font-size: 0.85rem; margin-bottom: 0.35rem; }
.bk-card .bk-review { color: var(--text); font-size: 0.8rem; line-height: 1.5; }
@media (max-width: 600px) { .bk-grid { grid-template-columns: 1fr; } }

.page-footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--scroll); display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; gap: 0.5rem; }
.page-footer a { color: var(--muted); margin-right: 0.75rem; }
.page-footer a:hover { color: var(--primary); }
.term-btn { color: var(--primary); border: 1px solid var(--scroll); padding: 3px 10px; font-family: inherit; font-size: 0.8rem; background: none; cursor: pointer; }
.term-btn:hover { border-color: var(--primary); }

/* ─── READING PROGRESS (post pages) ─────────────────────────── */
.reading-progress { position: fixed; top: 0; left: 0; height: 2px; background: var(--primary); z-index: 999; transition: width 0.1s; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 549px) {
  body { font-size: 0.9rem; }
  .post-scroll { padding: 1rem; }
}
