/* ================================================================
   ctos.css — D3F4ULT Portfolio
   Palette: direct port from Theme.qml
     gray50  #ffffff  → textPrimary
     gray200 #D9D9D9  → ctosGray (corner frame accents)
     gray300 #c3c3c3  → textPrimaryDimmer
     gray500 #7a7a7a  → textSecondary / secondary
     gray800 #0e0e0e  → background
     accentGreen #1bfd9c → success
     accentRed   #fc3e38 → error
   ================================================================ */

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

:root {
  --bg:       #0e0e0e;
  --bg-alt:   #141414;
  --gray:     #D9D9D9;   /* ctosGray — corner frames, logo fill */
  --text:     #ffffff;   /* textPrimary */
  --text-a:   #CACACA;   /* textPrimaryDim */
  --text-b:   #c3c3c3;   /* textPrimaryDimmer */
  --text-dim: #7a7a7a;   /* textSecondary */
  --sec:      #7a7a7a;   /* secondary — dividers, bar tracks */
  --success:  #1bfd9c;   /* accentGreen */
  --error:    #fc3e38;   /* accentRed */
  --border:   #1e1e1e;

  --bar-h:    28px;
  --cf-arm:   7px;
  --cf-thick: 1px;

  --font: 'JetBrains Mono', 'Fira Mono', monospace;
  --fs:   13px;
  --lh:   20px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gray); color: var(--bg); }

::-webkit-scrollbar       { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--sec); }

/* ── CornerFrame — 8-gradient trick, matches QML CornerFrame ──── */
.cf {
  --cfc: var(--gray);
  background:
    linear-gradient(var(--cfc),var(--cfc)) 0    0    / var(--cf-arm) var(--cf-thick) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 0    0    / var(--cf-thick) var(--cf-arm) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 100% 0    / var(--cf-arm) var(--cf-thick) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 100% 0    / var(--cf-thick) var(--cf-arm) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 0    100% / var(--cf-arm) var(--cf-thick) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 0    100% / var(--cf-thick) var(--cf-arm) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 100% 100% / var(--cf-arm) var(--cf-thick) no-repeat,
    linear-gradient(var(--cfc),var(--cfc)) 100% 100% / var(--cf-thick) var(--cf-arm) no-repeat;
}
.cf.dim { --cfc: #2e2e2e; }  /* very dim inactive workspace */
.cf.hi  { --cfc: var(--text); }
.cf.ok  { --cfc: var(--success); }

/* ── Bar ──────────────────────────────────────────────────────── */
#bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  user-select: none;
}

/* [CT]OS logo */
#logo {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-ct {
  background: var(--gray);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 1px 4px 0;
  line-height: 18px;
  height: 18px;
}
.logo-os {
  color: var(--gray);
  font-size: 12px;
  font-weight: 300;
  padding-left: 2px;
  letter-spacing: 0.04em;
}

/* ── Workspaces ────────────────────────────────────────────────── */
#workspaces {
  display: flex;
  align-items: center;
  height: 100%;
}
.ws {
  width: var(--bar-h);
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  --cfc: #2e2e2e;
  transition: background 0.15s;
  position: relative;
  flex-shrink: 0;
}
.ws:hover          { background: rgba(217,217,217,0.05); --cfc: var(--sec); }
.ws.active         { --cfc: var(--gray); }

/* Workspace icon — text glyph */
.ws-icon {
  font-size: 11px;
  font-weight: 500;
  color: #2e2e2e;
  transition: color 0.15s;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
}
.ws:hover  .ws-icon { color: var(--sec); }
.ws.active .ws-icon { color: var(--gray); }

/* Crosshair for WS1 (replaces text icon when active) */
.ws-cross {
  display: none;
  width: 9px;
  height: 9px;
  position: absolute;
  pointer-events: none;
}
.ws.active .ws-cross  { display: block; }
.ws.active .ws-icon   { display: none; }
.ws-cross::before {
  content: '';
  position: absolute;
  width: 9px; height: 1px;
  background: var(--gray);
  top: 4px; left: 0;
}
.ws-cross::after {
  content: '';
  position: absolute;
  width: 1px; height: 9px;
  background: var(--gray);
  left: 4px; top: 0;
}

/* 1px dividers between workspaces */
.ws-sep { width: 1px; height: 100%; background: var(--border); flex-shrink: 0; }

