/* ============ Fun & interactive layer ============ */

/* ---------- Floating dock ---------- */
.dock {
  position: fixed; z-index: 55; right: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px; border-radius: 999px;
  background: rgba(13,13,22,.7); backdrop-filter: blur(16px); border: 1px solid var(--border);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.8);
}
.dock button {
  position: relative; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: 600 14px "JetBrains Mono", monospace;
  display: grid; place-items: center; transition: transform .4s var(--ease), background .3s, border-color .3s;
}
.dock button:hover { transform: translateY(-4px) scale(1.08); border-color: var(--accent-2); }
.dock button[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); right: 0; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 11px; font-weight: 600;
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .2s, transform .3s var(--ease);
}
.dock button:hover::after { opacity: 1; transform: none; }
.dock .swatch { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(var(--accent), var(--accent-2), var(--accent-3), var(--accent)); }
.dock .kbd { position: absolute; top: -6px; left: -6px; font-size: 9px; padding: 2px 5px; border-radius: 5px; background: var(--accent); color: #fff; }
@media (hover: none), (max-width: 800px) { .dock .kbd { display: none; } .dock button[data-tip]::after { display: none; } }

/* ---------- Terminal ---------- */
.term-overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(6,6,10,.6); backdrop-filter: blur(10px);
  opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s;
}
.term-overlay.open { opacity: 1; visibility: visible; transition: opacity .3s; }
.terminal {
  width: min(760px, 100%); height: min(520px, 80svh); display: flex; flex-direction: column;
  border-radius: 18px; overflow: hidden; background: #0a0a12; border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 0 0 1px rgba(124,92,255,.25), 0 50px 120px -30px rgba(124,92,255,.55);
  transform: translateY(30px) scale(.96); transition: transform .5s var(--ease);
  font: 14px/1.65 "JetBrains Mono", monospace;
}
.term-overlay.open .terminal { transform: none; }
.terminal-head { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.terminal-head .mock-bar { margin: 0; }
.terminal-head button { margin-left: auto; background: none; border: 0; color: var(--muted); font: inherit; }
.terminal-out { flex: 1; overflow-y: auto; padding: 16px 18px; white-space: pre-wrap; word-break: break-word; overscroll-behavior: contain; }
.terminal-out .cmd { color: var(--text); }
.terminal-out .cmd::before { content: "alessio@portfolio:~$ "; color: var(--accent-2); }
.terminal-out .dim { color: var(--muted); }
.terminal-out .hl { color: var(--accent-2); }
.terminal-out .warn { color: var(--accent-3); }
.terminal-out .ok { color: #4ade80; }
.terminal-in { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.terminal-in label { color: var(--accent-2); white-space: nowrap; }
.terminal-in input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; caret-color: var(--accent-2); }
.term-chips { display: flex; gap: 6px; padding: 0 18px 12px; overflow-x: auto; scrollbar-width: none; }
.term-chips button { flex: none; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font: 12px "JetBrains Mono", monospace; }
.term-chips button:hover { color: var(--text); border-color: var(--accent-2); }
@media (max-width: 600px) { .terminal { font-size: 12.5px; height: 80svh; } .terminal-in label { display: none; } }

/* ---------- Bug Hunt ---------- */
.game { padding: 40px 0 140px; }
.game-box {
  position: relative; height: clamp(380px, 58vh, 520px); border-radius: 28px; overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(124,92,255,.18), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0,229,199,.12), transparent 50%),
    var(--bg-2);
  border: 1px solid var(--border); touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.game-box::before {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
}
.game-hud { position: absolute; top: 16px; left: 16px; right: 16px; z-index: 3; display: flex; justify-content: space-between; gap: 8px; font: 600 14px "JetBrains Mono", monospace; pointer-events: none; }
.game-hud span { padding: 8px 14px; border-radius: 999px; background: rgba(6,6,10,.7); border: 1px solid var(--border); }
.game-hud b { color: var(--accent-2); }
.game-screen {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; background: rgba(6,6,10,.72); backdrop-filter: blur(6px);
  transition: opacity .4s, visibility 0s;
}
.game-screen.hidden { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }
.game-screen h3 { font-size: clamp(28px, 4.5vw, 52px); letter-spacing: -0.04em; line-height: 1.05; }
.game-screen p { color: var(--muted); max-width: 460px; }
.game-legend { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; font: 13px "JetBrains Mono", monospace; color: var(--muted); }
.bug {
  position: absolute; z-index: 2; width: 52px; height: 52px; margin: -26px 0 0 -26px; border: 0; background: none; padding: 0;
  font-size: 36px; line-height: 52px; text-align: center; will-change: transform; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6));
}
.bug.feature { font-size: 32px; }
.splat { position: absolute; z-index: 1; pointer-events: none; font: 700 18px "JetBrains Mono", monospace; transform: translate(-50%, -50%); animation: splat .8s var(--ease) forwards; }
.splat.plus { color: #4ade80; } .splat.minus { color: var(--accent-3); }
@keyframes splat { from { opacity: 1; transform: translate(-50%, -50%) scale(.6); } to { opacity: 0; transform: translate(-50%, -160%) scale(1.3); } }
.game-box.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- Toasts (achievements) ---------- */
.toasts { position: fixed; z-index: 85; left: 50%; top: max(84px, calc(env(safe-area-inset-top) + 70px)); transform: translateX(-50%); display: grid; gap: 10px; pointer-events: none; width: min(380px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px;
  background: rgba(13,13,22,.92); backdrop-filter: blur(14px); border: 1px solid rgba(0,229,199,.35);
  box-shadow: 0 20px 50px -20px rgba(0,229,199,.5);
  animation: toastIn .6s var(--ease), toastOut .5s ease 3.4s forwards;
}
.toast .ico { font-size: 28px; }
.toast small { display: block; color: var(--accent-2); font: 600 11px "JetBrains Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.toast b { font-size: 15px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* ---------- Click sparks + confetti + matrix ---------- */
.spark { position: fixed; z-index: 92; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; }
.fx-canvas { position: fixed; inset: 0; z-index: 91; pointer-events: none; }
body.party .aurora span { animation-duration: 3s; opacity: .6; }
body.party .grad, body.party .split.grad .char { animation: hue 1.2s linear infinite; }
@keyframes hue { to { filter: hue-rotate(360deg); } }

/* ---------- Hero letters jelly ---------- */
.hero h1 .char { pointer-events: auto; }

/* ---------- Footer timer ---------- */
.time-spent { color: var(--muted); }
.time-spent b { color: var(--accent-2); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .spark, .fx-canvas { display: none; }
}

/* ---------- Tools: macOS dock ---------- */
.tools { padding: 40px 0 120px; overflow: hidden; }
.tools-hint { color: var(--muted); font-size: 13px; margin: -24px 0 24px; }
.mac-dock-wrap { display: flex; justify-content: center; margin-bottom: 64px; }
.mac-dock {
  display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; height: 80px;
  border-radius: 24px; background: rgba(255,255,255,.06); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.12); box-shadow: 0 30px 80px -30px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.08);
  max-width: 100%;
}
/* icons pop out of the top of the dock when magnified, like macOS */
@media (max-width: 1150px) and (min-width: 801px) { .dock-item { width: calc(44px * var(--s)); height: calc(44px * var(--s)); } .mac-dock { height: 68px; gap: 8px; } }
.dock-item {
  --s: 1; position: relative; flex: none; padding: 0; border: 0; background: none;
  width: calc(56px * var(--s)); height: calc(56px * var(--s));
  transition: width .18s ease-out, height .18s ease-out;
}
.dock-item .ic { width: 100%; height: 100%; border-radius: 22%; }
.dock-item em {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translate(-50%, 6px); white-space: nowrap;
  padding: 5px 10px; border-radius: 8px; background: rgba(13,13,22,.95); border: 1px solid var(--border);
  font: 600 12px "JetBrains Mono", monospace; font-style: normal; color: var(--text);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease);
}
.dock-item:hover em, .dock-item:focus-visible em { opacity: 1; transform: translate(-50%, 0); }
.dock-item:active { transform: translateY(-14px); transition: transform .15s; }

