/* =========================================================================
   Rangkaian — Windows 95/98 + PuTTY
   ========================================================================= */

@font-face {
  font-family: "Pixelated MS Sans Serif";
  src: url("../assets/fonts/ms_sans_serif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Pixelated MS Sans Serif";
  src: url("../assets/fonts/ms_sans_serif_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Windows 98 standard palette */
  --desktop: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --hilight: #ffffff;
  --shadow: #808080;
  --dkshadow: #0a0a0a;
  --title: #000080;
  --title-text: #ffffff;
  --title-inactive: #808080;
  --title-inactive-text: #c0c0c0;

  /* PuTTY default colours */
  --term-bg: #000000;
  --term-fg: #bbbbbb;
  --term-green: #00bb00;

  --ui-font: "Pixelated MS Sans Serif", "Microsoft Sans Serif", "MS Sans Serif", Tahoma, Geneva, Arial, sans-serif;
  --term-font: "IBM Plex Mono", "Courier New", Courier, "Liberation Mono", monospace;

  --taskbar-h: 28px;
  --ui-zoom: 1;
  --term-fs: 15px;
  --term-lh: 19px;
  --term-cols: 80;
  --term-rows: 26;

  /* Pixel glyphs (title-bar controls, scrollbar arrows, dither) */
  --glyph-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='7'%3E%3Cpath fill-rule='evenodd' d='M0 0h2v1h1v1h2V1h1V0h2v1H7v1H6v1H5v1h1v1h1v1h1v1H6V6H5V5H3v1H2v1H0V6h1V5h1V4h1V3H2V2H1V1H0z' fill='%23000'/%3E%3C/svg%3E");
  --glyph-min: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='2'%3E%3Crect width='6' height='2' fill='%23000'/%3E%3C/svg%3E");
  --glyph-max: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9'%3E%3Cpath fill-rule='evenodd' d='M9 0H0v9h9zM8 2H1v6h7z' fill='%23000'/%3E%3C/svg%3E");
  --glyph-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4'%3E%3Cpath d='M3 0h1v1h1v1h1v1h1v1H0V3h1V2h1V1h1z' fill='%23000'/%3E%3C/svg%3E");
  --glyph-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z' fill='%23000'/%3E%3C/svg%3E");
  --dither: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23c0c0c0'/%3E%3Crect width='1' height='1' fill='%23fff'/%3E%3Crect x='1' y='1' width='1' height='1' fill='%23fff'/%3E%3C/svg%3E");
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--desktop);
}

body {
  font-family: var(--ui-font);
  font-size: 11px;
  line-height: 13px;
  color: #000;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body.busy,
body.busy * { cursor: progress !important; }

img { image-rendering: pixelated; }

button {
  font: inherit;
  color: inherit;
  margin: 0;
  border: 0;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

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

.desktop {
  position: fixed;
  inset: 0 0 calc(var(--taskbar-h) * var(--ui-zoom)) 0;
  overflow: hidden;
  background: var(--desktop);
}

.icons {
  zoom: var(--ui-zoom);
  list-style: none;
  margin: 0;
  padding: 2px 0 0 0;
  display: flex;
  flex-direction: column;
}

.icon {
  width: 75px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  color: #fff;
  text-align: center;
  outline: none;
}
.icon img { display: block; margin-bottom: 4px; }
.icon span {
  padding: 1px 2px;
  border: 1px dotted transparent;
}
.icon.selected img { filter: brightness(0.55) sepia(1) hue-rotate(185deg) saturate(6); }
.icon.selected span {
  background: var(--title);
  border-color: #ffff80;
}

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

.window {
  position: absolute;
  background: var(--face);
  padding: 3px;
  box-shadow:
    inset -1px -1px var(--dkshadow),
    inset 1px 1px var(--light),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--hilight);
}

.titlebar {
  display: flex;
  align-items: center;
  height: 18px;
  padding: 0 2px 0 3px;
  background: var(--title);
  color: var(--title-text);
  font-weight: 700;
}
.window.inactive .titlebar {
  background: var(--title-inactive);
  color: var(--title-inactive-text);
}

.titlebar-icon { margin-right: 3px; flex: none; }

.titlebar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0;
}

.titlebar-controls { display: flex; flex: none; }

.tb-btn {
  width: 16px;
  height: 14px;
  padding: 0;
  background-color: var(--face);
  background-repeat: no-repeat;
  background-position: center;
  box-shadow:
    inset -1px -1px var(--dkshadow),
    inset 1px 1px var(--hilight),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
}
.tb-btn:active {
  box-shadow:
    inset -1px -1px var(--hilight),
    inset 1px 1px var(--dkshadow),
    inset -2px -2px var(--light),
    inset 2px 2px var(--shadow);
  background-position: calc(50% + 1px) calc(50% + 1px);
}
.tb-close { background-image: var(--glyph-close); background-position: 3px 3px; }
.tb-close:active { background-position: 4px 4px; }
.tb-min { background-image: var(--glyph-min); background-position: 4px 9px; }
.tb-min:active { background-position: 5px 10px; }
.tb-max { background-image: var(--glyph-max); background-position: 3px 2px; }
.tb-max:active { background-position: 4px 3px; }
.tb-gap { margin-left: 2px; }

/* ------------------------------------------------------------------ Buttons */

.btn {
  min-width: 75px;
  height: 23px;
  padding: 0 12px;
  background: var(--face);
  text-align: center;
  box-shadow:
    inset -1px -1px var(--dkshadow),
    inset 1px 1px var(--hilight),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--light);
}

