/* ═══════════════════════════════════════════════════════
   PSVCodes — style.css
   ═══════════════════════════════════════════════════════ */

:root {
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --bg:         #0d0f0e;
  --bg-panel:   #111412;
  --bg-panel-2: #161916;
  --border:     #2a3028;
  --border-hi:  #3d4f3a;
  --green:        #a8cc6e;  --green-bright:  #c8e88a;
  --cyan:         #5ebdab;  --cyan-bright:   #7fd4c1;
  --blue:         #5f8faf;  --blue-bright:   #7ab3d4;
  --yellow:       #d9c062;  --yellow-bright: #f0d870;
  --red:          #e05c79;
  --magenta:      #c68aee;
  --white:        #c5c8c6;  --white-dim:     #8a9080;
  --white-faint:  #4a5048;
  --text:         #b8c0b0;  --text-muted:    #6e7868;
  --text-faint:   #3a4038;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: clamp(12px, 1.1vw, 14px);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* CRT scanline overlay */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.06) 2px, rgba(0,0,0,0.06) 4px);
}

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

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

/* ─── Topbar ──────────────────────────────────────────── */

#topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 0 8px;
  height: 28px;
  flex-shrink: 0;
}
.topbar-logo {
  color: var(--green-bright); font-weight: 700; font-size: 13px;
  letter-spacing: 0.05em; padding: 0 10px; white-space: nowrap;
}
.topbar-nav { display: flex; align-items: center; overflow: hidden; }
.topbar-nav button {
  display: inline-flex; align-items: center; padding: 0 10px; height: 28px;
  font-family: var(--font-mono); font-size: 12px; color: var(--white-dim);
  background: none; border: none; border-right: 1px solid var(--border);
  cursor: pointer; transition: color 0.12s, background 0.12s; white-space: nowrap;
}
.topbar-nav button:first-child { border-left: 1px solid var(--border); }
.topbar-nav button:hover  { background: var(--bg-panel-2); color: var(--green); }
.topbar-nav button.active { background: var(--bg-panel-2); color: var(--green-bright); }
.tab-key   { color: var(--yellow); margin-right: 5px; font-size: 10px; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: 11px; }
#clock { color: var(--cyan); font-size: 12px; }

/* ─── Mobile tab bar (hidden on desktop) ─────────────── */

#mobile-tabs { display: none; }

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

#main { overflow: hidden; }
.view { display: none; height: 100%; overflow: hidden; flex-direction: column; }
.view.active { display: flex; }
#view-terminal { flex-direction: column; overflow: hidden; }

/* ─── Terminal ────────────────────────────────────────── */

#terminal-output {
  flex: 1; overflow-y: auto; padding: 12px 16px 8px;
  scrollbar-width: thin; scrollbar-color: var(--border-hi) transparent;
}
.term-line { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.term-error   { color: var(--red); }
.term-success { color: var(--green); }
.term-info    { color: var(--cyan); }
.term-warn    { color: var(--yellow); }
.term-dim     { color: var(--text-muted); }
.term-cmd     { color: var(--white); font-weight: 600; }

#input-line {
  display: flex; align-items: center; padding: 6px 16px;
  border-top: 1px solid var(--border); background: var(--bg-panel); flex-shrink: 0;
}
.prompt-prefix {
  display: flex; align-items: center; flex-shrink: 0; white-space: nowrap; user-select: none;
}
.prompt-user   { color: var(--green-bright); font-weight: 700; }
.prompt-at     { color: var(--white-dim); }
.prompt-host   { color: var(--cyan); font-weight: 600; }
.prompt-path   { color: var(--blue-bright); }
.prompt-dollar { color: var(--yellow); margin: 0 8px 0 4px; }
#cmd-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-mono); font-size: inherit; color: var(--white);
  caret-color: var(--green-bright); min-width: 0;
}

/* ─── Section header ─────────────────────────────────── */

