.mac-window[data-app-id="resume"] .content {
  padding: 0;
  background: #ffffff;
}
.mac-window[data-app-id="contact"] .content {
  background: #ffffff;
  padding-bottom: 16px; /* ensure comfortable space at bottom */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* let inner columns handle scrolling */
}
/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  height: 400vh; /* Long page for scrolling */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

/* Canvas styling */
canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
}

/* --- Mac Desktop Overlay (second page) --- */
#mac-desktop-root {
  position: fixed;
  inset: 0;
  z-index: 10; /* Above 3D canvas */
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none; /* Enabled when visible via JS */
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica,
    Arial, sans-serif;
  /* Plain background image (tint & blur removed per request) */
  background: url("assets/totoro.png") center center / cover no-repeat fixed;
  backdrop-filter: none;
  transition: opacity 0.6s ease;
}

/* Menubar */
#mac-menubar {
  height: 28px;
  background: rgba(193, 194, 195, 0.3);
  backdrop-filter: blur(28px) saturate(160%);
  color: #f5f5f7;
  font-size: 13px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 0.5px rgba(255, 255, 255, 0.08) inset,
    0 0 30px -8px rgba(0, 0, 0, 0.5);
}
#mac-menubar .left span.apple {
  font-size: 17px;
  margin-right: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
#mac-menubar .menu-item {
  position: relative;
  padding: 2px 9px 3px;
  border-radius: 5px;
  transition: background 0.18s ease, color 0.18s ease;
}
#mac-menubar .menu-item:hover {
  background: rgba(255, 255, 255, 0.15);
}
#mac-menubar .menu-item.active-app {
  font-weight: 600;
  color: #fff;
}
#mac-menubar .right .status-item {
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}
#mac-menubar .right .status-item:hover {
  opacity: 1;
}
/* Simple dropdown shell (hidden unless later implemented) */
.menubar-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: rgba(32, 33, 36, 0.72);
  backdrop-filter: blur(30px) saturate(180%);
  border-radius: 10px;
  padding: 6px 0;
  box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.65),
    0 0 0 0.5px rgba(255, 255, 255, 0.08) inset;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: none;
  font-size: 13px;
}
.menubar-dropdown .item {
  padding: 5px 16px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  transition: background 0.15s;
}
.menubar-dropdown .item:hover {
  background: rgba(255, 255, 255, 0.18);
}

#mac-menubar .left,
#mac-menubar .center,
#mac-menubar .right {
  display: flex;
  align-items: center;
  gap: 14px;
}
#mac-menubar .left {
  flex: 1;
}
#mac-menubar .center {
  flex: 1;
  justify-content: center;
  opacity: 0.4;
  pointer-events: none;
}
#mac-menubar .right {
  flex: 1;
  justify-content: flex-end;
  gap: 18px;
  font-variant-numeric: tabular-nums;
}

#mac-desktop-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 42px 32px 40px 32px; /* menubar spacing only */
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 42px 60px;
}

#mac-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  margin: 0 auto;
  display: none; /* toggle when items present */
  justify-content: center;
  gap: 10px;
  z-index: 12000;
  padding: 6px 10px;
  background: rgba(20, 22, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(12px) saturate(140%);
}

#mac-dock .dock-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
#mac-dock .dock-item:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px) scale(1.05);
}
#mac-dock .dock-item .dock-icon img {
  width: 18px;
  height: 18px;
  display: block;
}

/* Add more space at bottom when dock is visible */
#mac-desktop-root.has-dock #mac-desktop-area {
  padding-bottom: 84px;
}

.mac-icon {
  width: 128px; /* much larger container width for bigger icons */
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  position: relative;
  user-select: none;
  background-color: transparent;
}
.icon-img {
  width: 120px; /* larger icon box */
  height: 120px;
  margin: 0 auto 14px auto; /* keep label lower */
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
  border: 1px solid transparent; /* to make the border not make img shrink */
}

