/* ── Reset & root ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0c10;
  --fg:       #c8f05a;
  --fg-dim:   #4a5a20;
  --fg-muted: #3a4520;
  --accent:   #c8f05a;
  --prompt:   #f0c040;
  --err:      #f05a5a;
  --warn:     #f0c040;
  --link:     #7ad4ff;
  --border:   rgba(200, 240, 90, 0.08);
  --font:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --fs:       14px;
  --lh:       1.7;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  overflow: hidden;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fg-muted); border-radius: 2px; }

/* ── Selection ─────────────────────────────────────────────────────────────── */
::selection { background: rgba(200, 240, 90, 0.25); color: var(--fg); }

/* ── Boot screen ───────────────────────────────────────────────────────────── */
#boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#boot-text {
  font-family: var(--font);
  font-size: 12px;
  color: var(--fg-dim);
  white-space: pre;
  line-height: 1.4;
}

/* ── Language toggle ───────────────────────────────────────────────────────── */
.lang-toggle {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.lang-toggle:hover { opacity: 1; }
.lang-btn {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s;
}
.lang-btn.active { color: var(--fg); }
.lang-btn:hover { color: var(--fg); }
.lang-sep { color: var(--fg-muted); font-size: 11px; }

/* ── Terminal window ───────────────────────────────────────────────────────── */
#terminal {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 16px;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.t-dots { display: flex; gap: 6px; }
.t-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.t-dot--red    { background: #f05a5a; }
.t-dot--yellow { background: #f0c040; }
.t-dot--green  { background: #5ac88f; }
.t-title {
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}

/* ── Output area ───────────────────────────────────────────────────────────── */
.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 8px;
  scroll-behavior: smooth;
}

/* ── Prompt / input row ────────────────────────────────────────────────────── */
.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 0 4px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.t-prompt {
  color: var(--prompt);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  font-weight: 500;
}
.input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
#cmd-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  width: 100%;
  caret-color: transparent; /* we use custom cursor */
}
#cmd-input:disabled { opacity: 0.4; cursor: not-allowed; }

.t-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: var(--fg);
  vertical-align: middle;
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
  margin-left: 1px;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Output lines ──────────────────────────────────────────────────────────── */
.output-line {
  display: block;
  min-height: 1.4em;
  white-space: pre-wrap;
  word-break: break-word;
}
.line-cmd   { color: var(--fg); }
.line-out   { color: var(--fg); opacity: 0.8; }
.line-dim   { color: var(--fg-dim); }
.line-muted { color: var(--fg-muted); }
.line-err   { color: var(--err); }
.line-warn  { color: var(--warn); }
.line-accent{ color: var(--accent); }
.line-link  { color: var(--link); }
.line-prompt{ color: var(--prompt); }

.line-row   { display: flex; gap: 0; }
.row-prompt { color: var(--prompt); flex-shrink: 0; white-space: nowrap; user-select: none; }
.row-cmd    { color: var(--fg); word-break: break-all; }

/* ── Section helpers ───────────────────────────────────────────────────────── */
.sep {
  display: block;
  color: var(--fg-muted);
  margin: 4px 0;
}
.spacer { display: block; height: 8px; }
.green  { color: var(--fg); }
.dim    { color: var(--fg-dim); }
.muted  { color: var(--fg-muted); }
.accent { color: var(--accent); }
.link   { color: var(--link); }
.bold   { font-weight: 700; }
.err    { color: var(--err); }
.warn   { color: var(--warn); }

/* ── Contact modal ─────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  width: min(480px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--fg); }

.modal-heading {
  font-family: var(--font);
  font-size: 13px;
  color: var(--fg-dim);
  margin-bottom: 20px;
  font-weight: 400;
}
.modal-info {
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.8;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.modal-info a { color: var(--link); text-decoration: none; }
.modal-info a:hover { text-decoration: underline; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  background: rgba(200, 240, 90, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
}
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  border-color: rgba(200, 240, 90, 0.3);
  background: rgba(200, 240, 90, 0.06);
}
select {
  width: 100%;
  background: rgba(200, 240, 90, 0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a5a20'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select option {
  background: #0a0c10;
  color: #c8f05a;
}
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.form-hint {
  font-size: 11px;
  color: var(--fg-muted);
}
.btn-submit {
  background: rgba(200, 240, 90, 0.12);
  border: 1px solid rgba(200, 240, 90, 0.25);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-submit:hover {
  background: rgba(200, 240, 90, 0.2);
  border-color: rgba(200, 240, 90, 0.4);
}
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP ENVIRONMENT
   ═══════════════════════════════════════════════════════════════════ */

/* Desktop background */
#desktop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(200, 240, 90, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(200, 240, 90, 0.03) 0%, transparent 40%),
    #0a0c10;
  overflow: hidden;
  user-select: none;
}

/* Desktop icons grid */
#desktop-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, 80px);
  grid-auto-rows: 88px;
  gap: 4px;
  padding: 20px;
  align-content: start;
  height: calc(100vh - 40px);
}

.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.icon-item:hover {
  background: rgba(200, 240, 90, 0.06);
  border-color: rgba(200, 240, 90, 0.12);
}
.icon-item:active { transform: scale(0.96); }
.icon-item.selected {
  background: rgba(200, 240, 90, 0.1);
  border-color: rgba(200, 240, 90, 0.2);
}

.icon-emoji {
  font-size: 32px;
  line-height: 1;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}