.sec-header {
  font-size: 13px; font-weight: 700; letter-spacing: 0.1em;
  margin-bottom: 10px; color: var(--cyan);
  border-left: 3px solid var(--cyan); padding-left: 8px; flex-shrink: 0;
}
.sec-header.green  { color: var(--green);  border-color: var(--green); }
.sec-header.yellow { color: var(--yellow); border-color: var(--yellow); }

/* ─── Filter bar ─────────────────────────────────────── */

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px; flex-shrink: 0;
}
.filter-group { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-bar + .filter-bar { margin-top: 0; }

.filter-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 10px; padding: 2px 8px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.06em;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.filter-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.filter-btn.active {
  border-color: var(--green); color: var(--green-bright);
  background: rgba(168,204,110,0.08);
}

/* ─── Pagination ─────────────────────────────────────── */

.pagination {
  display: flex; gap: 4px; justify-content: center;
  padding: 12px 0 4px; flex-shrink: 0;
}
.page-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px; padding: 3px 10px; cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.page-btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.page-btn.active { border-color: var(--green); color: var(--green-bright); cursor: default; }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ─── Views (news / apps / contact) ──────────────────── */

#view-news, #view-apps, #view-contact {
  overflow-y: auto; padding: 12px;
  gap: 0;
  scrollbar-width: thin; scrollbar-color: var(--border-hi) transparent;
}

/* ─── News grid ───────────────────────────────────────── */

