/* ─── Tokens ───────────────────────────────────────────────── */
:root {
  --bg:           #1e1e2e;
  --menubar-bg:   rgba(30,30,46,0.82);
  --dock-bg:      rgba(255,255,255,0.12);
  --surface:      rgba(40,40,60,0.72);
  --surface-2:    rgba(50,50,72,0.9);
  --border:       rgba(255,255,255,0.1);
  --border-2:     rgba(255,255,255,0.06);
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #484f58;
  --accent:       #3fb950;
  --accent-blue:  #58a6ff;
  --accent-red:   #ff7b72;
  --accent-yellow:#e3b341;
  --accent-purple:#d2a8ff;
  --dot-red:      #ff5f57;
  --dot-yellow:   #febc2e;
  --dot-green:    #28c840;
  --radius:       12px;
  --radius-sm:    7px;
  --mono:         'JetBrains Mono', 'Cascadia Code', monospace;
  --sans:         'Inter', system-ui, -apple-system, sans-serif;
  --blur:         blur(24px) saturate(1.6);
  --window-shadow: 0 32px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.07);
}

[data-theme="light"] {
  --bg:           #c8d0e0;
  --menubar-bg:   rgba(220,225,235,0.85);
  --dock-bg:      rgba(255,255,255,0.35);
  --surface:      rgba(255,255,255,0.68);
  --surface-2:    rgba(255,255,255,0.92);
  --border:       rgba(0,0,0,0.09);
  --border-2:     rgba(0,0,0,0.05);
  --text:         #1c2128;
  --text-muted:   #57606a;
  --text-dim:     #adb5bd;
  --window-shadow: 0 32px 80px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.08);
}

/* ─── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s;
  user-select: none;
}

/* ─── Wallpaper ────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(63,185,80,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(88,166,255,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(210,168,255,0.07) 0%, transparent 70%);
  pointer-events: none;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(63,185,80,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(88,166,255,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(210,168,255,0.1) 0%, transparent 70%);
}

/* ─── Menu Bar ─────────────────────────────────────────────── */
#menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 28px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--menubar-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border-2);
}

.menubar-left, .menubar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.apple-logo {
  font-size: 15px;
  line-height: 1;
  margin-right: 4px;
}

.menubar-app-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.menubar-item {
  font-size: 11.5px;
  color: var(--text);
  padding: 2px 6px;
}

.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.theme-btn:hover { background: rgba(255,255,255,0.1); }
.theme-btn svg { width: 14px; height: 14px; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ─── Desktop ──────────────────────────────────────────────── */
#desktop {
  position: fixed;
  inset: 28px 0 0 0;
  z-index: 1;
  overflow: hidden;
}

/* ─── Windows ──────────────────────────────────────────────── */
.window {
  position: absolute;
  min-width: 320px;
  min-height: 200px;
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: var(--window-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.15s, opacity 0.18s, transform 0.18s;
  will-change: transform;
}

.window.opening {
  animation: winOpen 0.22s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes winOpen {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

.window.closing {
  animation: winClose 0.15s ease-in forwards;
}

@keyframes winClose {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.9); }
}

.window.inactive { box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05); }
.window.inactive .titlebar-dots .dot { background: var(--border) !important; }

/* Titlebar */
.titlebar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border-2);
  cursor: move;
  flex-shrink: 0;
  gap: 10px;
}

[data-theme="light"] .titlebar { background: rgba(0,0,0,0.03); }

.titlebar-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: filter 0.15s;
  position: relative;
}

.dot:hover { filter: brightness(1.2); }

.dot-close  { background: var(--dot-red); }
.dot-min    { background: var(--dot-yellow); }
.dot-max    { background: var(--dot-green); }

