/* ---------------------------------------------------------------
   Scribbleshort — retro desktop shell (homepage only).
   Progressive enhancement layer: only activates when desktop.js
   boots successfully. Original inline icons, no imported assets,
   no web fonts — monospace chrome uses the system stack.

   Shares its color palette and fonts with style.css (--bg, --dot,
   --panel, --text, --muted, --accent, --border, --serif, --mono) so
   navigating out to a real page looks like the same site. This file
   only adds the extra variables the window chrome needs.
   ----------------------------------------------------------------*/

[data-theme="light"] {
  --titlebar-bg: #d8cfb4;
  --dock-bg: rgba(26, 22, 18, 0.92);
  --dock-icon-bg: #f7f4ea;
  --dock-icon-fg: #1a1a1a;
  --shadow: 3px 4px 0 rgba(26, 22, 18, 0.35);
}

[data-theme="dark"] {
  --titlebar-bg: #2c2721;
  --dock-bg: rgba(238, 234, 226, 0.94);
  --dock-icon-bg: #201c17;
  --dock-icon-fg: #eeeae2;
  --shadow: 3px 4px 0 rgba(0, 0, 0, 0.5);
}

/* Hidden until desktop.js confirms it booted */
.desktop-root {
  display: none;
}

html.desktop-active body {
  overflow: hidden;
  height: 100vh;
}

html.desktop-active .static-fallback {
  display: none;
}

html.desktop-active .desktop-root {
  display: block;
}

.desktop-root {
  position: fixed;
  inset: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  font-family: var(--mono);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Status bar ---------- */

.status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.9rem;
  background: var(--titlebar-bg);
  border-bottom: 1.5px solid var(--border);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  z-index: 900;
}

.status-bar__brand {
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 0;
}

.status-bar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-bar__clock {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.status-bar__theme {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  text-transform: uppercase;
}

.status-bar__theme:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--panel);
}

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

.desktop-surface {
  position: absolute;
  top: 32px;
  left: 0;
  right: 0;
  bottom: 84px;
  overflow: hidden;
}

/* ---------- Windows ---------- */

.window {
  position: absolute;
  min-width: 280px;
  min-height: 180px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: window-in 0.12s ease-out;
}

@keyframes window-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.window.is-focused {
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.3);
}

.window.is-minimized {
  display: none;
}

.window.is-maximized {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.window__titlebar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 30px;
  padding: 0 0.6rem;
  background: var(--titlebar-bg);
  border-bottom: 1.5px solid var(--border);
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.window__controls {
  display: flex;
  gap: 0.4rem;
}

.window__controls button {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--border);
  background: var(--panel);
  padding: 0;
  cursor: pointer;
  font-size: 0;
}

.window__controls button.close:hover { background: #c1633d; }
.window__controls button.minimize:hover { background: #d8b85a; }
.window__controls button.maximize:hover { background: #6f9e6a; }

.window__title {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window__content {
  flex: 1;
  overflow: auto;
  padding: 1.4rem 1.6rem;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--panel);
}

.window__content h1,
.window__content h2,
.window__content h3 {
  font-family: var(--serif);
}

.window__content a {
  color: var(--accent);
}

/* Type + date line for an entry opened in a window — .entry-kicker is the
   category/type ("Short Fiction", "Blog"), .entry-kicker-date is the date
   directly under it. Added by desktop.js alongside the site's normal
   .eyebrow/.meta classes (kept for typography), just laid out more
   deliberately than the plain article view: a small label chip above a
   clearly separated, slightly larger date line. */
.window__content .entry-kicker {
  display: inline-block;
  margin: 0 0 0.3rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.68rem;
}

.window__content .entry-kicker-date {
  display: block;
  margin: 0 0 1.1rem;
  font-size: 0.8rem;
}

.window__content .win-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
}

.window__content .win-list li {
  border-bottom: 1px solid var(--dot);
  padding: 0.75rem 0;
}

.window__content .win-list li:first-child {
  padding-top: 0;
}

.window__content .win-list a {
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}

.window__content .win-list a:hover {
  color: var(--accent);
}

.window__content .win-list .meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  margin-top: 0.2rem;
}

/* ---------- Terminal window (always dark, on purpose) ---------- */

.window--terminal .window__content {
  background: #100e0b;
  color: #d9d2c0;
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 1rem 1.2rem;
}

.terminal-log {
  white-space: pre-wrap;
  margin: 0 0 0.6rem;
}

.terminal-log .prompt {
  color: var(--accent);
}

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.terminal-input-row .prompt {
  color: var(--accent);
}

.terminal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #d9d2c0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

/* ---------- Search overlay ---------- */

.search-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 950;
}

.search-overlay.is-open {
  display: flex;
}

.search-box {
  width: min(90vw, 520px);
  background: var(--panel);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}

.search-box input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.9rem 1rem;
  font-family: var(--mono);
  font-size: 1rem;
  border: none;
  border-bottom: 1.5px solid var(--border);
  outline: none;
  background: var(--panel);
  color: var(--text);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow: auto;
}

.search-results li a {
  display: block;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.88rem;
  border-bottom: 1px solid var(--dot);
}

.search-results li a:hover,
.search-results li a.is-active {
  background: var(--accent);
  color: var(--panel);
}

.search-empty {
  padding: 0.9rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Dock ---------- */

.dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: var(--dock-bg);
  border-radius: 14px;
  z-index: 900;
}

.dock__item {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 9px;
  border: none;
  background: var(--dock-icon-bg);
  color: var(--dock-icon-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.dock__item:hover {
  transform: translateY(-5px);
}

.dock__item svg {
  width: 22px;
  height: 22px;
}

.dock__item .dock__dot {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dock-icon-fg);
  opacity: 0;
}

.dock__item.has-window .dock__dot {
  opacity: 0.9;
}

.dock__label {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--titlebar-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}

.dock__item:hover .dock__label {
  opacity: 1;
}

/* ---------- Small screens: desktop UI steps aside for the static site ---------- */

@media (max-width: 46rem) {
  html.desktop-active .static-fallback {
    display: block;
  }
  html.desktop-active .desktop-root {
    display: none;
  }
  html.desktop-active body {
    overflow: auto;
    height: auto;
  }
}
