/* Works — "Titik OS", a small desktop to browse the selected work like your own laptop.
 *
 * Icons, explorer and viewer windows, a taskbar with a live Jakarta clock. Windows use the
 * brand's three dots as their controls (minimise · maximise · close), so it reads as its own
 * OS rather than an imitation of one. desk.js handles opening, dragging, stacking and the
 * taskbar; without JS, .desk__fallback lists the projects as plain links.
 */

.desk {
  --desk-bar-h: 2.75rem;
  display: grid;
  gap: var(--space-sm);
}

/* Monitor: a black bezel with a glass sheen and a camera dot, on a silver stand. */
.monitor {
  display: grid;
  justify-items: center;
}

.monitor__bezel {
  position: relative;
  width: 100%;
  padding: clamp(0.5rem, 1.1vw, 0.9rem);
  padding-block-end: clamp(0.75rem, 1.6vw, 1.25rem); /* slightly deeper chin */
  border-radius: calc(var(--radius-lg) + 0.25rem);
  background-image: linear-gradient(150deg, var(--color-ink-3), var(--color-ink) 35%, var(--color-ink) 70%, var(--color-ink-2));
  box-shadow:
    inset 0 0 0 1px color-mix(in oklch, var(--color-paper) 14%, transparent),
    0 2.5rem 3rem -2.25rem var(--color-shadow);
}

/* camera */
.monitor__bezel::before {
  content: "";
  position: absolute;
  inset-block-start: calc(clamp(0.5rem, 1.1vw, 0.9rem) / 2 - 0.15rem);
  left: 50%;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background-color: var(--color-ink-3);
  translate: -50% 0;
}

/* glass sheen across the screen — above the content, never in the way of clicks */
.monitor__bezel::after {
  content: "";
  position: absolute;
  inset: clamp(0.5rem, 1.1vw, 0.9rem);
  inset-block-end: clamp(0.75rem, 1.6vw, 1.25rem);
  z-index: 1; /* above the screen (its own stacking context), below the fixed header */
  border-radius: 0.5rem;
  background-image: linear-gradient(115deg, color-mix(in oklch, var(--color-paper) 16%, transparent) 0%, color-mix(in oklch, var(--color-paper) 5%, transparent) 38%, transparent 38.5%, transparent 100%);
  pointer-events: none;
}

.monitor__stand {
  display: grid;
  justify-items: center;
  width: 100%;
}

