/* ============================================================
   Celia OS — a Mac OS 9 flavoured desktop
   ============================================================ */

:root {
  --platinum: #dddddd;
  --platinum-hi: #ffffff;
  --platinum-lo: #9a9a9a;
  --paper: #ececec;
  --ink: #000000;
  --desk: #b9bdd7;
  --wallpaper: url("../images/quantum-foam.jpg");
  --link: #0033a0;
  --focus: #3355aa;
  --font: Chicago, Geneva, Verdana, Tahoma, "DejaVu Sans", sans-serif;
}

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

html { height: 100%; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1c1c1c;
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.45;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; }
a { color: inherit; }

/* ------------------------------------------------------------
   Startup screen
   ------------------------------------------------------------ */
.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: #c4c4c4;
  background-image: radial-gradient(ellipse at center, #d6d6d6 0%, #a4a4a4 100%);
  transition: opacity .45s ease, visibility .45s;
  cursor: default;
}

.boot.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.boot-icon { image-rendering: pixelated; }

.boot-text {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}

.boot-bar {
  width: 190px;
  height: 14px;
  padding: 2px;
  background: #fff;
  border: 1px solid #000;
}

.boot-bar span {
  display: block;
  width: 0;
  height: 100%;
  background-image: repeating-linear-gradient(90deg, #1b3fa0 0 3px, #e8e8e8 3px 5px);
  animation: bootload 2.1s steps(26, end) forwards;
}

@keyframes bootload { to { width: 100%; } }

.boot-hint {
  margin: 0;
  font-size: 11px;
  color: #5a5a5a;
}

/* ------------------------------------------------------------
   Desktop
   ------------------------------------------------------------ */
.desktop {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--desk);
  background-image: var(--wallpaper);
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

.desktop-area {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}

/* ------------------------------------------------------------
   Menu bar
   ------------------------------------------------------------ */
.menubar {
  position: relative;
  z-index: 60;
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  height: 22px;
  padding: 0 4px;
  background: #eeeeee;
  border-bottom: 1px solid #000;
}

.menu-slot {
  position: relative;
  display: flex;
}

.mb-item {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 9px;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: default;
}

.mb-item:hover,
.menu-slot.open > .mb-item {
  background: #000;
  color: #fff;
}

.mb-apple img { display: block; }
.menu-slot.open > .mb-item img { filter: brightness(0) invert(1); }

.mb-clock {
  display: flex;
  align-items: center;
  margin-left: auto;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.menu-drop {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 70;
  display: none;
  min-width: 200px;
  padding: 2px;
  background: #dedede;
  border: 1px solid #000;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
}

.menu-slot.open > .menu-drop { display: block; }

.menu-drop > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 3px 10px;
  background: transparent;
  border: 0;
  font-size: 12px;
  text-align: left;
  cursor: default;
}

.menu-drop > button:hover,
.menu-drop > button:focus-visible {
  background: #000;
  color: #fff;
  outline: none;
}

.menu-drop .sc { font-size: 11px; opacity: .8; }

.menu-drop .sep {
  height: 0;
  margin: 3px 6px;
  border-top: 1px solid #7a7a7a;
  border-bottom: 1px solid #fff;
}

/* ------------------------------------------------------------
   Desktop icons
   ------------------------------------------------------------ */
.desk-icons {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.desk-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 78px;
  padding: 3px 2px;
  background: transparent;
  border: 0;
  color: #11111a;
  font-size: 11px;
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .95), 0 0 3px rgba(255, 255, 255, .8);
  cursor: default;
}

.desk-icon img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3));
  -webkit-user-drag: none;
  user-select: none;
}

.desk-icon-photo img {
  image-rendering: auto;
  object-fit: cover;
  background: #fff;
  outline: 1px solid #1a1a1a;
}

