/* ============================================================
   knoxler.net — Phase 1: static desktop
   Plain CSS, no frameworks. Win98 flavor, pastel + neon.
   ============================================================ */

:root {
  --face: #cfc8e6;
  --face-hi: #f6f3fd;
  --face-lo: #9a90bd;
  --face-dk: #5c5382;
  --ink: #221d38;
  --title-1: #221a4a;
  --title-2: #6d3fa8;
  --neon-pink: #ff7ad9;
  --neon-cyan: #59e6ff;
  --desk-1: #f2e6ff;
  --desk-2: #cfeaff;
  --taskbar-h: 44px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Tahoma, Verdana, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: radial-gradient(circle at 50% 18%, #2b2350 0%, #171230 62%, #100d22 100%);
  min-height: 100vh;
}

/* Desktop page: the monitor fills the viewport exactly — no scrolling */
body.desktop-page {
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ---------- CRT monitor ---------- */

/* The monitor is a fixed-size design canvas (1000px wide).
   JS sets --scale so it always fits the viewport with no page scroll. */
.crt {
  display: flex;
  flex-direction: column;
  width: 1000px;
  margin: 0;
  padding: 14px 18px 8px;
  background: linear-gradient(180deg, #ded9f0 0%, #c4bce0 100%);
  border: 2px solid #4e4675;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 #fff, 0 18px 40px rgba(0, 0, 0, 0.55);
  transform: scale(var(--scale, 1));
  transform-origin: center center;
}

.crt-bezel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 8px;
}

.crt-brand {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #6c6494;
  border: 1px dashed #8d85b5;
  padding: 2px 8px;
  border-radius: 3px;
}

.crt-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #39ff8e;
  box-shadow: 0 0 8px #39ff8e;
}

/* 960×540 screen: the 480×270 wallpaper scales to exactly 2×, no cropping */
.screen {
  position: relative;
  overflow: hidden;
  height: 540px;
  flex: none;
  background: linear-gradient(160deg, var(--desk-1), var(--desk-2));
  border: 3px solid #3c3560;
  border-radius: 8px;
  box-shadow: inset 0 0 42px rgba(20, 12, 50, 0.35);
}

.crt-bezel-bottom {
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.4em;
  color: #6c6494;
  padding-top: 8px;
}

/* ---------- wallpaper (4 stacked layers, per CLAUDE.md) ---------- */

.wallpaper,
.wallpaper-layer {
  position: absolute;
  inset: 0;
}

.wallpaper-layer img {
  /* Fill exactly: layers must align with each other. A 480×270 artwork
     lands at precisely 2× on the 960×540 screen. */
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: pixelated;
}

/* Empty state: a faint dashed frame filling the whole screen behind
   everything (like a real wallpaper), label small and out of the way. */
.wallpaper-placeholder {
  position: absolute;
  inset: 6px;
  border: 2px dashed rgba(70, 55, 120, 0.3);
  border-radius: 6px;
  pointer-events: none;
  z-index: 0;
}

/* ---------- dashed placeholders ---------- */

.ph-box {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(70, 55, 120, 0.55);
  background: rgba(255, 255, 255, 0.35);
  color: #4a3f78;
  font-family: ui-monospace, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.ph-name {
  font-size: 12px;
  font-weight: 700;
}

.ph-note {
  font-size: 10px;
  letter-spacing: 0.05em;
}

.ph-wallpaper {
  position: absolute;
  left: 50%;
  bottom: calc(var(--taskbar-h) + 10px);
  transform: translateX(-50%);
  padding: 3px 10px;
  white-space: nowrap;
}

.ph-wallpaper .ph-name {
  font-size: 10px;
}

.asset-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ---------- desktop icons ---------- */

.icons {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: repeat(4, 92px);
  gap: 8px;
  align-content: start;
  z-index: 1;
}

.icon {
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.icon:hover {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(70, 55, 120, 0.35);
}

.icon-box {
  width: 48px;
  height: 48px;
  padding: 4px;
  font-size: 10px;
}

.icon.has-asset .icon-box {
  border-style: solid;
  background: transparent;
}

.icon-name {
  font-size: 12px;
  font-weight: 700;
  color: #241d45;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ---------- frog assistant placeholder ---------- */

.frog {
  position: absolute;
  right: 14px;
  bottom: calc(var(--taskbar-h) + 12px);
  width: 64px;
  height: 64px;
  padding: 4px;
  font-size: 10px;
  z-index: 1;
}

/* ---------- windows ---------- */

.windows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.window {
  position: absolute;
  width: min(380px, calc(100% - 24px));
  min-width: 240px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  box-shadow: 0 10px 24px rgba(15, 10, 40, 0.45);
  pointer-events: auto;
}

.window.dragging {
  box-shadow: 0 16px 34px rgba(15, 10, 40, 0.55);
}

.window.dragging .titlebar {
  cursor: grabbing;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px;
  background: linear-gradient(90deg, var(--title-1), var(--title-2));
  color: #fff;
  cursor: move;
  user-select: none;
}

.title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titlebar-buttons {
  display: inline-flex;
  gap: 4px;
  flex: none;
}

.titlebar button {
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  color: var(--ink);
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  cursor: pointer;
}

.titlebar button:active {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
}

.window-body {
  padding: 16px;
  min-height: 120px;
}

.coming-soon {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.coming-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: #55497e;
}

/* ---------- settings window ---------- */

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-weight: 700;
  cursor: pointer;
}

.setting-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--title-2);
}

/* ---------- taskbar ---------- */

.taskbar {
  /* Lives inside the CRT screen — part of the fake desktop. */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--taskbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--face);
  border-top: 2px solid var(--face-hi);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
  z-index: 3; /* always above the windows layer */
}