.icon-label {
  font-family: var(--font);
  font-size: 10px;
  color: #c8f05a;
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  word-break: break-word;
}
.icon-label-en {
  display: none;
  font-size: 9px;
  color: rgba(200, 240, 90, 0.6);
  margin-top: 1px;
}
html[lang=en] .icon-label-en { display: block; }
html[lang=en] .icon-label-it { display: none; }

/* Taskbar */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(12, 14, 20, 0.95);
  border-top: 1px solid rgba(200, 240, 90, 0.12);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  z-index: 900;
  backdrop-filter: blur(8px);
}

#taskbar-start {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  cursor: pointer;
  border-right: 1px solid rgba(200, 240, 90, 0.08);
}
#taskbar-start:hover { background: rgba(200, 240, 90, 0.05); }
.taskbar-logo { font-size: 14px; color: #c8f05a; }
.taskbar-brand { font-family: var(--font); font-size: 11px; color: rgba(200, 240, 90, 0.5); }

#taskbar-windows {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 0 8px;
  overflow: hidden;
  height: 100%;
}

.taskbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  color: rgba(200, 240, 90, 0.6);
  background: transparent;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  transition: background 0.1s, color 0.1s;
}
.taskbar-btn:hover { background: rgba(200, 240, 90, 0.08); color: #c8f05a; }
.taskbar-btn.active {
  background: rgba(200, 240, 90, 0.12);
  color: #c8f05a;
  box-shadow: 0 -1px 0 rgba(200, 240, 90, 0.3) inset;
}
.taskbar-btn-icon { font-size: 13px; }

#taskbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-left: 1px solid rgba(200, 240, 90, 0.08);
}
#taskbar-clock { font-family: var(--font); font-size: 11px; color: rgba(200, 240, 90, 0.7); padding: 0 8px; }

.taskbar-lang { display: flex; align-items: center; gap: 2px; }
.taskbar-lang button {
  background: none;
  border: none;
  color: rgba(200, 240, 90, 0.4);
  font-family: var(--font);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.taskbar-lang button:hover { color: #c8f05a; }
.taskbar-lang button.active { color: #c8f05a; background: rgba(200, 240, 90, 0.08); }

/* Window container */
#windows-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
}

/* Desktop windows */
.win {
  position: absolute;
  background: #0d1018;
  border: 1px solid rgba(200, 240, 90, 0.15);
  border-radius: 8px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(200, 240, 90, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
  min-width: 340px;
  min-height: 240px;
}
.win.focused {
  border-color: rgba(200, 240, 90, 0.35);
  box-shadow: 0 20px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(200, 240, 90, 0.1);
}

.win-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  background: rgba(12, 14, 20, 0.9);
  border-bottom: 1px solid rgba(200, 240, 90, 0.08);
  flex-shrink: 0;
  cursor: move;
}
.win-icon { font-size: 14px; }
.win-title { font-family: var(--font); font-size: 12px; color: rgba(200, 240, 90, 0.7); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-controls { display: flex; gap: 6px; margin-left: auto; }
.win-ctrl { width: 12px; height: 12px; border-radius: 50%; border: none; cursor: pointer; opacity: 0.7; }
.win-ctrl:hover { opacity: 1; }
.win-ctrl--close { background: #f05a5a; }
.win-ctrl--min  { background: #f0c040; }
.win-ctrl--max  { background: #5ac88f; }

.win-body { flex: 1; overflow-y: auto; padding: 20px 24px; scroll-behavior: smooth; }

/* Window content styles */
.win-content { font-family: var(--font); font-size: 13px; color: rgba(200, 240, 90, 0.85); line-height: 1.8; }
.win-content h2 { color: #c8f05a; font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.win-content h3 { color: #c8f05a; font-size: 13px; font-weight: 500; margin: 16px 0 8px; }
.win-content p  { margin: 8px 0; }
.win-content a  { color: #7ad4ff; text-decoration: none; }
.win-content a:hover { text-decoration: underline; }
.win-content ul { margin: 8px 0; padding-left: 20px; }
.win-content li { margin: 4px 0; }
.win-content hr  { border: none; border-top: 1px solid rgba(200, 240, 90, 0.08); margin: 16px 0; }
.win-badge { display: inline-block; background: rgba(200, 240, 90, 0.12); border: 1px solid rgba(200, 240, 90, 0.2); border-radius: 3px; padding: 1px 6px; font-size: 10px; color: rgba(200, 240, 90, 0.6); margin-left: 6px; }

/* Terminal window — full terminal experience */
#win-terminal .win-body {
  padding: 0;
  background: #0a0c10;
  display: flex;
  flex-direction: column;
}
#win-terminal .terminal-titlebar {
  flex-shrink: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(200, 240, 90, 0.08);
}
#win-terminal .terminal-output { flex: 1; }
#win-terminal .terminal-input-row { flex-shrink: 0; }

@media (max-width: 600px) {
  #desktop-icons { grid-template-columns: repeat(auto-fill, 70px); grid-auto-rows: 82px; padding: 12px; }
  .icon-emoji { font-size: 26px; }
  .icon-label { font-size: 9px; }
  .win { min-width: 280px; border-radius: 6px; }
  .win-body { padding: 14px 16px; }
  #win-terminal { width: calc(100vw - 16px) !important; left: 8px !important; top: 8px !important; height: calc(100vh - 64px) !important; }
  #win-chisiamo, #win-servizi, #win-progetti { width: calc(100vw - 16px) !important; left: 8px !important; }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }