/* ==========================================================================
   lucastang.dev — animated boot/desktop intro
   Monitor screen fractions (of assets/desk-photo.png, 1448x1086, re-measured
   via edge detection against the bezels) live in boot.js as SCREENS — the
   overlay divs are positioned in JS against the photo's actual object-fit:
   cover render rect, not fixed CSS %, so alignment holds at any viewport
   aspect ratio. See computeCoverRect()/updateMonitorPositions() in boot.js.
   ========================================================================== */

:root {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #cccccc;
  --orange: #f97316;
  --accent: #7f5af0;

  /* Center of the whole monitor cluster, used as the zoom transform-origin */
  --cluster-cx: 43.38%;
  --cluster-cy: 53.27%;

  /* How far in Scene 2 pushes the camera (also the tight-zoom scroll limit) */
  --zoom-scale: 2.6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

/* ---------- Stage: the photo + everything pinned to it ---------- */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  transform-origin: var(--cluster-cx) var(--cluster-cy);
  transition: transform 1.4s cubic-bezier(.62,0,.3,1);
}

#stage.zoomed {
  transform: scale(var(--zoom-scale));
}

#desk-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(0px);
}

/* Monitor overlay divs — left/top/width/height are set in boot.js against
   the photo's computed object-fit:cover render rect, kept in the same
   untransformed layout space as #stage so the shared #stage scale carries
   both the photo and these overlays together at any zoom level. */
.monitor-overlay {
  position: absolute;
  overflow: hidden;
  background: #000;
  transition: opacity .25s ease;
}

/* ---------- Scene 1: boot flicker ---------- */

.monitor-overlay.flicker {
  animation: flicker 1.1s steps(1, end) 1;
}

@keyframes flicker {
  0%   { background: #000; }
  8%   { background: #dfe9ff; }
  16%  { background: #000; }
  26%  { background: #dfe9ff; }
  36%  { background: #04060c; }
  100% { background: #04060c; }
}

.boot-splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #04060c;
  opacity: 0;
  transition: opacity .3s ease;
}

.boot-splash.visible { opacity: 1; }

.boot-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid #2a2f3d;
  border-top-color: var(--ink);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scene 3: rendered desktop screens ---------- */

.screen-content {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .6s ease;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.screen-content.visible { opacity: 1; }

/* Bottom monitor: code editor / terminal, wrapped in a zoomable stage */

#code-stage {
  position: absolute;
  inset: 0;
  transform-origin: center center;
}

#code-editor {
  display: flex;
  height: 100%;
  background: #282a36;
  font-size: clamp(5px, 0.75vw, 9px);
  line-height: 1.6;
}

#code-editor .gutter {
  padding: 6px 8px;
  color: #6272a4;
  text-align: right;
  user-select: none;
  border-right: 1px solid #414458;
}

#code-editor .code-body {
  flex: 1;
  padding: 6px 10px;
  white-space: pre-wrap;
  color: #f8f8f2;
  overflow: hidden;
}

#code-editor .code-body .kw { color: #ff79c6; }
#code-editor .code-body .str { color: #f1fa8c; }
#code-editor .code-body .fn { color: #50fa7b; }
#code-editor .code-body .cm { color: #6272a4; }
#code-editor .code-body .num { color: #bd93f9; }

#terminal-panel {
  position: absolute;
  inset: 0;
  height: 100%;
  background: #282a36;
  color: #f8f8f2;
  padding: 6px 10px;
  font-size: clamp(5px, 0.75vw, 9px);
  line-height: 1.7;
  opacity: 0;
  transition: opacity .35s ease;
}

#terminal-panel.visible { opacity: 1; }

#terminal-panel .prompt { color: #50fa7b; }
#terminal-panel .out { color: #6272a4; }

/* Top monitor: split preview / spotify */

#top-monitor-inner {
  display: flex;
  height: 100%;
}

#preview-pane, #spotify-pane {
  flex: 1 1 50%;
  height: 100%;
  overflow: hidden;
}

#preview-pane {
  border-right: 1px solid #1f2733;
  background: #0d1117;
  display: flex;
  flex-direction: column;
}

/* ---------- Fake GitHub mockup (top-left panel) ----------
   Entirely static/invented: no real repo data, no outbound links. */