/* ── Sysinfo (right side of bar) ─────────────────────────────── */
#sysinfo {
  margin-left: auto;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  border-left: 1px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  gap: 2px;
}
.si-val  { color: var(--text); }
.si-dim  { color: var(--text-dim); }
.si-sep  { color: #2e2e2e; }

/* ── Shell — terminal area below bar ─────────────────────────── */
#shell {
  position: fixed;
  top: var(--bar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 20px 0;
  transition: opacity 0.2s;
}
#shell.hidden { opacity: 0; pointer-events: none; }

#output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-bottom: 8px;
}

/* ── Terminal line types ────────────────────────────────────────
   Matches QML terminal log style exactly
   ────────────────────────────────────────────────────────────── */
.tl {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: var(--lh);
  color: var(--text-b);   /* textPrimaryDimmer — matches QML log color */
}
.tl.dim     { color: var(--text-dim); }
.tl.hi      { color: var(--text); }
.tl.ok      { color: var(--success); }
.tl.err     { color: var(--error); }
.tl.blank   { display: block; height: 6px; }
.tl.dim-rule{ color: #2e2e2e; }

/* version border — QML versionBorder Rectangle */
.ver-border {
  display: block;
  border: 1px solid var(--border);
  padding: 3px 10px;
  color: #444;
  font-size: 12px;
  margin-bottom: 4px;
  line-height: 18px;
}

/* echoed input */
.tl-input { display: flex; line-height: var(--lh); }
.tl-prompt { color: var(--gray); flex-shrink: 0; }
.tl-typed  { color: var(--text); }

/* ── Clickable terminal links ─────────────────────────────────── */
.tl-link {
  color: var(--success);
  cursor: pointer;
  border-bottom: 1px solid rgba(27,253,156,0.3);
  transition: border-color 0.15s, color 0.15s;
}
.tl-link:hover {
  color: #fff;
  border-color: var(--success);
}

/* ── Input row ───────────────────────────────────────────────── */
#input-row {
  display: flex;
  align-items: center;
  padding: 6px 0 14px;
  flex-shrink: 0;
}
#prompt-sym {
  color: var(--gray);
  flex-shrink: 0;
  user-select: none;
}
#cmd-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  caret-color: var(--gray);
}

/* ── Post viewer overlay ─────────────────────────────────────── */
#post-viewer {
  position: fixed;
  top: var(--bar-h);
  left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  z-index: 150;
  animation: fadein 0.15s ease;
}
#post-viewer.open { display: flex; }

#pv-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--bar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
}
#pv-title { color: var(--text-dim); letter-spacing: 0.06em; }
#pv-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}
#pv-close:hover { color: var(--error); border-color: var(--error); }

#pv-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px min(10%, 80px);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* ── Markdown content styles (for post viewer) ───────────────── */
#pv-content h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin: 0 0 24px;
  letter-spacing: 0.02em;
}
#pv-content h2 {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-a);
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
}
#pv-content h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-b);
  margin: 20px 0 8px;
}
#pv-content p  { color: var(--text-b); line-height: 1.75; margin-bottom: 14px; }
#pv-content a  { color: var(--success); text-decoration: none; border-bottom: 1px solid rgba(27,253,156,0.3); }
#pv-content a:hover { border-color: var(--success); }
#pv-content strong { color: var(--text); font-weight: 600; }
#pv-content em { color: var(--text-a); font-style: italic; }
#pv-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
#pv-content blockquote {
  border-left: 2px solid var(--sec);
  padding: 4px 16px;
  margin: 12px 0;
  color: var(--text-dim);
}
#pv-content pre {
  background: #111;
  border: 1px solid var(--border);
  border-left: 2px solid var(--sec);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 14px 0;
}
#pv-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: var(--text-b);
  font-size: 12px;
  line-height: 1.65;
}
#pv-content code {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-size: 0.9em;
  color: var(--success);
}
#pv-content ul, #pv-content ol {
  padding-left: 22px;
  margin-bottom: 14px;
  color: var(--text-b);
  line-height: 1.75;
}
#pv-content ul li::marker { color: var(--sec); }
#pv-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 12px;
}
#pv-content th {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 7px 12px;
  color: var(--text-a);
  text-align: left;
  font-weight: 500;
}
#pv-content td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  color: var(--text-b);
}

/* post meta row */
#pv-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 28px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
#pv-meta .pv-tag {
  color: var(--success);
  font-size: 11px;
}

/* ── Misc ────────────────────────────────────────────────────── */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 600px) {
  #sysinfo .si-extra { display: none; }
  #shell { padding: 10px 12px 0; }
  :root  { --fs: 12px; }
  #pv-content { padding: 20px 16px; }
}

