/* =========================================================
   BTRX-OS — styles
   colors live at the top. each theme is a "yarn color".
   ========================================================= */

:root {
  /* plum (default) */
  --bg:      #0d0a12;
  --bg-2:    #16111d;
  --bg-3:    #211a2b;
  --line:    #3a2f48;
  --text:    #e9e1f0;
  --dim:     #9a8ca8;
  --accent:  #d9a0e8;
  --accent-2:#8fd6b4;
  --warn:    #f2c46d;
  --shadow:  #000000;

  --font-ui:   "Pixelify Sans", "Courier New", monospace;
  --font-body: "VT323", "Courier New", monospace;
  --win-radius: 0px;
}

:root[data-theme="moss"] {
  --bg: #090d0a; --bg-2: #101711; --bg-3: #172219; --line: #2c3f2f;
  --text: #dfeedd; --dim: #8aa38c; --accent: #9be08a; --accent-2: #e8c77a;
}
:root[data-theme="amber"] {
  --bg: #0f0b07; --bg-2: #18120b; --bg-3: #241a10; --line: #47331c;
  --text: #f6e6cc; --dim: #b39a78; --accent: #ffb04a; --accent-2: #e9806e;
}
:root[data-theme="ink"] {
  --bg: #070a10; --bg-2: #0e1320; --bg-3: #151c2e; --line: #28324d;
  --text: #dde6f7; --dim: #8592b0; --accent: #8fb6ff; --accent-2: #f39ac0;
}
:root[data-theme="rose"] {
  --bg: #100809; --bg-2: #1a0f11; --bg-3: #26161a; --line: #4a2a31;
  --text: #f4e2e4; --dim: #b48d93; --accent: #f08aa2; --accent-2: #a7c8e8;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 21px;
  line-height: 1.3;
  overflow: hidden;
  -webkit-font-smoothing: none;
  transition: background .4s;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }
img { image-rendering: auto; }
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
::selection { background: var(--accent); color: var(--bg); }

/* ---------- desktop ---------- */
.desktop {
  position: fixed;
  inset: 0 0 44px 0;
  background:
    radial-gradient(ellipse at 70% 30%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(ellipse at 20% 90%, color-mix(in srgb, var(--accent-2) 6%, transparent), transparent 55%),
    var(--bg);
  overflow: hidden;
}
/* subtle dotted grid, like graph paper / a crochet chart */
.desktop::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}

.wordmark {
  position: absolute;
  right: 6vw; top: 50%;
  transform: translateY(-58%);
  text-align: right;
  pointer-events: none;
  user-select: none;
}
.wordmark h1 {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: clamp(64px, 15vw, 210px);
  line-height: .85;
  margin: 0;
  letter-spacing: .04em;
  color: transparent;
  -webkit-text-stroke: 2px color-mix(in srgb, var(--accent) 55%, transparent);
  position: relative;
}
.tagline {
  margin: 14px 4px 0 0;
  color: var(--dim);
  font-size: 22px;
  min-height: 1.3em;
}
.tagline::after { content: "▌"; color: var(--accent); animation: blink 1s steps(1) infinite; }