.gh-topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: #1c2128;
  font-size: clamp(5px, .8vw, 9px);
  color: #8b949e;
  flex: 0 0 auto;
}

.gh-topbar .dot {
  width: 5px; height: 5px; border-radius: 50%; background: #495264;
}

.gh-topbar .url {
  flex: 1;
  background: #0d1117;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 4px;
  color: #c9d1d9;
}

.gh-body {
  flex: 1;
  display: flex;
  min-height: 0;
  font-size: clamp(5px, .75vw, 8.5px);
}

.gh-main {
  flex: 1;
  padding: 5px 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.gh-stats {
  display: flex;
  gap: 8px;
  color: #8b949e;
  flex: 0 0 auto;
  margin-bottom: 4px;
}

.gh-graph {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 1.5px;
  flex: 0 0 auto;
  margin-bottom: 5px;
}

.gh-graph .gh-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 1px;
  background: #161b22;
}

.gh-graph .gh-cell[data-level="1"] { background: #0e4429; }
.gh-graph .gh-cell[data-level="2"] { background: #006d32; }
.gh-graph .gh-cell[data-level="3"] { background: #26a641; }
.gh-graph .gh-cell[data-level="4"] { background: #39d353; }

.gh-commits {
  list-style: none;
  color: #8b949e;
  line-height: 1.7;
  overflow: hidden;
}

.gh-commits .gh-hash {
  color: #6ca6f7;
  margin-right: 4px;
}

.gh-commits em {
  float: right;
  font-style: normal;
  color: #565d68;
}

/* ---------- Custom Spotify-style widget (top-right panel) ----------
   Own player UI over real static playlist data (see boot.js TRACKS), not
   Spotify's iframe/chrome. */

#spotify-pane {
  background: #121212;
}

.sp-widget {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 1vw, 8px);
  padding: clamp(4px, 2vw, 10px);
  font-size: clamp(5px, .85vw, 9px);
}

.sp-art {
  width: clamp(24px, 34%, 64px);
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  background: #282828;
  flex: 0 0 auto;
}

.sp-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sp-info {
  width: 100%;
  text-align: center;
  color: #fff;
}

.sp-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-artist {
  color: #b3b3b3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-progress {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: #4d4d4d;
  margin-top: 4px;
  overflow: hidden;
}

.sp-progress-fill {
  height: 100%;
  width: 0%;
  background: #1db954;
}

.sp-controls {
  display: flex;
  align-items: center;
  gap: clamp(8px, 3vw, 18px);
}

.sp-btn {
  background: none;
  border: 0;
  padding: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.sp-icon-prev {
  border-right: 6px solid #fff;
}

.sp-icon-next {
  border-left: 6px solid #fff;
}

.sp-icon-playpause {
  position: relative;
  display: inline-block;
  width: 9px;
  height: 10px;
}

.sp-icon-playpause.is-playing::before,
.sp-icon-playpause.is-playing::after {
  content: "";
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: #fff;
}

.sp-icon-playpause.is-playing::before { left: 0; }
.sp-icon-playpause.is-playing::after { left: 6px; }

.sp-icon-playpause.is-paused {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #fff;
}

/* ---------- Header (Scene 5) ---------- */

#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #000000;
  border-bottom: 1px solid #222;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform .7s cubic-bezier(.16,1,.3,1), opacity .7s ease;
}

#site-header.visible {
  transform: translateY(0);
  opacity: 1;
}

#site-header .nav {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#site-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

#site-header .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
}

#site-header .logo {
  font-family: "Architects Daughter", cursive;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
}

#site-header .links {
  display: flex;
  gap: 1.5rem;
}

#site-header .links a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.85;
  transition: opacity .15s ease;
}

#site-header .links a:hover { opacity: 1; color: var(--orange); }

/* ---------- Scroll hint (Scene 0) ---------- */

#scroll-hint {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.55);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: bob 2s ease-in-out infinite;
  transition: opacity .3s ease;
}

@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

body.booted #scroll-hint { opacity: 0; pointer-events: none; }

/* ---------- Reduced motion: static final state only ---------- */

@media (prefers-reduced-motion: reduce) {
  #stage, .monitor-overlay, .screen-content, #site-header, #terminal-panel {
    transition: none !important;
    animation: none !important;
  }
}