/* ================================================================
   LOCKSCREEN
   Inspired by QML greeter: Accents, FieldGroup, Terminal, Time,
   Status, DeviceId, Splash components
   ================================================================ */

#lockscreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}
#lockscreen.fade-out { opacity: 0; pointer-events: none; }
#lockscreen.gone     { display: none; }

/* ── Page-corner accent marks (QML Accents component) ────────── */
.ls-accent {
  position: absolute;
  width: 40px;
  height: 40px;
  --ac: #1e1e1e;
}
/* TL */
.ls-accent.tl {
  top: 28px; left: 28px;
  background:
    linear-gradient(var(--ac),var(--ac)) 0 0 / 20px 1px no-repeat,
    linear-gradient(var(--ac),var(--ac)) 0 0 / 1px 20px no-repeat;
}
/* TR */
.ls-accent.tr {
  top: 28px; right: 28px;
  background:
    linear-gradient(var(--ac),var(--ac)) 100% 0 / 20px 1px no-repeat,
    linear-gradient(var(--ac),var(--ac)) 100% 0 / 1px 20px no-repeat;
}
/* BL */
.ls-accent.bl {
  bottom: 28px; left: 28px;
  background:
    linear-gradient(var(--ac),var(--ac)) 0 100% / 20px 1px no-repeat,
    linear-gradient(var(--ac),var(--ac)) 0 100% / 1px 20px no-repeat;
}
/* BR */
.ls-accent.br {
  bottom: 28px; right: 28px;
  background:
    linear-gradient(var(--ac),var(--ac)) 100% 100% / 20px 1px no-repeat,
    linear-gradient(var(--ac),var(--ac)) 100% 100% / 1px 20px no-repeat;
}

/* ── Top-left time ───────────────────────────────────────────── */
#ls-time-block {
  position: absolute;
  top: 28px; left: 52px;
}
#ls-clock {
  font-size: 42px;
  font-weight: 300;
  color: var(--text-b);
  line-height: 1;
  letter-spacing: 0.06em;
}
#ls-date-str {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  margin-top: 4px;
}

/* ── Bottom-left fake terminal log ──────────────────────────── */
#ls-log {
  position: absolute;
  bottom: 36px;
  left: 40px;
  width: min(420px, 38vw);
  font-size: 12px;
}
.ls-ver-border {
  border: 1px solid var(--border);
  padding: 3px 10px;
  color: #333;
  font-size: 11px;
  line-height: 18px;
  margin-bottom: 4px;
}
#ls-log-lines { display: flex; flex-direction: column; gap: 0; }
.ls-log-line  { color: #2e2e2e; line-height: 18px; white-space: nowrap; overflow: hidden; }
.ls-log-line.vis { color: var(--text-dimmer); }

/* ── Bottom-right device id ──────────────────────────────────── */
#ls-device {
  position: absolute;
  bottom: 36px; right: 40px;
  text-align: right;
}
.ls-device-line { font-size: 10px; color: var(--text-dim); letter-spacing: 0.2em; }
.ls-device-id   { font-size: 18px; font-weight: 500; color: var(--text-b); letter-spacing: 0.06em; line-height: 1.3; }
.ls-device-env  { font-size: 13px; color: #333; letter-spacing: 0.1em; }

/* ── Top-right status panel ──────────────────────────────────── */
#ls-status {
  position: absolute;
  top: 28px; right: 40px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}
.ls-status-row  { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.ls-status-dot  { width: 4px; height: 4px; border-radius: 50%; background: var(--border); }
.ls-status-lbl  { color: var(--text-dim); letter-spacing: 0.12em; }
.ls-status-val  { color: var(--text-dimmer); letter-spacing: 0.1em; }
.ls-status-val.ok   { color: var(--success); }
.ls-status-val.warn { color: #888; }

/* ── Centre container ────────────────────────────────────────── */
#ls-centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

/* ── Splash logo ─────────────────────────────────────────────── */
#ls-splash {
  --cfc: var(--gray);
  padding: 12px 32px;
}
#ls-splash-inner { display: flex; align-items: baseline; }
.splash-ct {
  font-size: 36px;
  font-weight: 700;
  background: var(--gray);
  color: var(--bg);
  padding: 2px 8px 0;
  line-height: 1.15;
  letter-spacing: 0.08em;
}
.splash-os {
  font-size: 36px;
  font-weight: 300;
  color: var(--gray);
  padding-left: 4px;
  letter-spacing: 0.06em;
}

/* ── Login form ──────────────────────────────────────────────── */
#ls-form { display: flex; flex-direction: column; align-items: center; gap: 12px; }

#ls-form-inner {
  --cfc: #2e2e2e;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 320px;
  transition: --cfc 0.3s;
}
#ls-form-inner:focus-within { --cfc: var(--gray); }