.monitor__neck {
  width: clamp(4.5rem, 14%, 10rem);
  height: clamp(1.75rem, 4vw, 3.25rem);
  background-image: linear-gradient(to right, var(--color-rule), var(--color-paper-2) 30%, var(--color-paper) 50%, var(--color-paper-2) 70%, var(--color-rule));
  clip-path: polygon(14% 0, 86% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 0.5rem 0.75rem -0.5rem var(--color-shadow);
}

.monitor__foot {
  width: clamp(8rem, 30%, 20rem);
  height: clamp(0.5rem, 1vw, 0.75rem);
  border-radius: 50% 50% var(--radius-pill) var(--radius-pill) / 100% 100% 100% 100%;
  background-image: linear-gradient(to bottom, var(--color-paper), var(--color-rule));
  box-shadow: 0 0.6rem 1rem -0.4rem var(--color-shadow);
}

.desk__screen {
  position: relative;
  isolation: isolate;
  overflow: clip;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 0.5rem; /* the panel inside the bezel */
  background-color: var(--color-ink);
  user-select: none;
}

@media (min-width: 40rem) {
  .desk__screen {
    aspect-ratio: 4 / 3;
  }
}

@media (min-width: 64rem) {
  .desk__screen {
    aspect-ratio: 16 / 8.5;
  }
}

.desk__wallpaper {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.desk__hint {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (hover: none) {
  .desk__hint {
    display: none;
  }
}

/* Without JS: no desktop, just the list. */
.desk__fallback {
  display: none;
}

html:not(.js) .desk__screen,
html:not(.js) .desk__hint {
  display: none;
}

html:not(.js) .desk__fallback {
  display: grid;
  gap: var(--space-sm);
}

.desk__fallback a {
  font-weight: 700;
}

.desk__fallback span {
  color: var(--color-muted);
}

/* Icons ---------------------------------------------------------------------- */

.desk__icons {
  position: absolute;
  inset-block: var(--space-md) calc(var(--desk-bar-h) + var(--space-md));
  inset-inline-start: var(--space-md);
  z-index: 1;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: var(--space-sm);
}

.desk-icon {
  display: grid;
  justify-items: center;
  gap: var(--space-2xs);
  width: 6rem;
  padding: var(--space-xs) var(--space-2xs);
  border: var(--rule-hair) solid transparent;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--color-paper);
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: default;
  --color-focus: var(--color-lime);
}

.desk-icon__label {
  max-width: 100%;
  padding: 0 var(--space-2xs);
  border-radius: 0.25rem;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.3;
  text-shadow: 0 1px 3px var(--color-shadow);
  overflow-wrap: anywhere;
}

@media (hover: hover) {
  .desk-icon:hover {
    border-color: color-mix(in oklch, var(--color-paper) 30%, transparent);
    background-color: color-mix(in oklch, var(--color-paper) 14%, transparent);
  }
}

.desk-icon.is-selected {
  border-color: color-mix(in oklch, var(--color-lime) 70%, transparent);
  background-color: color-mix(in oklch, var(--color-lime) 22%, transparent);
}

.desk-icon.is-selected .desk-icon__label {
  background-color: var(--color-lime);
  color: var(--color-ink);
  text-shadow: none;
}

/* Glyphs: drawn in CSS, so no icon set to license or mismatch. */
.desk-icon__glyph {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 2.75rem;
}

.desk-icon__glyph--folder {
  margin-block-start: 0.4rem;
  border-radius: 0.3rem 0.45rem 0.45rem 0.45rem;
  background-color: var(--color-blue);
  box-shadow: inset 0 -0.6rem 0 color-mix(in oklch, var(--color-blue-deep) 55%, transparent);
}

.desk-icon__glyph--folder::before {
  content: "";
  position: absolute;
  inset-block-start: -0.4rem;
  inset-inline-start: 0;
  width: 45%;
  height: 0.6rem;
  border-radius: 0.3rem 0.3rem 0 0;
  background-color: var(--color-blue);
}

.desk-icon__glyph--file {
  width: 2.5rem;
  height: 3.1rem;
  border-radius: 0.25rem;
  background-color: var(--color-paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 0.45rem, var(--color-rule) 0.45rem calc(0.45rem + 2px));
  background-position: 0.45rem 0.85rem;
  background-size: calc(100% - 0.9rem) calc(100% - 1.3rem);
  background-repeat: no-repeat;
  box-shadow: 0 0.25rem 0.75rem -0.25rem var(--color-shadow);
}

.desk-icon__glyph--app {
  width: 3rem;
  height: 3rem;
  border-radius: 0.8rem;
  background-color: var(--color-lime);
  color: var(--color-ink);
  box-shadow: 0 0.25rem 0.75rem -0.25rem var(--color-shadow);
}

.desk-icon__mark {
  width: 1.75rem;
  height: auto;
}

.desk-icon__badge {
  width: 1.6rem;
  height: 1.6rem;
  fill: var(--color-paper);
}

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

.win {
  --x: 0px;
  --y: 0px;
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(var(--win-w, 32rem), calc(100% - 2 * var(--space-md)));
  max-height: calc(100% - var(--desk-bar-h) - 2 * var(--space-md));
  overflow: hidden;
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-ink) 15%, transparent);
  border-radius: var(--radius-md);
  background-color: var(--color-paper);
  color: var(--color-ink);
  box-shadow: 0 1.5rem 3rem -1rem var(--color-shadow);
  translate: var(--x) var(--y);
  user-select: text;
}

.win[hidden] {
  display: none;
}

.win.is-min {
  display: none;
}

.win.is-max {
  translate: 0 0;
  inset: 0 0 var(--desk-bar-h);
  width: auto;
  max-height: none;
  border-radius: 0;
}