.start,
.quickview {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  cursor: pointer;
  flex: none;
}

.start:active,
.quickview:active {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
}

.start[aria-expanded="true"] {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  background: #bdb4dd;
}

.start-dot {
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-cyan));
  border-radius: 3px;
}

.taskbar-windows {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
}

.taskbtn {
  max-width: 150px;
  padding: 5px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  cursor: pointer;
  font-weight: 700;
}

.taskbtn.is-minimized {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  background: #b7aed6;
}

.quickview {
  color: #4a2b7d;
}

.tray {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 2px solid;
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  background: var(--face);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  flex: none;
}

.tray-label {
  color: #6d6299;
  letter-spacing: 0.15em;
}

/* ---------- start menu ---------- */

.start-menu {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  min-width: 210px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4);
  padding: 4px;
  z-index: 4;
}

.start-menu-banner {
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.18em;
  padding: 8px 10px;
  color: #fff;
  background: linear-gradient(90deg, var(--title-1), var(--title-2));
}

.start-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: transparent;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
}

.start-item:hover,
.start-item:focus-visible {
  background: var(--title-1);
  color: #fff;
}

.start-sep {
  border: 0;
  border-top: 1px solid var(--face-dk);
  border-bottom: 1px solid var(--face-hi);
  margin: 4px 2px;
}

/* ---------- Quick View + 404 pages ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f4f1fb;
  color: var(--ink);
}

.page-header {
  text-align: center;
  padding: 28px 16px 8px;
}

.back-link {
  font-size: 13px;
  font-weight: 700;
  color: #4a3f78;
  text-decoration: underline;
}

.page-header h1 {
  margin: 14px 0 4px;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.3em;
  font-size: 30px;
}

.tagline {
  margin: 0;
  color: #55497e;
}

.quick-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  padding: 20px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  align-content: start;
}

.quick-section {
  background: #fff;
  border: 2px solid #d8d2ee;
  padding: 14px;
}

.quick-section h2 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ph-content {
  width: 100%;
  padding: 18px 10px;
}

.page-footer {
  text-align: center;
  padding: 18px;
  color: #8a80b5;
  font-size: 12px;
}

/* ---------- 404 error screen ---------- */

.error-page {
  background: radial-gradient(circle at 50% 30%, #2b2350, #120e26 70%);
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.error-window {
  width: min(460px, 100%);
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  text-align: left;
}

.error-titlebar {
  padding: 6px 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #6d1030, #a01f3f);
}

.error-body {
  display: flex;
  gap: 16px;
  padding: 20px;
  align-items: flex-start;
}

.error-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #c81e3c;
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  line-height: 44px;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.25);
}