.dot-close::after, .dot-min::after, .dot-max::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.titlebar-dots:hover .dot-close::after  { content: '×'; opacity: 1; font-size: 10px; color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.titlebar-dots:hover .dot-min::after    { content: '−'; opacity: 1; font-size: 10px; color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.titlebar-dots:hover .dot-max::after    { content: '+'; opacity: 1; font-size: 10px; color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-weight: 700; }

.titlebar-title {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.titlebar-spacer { width: 46px; flex-shrink: 0; }

/* Window body */
.window-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Resize handle */
.resize-handle {
  position: absolute;
  bottom: 0; right: 0;
  width: 16px; height: 16px;
  cursor: se-resize;
  opacity: 0.4;
}

.resize-handle::after {
  content: '';
  position: absolute;
  bottom: 3px; right: 3px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  border-radius: 1px;
}

/* ─── Window Content — shared ──────────────────────────────── */
.win-section { margin-bottom: 24px; }
.win-section:last-child { margin-bottom: 0; }

.win-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.win-h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.win-body {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.win-body a {
  color: var(--accent-blue);
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.win-body a:hover { border-color: var(--accent-blue); }

.divider {
  border: none;
  border-top: 1px solid var(--border-2);
  margin: 20px 0;
}

/* ─── About window ─────────────────────────────────────────── */
.about-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4facfe, #43e97b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.about-name { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.03em; }
.about-role { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  text-decoration: none;
}
.pill:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.pill svg { width: 13px; height: 13px; }

/* ─── Projects window ──────────────────────────────────────── */
.project-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border-2);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.project-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.14);
}

.project-card:last-child { margin-bottom: 0; }

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.project-name { font-size: 0.9rem; font-weight: 600; }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
}
.badge-green { background: rgba(63,185,80,0.15); color: var(--accent); border: 1px solid rgba(63,185,80,0.3); }
.badge-blue  { background: rgba(88,166,255,0.12); color: var(--accent-blue); border: 1px solid rgba(88,166,255,0.25); }
.badge-purple{ background: rgba(210,168,255,0.12); color: var(--accent-purple); border: 1px solid rgba(210,168,255,0.25); }

.project-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ─── Skills window ────────────────────────────────────────── */
.skill-group { margin-bottom: 20px; }
.skill-group-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.skill-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--border-2);
}

/* ─── Contact window ───────────────────────────────────────── */
.contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-2);
}
.contact-row:last-child { border-bottom: none; }

.contact-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.contact-label { font-size: 11px; color: var(--text-muted); }
.contact-value { font-size: 13px; font-weight: 500; }

.contact-row a { text-decoration: none; color: inherit; }
.contact-row a:hover .contact-value { color: var(--accent-blue); }

/* ─── Terminal window ──────────────────────────────────────── */
.window-terminal {
  background: rgba(13,17,23,0.92) !important;
}
[data-theme="light"] .window-terminal {
  background: rgba(18,22,30,0.95) !important;
}

.window-terminal .titlebar {
  background: rgba(255,255,255,0.03);
}

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #30363d transparent;
}

.term-line { display: flex; gap: 6px; white-space: pre-wrap; word-break: break-all; }
.term-prompt { color: #3fb950; flex-shrink: 0; }
.term-input-line { display: flex; gap: 6px; align-items: baseline; margin-top: 2px; }
.term-input-prompt { color: #3fb950; flex-shrink: 0; }

#term-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #c9d1d9;
  caret-color: #3fb950;
  line-height: 1.65;
}

.term-out   { color: #c9d1d9; }
.term-err   { color: #ff7b72; }
.term-ok    { color: #3fb950; }
.term-info  { color: #58a6ff; }
.term-key   { color: #58a6ff; }
.term-label { color: #d2a8ff; }
.term-muted { color: #484f58; }
.term-yellow{ color: #e3b341; }

/* ─── Dock ─────────────────────────────────────────────────── */
#dock {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
}

.dock-inner {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px;
  background: var(--dock-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
}

.dock-item:hover { transform: translateY(-8px) scale(1.15); }
.dock-item:active { transform: translateY(-4px) scale(1.05); }

.dock-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.dock-icon svg { width: 100%; height: 100%; display: block; }
.dock-item:hover .dock-icon { box-shadow: 0 8px 24px rgba(0,0,0,0.35); }

.dock-label {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
  position: absolute;
  bottom: -18px;
  background: var(--surface-2);
  backdrop-filter: blur(8px);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  pointer-events: none;
}

.dock-item:hover .dock-label { opacity: 1; transform: translateY(0); }

.dock-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  bottom: -8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.dock-dot.visible { opacity: 1; }

.dock-separator {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 2px;
  align-self: center;
}

/* ─── Messages window ──────────────────────────────────────── */
.messages-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
}

.messages-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border-2);
  text-align: center;
  flex-shrink: 0;
}

.messages-header-name {
  font-size: 13px;
  font-weight: 600;
}

.messages-header-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.msg-row.visitor { justify-content: flex-end; }
.msg-row.rafael  { justify-content: flex-start; }

.msg-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-row.visitor .msg-bubble {
  background: #0b84fe;
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg-row.rafael .msg-bubble {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin: 0 4px 2px;
  flex-shrink: 0;
}

.messages-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-2);
  flex-shrink: 0;
}

.messages-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
}

.messages-input:focus { border-color: #0b84fe; }
.messages-input::placeholder { color: var(--text-muted); }

.messages-send {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #0b84fe;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.messages-send:disabled { background: var(--border); cursor: default; }
.messages-send svg { width: 14px; height: 14px; fill: white; }

.msg-typing {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  width: fit-content;
}

.msg-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.2s ease-in-out infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.msg-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: auto;
  padding: 20px;
  line-height: 1.6;
}

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ─── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .window.opening, .window.closing { animation: none; }
  .dock-item, .dock-item:hover { transform: none; }
}