.win.is-front {
  box-shadow: 0 2rem 4rem -1rem var(--color-shadow), 0 0 0 2px color-mix(in oklch, var(--color-blue) 45%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .win.is-opening {
    animation: win-open var(--dur-short) var(--ease-out);
  }
}

@keyframes win-open {
  from {
    opacity: 0;
    scale: 0.92;
  }
}

.win--note {
  --win-w: 22rem;
}

.win--explorer {
  --win-w: 34rem;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.win--viewer {
  --win-w: 40rem;
}

.win__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: 2.5rem;
  padding: 0 var(--space-xs) 0 var(--space-md);
  background-color: var(--color-paper-2);
  border-block-end: var(--rule-hair) solid var(--color-rule);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.win.is-dragging .win__bar {
  cursor: grabbing;
}

.win.is-max .win__bar {
  cursor: default;
}

.win__title {
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* The three dots are the window controls; a symbol shows inside each on hover/focus. */
.win__controls {
  display: flex;
  gap: 0.15rem;
}

.win__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  color: var(--color-ink);
}

.win__btn::before {
  content: "";
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background-color: var(--dot);
  transition: scale var(--dur-short) var(--ease-out);
}

.win__btn::after {
  position: absolute;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--dur-micro) var(--ease-out);
}

.win__btn--min {
  --dot: var(--color-rule);
}

.win__btn--min::after {
  content: "–";
}

.win__btn--max {
  --dot: var(--color-blue);
  color: var(--color-paper);
}

.win__btn--max::after {
  content: "□";
}

.win__btn--close {
  --dot: var(--color-lime);
}

.win__btn--close::after {
  content: "×";
  font-size: 0.75rem;
}

.win__controls:hover .win__btn::before,
.win__btn:focus-visible::before {
  scale: 1.35;
}

.win__controls:hover .win__btn::after,
.win__btn:focus-visible::after {
  opacity: 1;
}

.win__body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.win__body--note {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.win__path {
  padding: var(--space-xs) var(--space-md);
  border-block-end: var(--rule-hair) solid var(--color-rule);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.win__path span {
  margin-inline: 0.25rem;
}

.win__files {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: var(--space-sm);
  padding: var(--space-md);
}

.win__files .desk-icon {
  width: 8rem;
  color: var(--color-ink);
  --color-focus: var(--color-blue);
}

.win__files .desk-icon__label {
  text-shadow: none;
}

@media (hover: hover) {
  .win__files .desk-icon:hover {
    border-color: var(--color-rule);
    background-color: var(--color-paper-2);
  }
}

.win__files .desk-icon.is-selected {
  border-color: color-mix(in oklch, var(--color-blue) 45%, transparent);
  background-color: color-mix(in oklch, var(--color-blue) 10%, transparent);
}

.win__files .desk-icon.is-selected .desk-icon__label {
  background-color: var(--color-blue);
  color: var(--color-paper);
}

.win__status {
  padding: var(--space-2xs) var(--space-md);
  border-block-start: var(--rule-hair) solid var(--color-rule);
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.win__body--viewer {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.win__shot {
  width: 100%;
  height: 100%;
  min-height: 9rem;
  max-height: 22rem;
  object-fit: cover;
  background-color: var(--color-paper-2);
}

.win.is-max .win__shot {
  max-height: none;
}

.win__meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  padding: var(--space-md);
}

.win__meta .btn {
  grid-column: 1 / -1;
  justify-self: start;
}

@media (min-width: 40rem) {
  .win__meta {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .win__meta .btn {
    grid-column: auto;
  }
}

.win__badge {
  width: 2.75rem;
  height: 2.75rem;
  fill: var(--color-blue);
}

.win__text {
  display: grid;
  min-width: 0;
}

.win__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: var(--leading-tight);
  text-transform: uppercase;
}

.win__tags {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

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

.desk__taskbar {
  position: absolute;
  inset: auto 0 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  height: var(--desk-bar-h);
  padding-inline: var(--space-xs) var(--space-md);
  background-color: color-mix(in oklch, var(--color-ink) 70%, transparent);
  color: var(--color-paper);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  --color-focus: var(--color-lime);
}

.desk__start {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--color-paper);
  --logo-dot: var(--color-lime);
}

.desk__start-mark {
  width: 1.3rem;
  height: auto;
}

@media (hover: hover) {
  .desk__start:hover {
    background-color: color-mix(in oklch, var(--color-paper) 14%, transparent);
  }
}

.desk__tasks {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: var(--space-2xs);
  overflow: hidden;
}

.desk__task {
  position: relative;
  max-width: 11rem;
  min-height: 2rem;
  padding: 0 var(--space-sm);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-md);
  background-color: color-mix(in oklch, var(--color-paper) 10%, transparent);
  color: var(--color-paper);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.desk__task::after {
  content: "";
  position: absolute;
  inset-inline: 30%;
  inset-block-end: 0.15rem;
  height: 2px;
  border-radius: 2px;
  background-color: color-mix(in oklch, var(--color-paper) 40%, transparent);
}

.desk__task.is-front {
  background-color: color-mix(in oklch, var(--color-paper) 22%, transparent);
}

.desk__task.is-front::after {
  background-color: var(--color-lime);
}

@media (hover: hover) {
  .desk__task:hover {
    background-color: color-mix(in oklch, var(--color-paper) 28%, transparent);
  }
}

.desk__tray {
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.desk__tray span {
  opacity: 0.6;
}
