/* =========================================================
   MICRODESK II — a 1-bit desktop in a beige plastic case
   Palette:  case #d8cfbc · highlight #efe8d8 · shadow #a1977f
             screen #f2f0e6 · ink #141412 · LED #ff9b2f
   ========================================================= */

:root {
  --case:        #d8cfbc;
  --case-hi:     #efe8d8;
  --case-lo:     #a1977f;
  --case-dk:     #6f664f;
  --screen:      #f2f0e6;
  --ink:         #141412;
  --led:         #ff9b2f;
  --go:          #2f7d3a;
  --wait:        #c26a12;
  --stop:        #b3282d;
  --info:        #2f5f9e;
  --band-blue:   #1c6fe0;
  --band-green:  #1fa851;

  --display: "Silkscreen", "Chicago", "Courier New", monospace;
  --body:    "IBM Plex Mono", "Monaco", "Courier New", monospace;

  --line: 2px solid var(--ink);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  padding: clamp(10px, 3vw, 44px);
  display: grid;
  place-items: center;
  font-family: var(--body);
  color: var(--ink);
  background-color: #3b382f;
  background-image:
    radial-gradient(120% 90% at 50% 0%, #55503f 0%, #2a2822 70%, #1c1a16 100%);
}

/* ---------- The physical machine ---------- */

.monitor {
  width: min(1040px, 100%);
  background: var(--case);
  border-radius: 20px 20px 14px 14px;
  padding: clamp(14px, 2.4vw, 26px);
  box-shadow:
    inset 0 2px 0 var(--case-hi),
    inset 0 -3px 0 var(--case-lo),
    inset 3px 0 0 rgba(255,255,255,.28),
    inset -3px 0 0 rgba(0,0,0,.12),
    0 30px 60px rgba(0,0,0,.55);
}

.bezel {
  background: #2b2823;
  border-radius: 12px;
  padding: clamp(10px, 1.6vw, 16px);
  box-shadow:
    inset 0 0 0 2px #14120f,
    inset 0 4px 12px rgba(0,0,0,.7);
}

.screen {
  position: relative;
  overflow: hidden;
  background: var(--screen);
  border-radius: 7px;
  min-height: 78svh;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 30px rgba(230, 226, 200, .18),
    inset 0 0 60px rgba(0,0,0,.16);
}

/* Scanlines + corner vignette, drawn over everything */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background-image:
}

/* ---------- Case plate below the screen ---------- */

.case-plate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 2px;
}

.brand {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--case-dk);
  text-shadow: 0 1px 0 var(--case-hi);
}

.brand b { color: var(--case-dk); }

.led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--led);
  box-shadow: 0 0 8px 2px rgba(255, 155, 47, .65), inset 0 -1px 1px rgba(0,0,0,.4);
}

/* ---------- Menu bar ---------- */

.menubar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 26px;
  padding: 0 12px;
  background: var(--screen);
  border-bottom: var(--line);
  font-family: var(--display);
  font-size: 10px;
  flex: none;
}

.menu-logo { display: flex; color: var(--ink); }

.menu-item { letter-spacing: .02em; }

.menu-clock { margin-left: auto; }

/* ---------- Desktop surface ---------- */

.desktop {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  align-items: start;
  gap: clamp(16px, 3vw, 40px);
  padding: clamp(18px, 3vw, 34px);

  /* dithered grey, the way a monochrome desktop faked a tone */
  background-color: var(--screen);
  background-image: url("images/dog.jpg");
  background-size: cover;
  background-position: center;
/* ---------- Windows ---------- */

.window {
  background: var(--screen);
  border: var(--line);
  box-shadow: 5px 5px 0 var(--ink);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 6px;
  border-bottom: var(--line);
  background-image: repeating-linear-gradient(to bottom,
    var(--ink) 0 1px, transparent 1px 3px);
}

.titlebar .title {
  margin: 0 auto;
  padding: 2px 10px;
  background: var(--screen);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box {
  flex: none;
  width: 13px;
  height: 13px;
  border: var(--line);
  background: var(--screen);
}

a.box { display: block; }
a.box:hover, a.box:focus-visible { background: var(--ink); }

.window-body {
  padding: clamp(16px, 2.4vw, 26px);
  font-size: 13px;
  line-height: 1.65;
}

.window-body p { margin: 0 0 14px; }
.window-body p:last-child { margin-bottom: 0; }

.window-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 4px 0 14px;
  border: var(--line);
}

.figure-half {
  width: 33.33%;
  height: auto;
}

.figure-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 4px 0 14px;
}

.figure-row figure {
  flex: 1 1 0;
  min-width: 160px;
  margin: 0;
}

.figure-row img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--screen);
  margin: 0;
}

.figure-row figcaption {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 9px;
  text-align: center;
  opacity: .7;
}