.glitch.go::before, .glitch.go::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  -webkit-text-stroke: 2px var(--accent-2);
  clip-path: inset(0 0 60% 0);
  animation: glitch .5s steps(2) 3;
}
.glitch.go::after { -webkit-text-stroke-color: var(--accent); clip-path: inset(55% 0 0 0); animation-direction: reverse; }
@keyframes glitch {
  0% { transform: translate(-6px, 2px); } 50% { transform: translate(5px, -3px); } 100% { transform: translate(0); }
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- desktop icons ---------- */
.icons {
  position: absolute;
  top: 18px; left: 14px;
  display: grid;
  grid-template-columns: repeat(2, 96px);
  gap: 10px 6px;
  z-index: 2;
}
.icon {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 4px;
  border: 1px dashed transparent;
}
.icon:hover, .icon:focus-visible { border-color: var(--line); background: color-mix(in srgb, var(--bg-3) 70%, transparent); outline: none; }
.icon:active .icon-img { transform: translateY(2px); }
.icon-img { width: 44px; height: 44px; display: block; image-rendering: pixelated; background-size: contain; background-repeat: no-repeat; }
.icon-label {
  font-size: 19px; line-height: 1;
  padding: 2px 4px;
  color: var(--text);
}
.icon:hover .icon-label, .icon:focus-visible .icon-label { background: var(--accent); color: var(--bg); }

/* ---------- the cat ---------- */
.cat {
  position: absolute;
  bottom: 0; left: 46%;
  z-index: 3;
}
.cat-sprite { display: block; width: 64px; height: 40px; background-size: contain; background-repeat: no-repeat; image-rendering: pixelated; }
.cat.awake .cat-sprite { animation: hop .35s steps(2) 2; }
@keyframes hop { 50% { transform: translateY(-6px); } }
.cat-say {
  position: absolute; bottom: 44px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 18px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 1px 8px;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.cat-say.show { opacity: 1; }

/* ---------- windows ---------- */
.win {
  position: absolute;
  min-width: 280px;
  max-width: calc(100vw - 20px);
  max-height: calc(100% - 20px);
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow), 0 0 0 1px #000;
  animation: pop .14s steps(3);
}
.win.focused { border-color: var(--accent); }
.win.minimized { display: none; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

.titlebar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 10px;
  background: var(--bg-3);
  border-bottom: 2px solid var(--line);
  font-family: var(--font-ui);
  font-size: 15px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.win.focused .titlebar {
  background: repeating-linear-gradient(0deg, var(--bg-3) 0 2px, color-mix(in srgb, var(--accent) 16%, var(--bg-3)) 2px 4px);
}
.titlebar:active { cursor: grabbing; }
.titlebar .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win.focused .titlebar .t { color: var(--accent); }
.tb-btn {
  width: 22px; height: 20px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-family: var(--font-ui);
  font-size: 13px; line-height: 1;
}
.tb-btn:hover { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.win-body { overflow: auto; padding: 16px 18px 20px; flex: 1; }
.win-body::-webkit-scrollbar { width: 12px; }
.win-body::-webkit-scrollbar-track { background: var(--bg-2); border-left: 1px solid var(--line); }
.win-body::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--bg-2); }
.statusbar {
  border-top: 1px solid var(--line);
  padding: 2px 10px;
  font-size: 17px;
  color: var(--dim);
  display: flex; justify-content: space-between; gap: 12px;
}

/* ---------- shared bits inside windows ---------- */
.win h2 { font-family: var(--font-ui); font-weight: 600; font-size: 26px; margin: 0 0 8px; color: var(--accent); }
.win h3 { font-family: var(--font-ui); font-weight: 400; font-size: 19px; margin: 18px 0 6px; color: var(--accent-2); }
.win p { margin: 0 0 12px; }
.dim { color: var(--dim); }
.tag {
  display: inline-block;
  font-size: 17px; line-height: 1;
  padding: 3px 6px 2px;
  border: 1px solid var(--line);
  color: var(--dim);
  margin: 0 4px 4px 0;
}
.back {
  color: var(--dim); font-size: 19px; margin-bottom: 10px;
}
.back:hover { color: var(--accent); }
.empty { color: var(--dim); text-align: center; padding: 30px 10px; }

/* about */
.about-grid { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start; }
.avatar { width: 96px; height: 96px; image-rendering: pixelated; border: 2px solid var(--line); background: var(--bg-3); }
.likes { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 20px; }
.likes li::before { content: "♡ "; color: var(--accent); }
.currently { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
.currently dt { color: var(--dim); }
.currently dd { margin: 0; }
.visits { margin-top: 18px; font-size: 18px; color: var(--dim); border-top: 1px dashed var(--line); padding-top: 10px; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.thumb { text-align: left; display: block; }
.thumb .frame {
  aspect-ratio: 1;
  background: var(--bg-3);
  border: 2px solid var(--line);
  overflow: hidden;
  display: block;
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform .1s steps(2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover .frame, .thumb:focus-visible .frame { border-color: var(--accent); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shadow); }
.thumb .cap { display: block; margin-top: 6px; font-size: 19px; line-height: 1.1; }
.thumb .cap small { display: block; color: var(--dim); font-size: 16px; }

.viewer img {
  display: block;
  max-width: 100%;
  max-height: 58vh;
  margin: 0 auto 14px;
  border: 2px solid var(--line);
  background: var(--bg-3);
}
.viewer-nav { display: flex; justify-content: space-between; margin-top: 14px; }
.btn {
  border: 2px solid var(--line);
  background: var(--bg-3);
  padding: 3px 12px;
  font-size: 19px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.heart { font-size: 19px; color: var(--dim); }
.heart.on { color: var(--accent); }

/* thoughts */
.entries { list-style: none; margin: 0; padding: 0; }
.entries li + li { border-top: 1px dashed var(--line); }
.entry-link { display: flex; gap: 14px; width: 100%; text-align: left; padding: 8px 4px; }
.entry-link:hover { background: var(--bg-3); }
.entry-link:hover .entry-title { color: var(--accent); }
.entry-date { color: var(--dim); white-space: nowrap; }
.entry-title { flex: 1; }
.entry-mood { color: var(--dim); }
.entry-text { white-space: pre-wrap; max-width: 60ch; font-size: 22px; }
.entry-text p { margin: 0 0 14px; }
.entry-head { color: var(--dim); margin-bottom: 14px; }

/* designs */
.design-card { display: grid; grid-template-columns: 120px 1fr; gap: 14px; text-align: left; width: 100%; padding: 10px; border: 1px solid transparent; }
.design-card + .design-card { margin-top: 8px; }
.design-card:hover { border-color: var(--line); background: var(--bg-3); }
.design-card img { width: 120px; height: 120px; object-fit: cover; border: 2px solid var(--line); background: var(--bg-3); }
.design-card .name { font-size: 23px; color: var(--accent); display: block; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: 0 14px; margin: 10px 0 14px; }
.specs dt { color: var(--dim); }
.specs dd { margin: 0; }
.pattern {
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 20px;
  margin: 0 0 12px;
}
.design-hero { display: block; max-width: 100%; max-height: 42vh; border: 2px solid var(--line); background: var(--bg-3); margin-bottom: 12px; }

/* bookshelf */
.shelf {
  display: flex; align-items: flex-end; gap: 3px;
  padding: 0 10px;
  min-height: 170px;
  border-bottom: 10px solid var(--line);
  box-shadow: 0 6px 0 var(--shadow);
  margin-bottom: 18px;
  overflow-x: auto;
}
.spine {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  width: 38px;
  padding: 10px 0;
  font-size: 17px;
  line-height: 38px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 2px solid rgba(0,0,0,.45);
  color: rgba(255,255,255,.88);
  flex-shrink: 0;
  transition: transform .12s steps(2);
}
.spine.lean { transform: rotate(186deg) translateX(-4px); margin: 0 6px; }
.spine:hover, .spine:focus-visible, .spine.sel { transform: rotate(180deg) translateY(12px); }
.shelf-label { font-family: var(--font-ui); font-size: 14px; color: var(--dim); margin: 0 0 4px; text-transform: uppercase; letter-spacing: .1em; }
.book-detail { min-height: 90px; border: 1px dashed var(--line); padding: 10px 14px; }
.stars { color: var(--warn); letter-spacing: 2px; }

/* doodle */
.doodle { display: flex; gap: 14px; flex-wrap: wrap; }
.doodle canvas {
  width: 320px; height: 320px;
  max-width: 100%;
  image-rendering: pixelated;
  border: 2px solid var(--line);
  background: var(--bg);
  cursor: crosshair;
  touch-action: none;
  aspect-ratio: 1;
}
.doodle-tools { display: flex; flex-direction: column; gap: 10px; min-width: 120px; }
.swatches { display: grid; grid-template-columns: repeat(4, 26px); gap: 4px; }
.swatch { width: 26px; height: 26px; border: 2px solid var(--line); }
.swatch.on { outline: 2px solid var(--text); outline-offset: 1px; }

/* guestbook */
.gb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gb-head h2 { margin: 0; }
.gb-entry { display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 12px 0; border-top: 1px dashed var(--line); }
.gb-stamp { font-size: 28px; line-height: 1; color: var(--accent); text-align: center; padding-top: 2px; }
.win .gb-meta { margin: 0 0 2px; }
.gb-meta strong { color: var(--accent-2); font-weight: normal; }
.win .gb-msg { white-space: pre-wrap; margin: 0 0 6px; overflow-wrap: anywhere; }
.win .gb-reply { margin: 0; padding-left: 10px; border-left: 2px solid var(--accent); color: var(--dim); }
.gb-reply span { color: var(--accent); }
.gb-form { display: flex; flex-direction: column; gap: 6px; max-width: 460px; }
.gb-form label, .gb-label { color: var(--dim); margin-top: 8px; display: flex; justify-content: space-between; }
.field {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  padding: 6px 10px;
  resize: vertical;
}
.field:focus { border-color: var(--accent); outline: none; }
.gb-stamps { display: flex; flex-wrap: wrap; gap: 4px; }
.gb-pick { width: 38px; height: 38px; border: 2px solid var(--line); font-size: 20px; color: var(--dim); }
.gb-pick:hover { color: var(--text); }
.gb-pick.on { border-color: var(--accent); background: var(--bg-3); color: var(--accent); }
.gb-form .btn { align-self: flex-start; margin-top: 12px; }
.win .gb-status { min-height: 1.3em; margin: 4px 0 0; color: var(--warn); }
.gb-trap { position: absolute; left: -9999px; }
.win .gb-sent { font-size: 30px; color: var(--accent); margin-bottom: 6px; }

/* ---------- taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 44px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px;
  background: var(--bg-2);
  border-top: 2px solid var(--line);
  z-index: 9000;
}
.start-btn {
  font-family: var(--font-ui);
  font-size: 16px;
  padding: 4px 12px;
  border: 2px solid var(--line);
  background: var(--bg-3);
  color: var(--accent);
}
.start-btn:hover, .start-btn[aria-expanded="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.tasks { flex: 1; display: flex; gap: 4px; overflow: hidden; min-width: 0; }
.task {
  max-width: 160px; min-width: 0;
  padding: 3px 10px;
  border: 1px solid var(--line);
  font-size: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--dim);
}
.task.active { color: var(--text); border-color: var(--accent); background: var(--bg-3); }
.tray { display: flex; align-items: center; gap: 2px; border-left: 1px solid var(--line); padding-left: 6px; }
.tray-btn { width: 30px; height: 30px; font-size: 18px; color: var(--dim); }
.tray-btn:hover, .tray-btn.on { color: var(--accent); }
.clock { font-size: 19px; padding: 0 6px; color: var(--dim); min-width: 62px; text-align: right; }

.start-menu {
  position: fixed; left: 6px; bottom: 50px;
  z-index: 9001;
  width: 220px;
  background: var(--bg-2);
  border: 2px solid var(--accent);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 0 0 6px;
}
.start-title {
  margin: 0 0 6px; padding: 8px 12px;
  font-family: var(--font-ui); font-size: 14px; letter-spacing: .2em;
  background: var(--accent); color: var(--bg);
}
.start-menu button { display: block; width: 100%; text-align: left; padding: 4px 14px; font-size: 20px; }
.start-menu button:hover, .start-menu button:focus-visible { background: var(--bg-3); color: var(--accent); outline: none; }
.start-menu hr { border: 0; border-top: 1px dashed var(--line); margin: 6px 0; }

/* ---------- boot + shutdown ---------- */
.boot, .shutdown {
  position: fixed; inset: 0;
  z-index: 10000;
  background: #050407;
  color: var(--accent);
  padding: 6vh 7vw;
  cursor: pointer;
}
.boot.done { animation: off .45s forwards; }
@keyframes off {
  60% { transform: scaleY(.01); opacity: 1; }
  100% { transform: scaleY(0) scaleX(0); opacity: 0; }
}
.boot-text { font-family: var(--font-body); font-size: 22px; margin: 0; white-space: pre-wrap; }
.boot-skip { position: absolute; bottom: 5vh; left: 7vw; color: var(--dim); animation: blink 1.4s steps(1) infinite; margin: 0; }
.shutdown { display: grid; place-content: center; text-align: center; color: var(--warn); font-size: 26px; }
.shutdown[hidden] { display: none; }

/* ---------- crt effect ---------- */
.crt-overlay {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 20000;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,.55) 100%);
  animation: flicker 6s infinite;
}
:root.no-crt .crt-overlay { display: none; }
@keyframes flicker { 0%, 100% { opacity: .9; } 50% { opacity: .82; } 51% { opacity: .95; } }

/* sparkle cursor trail */
.spark {
  position: fixed;
  pointer-events: none;
  z-index: 19999;
  color: var(--accent);
  font-size: 14px;
  animation: spark .8s forwards;
}
@keyframes spark { to { transform: translateY(18px) scale(.3); opacity: 0; } }

/* ---------- phones: windows become full sheets ---------- */
@media (max-width: 720px) {
  body { font-size: 20px; }
  .icons { grid-template-columns: repeat(3, 1fr); left: 10px; right: 10px; top: 14px; }
  .wordmark { right: 16px; left: 16px; top: 58%; transform: translateY(-50%); text-align: center; }
  .wordmark h1 { font-size: 29vw; }
  .tagline { margin-right: 0; }
  .win {
    left: 6px !important; top: 6px !important;
    width: calc(100vw - 12px) !important;
    height: calc(100% - 12px) !important;
    max-height: none;
  }
  .titlebar { cursor: default; font-size: 16px; padding: 7px 8px 7px 12px; }
  .tb-btn { width: 30px; height: 28px; }
  .about-grid { grid-template-columns: 1fr; }
  .likes { columns: 1; }
  .design-card { grid-template-columns: 84px 1fr; }
  .design-card img { width: 84px; height: 84px; }
  .tray-btn#sparkle-btn { display: none; }
  .clock { display: none; }
  .cat { left: auto; right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