/* shared logo tile */
.ic {
  display: grid; place-items: center; flex: none; padding: 0;
  background: linear-gradient(160deg, #ffffff, #e9e9f1); border-radius: 14px;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.7), inset 0 -2px 0 rgba(0,0,0,.08);
}
/* % padding would resolve against the parent's width, so size the logo instead */
.ic img { width: 64%; height: 64%; object-fit: contain; }
.ic .mask {
  display: block; width: 64%; height: 64%; background: var(--c);
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat;
}

/* ---------- Tools: cards ---------- */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tool-card {
  position: relative; display: flex; gap: 16px; align-items: flex-start; padding: 20px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--border); overflow: hidden;
  transition: transform .5s var(--ease), border-color .3s, box-shadow .4s;
}
.tool-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .4s;
  background: radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--brand) 35%, transparent), transparent 60%);
}
.tool-card:hover { transform: translateY(-6px); border-color: color-mix(in srgb, var(--brand) 60%, transparent); box-shadow: 0 24px 50px -24px var(--brand); }
.tool-card:hover::before { opacity: 1; }
.tool-card { isolation: isolate; }
.tool-card .ic { width: 52px; height: 52px; transition: transform .6s var(--ease); }
.tool-card:hover .ic { transform: rotate(-8deg) scale(1.08); }
.tool-card h3 { font-size: 18px; letter-spacing: -0.02em; margin-bottom: 4px; }
.tool-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.tool-card.ping { animation: ping-card 1.4s var(--ease); }
@keyframes ping-card {
  0% { box-shadow: 0 0 0 0 var(--brand); border-color: var(--brand); }
  60% { box-shadow: 0 0 0 14px transparent; border-color: var(--brand); }
}