.lead {
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.5;
}

.signoff {
  padding-top: 12px;
  border-top: 1px dashed var(--ink);
  font-size: 11px;
  opacity: .7;
}

.statusbar {
  display: flex;
  gap: 18px;
  padding: 5px 12px;
  border-top: var(--line);
  font-family: var(--display);
  font-size: 9px;
}

.statusbar span:last-child { margin-left: auto; }

/* ---------- Desktop icons ---------- */

.icons {
  display: grid;
  justify-items: center;
  gap: 20px;
}

.icon {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 100%;
  color: var(--ink);
  text-decoration: none;
}

.icon-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
}

/* selection dither, the old way of "highlighting" an icon */
.icon-art::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image:
    linear-gradient(45deg, var(--ink) 25%, transparent 25% 75%, var(--ink) 75%),
    linear-gradient(45deg, var(--ink) 25%, transparent 25% 75%, var(--ink) 75%);
  background-size: 2px 2px;
  background-position: 0 0, 1px 1px;
  mix-blend-mode: multiply;
}

.icon-label {
  padding: 2px 5px;
  font-family: var(--display);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}

a.icon:hover .icon-label,
a.icon:focus-visible .icon-label {
  background: var(--ink);
  color: var(--screen);
}

a.icon:hover .icon-art::after,
a.icon:focus-visible .icon-art::after { opacity: .55; }

a.icon:focus-visible { outline: 2px dotted var(--ink); outline-offset: 4px; }

a.icon:active .icon-art { transform: translate(1px, 1px); }

.icon-static { cursor: default; }

.icon-trash { margin-top: 26px; }

/* ---------- Interior pages ---------- */

.desktop-single { grid-template-columns: minmax(0, 1fr); }

.doc-window { max-width: 700px; margin: 0 auto; }

.window-body h2 {
  margin: 26px 0 10px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: .04em;
}

.window-body h2:first-child { margin-top: 0; }

.window-body ul {
  margin: 0 0 14px;
  padding-left: 18px;
}

.window-body li { margin-bottom: 6px; }

.li-trigger {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.li-trigger:hover,
.li-trigger:focus-visible { background: var(--ink); color: var(--screen); }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
  background: rgba(20, 20, 18, .78);
}

.lightbox[hidden] { display: none; }

.lightbox .monitor { width: fit-content; max-width: 100%; }

.lightbox-screen {
  min-height: 0;
  max-width: min(90vw, 900px);
}

.lightbox-screen .titlebar .box { cursor: pointer; }

.lightbox-body {
  position: relative;
  display: grid;
  place-items: center;
  padding: 16px;
  background: repeating-linear-gradient(45deg,
    rgba(20,20,18,.06) 0 2px, transparent 2px 8px);
}

.lightbox-body img {
  display: block;
  max-width: min(80vw, 820px);
  max-height: 35svh;
  width: auto;
  height: auto;
  border: var(--line);
  background: var(--screen);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: var(--line);
  background: var(--screen);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--display);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible { background: var(--ink); color: var(--screen); }
.lightbox-nav:active { transform: translateY(-50%) translate(2px, 2px); box-shadow: none; }

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: var(--line);
  font-family: var(--display);
  font-size: 10px;
}

.window-body a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.window-body a:hover,
.window-body a:focus-visible { background: var(--ink); color: var(--screen); }

/* A filed entry: name on the left, date on the right */
.entry {
  padding: 14px 0;
  border-bottom: 1px dashed var(--ink);
}

.entry:last-of-type { border-bottom: 0; }

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--display);
  font-size: 11px;
}

.entry-date { font-size: 9px; opacity: .65; white-space: nowrap; }

.entry p { margin: 6px 0 0; }

.footer-row {
  margin-top: 26px;
  padding-top: 18px;
  border-top: var(--line);
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-block;
  padding: 6px 18px;
  border: var(--line);
  border-radius: 7px;
  background: var(--screen);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--display);
  font-size: 10px;
  color: var(--ink);
  text-decoration: none;
}

.btn:hover, .btn:focus-visible { background: var(--ink); color: var(--screen); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }

/* ---------- Folder list view ---------- */

.filelist { margin-top: 4px; }

.filelist-head,
.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px 104px;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
}

.filelist-head {
  border-bottom: var(--line);
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: .04em;
}

.file-row {
  border-bottom: 1px dashed var(--ink);
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
}

.file-row:last-child { border-bottom: 0; }

.file-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-family: var(--display);
  font-size: 11px;
}

.file-name svg { flex: none; }

.file-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta { font-size: 10px; opacity: .75; }

a.file-row:hover,
a.file-row:focus-visible { background: var(--ink); color: var(--screen); }

a.file-row:hover .file-meta,
a.file-row:focus-visible .file-meta { opacity: .85; }