/* The default button of a dialog carries an extra black frame */
.btn.default {
  box-shadow:
    inset 0 0 0 1px #000,
    inset -2px -2px var(--dkshadow),
    inset 2px 2px var(--hilight),
    inset -3px -3px var(--shadow),
    inset 3px 3px var(--light);
}
.btn:focus { outline: 1px dotted #000; outline-offset: -5px; }
.btn:focus:not(.default) { outline-offset: -4px; }

.btn:active,
.btn.pressed {
  padding-top: 2px;
  padding-left: 14px;
  padding-right: 10px;
  box-shadow:
    inset -1px -1px var(--hilight),
    inset 1px 1px var(--dkshadow),
    inset -2px -2px var(--light),
    inset 2px 2px var(--shadow);
}
.btn.default:active,
.btn.default.pressed {
  box-shadow:
    inset 0 0 0 1px #000,
    inset 0 0 0 2px var(--shadow);
}

/* ------------------------------------------------------------------ Message box */

.msgbox {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 580px;
  max-width: calc(100vw - 20px);
  z-index: 20;
}
.msgbox.placed { transform: none; }

.msgbox .titlebar {
  height: 22px;
  padding: 0 3px 0 4px;
}
.msgbox .titlebar-text {
  font-size: 12px;
  line-height: 22px;
}
.msgbox .tb-btn {
  width: 18px;
  height: 16px;
}

.msgbox-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 22px 18px 16px;
}
.msgbox-logo {
  height: 38px;
  width: auto;
  max-width: 44%;
  object-fit: contain;
  image-rendering: auto;
}
.logo-sep {
  display: inline-block;
  width: 2px;
  height: 34px;
  flex: none;
  box-shadow: inset 1px 0 var(--shadow), inset -1px 0 var(--hilight);
}

.etched {
  height: 2px;
  margin: 0 10px;
  border: 0;
  box-shadow: inset 0 1px var(--shadow), inset 0 -1px var(--hilight);
}

.msgbox-body {
  padding: 18px 28px 12px;
  text-align: center;
  display: block;
}
.msgbox-text {
  width: 100%;
  margin: 0;
  user-select: text;
  -webkit-user-select: text;
}
.msgbox-heading {
  margin: 0 0 14px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #000;
  text-align: center;
}
.msgbox-text .notice {
  margin: 0 auto 18px;
  max-width: 510px;
  font-size: 13.5px;
  line-height: 22px;
  color: #111;
  text-align: center;
  white-space: normal;
}
.msgbox-text .notice strong {
  font-weight: 700;
  color: #000;
}
.pantun-wrap {
  margin: 18px auto 4px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  display: block;
  text-align: center;
}
.msgbox-text .pantun {
  margin: 0;
  font-size: 14.5px;
  line-height: 24px;
  color: #000;
  letter-spacing: 0.3px;
  white-space: normal;
  font-style: italic;
}
.msgbox-text .attribution {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 18px;
  color: #222;
  font-style: normal;
  font-weight: 700;
  text-align: center;
}