.icon-img img {
  width: 100%;
  height: 100%;
  padding: 0.2rem; /* more internal padding for larger icons */
  border-radius: inherit;
  object-fit: cover;
}
.label-bg {
  display: inline-block; /* icon label */
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: opacity 0.22s ease, transform 0.15s ease;
  pointer-events: none;
}
.selected .label-bg {
  opacity: 1;
  background: rgba(0, 122, 255, 0.55);
}

.mac-icon:focus-visible .icon-img,
.mac-icon.selected .icon-img {
  cursor: default;
  background: rgba(255, 255, 255, 0.212);
  border: 1px solid rgba(255, 255, 255, 0.257);
  border-radius: 3px;
}

.mac-icon:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}
.mac-icon:hover .label-bg,
.mac-icon.selected .label-bg {
  opacity: 1;
}

/* Windows */
.mac-window {
  position: absolute;
  top: 120px;
  left: 160px;
  width: min(720px, 70vw);
  height: min(480px, 60vh);
  background: rgba(19, 21, 26, 0.82);
  backdrop-filter: blur(30px) saturate(170%);
  border-radius: 14px;
  box-shadow: 0 18px 40px -10px rgba(0, 0, 0, 0.7),
    0 0 0 0.5px rgba(255, 255, 255, 0.15) inset;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.4, 0.8, 0.2, 1);
  overflow: hidden;
}
.mac-window.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}
.mac-window.active {
  box-shadow: 0 22px 50px -12px rgba(0, 0, 0, 0.75),
    0 0 0 0.5px rgba(255, 255, 255, 0.25) inset;
}

.mac-window .titlebar {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0)
  );
  user-select: none;
  cursor: grab;
}
.traffic-lights {
  display: flex;
  gap: 8px;
}
.traffic-lights span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: block;
  position: relative;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55) inset, 0 1px 2px rgba(0, 0, 0, 0.7);
  cursor: pointer;
}
.traffic-lights .close {
  background: #ff5f56;
}
.traffic-lights .minimize {
  background: #ffbd2e;
}
.traffic-lights .zoom {
  background: #27c93f;
}
.mac-window .title {
  font-size: 13px;
  font-weight: 500;
  color: #f0f0f0;
  letter-spacing: 0.2px;
}

.mac-window .content {
  flex: 1;
  padding: 20px 0 0; /* default content padding */
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
  color: #d6d9df;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: thin;
  outline: none; /* Remove default focus outline */
}

/* Terminal (Skills) window: force white background */
.mac-window[data-app-id="skills"] .content {
  background: #ffffff;
  color: #000000;
  padding: 0; /* let terminal container own spacing */
  overflow: hidden; /* avoid double scrollbars; inner terminal scrolls */
}

/* About window styles */
.mac-window .content .about-root {
  background: rgb(48, 48, 48);
  color: #e5e7eb;
  /* Create a visible gap on all sides inside the window content */
  margin: 14px 18px 18px 18px;
  border-radius: 12px;
  /* Account for margins so content can still stretch vertically when window grows */
  min-height: calc(100% - 32px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "SF Pro Text", system-ui, sans-serif;
}
.mac-window[data-app-id="about"] .content {
  padding-top: 0;
  background: rgb(48, 48, 48);
}
.mac-window .content .about-section {
  display: block;
}
.mac-window .content .about-hero h1 {
  font-size: 26px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: #f3f4f6;
}
.mac-window .content .about-hero p {
  color: #9aa3b2;
}
.mac-window .content .about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.mac-window .content .card {
  background: #171a21;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 18px;
}
.mac-window .content .card-icon {
  width: 36px;
  height: 36px;
  background: #2a3242;
  color: #e6edf7;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 18px;
}
.mac-window .content .card h3 {
  margin: 0 0 6px;
  color: #e5e7eb;
  font-size: 16px;
}
.mac-window .content .card p {
  margin: 0;
  color: #a7b0bf;
  font-size: 13px;
}
.mac-window .content .panel {
  background: #141821;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 18px;
}
.mac-window .content .panel h3 {
  color: #e5e7eb;
  margin: 0 0 8px;
  font-size: 16px;
}
.mac-window .content .panel p,
.mac-window .content .panel li {
  color: #c5ccd8;
}

/* About split layout */
.mac-window .content .about-split {
  display: grid;
  grid-template-columns: 1fr 2fr; /* left 1/3, right 2/3 */
  gap: 22px;
  align-items: start;
}
.mac-window .content .about-photo {
  border: 1px solid rgb(71, 71, 71);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.mac-window .content .about-photo img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
}
.mac-window .content .about-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mac-window .content .detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid rgb(71, 71, 71);
  border-radius: 10px;
  background: transparent; /* border-only box */
}
.mac-window .content .detail-label {
  color: #a7b0bf;
  font-weight: 600;
}
.mac-window .content .detail-value {
  color: #e5e7eb;
}
.mac-window .content .detail-value a {
  color: #cbd6ff;
  text-decoration: none;
}
.mac-window .content .detail-value a:hover {
  text-decoration: underline;
}

