/* Design tokens shared across the Finder shell, file icons, and floating windows. */
:root {
  --glass: rgba(246, 248, 249, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(40, 49, 56, 0.16);
  --ink: #182128;
  --muted: #67727d;
  --blue: #1473e6;
  --folder-top: #ffd66f;
  --folder-bottom: #f5aa2f;
  --sidebar: rgba(225, 233, 236, 0.72);
  --shadow: 0 30px 80px rgba(17, 26, 33, 0.34);
}

/* Global reset and page background. */
* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #233139 url("assets/wallpaper.png") center / cover fixed no-repeat;
}

button,
input {
  font: inherit;
}

/* Desktop stage that centers the Finder until JavaScript applies a custom layout. */
.desktop {
  min-height: 100vh;
  padding: 38px clamp(14px, 4vw, 54px) 34px;
  display: grid;
  place-items: center;
}

/* macOS-style menu bar at the top of the viewport. */
.menubar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  height: 28px;
  padding: 0 clamp(12px, 2vw, 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(23, 31, 36, 0.32);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(18px) saturate(1.35);
  font-size: 13px;
  font-weight: 500;
}

.menu-left {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

/* Finder window frame and grid: toolbar spans top, then sidebar/content/preview. */
.finder-window {
  width: min(1120px, 100%);
  height: min(720px, calc(100vh - 82px));
  min-width: 320px;
  min-height: 430px;
  position: relative;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr) 286px;
  grid-template-rows: 58px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 14px;
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.25);
}

/* Inactive windows become slightly muted, like real macOS windows in the background. */
.finder-window:not(.active-window),
.text-window:not(.active-window),
.pdf-window:not(.active-window) {
  filter: saturate(0.82);
}

.finder-window:not(.active-window) .toolbar,
.text-window:not(.active-window) .text-window-toolbar,
.pdf-window:not(.active-window) .pdf-window-toolbar {
  background: rgba(232, 235, 237, 0.9);
}

.finder-window:not(.active-window) .light,
.text-window:not(.active-window) .light,
.text-window:not(.active-window) .text-window-close,
.pdf-window:not(.active-window) .light,
.pdf-window:not(.active-window) .pdf-window-close {
  background: #b9bdc0;
}

.has-saved-window-state:not(.window-state-ready) .finder-window {
  visibility: hidden;
}

.finder-window.is-resizing,
.finder-window.is-dragging {
  user-select: none;
}

/* Finder-specific resize and drag handles injected by resize-window.js. */
.resize-handle {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(20, 115, 230, 0);
  transition: background 120ms ease;
}

.resize-handle:hover::after,
.resize-handle:focus-visible::after {
  background: rgba(20, 115, 230, 0.22);
}

.resize-handle.nw {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.resize-handle.ne {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.resize-handle.sw {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}

.resize-handle.se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}

.window-drag-handle {
  position: absolute;
  top: 0;
  left: 76px;
  right: 12px;
  z-index: 5;
  height: 16px;
  cursor: grab;
  touch-action: none;
}

.finder-window.is-dragging .window-drag-handle {
  cursor: grabbing;
}

/* Finder toolbar, nav controls, title, and search field. */
.toolbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 86px minmax(120px, 1fr) minmax(150px, 230px);
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 251, 0.78);
  cursor: grab;
  touch-action: none;
}

.finder-window.is-dragging .toolbar {
  cursor: grabbing;
}

.toolbar button,
.toolbar a,
.toolbar input {
  cursor: auto;
}

