/* ============================================================
   Atelier OS — Portfolio UI kit styles
   Layered on top of ../../colors_and_type.css
   ============================================================ */

* { box-sizing: border-box; }

html, body, #root {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  /* Custom pixel cursor — small intrinsic size so it doesn't render huge */
  cursor: url("../../assets/icons/cursor-arrow-sm.svg") 1 1, default;
}

button { font-family: inherit; }

/* ----- Desktop ----- */
.desktop {
  height: 100%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

.workspace {
  position: relative;
  flex: 1;
  background: var(--paper);
  background-image:
    radial-gradient(rgba(27,27,27,0.05) 1px, transparent 1px);
  background-size: 3px 3px;
  overflow: hidden;
}

/* ----- Menubar ----- */
.menubar {
  flex: 0 0 22px;
  height: 22px;
  background: var(--surface-pure);
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 8px;
  position: relative;
  z-index: 1000;
}
.menubar .apple {
  background: none; border: 0; padding: 0; margin: 0;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: inherit;
}
.menubar .apple img { width: 16px; height: 16px; image-rendering: pixelated; }
.menubar .m {
  background: none; border: 0; padding: 3px 6px; margin: 0;
  font-family: var(--font-pixel); font-size: 12px; line-height: 1; font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--ink);
  cursor: inherit;
}
.menubar .m.selected {
  background: var(--ink);
  color: var(--surface-pure);
}
.menubar .clock {
  margin-left: auto;
  font-family: var(--font-pixel); font-size: 12px; line-height: 1; font-weight: 300;
  letter-spacing: .04em;
}

/* ── Menubar pull-down menus (classic-Mac) ────────────────────────────────
   Each title is wrapped in a .menu-group so its dropdown anchors beneath it.
   Items use the same ink-invert highlight as a selected title. The overlay
   sits just below the menubar (z 999 < 1000) to catch outside clicks while
   leaving the titles clickable for menu-to-menu switching. */
.menu-group { position: relative; display: inline-flex; align-items: center; height: 100%; }
.menu-overlay { position: fixed; inset: 0; z-index: 999; }
.menu-dropdown {
  position: absolute; top: 100%; left: 0;
  min-width: 184px;
  background: var(--surface-pure);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-window);
  padding: 3px 0;
  z-index: 1001;
  display: flex; flex-direction: column;
}
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0;
  font-family: var(--font-pixel); font-size: 12px; font-weight: 300; line-height: 1.1;
  letter-spacing: .03em; color: var(--ink);
  padding: 5px 16px; cursor: inherit; white-space: nowrap;
}
.menu-item:hover { background: var(--ink); color: var(--surface-pure); }
.menu-item:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.menu-sep { height: 1px; background: var(--ink-4); margin: 3px 0; }

/* ----- Desktop icons ----- */
.desk-icon {
  position: absolute;
  z-index: 2;          /* sit above the dot-field canvas (z 1) so dots don't show through icon bodies; still below windows (z 11+) */
  width: 76px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: 0; padding: 4px;
  cursor: inherit;
}
.desk-icon img {
  width: 48px; height: 48px;
  image-rendering: pixelated;
}
.desk-icon .lbl {
  font-family: var(--font-pixel); font-size: 10px; line-height: 1.15; font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-align: center;
  padding: 1px 4px;
  max-width: 76px;
  word-wrap: break-word;
}
.desk-icon.selected img { filter: invert(1); }
.desk-icon.selected .lbl {
  background: var(--ink);
  color: var(--surface-pure);
}

/* ----- Window ----- */
.win {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--ink-4);
  border-radius: 8px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-window-deep);
  overflow: hidden;
}
.win-inactive {
  box-shadow: var(--shadow-window);
}