.desk-icon span {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  padding: 0 3px;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.desk-icon:focus { outline: none; }
.desk-icon:focus-visible span { outline: 1px dotted #11111a; outline-offset: 1px; }

.desk-icon.selected span {
  background: #000;
  color: #fff;
  text-shadow: none;
}

.desk-icon.trash {
  position: absolute;
  right: 14px;
  bottom: 16px;
}

/* ------------------------------------------------------------
   Windows
   ------------------------------------------------------------ */
.window {
  position: absolute;
  left: var(--x, 60px);
  top: var(--y, 80px);
  z-index: 10;
  display: none;
  width: var(--w, 320px);
  min-width: 230px;
  min-height: 110px;
  padding: 2px;
  background: var(--platinum);
  border: 1px solid #000;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
}

.window.open {
  display: flex;
  flex-direction: column;
  height: var(--h, auto);
}

.zoom-rect {
  position: fixed;
  z-index: 9999;
  box-sizing: border-box;
  border: 1px dotted #000;
  outline: 1px dotted #fff;
  outline-offset: -2px;
  pointer-events: none;
}

#win-about { --x: 6vw; --y: 12vh; --w: 322px; }
#win-links { --x: calc(6vw + 344px); --y: calc(12vh + 46px); --w: 296px; }
#win-photo { --x: 62vw; --y: 14vh; --w: 300px; --h: 300px; }
#win-video { --x: 46vw; --y: 10vh; --w: 480px; --h: 300px; }
#win-rename { --x: calc(50% - 155px); --y: 30vh; --w: 310px; }
#win-finder { --x: 40vw; --y: 52vh; --w: 430px; --h: 250px; }
#win-trash { --x: calc(50% - 140px); --y: 18vh; --w: 280px; --h: 300px; }

.titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  padding: 0 3px;
  background-image: repeating-linear-gradient(to bottom, #000 0 1px, #fff 1px 2px);
  cursor: grab;
  touch-action: none;
}

.titlebar:active { cursor: grabbing; }

.window:not(.active) .titlebar {
  background-image: repeating-linear-gradient(to bottom, #8a8a8a 0 1px, #fff 1px 2px);
}

.wtitle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 44px);
  padding: 0 6px;
  overflow: hidden;
  background: var(--platinum);
  border-left: 1px solid #000;
  border-right: 1px solid #000;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window:not(.active) .wtitle { color: #8a8a8a; }

.cbox {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  padding: 0;
  background: var(--platinum);
  border: 1px solid #000;
  cursor: default;
}

.cbox:hover,
.cbox:focus-visible { background: #fff; }

.cbox.zoom::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 1px solid #000;
}

.window-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 2px;
  padding: 12px;
  overflow: auto;
  background: var(--paper);
  border: 1px solid #000;
  font-size: 12px;
}

/* ------------------------------------------------------------
   About window
   ------------------------------------------------------------ */
.about-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #9c9c9c;
  box-shadow: 0 1px 0 #fff;
}

.about-head img {
  flex: 0 0 auto;
  image-rendering: pixelated;
}

.about-name {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
  letter-spacing: .01em;
}

.about-meta {
  margin: 3px 0 0;
  font-size: 11px;
  color: #3a3a3a;
}

.about-text { margin: 0 0 12px; }

.about-wish {
  margin: 0 0 12px;
  font-weight: 700;
}

.about-text a {
  color: var(--link);
  text-decoration: underline;
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 3px 14px;
  background: var(--platinum);
  border: 1px solid #000;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 #fff,
    inset 0 -1px 0 var(--platinum-lo),
    inset 1px 0 0 #f4f4f4,
    inset -1px 0 0 var(--platinum-lo);
  font-size: 12px;
  text-decoration: none;
  cursor: default;
}

.btn:hover { background: #e8e8e8; }

.btn:active {
  background: #d0d0d0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}

.btn.default {
  outline: 1px solid #000;
  outline-offset: 1px;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn.default:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   Links window
   ------------------------------------------------------------ */
.links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #000;
  color: #000;
  text-decoration: none;
}

.link-row:hover,
.link-row:focus-visible {
  background: #000;
  color: #fff;
  outline: none;
}

.link-badge {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 700;
}

.link-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.link-txt strong { font-size: 12px; }

.link-txt small {
  font-size: 10px;
  opacity: .75;
  word-break: break-all;
}

.link-arrow {
  margin-left: auto;
  font-size: 13px;
  opacity: .7;
}

.hint {
  margin: 10px 0 0;
  font-size: 10.5px;
  color: #444;
}

/* ------------------------------------------------------------
   Trash window
   ------------------------------------------------------------ */
.trash-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
}

.trash-body img { width: 44px; height: 44px; }
.trash-body p { margin: 0; }

.trash-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trash-list[hidden] { display: none; }

.trash-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  background: #fff;
  border: 1px solid #000;
  font-size: 11px;
  text-align: left;
}