.mac-window .content h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
}
.mac-window .content h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}
.mac-window .content p {
  margin: 0 0 12px;
}
.mac-window .content ul {
  margin: 0 0 14px 18px;
  padding: 0;
}
.mac-window .content li {
  margin: 4px 0;
}

/* Window polish */
.mac-window {
  border-radius: 16px;
  background: rgba(22, 24, 28, 0.78);
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.85),
    0 0 0 0.6px rgba(255, 255, 255, 0.14) inset;
}
.mac-window .titlebar {
  height: 38px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.09),
    rgba(255, 255, 255, 0.02)
  );
  padding: 0 14px;
}
.traffic-lights span {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55) inset, 0 1px 2px rgba(0, 0, 0, 0.75),
    0 0 4px rgba(0, 0, 0, 0.6);
}
.traffic-lights span::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0) 60%
  );
  opacity: 0.9;
  pointer-events: none;
}
.mac-window.active {
  box-shadow: 0 34px 90px -30px rgba(0, 0, 0, 0.9),
    0 0 0 0.8px rgba(255, 255, 255, 0.25) inset;
}
.mac-window.zoomed {
  transition: all 0.4s cubic-bezier(0.4, 0.8, 0.2, 1);
}

/* Scrollbar subtle styling */
.mac-window .content::-webkit-scrollbar {
  width: 10px;
}
.mac-window .content::-webkit-scrollbar-track {
  background: transparent;
}
.mac-window .content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: content-box;
}
.mac-window .content:focus {
  outline: 2px solid rgba(0, 123, 255, 0.5);
  outline-offset: -2px;
}

/* show resize cursors near edges (invisible handles) */
.mac-window {
  position: absolute;
}
.mac-window:hover {
  --edge: 10px;
}
.mac-window {
  touch-action: none;
}
.mac-window::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
}

/* cursors when hovering near edges handled via JS; provide default */
.mac-window.resizing {
  cursor: nwse-resize;
}

@media (max-width: 820px) {
  #mac-desktop-area {
    gap: 38px 40px;
    padding: 40px 20px 70px;
  }
  .mac-window {
    width: min(94vw, 760px);
    height: min(70vh, 520px);
    left: 20px;
    top: 86px;
  }
  .mac-icon {
    width: 96px; /* mobile-adjusted container */
  }
  .mac-icon .icon-img {
    width: 86px;
    height: 86px;
    margin: 0 auto 10px auto;
  }
  .mac-window .content .about-split {
    grid-template-columns: 1fr;
  }
}

/* Loading Spinner */
.code-rain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.code-line {
  position: absolute;
  color: rgba(0, 122, 255, 0.6);
  font-family: "Courier New", monospace;
  font-size: 14px;
  white-space: nowrap;
  top: -50px;
  animation: fall linear infinite;
}