a.file-row:focus-visible { outline: 2px dotted var(--ink); outline-offset: -2px; }

.file-row-empty { opacity: .45; cursor: default; }

.file-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--ink);
  font-size: 11px;
  opacity: .75;
}

/* ---------- Trading dashboard ---------- */

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.stat {
  border: var(--line);
  background: var(--screen);
}

.stat-total {
  grid-column: 1 / -1;
  justify-self: center;
  width: calc((100% - 20px) / 3);
}

.stat-key {
  padding: 3px 8px;
  border-bottom: var(--line);
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: .06em;
}

.stat-val {
  padding: 12px 8px 6px;
  font-family: var(--display);
  font-size: 19px;
  line-height: 1;
  text-align: center;
  word-break: break-all;
}

.stat-sub {
  padding: 0 8px 9px;
  font-size: 9px;
  text-align: center;
  opacity: .7;
}

.ticker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 16px;
  padding: 10px 12px;
  border: var(--line);
  background-image: repeating-linear-gradient(to bottom,
    rgba(20, 20, 18, .07) 0 1px, transparent 1px 4px);
  font-size: 11px;
}

.ticker div { display: flex; justify-content: space-between; gap: 10px; }

.ticker-wide {
  grid-column: 1 / -1;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px dashed var(--ink);
}

.ticker-wide span {
  font-family: var(--display);
  font-size: 14px;
}

.ticker b { font-family: var(--display); font-size: 10px; font-weight: 400; }

.chart {
  width: 100%;
  height: 300px;
  margin: 16px 0;
  border: var(--line);
  background: var(--screen);
}

.chart text { font-family: var(--body); }

.rule {
  width: 100%;
  margin: 16px 0;
  border: var(--line);
  border-collapse: collapse;
  font-size: 12px;
}

.rule th,
.rule td {
  padding: 7px 10px;
  border-bottom: 1px dashed var(--ink);
  text-align: left;
}

.rule tr:last-child th,
.rule tr:last-child td { border-bottom: 0; }

.rule th {
  width: 62px;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 400;
  border-right: var(--line);
}

.rule td:nth-child(2) {
  width: 110px;
  font-family: var(--display);
  font-size: 10px;
}

.rule td:last-child { opacity: .75; }

.chart-caption {
  margin-top: -8px;
  font-size: 10px;
  text-align: center;
  opacity: .65;
}

.signal {
  padding: 10px 12px;
  border: var(--line);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--display);
  font-size: 11px;
  text-align: center;
}

.signal.is-flat  { background: var(--wait); color: #fff; border-color: var(--ink); }
.signal.is-long  { background: var(--go);   color: #fff; border-color: var(--ink); }
.signal.is-short { background: var(--stop); color: #fff; border-color: var(--ink); }

.log {
  max-height: 190px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 10px 12px;
  border: var(--line);
  font-size: 11px;
  line-height: 1.75;
}

.log p { margin: 0; }
.log time { opacity: .6; margin-right: 8px; }

.feed-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: var(--line);
  font-family: var(--display);
  font-size: 9px;
}

.feed-state .dot {
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.feed-state.is-live .dot { background: var(--ink); }
.feed-state.is-error { background: var(--ink); color: var(--screen); }
.feed-state.is-error .dot { border-color: var(--screen); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.caveat {
  margin-top: 22px;
  padding: 12px 14px;
  border: 1px dashed var(--ink);
  font-size: 11px;
  line-height: 1.65;
}

.caveat b { font-family: var(--display); font-size: 10px; font-weight: 400; }
.caveat ul { margin: 8px 0 0; padding-left: 18px; }

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .screen { animation: power-on 700ms cubic-bezier(.2, .8, .2, 1); }

  @keyframes power-on {
    0%   { transform: scaleY(.004); filter: brightness(3); }
    45%  { transform: scaleY(.004); filter: brightness(3); }
    75%  { transform: scaleY(1);    filter: brightness(1.6); }
    100% { transform: scaleY(1);    filter: brightness(1); }
  }

  .led { animation: pulse 4s ease-in-out infinite; }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .72; }
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  .screen { min-height: 0; border-radius: 5px; }

  .desktop {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .icons {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 16px;
  }

  .icon-trash { margin-top: 0; }

  .menubar { gap: 11px; padding: 0 8px; font-size: 9px; }
  .menu-item:nth-child(n + 4) { display: none; }

  .window { box-shadow: 3px 3px 0 var(--ink); }

  .filelist-head,
  .file-row { grid-template-columns: minmax(0, 1fr) 74px; }

  .file-meta:nth-of-type(2) { display: none; }

  .readout { grid-template-columns: minmax(0, 1fr); }

  .stat-total { width: 100%; }

  .stat-val { font-size: 17px; }

  .ticker { grid-template-columns: minmax(0, 1fr); }
}