.titlebar {
  position: relative;
  flex: 0 0 22px;
  height: 22px;
  border-bottom: 1px solid var(--ink-4);
  display: flex; align-items: center;
  user-select: none;
  cursor: inherit;
}
.titlebar.active {
  background: var(--surface);
}
.titlebar.inactive {
  background: #E2E2E2;
}
.tb-close, .tb-zoom {
  width: 12px; height: 12px;
  border: 1px solid var(--ink);
  background: var(--surface);
  padding: 0; margin: 0;
  box-sizing: border-box;
  border-radius: 3px;
  cursor: inherit;
}
.tb-close { margin-left: 6px; margin-right: auto; position: relative; }
.tb-close::before,
.tb-close::after {
  content: '';
  position: absolute;
  width: 1px; height: 7px;
  background: var(--ink);
  top: 1px; left: 4px;
}
.tb-close::before { transform: rotate(45deg); }
.tb-close::after  { transform: rotate(-45deg); }
.tb-close:hover { background: var(--paper-2); }
.tb-close:active { background: var(--ink); }
.tb-close:active::before,
.tb-close:active::after { background: var(--surface); }
.tb-title {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  padding: 0 8px;
  font-family: var(--font-pixel); font-size: 12px; line-height: 1; font-weight: 300;
  letter-spacing: .04em;
  color: var(--ink);
  white-space: nowrap;
  max-width: calc(100% - 60px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.titlebar.inactive .tb-title { color: var(--ink-3); background: #E2E2E2; }
.win-body {
  flex: 1;
  position: relative;
  min-height: 0;
}
.win-body.scroll { overflow: auto; }

/* Hide scrollbar, keep scroll functionality */
.win-body.scroll::-webkit-scrollbar { display: none; }
.win-body.scroll { scrollbar-width: none; }

/* ── Resize handles ───────────────────────────────────────────────────────
   Every window resizes from any corner. Bottom-right keeps the visible dot
   grip; the other three corners are invisible drag zones. They sit above the
   titlebar/body so corners are grabbable, while interactive controls
   (buttons/links) are lifted above the grips so they stay clickable. */
.win-resize, .win-grip {
  position: absolute;
  width: 16px; height: 16px;
  pointer-events: auto;
  z-index: 1;
}
.win-resize {
  right: 0; bottom: 0;
  width: 14px; height: 14px;
  cursor: se-resize;      /* diagonal arrow pointing bottom-right, standard resize cursor */
  color: var(--ink);
}
.win-grip-nw { left: 0;  top: 0;    cursor: nwse-resize; }
.win-grip-ne { right: 0; top: 0;    cursor: nesw-resize; }
.win-grip-sw { left: 0;  bottom: 0; cursor: nesw-resize; }
.win-resize svg { display: block; }
/* Keep clickable controls above the corner grips so they win where they overlap.
   Scoped to desktop windows (:not(.m-win)) so it can't disturb mobile's sticky
   titlebar stacking. */
.win:not(.m-win) button, .win:not(.m-win) a { position: relative; z-index: 2; }

/* ── Keyboard focus indicators (a11y) ───────────────────────────────────────
   Visible focus rings on desktop window chrome (close box, project/drawings
   tabs + filters, project rows, image-window nav/zoom) and the desktop icons.
   Matches the .ui-btn ring (2px var(--ink) outline). Uses
   :focus-visible so it only shows on keyboard nav — mouse users see no change.
   Scoped to desktop (:not(.m-win)) so it can't disturb mobile's sticky chrome. */
.win:not(.m-win) button:focus-visible,
.win:not(.m-win) a:focus-visible,
.desk-icon:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.tb-close:focus-visible { outline-offset: 1px; } /* tight to the 12px close box */

/* ----- Document content (inside windows) ----- */
.doc {
  padding: 22px 26px 18px;
}
.doc-head { margin-bottom: 14px; }
.doc-head .t-eyebrow { margin-bottom: 6px; }
.doc-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: -0.014em;
  color: var(--ink);
  margin: 0;
}
.doc p { margin: 0 0 12px; }
.doc-foot { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--ink-4); }

/* Finder/list view */
.finder { display:flex; flex-direction:column; height: 100%; }
.finder-bar {
  display:flex; align-items:center; gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--ink-4);
  background: var(--surface);
  font-family: var(--font-mono); font-size: 11px; line-height: 1; font-weight: 300;
  color: var(--ink-2);
}
.finder-bar .spacer { flex: 1; }
.finder-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 13px;
}
.finder-table thead {
  background: var(--paper-2);
  border-bottom: 1px solid var(--ink);
}
.finder-table th {
  text-align: left;
  font-family: var(--font-pixel); font-size: 11px; line-height: 1; font-weight: 300;
  letter-spacing: .04em;
  padding: 4px 8px;
  border-right: 1px solid var(--ink-4);
  color: var(--ink);
}
.finder-table th:last-child { border-right: 0; }
.finder-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--paper-3);
}
.finder-table tr:hover td {
  background: var(--paper-2);
}
.finder-table .name-cell {
  display: flex; align-items: center; gap: 8px;
}
.finder-table .name-cell img {
  width: 16px; height: 16px;
  image-rendering: pixelated;
}