.code-line:nth-child(1) {
  left: 5%;
  animation-duration: 15s;
  animation-delay: 0s;
}
.code-line:nth-child(2) {
  left: 10%;
  animation-duration: 18s;
  animation-delay: 1s;
}
.code-line:nth-child(3) {
  left: 15%;
  animation-duration: 12s;
  animation-delay: 2s;
}
.code-line:nth-child(4) {
  left: 20%;
  animation-duration: 20s;
  animation-delay: 3s;
}
.code-line:nth-child(5) {
  left: 25%;
  animation-duration: 16s;
  animation-delay: 4s;
}
.code-line:nth-child(6) {
  left: 30%;
  animation-duration: 14s;
  animation-delay: 5s;
}
.code-line:nth-child(7) {
  left: 35%;
  animation-duration: 22s;
  animation-delay: 6s;
}
.code-line:nth-child(8) {
  left: 40%;
  animation-duration: 17s;
  animation-delay: 7s;
}
.code-line:nth-child(9) {
  left: 45%;
  animation-duration: 19s;
  animation-delay: 8s;
}
.code-line:nth-child(10) {
  left: 50%;
  animation-duration: 13s;
  animation-delay: 9s;
}
.code-line:nth-child(11) {
  left: 55%;
  animation-duration: 21s;
  animation-delay: 10s;
}
.code-line:nth-child(12) {
  left: 60%;
  animation-duration: 15.5s;
  animation-delay: 11s;
}
.code-line:nth-child(13) {
  left: 65%;
  animation-duration: 23s;
  animation-delay: 12s;
}
.code-line:nth-child(14) {
  left: 70%;
  animation-duration: 16.5s;
  animation-delay: 13s;
}
.code-line:nth-child(15) {
  left: 75%;
  animation-duration: 19.5s;
  animation-delay: 14s;
}
.code-line:nth-child(16) {
  left: 80%;
  animation-duration: 14.5s;
  animation-delay: 15s;
}
.code-line:nth-child(17) {
  left: 85%;
  animation-duration: 20.5s;
  animation-delay: 0.5s;
}
.code-line:nth-child(18) {
  left: 90%;
  animation-duration: 13.5s;
  animation-delay: 1.5s;
}
.code-line:nth-child(19) {
  left: 95%;
  animation-duration: 24s;
  animation-delay: 2.5s;
}
.code-line:nth-child(20) {
  left: 12%;
  animation-duration: 17.5s;
  animation-delay: 3.5s;
}
.code-line:nth-child(21) {
  left: 22%;
  animation-duration: 18.5s;
  animation-delay: 4.5s;
}
.code-line:nth-child(22) {
  left: 32%;
  animation-duration: 15.2s;
  animation-delay: 5.5s;
}
.code-line:nth-child(23) {
  left: 42%;
  animation-duration: 21.5s;
  animation-delay: 6.5s;
}
.code-line:nth-child(24) {
  left: 52%;
  animation-duration: 12.5s;
  animation-delay: 7.5s;
}

@keyframes fall {
  0% {
    top: -50px;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    top: 100vh;
    opacity: 0;
  }
}

.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.code-spinner {
  display: flex;
  align-items: center;
  font-family: "Courier New", monospace;
  font-size: 48px;
  color: #007aff;
  font-weight: bold;
}

.bracket {
  animation: pulse 1.5s ease-in-out infinite;
}

.bracket:nth-child(1) {
  animation-delay: 0s;
}

.bracket:nth-child(3) {
  animation-delay: 0.5s;
}

.spinner-core {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 3px solid #34c759;
  animation: spin 1s linear infinite;
  margin: 0 10px;
  box-shadow: 0 0 10px rgba(52, 199, 89, 0.5);
}

.typing-text {
  color: #fff;
  font-size: 18px;
  margin-top: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  border-right: 2px solid #007aff;
  animation: blink-caret 0.75s step-end infinite;
  white-space: nowrap;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

@keyframes blink-caret {
  from,
  to {
    border-color: transparent;
  }
  50% {
    border-color: #007aff;
  }
}