/* ---------- Logo wall ---------- */
.logo-wall { margin-top: 96px; display: grid; gap: 16px; -webkit-mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.wall-row { overflow: hidden; }
.wall-track { display: flex; width: max-content; gap: 14px; animation: wall 50s linear infinite; }
.wall-dup { display: flex; gap: 14px; }
.wall-row.rev .wall-track { animation-direction: reverse; animation-duration: 60s; }
.logo-wall:hover .wall-track { animation-play-state: paused; }
@keyframes wall { to { transform: translateX(calc(-50% - 7px)); } }
.wall-chip {
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--border); font-weight: 500; white-space: nowrap;
  transition: transform .4s var(--ease), border-color .3s, background .3s;
}
.wall-chip .ic { width: 40px; height: 40px; border-radius: 11px; }
.wall-chip:hover { transform: translateY(-4px) scale(1.04); border-color: var(--accent-2); background: rgba(255,255,255,.07); }

@media (max-width: 800px) {
  .mac-dock-wrap { justify-content: flex-start; margin-inline: -20px; padding-inline: 20px; margin-bottom: 40px; }
  .mac-dock { height: auto; padding: 10px; gap: 8px; overflow-x: auto; scrollbar-width: none; }
  .dock-item { width: 48px; height: 48px; }
  .dock-item em { display: none; }
  .tools-grid { grid-template-columns: 1fr; }
  .tool-card { padding: 16px; }
  .tool-card .ic { width: 44px; height: 44px; }
  .logo-wall { margin-top: 64px; }
  .wall-chip { padding: 8px 14px 8px 8px; font-size: 14px; }
  .wall-chip .ic { width: 34px; height: 34px; }
  .dock { right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .wall-track { animation: none; flex-wrap: wrap; width: auto; justify-content: center; }
  .wall-dup { display: none; }
}

/* ---------- Android ---------- */
.android { padding: 60px 0 140px; }
.android-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 64px; align-items: center; }
.android-lead { color: var(--muted); font-size: 18px; margin: -24px 0 28px; max-width: 560px; }
.android-lead b { color: var(--text); font-weight: 500; }
.android-feats { list-style: none; display: grid; gap: 14px; margin-bottom: 32px; }
.android-feats li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); transition: transform .4s var(--ease), border-color .3s; }
.android-feats li:hover { transform: translateX(6px); border-color: #3DDC84; }
.android-feats li > span { font-size: 22px; line-height: 1.2; }
.android-feats b { display: block; font-weight: 600; }
.android-feats div { color: var(--muted); font-size: 15px; }
.android-stack { display: flex; flex-wrap: wrap; gap: 10px; }
.android-stack .wall-chip .ic { width: 34px; height: 34px; }

.android-phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; perspective: 1200px; }
.android-phone {
  position: relative; width: min(300px, 70vw); aspect-ratio: 1038 / 2048; border-radius: 42px; padding: 10px;
  background: linear-gradient(145deg, #2a2a35, #0c0c12); border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 60px 120px -40px rgba(61,220,132,.45), 0 0 0 2px #1a1a22, inset 0 0 0 2px rgba(255,255,255,.05);
  transform-style: preserve-3d; transition: transform .2s ease-out; cursor: pointer;
}
.android-phone::after { content: ""; position: absolute; right: -4px; top: 22%; width: 4px; height: 60px; border-radius: 0 4px 4px 0; background: #2a2a35; }
.phone-notch { position: absolute; z-index: 3; top: 20px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #000; box-shadow: 0 0 0 2px #111; }
.phone-screens { position: relative; width: 100%; height: 100%; border-radius: 33px; overflow: hidden; background: #000; }
.phone-screens img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.08); transition: opacity .6s var(--ease), transform .9s var(--ease); }
.phone-screens img.on { opacity: 1; transform: none; }
.phone-notif {
  position: absolute; z-index: 4; top: 38px; left: 18px; right: 18px; padding: 10px 12px; border-radius: 16px;
  background: rgba(30,30,40,.92); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12);
  font-size: 12px; display: grid; gap: 2px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  transform: translateY(-140%); opacity: 0; transition: transform .7s var(--ease), opacity .4s;
}
.phone-notif.show { transform: none; opacity: 1; }
.phone-notif em { font-style: normal; color: #3DDC84; font-weight: 600; }
.phone-tabs { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); }
.phone-tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; padding: 7px 12px; border-radius: 999px; transition: background .3s, color .3s; }
.phone-tabs button.on { background: #3DDC84; color: #062b16; font-weight: 600; }
.phone-hint { color: var(--muted); font-size: 12px; }

@media (max-width: 1000px) {
  .android-grid { grid-template-columns: 1fr; gap: 48px; }
  .android-phone-wrap { order: -1; }
}
@media (max-width: 600px) {
  .android { padding: 40px 0 100px; }
  .android-lead { font-size: 16px; }
  .phone-tabs button { padding: 6px 9px; }
}