.error-heading {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.error-text p:last-child {
  margin: 0;
  font-size: 13px;
  color: #4a4170;
}

.error-actions {
  padding: 0 20px 20px;
  display: flex;
  justify-content: center;
}

.btn98 {
  display: inline-block;
  padding: 8px 22px;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  cursor: pointer;
}

.btn98:active {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
}

.error-footer {
  color: #9a8fd0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.2em;
  margin: 0;
}

/* ---------- CRT scanlines + flicker (Phase 3) ---------- */

/* Static scanline texture over the whole screen (windows included).
   Static = safe under reduced motion; the gentle flicker below only runs
   when the user's settings allow it. */
.crt-scanlines {
  position: absolute;
  inset: 0;
  z-index: 5000;
  pointer-events: none;
  opacity: 0.85;
  background: repeating-linear-gradient(
    0deg,
    rgba(16, 10, 40, 0.09) 0px,
    rgba(16, 10, 40, 0.09) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* Gentle flicker: a slow opacity wobble (7s cycle, nothing under 300ms).
   Gated on BOTH settings; the motion-off and prefers-reduced-motion rules
   below kill any animation anyway, so no fast flashing is possible. */
html[data-flicker="on"][data-motion="on"] .crt-scanlines {
  animation: crt-flicker 7s ease-in-out infinite;
}

@keyframes crt-flicker {
  0%, 100% { opacity: 0.85; }
  25% { opacity: 0.68; }
  50% { opacity: 0.9; }
  75% { opacity: 0.72; }
}

/* ---------- CRT power-on boot (Phase 3) ----------
   Black screen -> bright line sweeps -> wash out to the desktop.
   js/boot.js unhides and manages it; any key or click skips it. */
.crt-boot {
  position: absolute;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  background: #07070f;
  animation: boot-fade 0.35s linear 0.9s forwards;
}

/* Skip: stop the keyframes and fade out quickly. */
.crt-boot.boot-skipped,
.crt-boot.boot-skipped * {
  animation: none;
}

.crt-boot.boot-skipped {
  transition: opacity 0.22s linear;
  opacity: 0;
}

.boot-glow {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: #d9f3ff;
  box-shadow: 0 0 26px 6px rgba(130, 220, 255, 0.8);
  transform: scaleY(0);
  animation: boot-glow 0.9s ease-in-out forwards;
}

.boot-label {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.35em;
  color: #59e6ff;
  opacity: 0;
  animation: boot-label 0.45s ease-out 0.4s forwards;
}

@keyframes boot-glow {
  0% { transform: scaleY(0); opacity: 0; }
  30% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 1; }
}

@keyframes boot-label {
  to { opacity: 1; }
}

@keyframes boot-fade {
  to { opacity: 0; }
}

/* ---------- frog tips (Phase 3) ---------- */

.frog {
  cursor: pointer;
}

/* Once the real 64×64 sprite lands, drop the dashed placeholder frame. */
.frog.has-asset {
  border: 0;
  background: transparent;
}

.frog-bubble {
  position: absolute;
  right: 12px;
  bottom: calc(var(--taskbar-h) + 12px + 64px + 12px);
  z-index: 4000;
  max-width: 230px;
  padding: 10px 12px;
  background: var(--face-hi);
  border: 2px solid var(--face-dk);
  border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(34, 29, 56, 0.25);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

/* Little tail pointing at the frog */
.frog-bubble::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: var(--face-hi);
  border-right: 2px solid var(--face-dk);
  border-bottom: 2px solid var(--face-dk);
  transform: rotate(45deg);
}

/* ---------- motion handling ---------- */

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- mobile: tappable icon grid ---------- */

@media (max-width: 720px) {
  body.desktop-page {
    display: block;
  }

  /* Phones: full-bleed monitor, no scaling, tappable grid */
  .crt {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 6px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }

  .crt-bezel-top {
    padding: 2px 4px 6px;
  }

  .screen {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 6px;
  }

  .icons {
    position: absolute;
    inset: 10px 10px calc(var(--taskbar-h) + 10px);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 6px;
    padding: 8px;
    overflow-y: auto;
  }

  .icon {
    width: 100%;
    padding: 8px 4px;
  }

  .window {
    left: 8px !important;
    right: 8px !important;
    top: 10px !important;
    width: auto !important;
    min-width: 0;
    max-height: calc(100% - var(--taskbar-h) - 20px);
  }

  .window-body {
    overflow-y: auto;
  }

  .start-menu {
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0;
  }

  .taskbtn {
    max-width: 110px;
  }

  .tray-label {
    display: none;
  }

  .quickview {
    padding: 5px 9px;
  }
}