.news-grid { display: grid; gap: 8px; }
.news-card {
  border: 1px solid var(--border); background: var(--bg-panel);
  padding: 12px 14px; cursor: pointer; position: relative;
  transition: border-color 0.12s, background 0.12s;
  display: flex; align-items: center; gap: 12px;
}
.news-card:hover { border-color: var(--cyan); background: var(--bg-panel-2); }
.nc-thumb {
  width: 72px; height: 72px; flex-shrink: 0;
  border: 1px solid var(--border); overflow: hidden; background: var(--bg);
}
.nc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nc-content { flex: 1; min-width: 0; }
.nc-meta { display: flex; gap: 12px; margin-bottom: 6px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.nc-date   { color: var(--yellow); }
.nc-tag    { color: #000; background: var(--cyan); padding: 0 5px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.nc-title  { font-size: 13px; color: var(--white); font-weight: 600; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-excerpt { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.nc-arrow  { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--border-hi); flex-shrink: 0; }
.news-card:hover .nc-arrow  { color: var(--cyan); }
.news-card:hover .nc-title  { color: var(--cyan-bright); }

/* ─── Tag colors ─────────────────────────────────────── */

.nc-tag.tag-release  { background: var(--cyan);    color: #000; }
.nc-tag.tag-article  { background: var(--blue);    color: var(--white); }
.nc-tag.tag-tutorial { background: var(--magenta); color: var(--bg); }
.nc-tag.tag-note     { background: var(--yellow);  color: #000; }
.nc-tag.tag-update   { background: var(--green);   color: #000; }
.nc-tag.tag-news     { background: var(--cyan);    color: #000; }

/* ─── Article ─────────────────────────────────────────── */

#news-article { display: none; flex-direction: column; overflow: hidden; }
#news-article.active { display: flex; }
#news-list-wrapper.hidden { display: none; }

.article-back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--cyan);
  font-size: 12px; cursor: pointer; margin-bottom: 10px;
  background: none; border: none; font-family: var(--font-mono); flex-shrink: 0;
}
.article-back:hover { color: var(--cyan-bright); }
.article-date  { color: var(--yellow); font-size: 11px; margin-bottom: 6px; flex-shrink: 0; }
.article-title { color: var(--green-bright); font-size: 16px; font-weight: 700; margin-bottom: 10px; flex-shrink: 0; }
.article-body  { color: var(--text); font-size: 12.5px; line-height: 1.7; overflow-y: auto; flex: 1; }

/* Markdown rendered body */
.article-body p,
.md-body p   { margin-bottom: 10px; max-width: 80ch; }
.article-body h1, .md-body h1 { font-size: 16px; color: var(--green-bright); margin: 16px 0 8px; }
.article-body h2, .md-body h2 { font-size: 14px; color: var(--cyan-bright);  margin: 14px 0 6px; border-left: 2px solid var(--cyan); padding-left: 6px; }
.article-body h3, .md-body h3 { font-size: 13px; color: var(--yellow);       margin: 12px 0 5px; }
.article-body ul, .md-body ul,
.article-body ol, .md-body ol { padding-left: 20px; margin-bottom: 10px; }
.article-body li, .md-body li { margin-bottom: 3px; }
.article-body blockquote, .md-body blockquote {
  border-left: 3px solid var(--border-hi); padding-left: 10px;
  color: var(--text-muted); margin: 10px 0; font-style: italic;
}
.md-body blockquote p {
  margin: 0;
}
.article-body a, .md-body a { color: var(--cyan); text-decoration: underline; }
.article-body a:hover, .md-body a:hover { color: var(--cyan-bright); }
.article-body hr, .md-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.article-body table, .md-body table { border-collapse: collapse; margin-bottom: 10px; width: 100%; }
.article-body th, .md-body th { background: var(--bg-panel); color: var(--cyan); padding: 5px 10px; border: 1px solid var(--border); font-size: 11px; text-transform: uppercase; }
.article-body td, .md-body td { padding: 5px 10px; border: 1px solid var(--border); font-size: 12px; }
.article-body code, .md-body code {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  padding: 0 4px; color: var(--cyan); font-size: 11px;
}
.article-body pre, .md-body pre {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  padding: 10px 12px; overflow-x: auto; margin: 10px 0; font-size: 11.5px;
  color: var(--green);
}
.article-body pre code, .md-body pre code {
  background: none; border: none; padding: 0; color: inherit; font-size: inherit;
}

/* ─── Media gallery ───────────────────────────────────── */

.media-gallery {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.media-gallery-item {
  border: 1px solid var(--border); overflow: hidden;
  background: var(--bg); transition: border-color 0.12s;
}
.media-gallery-item:hover { border-color: var(--cyan); }
.media-gallery-item img {
  display: block; max-height: 220px; max-width: 100%;
  object-fit: contain; cursor: zoom-in;
}
.media-gallery-item.media-video video {
  display: block; max-height: 280px; max-width: 100%;
}

/* ─── Lightbox ────────────────────────────────────────── */

#lightbox-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox-overlay img {
  max-width: 92vw; max-height: 92vh;
  object-fit: contain; border: 1px solid var(--border-hi);
}

/* ─── Archive list ────────────────────────────────────── */

.archive-list {
  margin-bottom: 14px; border: 1px solid var(--border);
  background: var(--bg-panel);
}
.archive-list-label {
  padding: 5px 12px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: var(--bg-panel-2);
}
.archive-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border); transition: background 0.12s;
}
.archive-row:last-child { border-bottom: none; }
.archive-row:hover { background: var(--bg-panel-2); }
.archive-icon { font-size: 16px; flex-shrink: 0; }
.archive-name { flex: 1; font-size: 12px; color: var(--white); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-dl   { font-size: 11px; color: var(--cyan); flex-shrink: 0; transition: color 0.12s; }
.archive-row:hover .archive-dl { color: var(--cyan-bright); }

/* Archive download link on app card */
.app-link-archive {
  border-color: var(--magenta) !important; color: var(--magenta) !important;
}
.app-link-archive:hover { background: var(--magenta) !important; color: var(--bg) !important; }

/* ─── Apps grid ───────────────────────────────────────── */

.apps-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px;
}
.app-card {
  border: 1px solid var(--border); background: var(--bg-panel);
  padding: 14px; cursor: pointer; display: flex; flex-direction: column;
  gap: 7px; transition: border-color 0.12s, background 0.12s;
}
.app-card:hover { border-color: var(--magenta); background: var(--bg-panel-2); }
.app-icon      { font-size: 22px; }
.app-name      { color: var(--white); font-weight: 700; font-size: 13px; }
.app-card:hover .app-name { color: var(--magenta); }
.app-desc      { color: var(--text-muted); font-size: 11.5px; line-height: 1.5; }
.app-tags      { display: flex; flex-wrap: wrap; gap: 4px; }
.app-tag       { font-size: 10px; padding: 1px 6px; border: 1px solid var(--border-hi); color: var(--white-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.app-tag.php    { border-color: var(--blue);    color: var(--blue-bright); }
.app-tag.js     { border-color: var(--yellow);  color: var(--yellow-bright); }
.app-tag.ts     { border-color: var(--blue);    color: var(--blue-bright); }
.app-tag.cli    { border-color: var(--magenta); color: var(--magenta); }
.app-tag.go     { border-color: var(--cyan);    color: var(--cyan-bright); }
.app-tag.python { border-color: var(--green);   color: var(--green-bright); }
.app-tag.rust   { border-color: var(--red);     color: var(--red); }
.app-tag.swift  { border-color: var(--red);     color: var(--red); }
.app-tag.web    { border-color: var(--cyan);    color: var(--cyan-bright); }
.app-tag.api    { border-color: var(--green);   color: var(--green-bright); }
.app-links  { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.app-link {
  font-size: 11px; color: var(--cyan); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); padding: 2px 8px;
  transition: border-color 0.12s, color 0.12s;
}
.app-link:hover { border-color: var(--cyan); color: var(--cyan-bright); }
.app-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.app-version   { font-size: 10px; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 4px; }
.app-hint      { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-top: auto; padding-top: 4px; transition: color 0.12s; }
.app-card:hover .app-hint { color: var(--magenta); }
.app-status    { font-size: 10px; padding: 1px 6px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; flex-shrink: 0; }
.status-active   { border: 1px solid var(--green);       color: var(--green); }
.status-wip      { border: 1px solid var(--yellow);      color: var(--yellow); }
.status-archived { border: 1px solid var(--white-faint); color: var(--white-faint); }

/* ─── App detail ──────────────────────────────────────── */

#app-detail { display: none; flex-direction: column; overflow: hidden; padding: 12px; }
#app-detail.active { display: flex; }
#apps-list-wrapper.hidden { display: none; }
.app-icon-lg { font-size: 28px; margin-right: 8px; vertical-align: middle; }

/* ─── Contacts ────────────────────────────────────────── */

.contact-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px; max-width: 700px;
}
.contact-item {
  border: 1px solid var(--border); background: var(--bg-panel);
  padding: 14px; display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text); cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.contact-item:hover { border-color: var(--yellow); background: var(--bg-panel-2); }
.contact-icon { font-size: 20px; flex-shrink: 0; }
.contact-type { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 3px; }
.contact-val  { font-size: 13px; color: var(--yellow-bright); font-weight: 600; }
.contact-item:hover .contact-val { color: var(--white); }

/* ─── Status bar ──────────────────────────────────────── */

#statusbar {
  display: flex; align-items: center; height: 22px;
  background: var(--bg-panel); border-top: 1px solid var(--border);
  font-size: 11px; flex-shrink: 0; overflow: hidden;
}
.sb-seg { display: flex; align-items: center; padding: 0 10px; height: 100%; border-right: 1px solid var(--border); gap: 5px; white-space: nowrap; }
.sb-seg .label { color: var(--text-muted); }
.sb-green .val { color: var(--green); }
.sb-cyan  .val { color: var(--cyan); }
.sb-yellow .val { color: var(--yellow); }
.sb-blue  .val { color: var(--blue-bright); }
.sb-right {
  margin-left: auto; display: flex; align-items: center; height: 100%;
  border-left: 1px solid var(--border); padding: 0 10px;
  color: var(--text-muted); font-size: 10px; gap: 8px;
}
.sb-right kbd { border: 1px solid var(--border-hi); padding: 0 4px; font-family: var(--font-mono); font-size: 10px; color: var(--yellow); }
.rss-link { color: var(--text-muted); text-decoration: none; border: 1px solid var(--border); padding: 0 4px; font-size: 9px; letter-spacing: 0.06em; }
.rss-link:hover { color: var(--yellow); border-color: var(--yellow); }

/* ─── Matrix overlay ──────────────────────────────────── */

#matrix-overlay { display: none; position: fixed; inset: 0; background: #000; z-index: 10000; cursor: pointer; }
#matrix-overlay.active { display: block; }
#matrix-canvas { display: block; width: 100%; height: 100%; }
#matrix-hint { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: #00ff41; font-family: var(--font-mono); font-size: 12px; opacity: 0.7; }

/* ─── Misc ────────────────────────────────────────────── */

.hidden { display: none !important; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ═══════════════════════════════════════════════════════
   MOBILE  (≤ 640px)
   ═══════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  html, body { font-size: 13px; overflow: hidden; }

  /* Hide desktop topbar nav, show mobile tabs at bottom */
  .topbar-nav { display: none; }
  .topbar-logo { font-size: 12px; padding: 0 6px; }
  .topbar-right { display: none; }
  #topbar { grid-template-columns: 1fr; justify-items: start; padding: 0 6px; }

  /* Mobile tab bar at bottom */
  #mobile-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-panel); border-top: 1px solid var(--border);
    z-index: 500; height: 48px;
  }
  #mobile-tabs button {
    flex: 1; background: none; border: none; border-right: 1px solid var(--border);
    color: var(--white-dim); font-family: var(--font-mono); font-size: 10px;
    cursor: pointer; padding: 4px; text-transform: uppercase; letter-spacing: 0.04em;
    transition: color 0.12s, background 0.12s;
  }
  #mobile-tabs button:last-child { border-right: none; }
  #mobile-tabs button.active { color: var(--green-bright); background: var(--bg-panel-2); }

  /* Push content up (above mobile tab bar) */
  #app {
    grid-template-rows: 28px 1fr 22px;
    height: calc(100vh - 48px);
  }
  #statusbar { display: none; }

  /* Statusbar collapsed on mobile */

  /* Topbar clock stays */
  #topbar { grid-template-columns: 1fr auto; }
  .topbar-right { display: flex; }
  #clock { font-size: 11px; }

  /* Input line smaller */
  #input-line { padding: 5px 10px; }
  .prompt-prefix { font-size: 11px; }
  .prompt-path { display: none; }

  /* News / apps scroll properly */
  #view-news, #view-apps, #view-contact {
    padding: 8px; overflow-y: auto;
  }

  .news-card { padding: 10px; gap: 8px; }
  .nc-thumb  { width: 56px; height: 56px; }
  .nc-title  { font-size: 12px; white-space: normal; }
  .nc-arrow  { display: none; }

  .apps-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .app-card  { padding: 10px; gap: 5px; }
  .app-icon  { font-size: 18px; }
  .app-name  { font-size: 12px; }

  /* Article / app detail full screen */
  #news-article, #app-detail { padding: 8px; }
  .article-title { font-size: 14px; }
  .article-body  { font-size: 12px; }

  /* Filter bar wrap nicely */
  .filter-bar { gap: 4px; }
  .filter-btn { font-size: 9px; padding: 2px 6px; }

  /* Media gallery single column */
  .media-gallery { gap: 4px; }
  .media-gallery-item img { max-height: 160px; }

  /* Statusbar hidden, offset for mobile tabs */
  body::after {
    content: "";
    display: block;
    height: 48px;
  }
}

/* ─── TABLET (641px – 1024px) ─────────────────────────── */

@media (min-width: 641px) and (max-width: 1024px) {
  .apps-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .tab-label { display: none; }
  .tab-key   { margin-right: 0; }
  .topbar-nav button { padding: 0 8px; }
}