.nav-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.light {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.red {
  background: #ff5f57;
}

.yellow {
  background: #febc2e;
}

.green {
  background: #28c840;
}

.nav-buttons button {
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(42, 53, 60, 0.13);
  border-radius: 7px;
  color: #5d6770;
  background: rgba(255, 255, 255, 0.55);
  line-height: 1;
  font-size: 24px;
  cursor: pointer;
}

.nav-buttons button:disabled {
  cursor: default;
  opacity: 0.45;
}

.icon-button {
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(42, 53, 60, 0.13);
  border-radius: 7px;
  color: #5d6770;
  background: rgba(255, 255, 255, 0.55);
  line-height: 1;
  font-size: 24px;
  text-decoration: none;
}

.toolbar h1 {
  margin: 0;
  min-width: 0;
  justify-self: center;
  font-size: 15px;
  font-weight: 700;
}

.search {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid rgba(46, 56, 62, 0.13);
  border-radius: 8px;
  color: #87919a;
  background: rgba(255, 255, 255, 0.7);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

/* Sidebar and root Portfolio navigation. */
.sidebar {
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar nav {
  display: grid;
  gap: 5px;
}

.sidebar a {
  padding: 8px 10px;
  border-radius: 7px;
  color: #33414b;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.sidebar a.active,
.sidebar a:hover {
  color: #fff;
  background: var(--blue);
}

/* Main Finder content pane and breadcrumb path. */
.content {
  min-width: 0;
  overflow: auto;
  padding: 16px 18px 24px;
  background: rgba(255, 255, 255, 0.54);
}

.pathbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pathbar span:not(:last-child)::after {
  content: "›";
  padding-left: 6px;
  color: #8d969e;
}

/* File/folder grid items used by the root Portfolio and project folders. */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 26px 20px;
  align-content: start;
}

.folder {
  min-height: 132px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  padding: 10px 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.file {
  min-height: 132px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 10px;
  padding: 10px 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.folder:hover,
.folder:focus-visible,
.folder.selected,
.file:hover,
.file:focus-visible,
.file.selected {
  outline: 0;
  border-color: rgba(20, 115, 230, 0.26);
  background: rgba(20, 115, 230, 0.12);
}

/* Folder icon drawing made with CSS so project folders feel Finder-native. */
.folder-icon {
  position: relative;
  width: 86px;
  height: 66px;
  filter: drop-shadow(0 9px 10px rgba(104, 75, 29, 0.2));
}

.folder-icon::before,
.folder-icon::after {
  content: "";
  position: absolute;
  left: 0;
  display: block;
  background: linear-gradient(180deg, var(--folder-top), var(--folder-bottom));
}

.folder-icon::before {
  top: 7px;
  width: 42px;
  height: 18px;
  border-radius: 8px 10px 0 0;
}

.folder-icon::after {
  inset: 17px 0 0;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.folder.about .folder-icon::after,
.folder.about .folder-icon::before {
  background: linear-gradient(180deg, #84dbd2, #2ba7b1);
}

.folder strong {
  max-width: 106px;
  color: #27323a;
  font-size: 13px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.file strong {
  max-width: 106px;
  color: #27323a;
  font-size: 13px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

/* Document icons for TXT, PDF, and URL-like files. */
.file-icon {
  position: relative;
  width: 66px;
  height: 82px;
  display: grid;
  place-items: end center;
  padding-bottom: 12px;
  border: 1px solid rgba(42, 53, 60, 0.18);
  border-radius: 7px;
  color: #1473e6;
  background: linear-gradient(180deg, #fff 0%, #f5f8fb 100%);
  box-shadow: 0 9px 12px rgba(44, 56, 65, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.pdf-icon {
  color: #d43b30;
}

.link-icon {
  color: #16855b;
}

.file-icon::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 20px;
  height: 20px;
  border-left: 1px solid rgba(42, 53, 60, 0.13);
  border-bottom: 1px solid rgba(42, 53, 60, 0.13);
  border-radius: 0 7px 0 5px;
  background: linear-gradient(135deg, #dce7ef 0 50%, #ffffff 50% 100%);
}

.large-file-icon {
  width: 92px;
  height: 116px;
  margin: 2px auto 18px;
  font-size: 15px;
}

/* Right preview artwork for documents selected in the root Finder view. */
.preview-art.resume,
.preview-art.about-file {
  width: 90px;
  height: 112px;
  margin-top: 0;
  border: 1px solid rgba(42, 53, 60, 0.18);
  border-radius: 9px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  box-shadow: 0 18px 24px rgba(44, 56, 65, 0.16);
}

.preview-art.resume::before,
.preview-art.about-file::before {
  top: -1px;
  right: -1px;
  left: auto;
  width: 27px;
  height: 27px;
  border-left: 1px solid rgba(42, 53, 60, 0.14);
  border-bottom: 1px solid rgba(42, 53, 60, 0.14);
  border-radius: 0 9px 0 6px;
  background: linear-gradient(135deg, #dce7ef 0 50%, #ffffff 50% 100%);
}

.preview-art.resume::after {
  content: "PDF";
  inset: auto 16px 18px;
  display: grid;
  place-items: center;
  height: 28px;
  border-radius: 6px;
  color: #fff;
  background: #d43b30;
  font-size: 13px;
  font-weight: 800;
}

.preview-art.about-file::after {
  content: "TXT";
  inset: auto 16px 18px;
  display: grid;
  place-items: center;
  height: 28px;
  border-radius: 6px;
  color: #fff;
  background: #1473e6;
  font-size: 13px;
  font-weight: 800;
}

/* Finder preview pane and metadata typography. */
.preview {
  min-width: 0;
  overflow: auto;
  padding: 24px 20px;
  border-left: 1px solid var(--line);
  background: var(--glass-strong);
}

.preview-art {
  position: relative;
  width: 116px;
  height: 91px;
  margin: 4px auto 20px;
  filter: drop-shadow(0 18px 16px rgba(67, 50, 24, 0.18));
}

.preview-art::before,
.preview-art::after {
  content: "";
  position: absolute;
  left: 0;
  background: linear-gradient(180deg, var(--folder-top), var(--folder-bottom));
}

.preview-art::before {
  top: 7px;
  width: 58px;
  height: 24px;
  border-radius: 11px 13px 0 0;
}

.preview-art::after {
  inset: 26px 0 0;
  border-radius: 12px;
}

.preview-art.about::before,
.preview-art.about::after {
  background: linear-gradient(180deg, #84dbd2, #2ba7b1);
}

.preview-kind {
  margin: 0 0 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.preview h2 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 22px;
  line-height: 1.15;
}

.preview p {
  margin: 0;
  color: #4f5c66;
  font-size: 14px;
  line-height: 1.6;
}

.text-file-preview pre {
  width: 100%;
  margin: 16px 0 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #26323b;
  background: rgba(255, 255, 255, 0.68);
  white-space: pre-wrap;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* Inline links inside the aboutMe.txt preview/text window. */
.text-file-preview a,
.text-window-body a {
  color: #0969da;
  font-weight: 700;
  text-decoration: none;
}

.text-file-preview a:hover,
.text-window-body a:hover {
  text-decoration: underline;
}

/* Floating TextEdit and Preview windows are direct body children, not modal overlays. */
.text-window-layer {
  display: contents;
}

.pdf-window-layer {
  display: contents;
}

/* TextEdit-style aboutMe.txt window. */
.text-window {
  width: min(620px, calc(100vw - 44px));
  height: min(620px, calc(100vh - 76px));
  position: fixed;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  background: rgba(250, 252, 253, 0.94);
  box-shadow: 0 26px 70px rgba(12, 18, 24, 0.36);
  backdrop-filter: blur(20px) saturate(1.2);
}

/* Preview-style PDF window. */
.pdf-window {
  width: min(760px, calc(100vw - 36px));
  height: min(760px, calc(100vh - 58px));
  position: fixed;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  background: rgba(240, 243, 245, 0.95);
  box-shadow: 0 26px 70px rgba(12, 18, 24, 0.36);
  backdrop-filter: blur(20px) saturate(1.2);
}

/* Floating window toolbars and drag states. */
.text-window-toolbar {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 249, 0.9);
  cursor: grab;
  touch-action: none;
}

.pdf-window-toolbar {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 249, 0.9);
  cursor: grab;
  touch-action: none;
}

.text-window.is-dragging,
.text-window.is-dragging .text-window-toolbar,
.pdf-window.is-dragging,
.pdf-window.is-dragging .pdf-window-toolbar {
  cursor: grabbing;
  user-select: none;
}

.text-window.is-resizing,
.pdf-window.is-resizing {
  user-select: none;
}

/* Four-corner resize handles injected into TextEdit and Preview windows. */
.floating-resize-handle {
  position: absolute;
  z-index: 6;
  width: 18px;
  height: 18px;
  touch-action: none;
}

.floating-resize-handle::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(20, 115, 230, 0);
  transition: background 120ms ease;
}

.floating-resize-handle:hover::after,
.floating-resize-handle:focus-visible::after {
  background: rgba(20, 115, 230, 0.22);
}

.floating-resize-handle.nw {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.floating-resize-handle.ne {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.floating-resize-handle.sw {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}

.floating-resize-handle.se {
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
}

.text-window-toolbar h2 {
  margin: 0;
  justify-self: center;
  transform: translateX(-7px);
  color: #26323b;
  font-size: 14px;
  font-weight: 700;
}

.pdf-window-toolbar h2 {
  margin: 0;
  min-width: 0;
  justify-self: center;
  transform: translateX(15px);
  color: #26323b;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Close buttons and PDF toolbar action. */
.text-window-close {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.pdf-window-close {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.text-window-close:focus-visible,
.pdf-window-close:focus-visible,
.pdf-toolbar-link:focus-visible {
  outline: 2px solid rgba(20, 115, 230, 0.55);
  outline-offset: 3px;
}

/* Scrollable document bodies. */
.text-window-body {
  margin: 0;
  padding: 22px 24px;
  overflow: auto;
  color: #26323b;
  background: rgba(255, 255, 255, 0.78);
  white-space: pre-wrap;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.pdf-toolbar-link {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(42, 53, 60, 0.13);
  border-radius: 7px;
  color: #33414b;
  background: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #e4e7ea;
}

/* Finder preview metadata table. */
.metadata {
  margin: 22px 0 0;
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.metadata div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
}

.metadata dt {
  color: var(--muted);
  font-weight: 600;
}

.metadata dd {
  margin: 0;
  color: #26323b;
  overflow-wrap: anywhere;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 10px;
  padding: 0 14px;
  border-radius: 7px;
  color: #fff;
  background: var(--blue);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

/* Responsive Finder layout: collapse preview/sidebar as the viewport narrows. */
@media (max-width: 920px) {
  .desktop {
    padding: 42px 12px 18px;
    place-items: start center;
  }

  .finder-window {
    grid-template-columns: 168px minmax(0, 1fr);
    grid-template-rows: 58px minmax(0, 1fr) auto;
  }

  .preview {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 680px) {
  .menubar {
    font-size: 12px;
  }

  .menu-left span:not(:first-of-type),
  .menubar time {
    display: none;
  }

  .finder-window {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-radius: 12px;
  }

  .toolbar {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: 34px 34px;
    height: auto;
  }

  .toolbar h1 {
    justify-self: start;
  }

  .search {
    grid-column: 1 / -1;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 14px 12px 18px;
  }

  .folder-grid {
    grid-template-columns: repeat(2, minmax(116px, 1fr));
    gap: 18px 10px;
  }
}