.trash-item img {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.trash-item > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini {
  flex: 0 0 auto;
  padding: 1px 7px;
  background: var(--platinum);
  border: 1px solid #000;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 var(--platinum-lo);
  font-size: 10px;
  cursor: default;
}

.mini:hover { background: #e8e8e8; }
.mini:active { background: #d0d0d0; }

.trash-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-top: 2px;
}

.btn:disabled {
  color: #8a8a8a;
  background: #d8d8d8;
  box-shadow: inset 0 1px 0 #efefef, inset 0 -1px 0 var(--platinum-lo);
}

/* ------------------------------------------------------------
   Resize box (Mac OS 9 size box)
   ------------------------------------------------------------ */
.sizebox {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 2;
  width: 16px;
  height: 16px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(135deg, #000 0 1px, transparent 1px 3px);
  cursor: nwse-resize;
  touch-action: none;
}

/* ------------------------------------------------------------
   Scrollbars (Mac OS 9 platinum)
   ------------------------------------------------------------ */
.vscroll {
  position: absolute;
  right: 2px;
  z-index: 3;
  display: none;
  flex-direction: column;
  width: 16px;
  background: #d6d6d6;
  border: 1px solid #000;
  touch-action: none;
}

.window.has-scroll > .vscroll { display: flex; }

/* Make room for the bar; its own frame replaces the body's right border. */
.window.has-scroll > .window-body:not(.finder-body) {
  margin-right: 16px;
  border-right-width: 0;
}

/* In the Finder only the list scrolls, below the column headers. */
.window.has-scroll .finder-list { margin-right: 15px; }

/* The native bar is replaced by the one below, so keep it out of the way. */
.window-body,
.finder-list { scrollbar-width: none; }

.window-body::-webkit-scrollbar,
.finder-list::-webkit-scrollbar { width: 0; height: 0; }

.sb-arrow {
  position: relative;
  flex: 0 0 auto;
  height: 16px;
  padding: 0;
  background: var(--platinum);
  border: 0;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--platinum-lo);
  cursor: default;
}

.sb-arrow.up { border-bottom: 1px solid #000; }
.sb-arrow.down { border-top: 1px solid #000; }

.sb-arrow::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  transform: translate(-50%, -50%);
}

.sb-arrow.up::after { border-bottom: 5px solid #000; }
.sb-arrow.down::after { border-top: 5px solid #000; }

.sb-arrow:active {
  box-shadow: inset 1px 1px 0 var(--platinum-lo), inset -1px -1px 0 #fff;
}

.sb-track {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background-color: #d8d8d8;
  background-image: radial-gradient(#c3c3c3 1px, transparent 1px);
  background-size: 2px 2px;
}

.sb-knob {
  position: absolute;
  top: 0;
  right: 1px;
  left: 1px;
  height: 24px;
  padding: 0;
  background: var(--platinum);
  border: 1px solid #000;
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--platinum-lo);
  cursor: default;
}

.sb-knob:active { background: #cfcfcf; }

/* ------------------------------------------------------------
   Dragging things around
   ------------------------------------------------------------ */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 500;
  width: 32px;
  height: 32px;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5));
}

.drag-ghost img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.desk-icon[hidden] { display: none; }
.desk-icon.dragging { opacity: .3; }
.desk-icon.drop-target img { transform: scale(1.12); }

.desk-icon.drop-target > span {
  background: #000;
  color: #fff;
  text-shadow: none;
  outline: 1px solid #fff;
}

/* ------------------------------------------------------------
   Zoomed window
   ------------------------------------------------------------ */
.window.zoomed {
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  width: auto;
  height: auto;
}

.window.zoomed .titlebar { cursor: default; }
.window.zoomed .sizebox { display: none; }

.window.zoomed .window-body {
  flex: 1 1 auto;
  margin-top: 2px;
  overflow: auto;
}

/* ------------------------------------------------------------
   Sleep overlay
   ------------------------------------------------------------ */
.sleep {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: #000;
  cursor: pointer;
}

.sleep[hidden] { display: none; }

.sleep p {
  margin: 0;
  color: #4a4a4a;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: color .3s;
}

.sleep:hover p { color: #8a8a8a; }

/* ------------------------------------------------------------
   Photo viewer
   ------------------------------------------------------------ */
.photo-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: #fff;
}

.photo-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

/* ------------------------------------------------------------
   Video player
   ------------------------------------------------------------ */
.video-body {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: #000;
}

.video-body iframe {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.video-note {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: #8a8a8a;
  font-size: 11px;
  pointer-events: none;
}

/* ------------------------------------------------------------
   Rename dialog
   ------------------------------------------------------------ */
.rename-body { padding: 12px; }

.rename-label { margin: 0 0 7px; }

.field {
  width: 100%;
  padding: 3px 6px;
  background: #fff;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 #b0b0b0;
  color: #000;
  font: inherit;
  font-size: 12px;
  user-select: text;
  -webkit-user-select: text;
}

.field:focus {
  outline: 1px solid var(--focus);
  outline-offset: 1px;
}

.rename-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

#win-rename .sizebox,
#win-rename .cbox.zoom { display: none; }

/* ------------------------------------------------------------
   Finder
   ------------------------------------------------------------ */
.finder-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.finder-cols,
.finder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 60px;
  align-items: center;
  gap: 6px;
}

.finder-cols {
  flex: 0 0 auto;
  padding: 2px 8px;
  background: #e2e2e2;
  border-bottom: 1px solid #000;
  font-size: 10.5px;
  font-weight: 700;
  color: #333;
}

.finder-cols span + span {
  padding-left: 6px;
  border-left: 1px solid #b5b5b5;
}

.finder-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 1px 0;
  overflow: auto;
  background: #fff;
  list-style: none;
}

.finder-row {
  width: 100%;
  padding: 1px 8px;
  background: transparent;
  border: 0;
  color: #000;
  font-size: 11px;
  text-align: left;
  cursor: default;
}

.finder-row .f-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.finder-row .f-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finder-row img {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  object-fit: cover;
  image-rendering: auto;
}

.finder-row .f-meta {
  font-size: 10px;
  color: #4a4a4a;
}

.finder-row.selected {
  background: #000;
  color: #fff;
}

.finder-row.selected .f-meta { color: #d8d8d8; }

.finder-row:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -2px;
}

.finder-row.selected:focus-visible { outline-color: #fff; }

.finder-row.drop-target {
  background: #000;
  color: #fff;
}

.finder-row.drop-target .f-meta { color: #d8d8d8; }

.finder-row.dragging { opacity: .4; }

.finder-foot {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  background: #e4e4e4;
  border-top: 1px solid #000;
  font-size: 10.5px;
}

.finder-status {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: #333;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Right-click menu
   ------------------------------------------------------------ */
.ctx-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 400;
  display: none;
  min-width: 190px;
}

.ctx-menu.open { display: block; }

/* ------------------------------------------------------------
   Small screens
   ------------------------------------------------------------ */
@media (max-width: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .desktop {
    position: static;
    height: auto;
    min-height: 100vh;
    background-attachment: fixed;
    background-position: center top;
  }

  .desktop-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    overflow: visible;
  }

  .menubar { position: sticky; top: 0; }

  .desk-icons {
    position: static;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 4px;
    padding-bottom: 2px;
  }

  .desk-icon {
    width: auto;
    min-width: 66px;
  }

  .desk-icon.trash {
    position: static;
    margin-left: auto;
  }

  .window,
  .window.open {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
  }

  .sizebox { display: none; }

  /* Stacked layout: windows grow with their content, so no scrollbars. */
  .window.has-scroll > .vscroll { display: none; }
  .window.has-scroll > .window-body:not(.finder-body) { margin-right: 0; border-right-width: 1px; }
  .window.has-scroll .finder-list { margin-right: 0; }

  .window.zoomed {
    inset: auto;
    display: block;
    height: auto;
  }

  .window.zoomed .window-body {
    flex: none;
    overflow: visible;
  }

  .titlebar { cursor: default; }

  .menu-drop { min-width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot { transition: none; }
  .boot-bar span { animation-duration: .4s; }
}
