/* public/css/site.css */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root[data-theme='day'] {
  --bg: #FAF9F5; --win: #FFFFFF; --bar: #F4F2EC; --border: #E4E1D8;
  --fg: #1A1D23; --out: #5A5F6A; --dim: #9A958A; --accent: #B4540A;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
:root[data-theme='night'] {
  --bg: #0B0E14; --win: #0B0E14; --bar: #0E121A; --border: #1D2432;
  --fg: #E7EDF4; --out: #9AA4B4; --dim: #566070; --accent: #E5A158;
  --shadow: none;
}

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

body {
  background: var(--bg);
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: background 0.25s;
}

/* ---- window ---- */
#window {
  width: 100%;
  max-width: 720px;
  background: var(--win);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
body.maxed { padding: 0; }
body.maxed #window { max-width: none; max-height: none; height: 100vh; border: none; border-radius: 0; box-shadow: none; }
body.maxed #titlebar { background: transparent; border-bottom: none; }
body.min #window, body.closed #window { display: none; }
body.maxed #plain-link, body.min #plain-link, body.closed #plain-link,
body.maxed #contact-line, body.min #contact-line, body.closed #contact-line { display: none; }

#titlebar { background: var(--bar); border-bottom: 1px solid var(--border); padding: 8px 14px; display: flex; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: none; margin-right: 8px; cursor: pointer; position: relative; padding: 0; }
.dot.close { background: #FF5F57; }
.dot.min { background: #FEBC2E; }
.dot.max { background: #28C840; }
/* Enlarge the tap/click target to >=24x24 via an absolutely positioned
   ::before that overflows the 12px visible circle; out-of-flow, so it
   doesn't shift the titlebar layout. ::after stays free for the hover glyph. */
.dot::before {
  content: '';
  position: absolute;
  inset: -6px;
}
.dot:hover::after, .dot:focus-visible::after {
  content: attr(data-sym); position: absolute; inset: 0;
  font-size: 9px; line-height: 12px; text-align: center; color: rgba(0, 0, 0, 0.55);
}
#host { margin-left: auto; color: var(--dim); font-size: 11px; }
/* Padding enlarges the hit area to >=24px; matching negative margins cancel
   the padding's contribution to flex flow so the titlebar height/spacing
   and the glyph's visual position stay unchanged. */
#btn-theme {
  background: none; border: none; cursor: pointer; color: var(--dim); font-size: 14px; line-height: 1;
  padding: 6px; margin: -6px -6px -6px 4px;
}

#screen { padding: 14px 20px 18px; overflow-y: auto; flex: 1; cursor: text; }

/* ---- output lines ---- */
.line-fg { color: var(--fg); }
.line-out { color: var(--out); }
.line-dim { color: var(--dim); }
.line-accent { color: var(--accent); }
.line-error { color: #E24B4A; }
.line-cmd { color: var(--fg); font-weight: 700; }
#output > div { white-space: pre-wrap; overflow-wrap: anywhere; }
#output a, #screen a, #plain-link a, #closed a { color: var(--accent); text-decoration: none; }
#output a:hover, #output a:focus-visible { text-decoration: underline; }
#output pre { font: inherit; white-space: pre; }

/* ---- prompt ---- */
#prompt-line { display: flex; flex-wrap: wrap; align-items: baseline; position: relative; }
.prompt-user { color: var(--accent); }
.prompt-path { color: var(--dim); margin-right: 8px; }
#echo { color: var(--fg); font-weight: 700; white-space: pre; }
#cursor { display: inline-block; width: 8px; height: 17px; background: var(--accent); vertical-align: text-bottom; animation: blink 1.1s step-end infinite; }
#cmd { position: absolute; opacity: 0; width: 1px; height: 1px; font-size: 16px; }
#window:focus-within #titlebar { box-shadow: inset 0 -1px 0 var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ---- desktop ---- */
#desktop { position: fixed; inset: 0; display: none; }
body.min #desktop, body.closed #desktop { display: block; }
.icon {
  position: absolute; right: 28px; width: 96px; padding: 8px 4px;
  background: none; border: none; border-radius: 8px; cursor: pointer;
  color: var(--out); font-family: inherit; font-size: 11px; line-height: 1.4; text-align: center;
}
.icon:hover, .icon:focus-visible { background: color-mix(in srgb, var(--out) 12%, transparent); }
#icon-daedalus { top: 32px; }
#icon-trash { bottom: 64px; }
.glyph { display: block; margin: 0 auto 5px; width: 34px; height: 42px; border: 1.5px solid currentColor; border-radius: 4px; position: relative; opacity: 0.75; }
.glyph.folder { height: 32px; margin-top: 10px; border-radius: 2px 6px 6px 6px; }
.glyph.folder::before { content: ''; position: absolute; top: -8px; left: -1.5px; width: 15px; height: 6px; border: 1.5px solid currentColor; border-bottom: none; border-radius: 3px 3px 0 0; }
.glyph.trash { border-radius: 3px 3px 7px 7px; }
.glyph.trash::before { content: ''; position: absolute; top: 7px; left: 7px; right: 7px; border-top: 1.5px solid currentColor; }
.glyph.trash::after { content: ''; position: absolute; top: 14px; left: 11px; bottom: 7px; border-left: 1.5px solid currentColor; box-shadow: 9px 0 0 -0.25px currentColor; }
#desktop-toast {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%);
  max-width: 70%; padding: 10px 16px; border-radius: 8px; font-size: 12px; text-align: center;
  background: var(--bar); border: 1px solid var(--border); color: var(--out); z-index: 5;
}

/* ---- dock + closed ---- */
#dock {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  padding: 6px 16px; border-radius: 8px; cursor: pointer;
  background: var(--bar); border: 1px solid var(--border);
  color: var(--out); font-family: inherit; font-size: 12px;
}
body.min #dock { display: block; }
#closed { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
body.closed #closed { display: flex; }
#closed > * { pointer-events: auto; }
#reconnect { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; margin-top: 8px; }

#contact-line { margin-top: 14px; color: var(--dim); font-size: 12px; }
#contact-line a { color: var(--dim); text-decoration: none; }
#contact-line a:hover, #contact-line a:focus-visible { color: var(--accent); text-decoration: underline; }
#plain-link { margin-top: 4px; color: var(--dim); font-size: 12px; }
.noscript-note { color: var(--out); margin-top: 16px; }

/* ---- top program ---- */
#top-panel { white-space: pre; color: var(--out); line-height: 1.25; }
#top-panel .bar-fill { color: var(--accent); }
#top-panel .bar-empty { color: var(--dim); }
#top-panel .top-dot { color: #3DDBB4; }
/* fixed program palette, same in both themes (like real btop) --
   this governs bar/sparkline glyph fills only. */
#top-panel .top-low { color: #3DDBB4; }
#top-panel .top-mid { color: #E5A158; }
#top-panel .top-high { color: #E24B4A; }
#top-panel .top-dim { color: var(--dim); }
/* numeric/text labels (% figures) start from the same fixed hues as the
   glyphs, but get day-theme overrides below since the light teal/amber
   fail contrast on paper-white as plain text. */
#top-panel .top-low-t { color: #3DDBB4; }
#top-panel .top-mid-t { color: #E5A158; }
#top-panel .top-high-t { color: #E24B4A; }
:root[data-theme='day'] #top-panel .top-low-t { color: #0B7A5F; }
:root[data-theme='day'] #top-panel .top-mid-t { color: #9C5A0E; }
:root[data-theme='day'] #top-panel .top-high-t { color: #B02A29; }

/* ---- focus + motion + mobile ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot:focus-visible, #btn-theme:focus-visible { outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  #cursor { animation: none; }
  body { transition: none; }
}

@media (max-width: 600px) {
  body { padding: 0; }
  #window { max-width: none; max-height: none; height: 100dvh; border: none; border-radius: 0; }
  #plain-link { position: fixed; bottom: 6px; left: 0; right: 0; text-align: center; }
  #contact-line { position: fixed; bottom: 24px; left: 0; right: 0; text-align: center; }
  .icon { right: 16px; }
}