.msgbox-actions {
  display: flex;
  justify-content: center;
  padding: 14px 0 16px;
}
.msgbox-actions .btn.default {
  min-width: 95px;
  height: 26px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ PuTTY */

.putty { z-index: 10; }
.putty .titlebar { zoom: var(--ui-zoom); }

.putty-frame {
  display: flex;
  margin-top: 1px;
  background: var(--term-bg);
}

.term-viewport {
  position: relative;
  overflow: hidden;
  background: var(--term-bg);
  font-family: var(--term-font);
  font-size: var(--term-fs);
  line-height: var(--term-lh);
  width: calc(var(--term-cols) * 1ch + 6px);
  height: calc(var(--term-rows) * var(--term-lh) + 4px);
  max-width: calc(100vw - 16px - 6px - 16px);
  max-height: calc(100dvh - var(--taskbar-h) * var(--ui-zoom) - 18px * var(--ui-zoom) - 28px);
}

.term {
  margin: 0;
  padding: 2px 3px;
  min-height: 100%;
  color: var(--term-fg);
  font: inherit;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: break-word;
  -webkit-font-smoothing: auto;
  font-variant-ligatures: none;
  font-kerning: none;
}
.term .ok { color: var(--term-green); }

.cursor {
  display: inline-block;
  width: 1ch;
  background: var(--term-fg);
  color: var(--term-bg);
  animation: blink 1.06s step-end infinite;
}
.term.typing .cursor { animation: none; }
.putty.inactive .cursor {
  animation: none;
  background: transparent;
  outline: 1px solid var(--term-fg);
  outline-offset: -1px;
}

@keyframes blink {
  50% { visibility: hidden; }
}

/* Classic Win98 scrollbar (decorative; reflects the terminal scroll position) */
.scrollbar {
  flex: none;
  width: 16px;
  display: flex;
  flex-direction: column;
  background: var(--face);
}
.sb-btn {
  flex: none;
  height: 16px;
  background-color: var(--face);
  background-repeat: no-repeat;
  background-position: 4px 6px;
  box-shadow:
    inset -1px -1px var(--dkshadow),
    inset 1px 1px var(--light),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--hilight);
}
.sb-up { background-image: var(--glyph-up); }
.sb-down { background-image: var(--glyph-down); }
.sb-track {
  position: relative;
  flex: 1;
  background: var(--dither);
}
.sb-thumb {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  background: var(--face);
  box-shadow:
    inset -1px -1px var(--dkshadow),
    inset 1px 1px var(--light),
    inset -2px -2px var(--shadow),
    inset 2px 2px var(--hilight);
}
.sb-thumb.full { display: none; }
.sb-track:has(.sb-thumb.full) { background: var(--dither); }

/* ------------------------------------------------------------------ Taskbar */

.taskbar {
  zoom: var(--ui-zoom);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--taskbar-h);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 2px 2px;
  background: var(--face);
  box-shadow: inset 0 1px var(--light), inset 0 2px var(--hilight);
  z-index: 50;
}

.btn.start {
  flex: none;
  min-width: 0;
  height: 22px;
  padding: 0 5px 0 3px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.btn.start:active { padding: 2px 4px 0 4px; }
.btn.start img { image-rendering: auto; }

.tb-sep {
  flex: none;
  width: 2px;
  height: 20px;
  margin: 0 1px;
  box-shadow: inset 1px 0 var(--shadow), inset -1px 0 var(--hilight);
}

.tasks {
  flex: 1;
  min-width: 0;
  display: flex;
}

.btn.task {
  min-width: 0;
  width: 160px;
  max-width: 100%;
  height: 22px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  text-align: left;
}
.btn.task span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.btn.task.active {
  font-weight: 700;
  padding: 2px 3px 0 5px;
  background: var(--dither);
  box-shadow:
    inset -1px -1px var(--hilight),
    inset 1px 1px var(--dkshadow),
    inset -2px -2px var(--light),
    inset 2px 2px var(--shadow);
}

.tray {
  flex: none;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 4px;
  box-shadow: inset -1px -1px var(--hilight), inset 1px 1px var(--shadow);
}

.tray-sound {
  position: relative;
  width: 16px;
  height: 16px;
  padding: 0;
  background: transparent;
  cursor: default;
}
.tray-sound img { display: block; }
.tray-sound:focus-visible { outline: 1px dotted #000; outline-offset: 1px; }
/* Muted: classic red "no" sign over the speaker */
.tray-sound[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' shape-rendering='crispEdges'%3E%3Ccircle cx='4.5' cy='4.5' r='3.6' fill='none' stroke='%23f00' stroke-width='1.6'/%3E%3Cpath d='M2 2l5 5' stroke='%23f00' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat;
}

.clock {
  min-width: 52px;
  text-align: right;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ Power off */

.poweroff {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 1.6s linear;
  outline: none;
}
.poweroff.on {
  opacity: 1;
  pointer-events: auto;
  cursor: none;
}
.poweroff.instant { transition: none; }

/* ------------------------------------------------------------------ Utilities */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ Responsive */

@media (max-width: 720px) {
  :root {
    --term-fs: 13px;
    --term-lh: 16px;
  }
  .msgbox {
    width: calc(100vw - 16px);
  }
  .msgbox-banner {
    padding: 16px 12px 12px;
    gap: 10px;
  }
  .msgbox-logo {
    height: 26px;
    max-width: 44%;
  }
  .logo-sep {
    height: 24px;
  }
  .msgbox-body {
    padding: 14px 16px 10px;
  }
  .msgbox-text .notice {
    font-size: 12px;
    line-height: 18px;
    margin-bottom: 12px;
  }
  .msgbox-text .pantun {
    font-size: 13.5px;
    line-height: 21px;
  }
}

@media (max-width: 640px) and (pointer: coarse), (max-width: 480px) {
  :root { --ui-zoom: 1.25; }
}

@media (max-width: 480px) {
  :root {
    --term-fs: 8.5px;
    --term-lh: 12px;
  }
}

@media (max-height: 420px) and (pointer: coarse) {
  :root { --ui-zoom: 1; }
}


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