.lf-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-align: center;
}

.lf-field-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.lf-field-prefix { color: var(--gray); font-size: 14px; font-weight: 500; }
.lf-field {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  caret-color: var(--gray);
  letter-spacing: 0.05em;
}
.lf-field::placeholder { color: #333; }
.lf-field:focus::placeholder { color: var(--text-dimmer); }

.lf-error {
  font-size: 11px;
  color: var(--error);
  letter-spacing: 0.08em;
  min-height: 14px;
  text-align: center;
}

.lf-buttons { display: flex; flex-direction: column; gap: 8px; }

.lf-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 8px 0;
  cursor: pointer;
  transition: all 0.15s;
}
.lf-btn:hover { border-color: var(--sec); color: var(--text-b); }
.lf-btn.primary { border-color: var(--gray); color: var(--gray); }
.lf-btn.primary:hover { background: var(--gray); color: var(--bg); }
.lf-btn.secondary:hover { border-color: #444; }

#ls-disclaimer {
  font-size: 10px;
  color: #252525;
  letter-spacing: 0.08em;
  text-align: center;
  max-width: 320px;
  line-height: 1.6;
}

/* ── Bar / shell: hidden by default, shown after login ───────── */
#bar.hidden, #shell.hidden { display: none; }

/* Access tag in sysinfo */
.si-tag {
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 1px 6px;
  border: 1px solid;
  margin-right: 8px;
}
.si-tag.admin { color: var(--success); border-color: var(--success); }
.si-tag.guest { color: var(--text-dim); border-color: var(--border); }

/* ── Lockscreen animations ───────────────────────────────────── */
@keyframes ls-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#ls-centre { animation: ls-fadein 0.5s ease 0.1s both; }

/* ── Responsive lockscreen ───────────────────────────────────── */
@media (max-width: 700px) {
  #ls-log, #ls-device, #ls-status { display: none; }
  #ls-time-block { top: 20px; left: 20px; }
  #ls-clock { font-size: 28px; }
  .ls-accent { top: 12px !important; left: 12px !important; right: 12px !important; bottom: 12px !important; }
  #ls-form-inner { min-width: 280px; padding: 20px 20px; }
}

/* ================================================================
   IDLE OVERLAY — for `idle` admin command
   ================================================================ */

#idle-overlay {
  position: fixed;
  inset: 0;
  top: var(--bar-h, 28px);
  background: var(--bg);
  z-index: 160;
  display: none;
  flex-direction: column;
  font-family: var(--font);
}
#idle-overlay.open { display: flex; }

#idle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
}
#idle-title { color: var(--text-dim); letter-spacing: 0.1em; }
#idle-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}
#idle-close:hover { color: var(--error); border-color: var(--error); }

#idle-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 32px 20px;
  overflow: auto;
  gap: 20px;
}

#idle-art {
  font-family: var(--font);
  font-size: clamp(10px, 1.3vw, 14px);
  color: var(--text-b);
  line-height: 1.2;
  white-space: pre;
  margin: 0;
  text-align: left;
}

#idle-stopwatch-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 28px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.5);
  /* CornerFrame-style accents on the stopwatch panel */
  background-image:
    linear-gradient(var(--success), var(--success)) 0    0    / 8px 1px no-repeat,
    linear-gradient(var(--success), var(--success)) 0    0    / 1px 8px no-repeat,
    linear-gradient(var(--success), var(--success)) 100% 0    / 8px 1px no-repeat,
    linear-gradient(var(--success), var(--success)) 100% 0    / 1px 8px no-repeat,
    linear-gradient(var(--success), var(--success)) 0    100% / 8px 1px no-repeat,
    linear-gradient(var(--success), var(--success)) 0    100% / 1px 8px no-repeat,
    linear-gradient(var(--success), var(--success)) 100% 100% / 8px 1px no-repeat,
    linear-gradient(var(--success), var(--success)) 100% 100% / 1px 8px no-repeat,
    rgba(0,0,0,0.5);
}
#idle-stopwatch-label {
  font-size: 10px;
  color: var(--success);
  letter-spacing: 0.28em;
  opacity: 0.7;
}
#idle-stopwatch {
  font-size: 28px;
  color: var(--success);
  letter-spacing: 0.14em;
  font-family: var(--font);
  min-width: 110px;
  text-align: center;
  text-shadow: 0 0 12px rgba(27, 253, 156, 0.3);
}