/* Project window drawing tab */
.project-drawings-view {
  min-height: 100%;
  background: var(--surface);
}
.drawing-project {
  padding: 10px 12px 11px;
  border-bottom: 1px solid var(--paper-3);
}
.drawing-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  grid-auto-rows: auto;
  gap: 10px;
  align-items: start;
}
.drawing-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  padding: 0;
  border: 1px solid var(--paper-3);
  background: var(--paper-2);
  overflow: hidden;
  cursor: inherit;
  transform: translateZ(0);
  transition:
    border-color 120ms ease,
    outline-color 120ms ease,
    transform 120ms ease;
}
.drawing-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1);
  transition: transform 160ms ease;
}
.drawing-thumb:hover,
.drawing-thumb:focus-visible {
  border-color: var(--ink-2);
  outline: 1px solid var(--ink-2);
  outline-offset: 0;
}
.drawing-thumb:hover img,
.drawing-thumb:focus-visible img {
  transform: scale(1.015);
}
.drawing-thumb:active img {
  transform: translateY(1px) scale(1.01);
}
.drawing-project-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: inherit;
}
.drawing-project-title {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 400;
  color: var(--ink);
}
.drawing-project-sub {
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: .02em;
  color: var(--ink-2);
}
.drawing-project-meta:hover .drawing-project-title,
.drawing-project-meta:focus-visible .drawing-project-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.drawing-project-meta:focus-visible {
  outline: 1px solid var(--ink-2);
  outline-offset: 2px;
}
.drawing-project-meta:active {
  transform: translateY(1px);
}
@media (prefers-reduced-motion: reduce) {
  .drawing-thumb,
  .drawing-thumb img {
    transition: none;
  }
  .drawing-thumb:hover img,
  .drawing-thumb:focus-visible img,
  .drawing-thumb:active img {
    transform: none;
  }
}

/* Media tab — video tiles. Reuses the drawing-project-meta caption below. */
.media-grid {
  min-height: 100%;
  background: var(--surface);
  padding: 14px 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px 14px;
  align-content: start;
}
.media-item {
  display: flex;
  flex-direction: column;
}
.media-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  padding: 0;
  border: 1px solid var(--paper-3);
  background: var(--paper-2);
  overflow: hidden;
  cursor: inherit;
  transform: translateZ(0);
  transition:
    border-color 120ms ease,
    outline-color 120ms ease,
    transform 120ms ease;
}
.media-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1);
  transition: transform 160ms ease;
}
.media-tile:hover,
.media-tile:focus-visible {
  border-color: var(--ink-2);
  outline: 1px solid var(--ink-2);
  outline-offset: 0;
}
.media-tile:hover img,
.media-tile:focus-visible img {
  transform: scale(1.015);
}
.media-tile:active img {
  transform: translateY(1px) scale(1.01);
}
/* Play affordance — a beveled white disc with an ink triangle. */
.media-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-floating);
  transition: transform 120ms ease, background-color 120ms ease;
}
.media-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -5px;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent var(--ink);
}
.media-tile:hover .media-play,
.media-tile:focus-visible .media-play {
  transform: scale(1.06);
  background: var(--paper-2);
}
.media-tile:active .media-play {
  transform: scale(0.97);
}
/* Small corner badge marking the tile as video. */
.media-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--surface);
  background: var(--ink);
  border: 1px solid var(--ink);
}
.media-item .drawing-project-meta {
  margin-top: 10px;
}
@media (prefers-reduced-motion: reduce) {
  .media-tile,
  .media-tile img,
  .media-play {
    transition: none;
  }
  .media-tile:hover img,
  .media-tile:focus-visible img,
  .media-tile:active img,
  .media-tile:hover .media-play,
  .media-tile:focus-visible .media-play,
  .media-tile:active .media-play {
    transform: none;
  }
}
/* Drawing pages */
.drawing-page {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface);
}
.drawing-svg {
  flex: 1;
  width: 100%;
  background:
    var(--surface-pure)
    radial-gradient(rgba(27,27,27,0.03) 1px, transparent 1px) 0 0 / 3px 3px;
  min-height: 0;
}
.drawing-foot {
  display: flex;
  padding: 6px 12px;
  border-top: 1px solid var(--ink);
  background: var(--paper-2);
  font-size: 11px;
}

/* Photo page */
.photo-page {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface);
}
.photo-page image-slot {
  flex: 1;
  min-height: 0;
}

/* ----- About dialog ----- */
.modal-backdrop {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(27,27,27,0.18);
  z-index: 5000;
}
.dialog {
  background: var(--surface);
  border: 1px solid var(--ink-4);
  box-shadow: var(--shadow-window-deep);
  padding: 18px 20px;
  border-radius: 10px;
}
.dialog.about {
  width: 340px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: start;
}
.about-mark {
  width: 56px; height: 56px;
  image-rendering: pixelated;
}
.about-body .actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}
.btn {
  font-family: var(--font-pixel); font-size: 12px; line-height: 1; font-weight: 300;
  letter-spacing: .04em;
  padding: 7px 16px;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  cursor: inherit;
  box-shadow: var(--shadow-floating);
}
.btn.primary {
  box-shadow: 0 1px 2px rgba(17,17,17,0.06), 0 3px 8px rgba(17,17,17,0.08);
}
.btn:active {
  box-shadow: inset 0 1px 2px rgba(17,17,17,0.10);
  background: var(--paper);
  transform: translate(0, 1px);
}

/* ── Unified button system ───────────────────────────────────────────────
   One interaction model — shared radius (--r-1 4px), hover (--paper-2 + border
   deepen), active (inset press + 1px nudge), focus (2px --ink ring), and a
   reduced-motion guard — with weight/shape/size variants. Supersedes the old
   one-off .contact-btn and the inline-styled image-window nav buttons. Tokens
   only; no new colors. Deliberately EXCLUDES the classic-Mac titlebar controls
   (.tb-close/.tb-zoom) and the project tabs/filters — those are their own
   affordances, not push-buttons. Spec: _asset/svg_wip/34-button-system.svg */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-sizing: border-box;
  font-family: var(--font-pixel); font-size: 12px; font-weight: 400; line-height: 1;
  letter-spacing: .03em;
  padding: 6px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--r-1);
  background: var(--surface);
  color: var(--ink);
  cursor: inherit;
  box-shadow: var(--shadow-floating);
  transition: background 0.15s cubic-bezier(0.16,1,0.3,1), border-color 0.15s ease,
              transform 0.05s ease, box-shadow 0.1s ease;
}
.ui-btn:hover { background: var(--paper-2); border-color: var(--ink); }
.ui-btn:active { background: var(--paper-3); box-shadow: var(--shadow-pressed-inset); transform: translateY(1px); }
.ui-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ui-btn:disabled { opacity: .35; box-shadow: none; pointer-events: none; }

/* Quiet — lighter chrome for dense in-window controls (image-window nav). */
.ui-btn--quiet { border-color: var(--ink-4); box-shadow: none; }
.ui-btn--quiet:hover { border-color: var(--ink-3); }

/* Compact size. */
.ui-btn--sm { padding: 3px 10px; }

/* Icon — square, holds an 18px pixel glyph (contact buttons). */
.ui-btn--icon { width: 32px; height: 32px; padding: 6px; }
.ui-btn--icon img { width: 18px; height: 18px; image-rendering: pixelated; display: block; }

/* Text/ghost — borderless; for "more…" expanders. */
.ui-btn--text { border-color: transparent; background: none; box-shadow: none; color: var(--ink-2); padding: 4px 8px; }
.ui-btn--text:hover { background: var(--paper-2); border-color: transparent; color: var(--ink); }
.ui-btn--text:active { background: var(--paper-3); box-shadow: none; }

@media (prefers-reduced-motion: reduce) { .ui-btn { transition: none; } }

/* "more…" expander: ghost text button, full-width with a top divider rule. */
.more-btn { justify-content: flex-start; width: 100%; border-top: 1px solid var(--ink-4); border-radius: 0; margin-top: 6px; padding: 8px 0 6px; font-size: 11px; }

/* ── Contact icon buttons (About window / card) ──────────────────────────
   Pixel social/mail icons as link buttons; use .ui-btn .ui-btn--icon. */
.contact-row { display: flex; gap: 10px; }
