/* ============ Variables ============ */
:root {
  --sky:        #5C94FC;
  --brick:      #E86A17;
  --brick-dark: #B84B00;
  --coin:       #F8B800;
  --coin-dark:  #C47A00;
  --pipe:       #3A8C36;
  --pipe-dark:  #2A6C28;
  --pipe-light: #6CC466;
  --white:      #FFFFFF;
  --black:      #000000;
  --panel:      #FFFEF5;
  --red:        #CC2200;

  --ink:        #1A1A1A;
  --ink-dim:    #4A4A4A;
  --ink-muted:  #888888;

  --font-pixel: 'Press Start 2P', monospace;
  --font-body:  system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  --border:     3px solid var(--black);
  --shadow:     5px 5px 0 var(--black);
  --shadow-sm:  3px 3px 0 var(--black);
}

/* ============ Reset ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-pixel); cursor: pointer; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--coin);
  outline-offset: 2px;
}

/* ============ Sky + Clouds ============ */
.sky-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--sky);
  overflow: hidden;
  pointer-events: none;
}

/* Blocky Mario-style clouds: two rectangular tiers */
.cloud {
  position: absolute;
  background: var(--white);
}
.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: var(--white);
}
/* Top bump */
.cloud::before {
  left: 20%;
  width: 60%;
  height: 100%;
  top: -70%;
}
/* Second bump */
.cloud::after {
  left: 50%;
  width: 40%;
  height: 80%;
  top: -50%;
}

.c1 { width: 112px; height: 32px; top: 12%; left: 6%;   animation: drift 50s -5s  linear infinite; }
.c2 { width: 80px;  height: 24px; top: 7%;  left: 38%;  animation: drift 38s -18s linear infinite; }
.c3 { width: 96px;  height: 28px; top: 22%; left: 62%;  animation: drift 44s -30s linear infinite; }
.c4 { width: 128px; height: 32px; top: 38%; left: 82%;  animation: drift 55s -10s linear infinite; }
.c5 { width: 80px;  height: 24px; top: 28%; left: 18%;  animation: drift 32s -22s linear infinite; }

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(-110vw - 200px)); }
}

/* ============ Pixel panel (shared) ============ */
.pixel-panel {
  border: var(--border);
  box-shadow: var(--shadow);
  background: var(--panel);
}

/* ============ Ground strip ============ */
.ground-strip {
  position: relative;
  z-index: 1;
  height: 40px;
  background:
    repeating-linear-gradient(90deg,
      transparent 0, transparent 39px,
      var(--brick-dark) 39px, var(--brick-dark) 40px),
    repeating-linear-gradient(0deg,
      transparent 0, transparent 19px,
      var(--brick-dark) 19px, var(--brick-dark) 20px);
  background-color: var(--brick);
  border-top: 3px solid var(--black);
  border-bottom: 3px solid var(--black);
}

/* ============ Nav ============ */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  height: 54px;
  background: var(--black);
  border-bottom: 4px solid var(--coin);
}
.nav-brand {
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--white);
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.nav-links {
  display: flex;
  gap: 20px;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.05em;
}
.nav-links a {
  color: var(--coin);
  transition: color 0.1s;
}
.nav-links a:hover { color: var(--white); }
.nav-hud {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-pixel);
  font-size: 10px;
  white-space: nowrap;
}
.hud-coins { color: var(--coin); letter-spacing: 0.05em; }

/* ============ Hero ============ */
.hero {
  max-width: 960px;
  margin: 0 auto;
  padding: 80px 24px 64px;
  position: relative;
  z-index: 1;
}
.status-box {
  padding: 36px;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.05em;
  margin-bottom: 28px;
}
.dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.dot-green  { background: #00C040; border: 2px solid var(--black); }
.dot-cyan   { background: #40C0C0; border: 2px solid var(--black); }
.dot-amber  { background: var(--coin); border: 2px solid var(--black); }
.hero h1 {
  font-family: var(--font-pixel);
  font-size: clamp(32px, 6vw, 60px);
  font-weight: normal;
  letter-spacing: 0.03em;
  margin-bottom: 14px;
  color: var(--black);
  text-shadow: 4px 4px 0 var(--brick);
  line-height: 1.2;
}
.hero .role {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--pipe-dark);
  margin-bottom: 24px;
  line-height: 2;
  letter-spacing: 0.04em;
}
.hero .tagline {
  font-family: var(--font-body);
  font-size: 16px;
  max-width: 560px;
  margin-bottom: 36px;
  color: var(--ink-dim);
  line-height: 1.75;
}
.cta-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 14px 20px;
  border: var(--border);
  box-shadow: var(--shadow);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: transform 0.06s, box-shadow 0.06s;
  line-height: 1.5;
}
.btn:hover  { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--black); }
.btn:active { transform: translate(5px, 5px); box-shadow: none; }
.btn-primary            { background: var(--coin);  color: var(--black); }
.btn-primary:hover      { background: var(--coin-dark); }
.btn-ghost:hover        { background: var(--pipe);  color: var(--white); }
.hero-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--ink-muted);
  padding-top: 20px;
  border-top: 3px solid var(--black);
  letter-spacing: 0.04em;
  line-height: 2;
}
.hero-meta .val { color: var(--brick); }

/* ============ Sections ============ */
main {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 40px;
}
.section {
  background: var(--panel);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  position: relative;
  z-index: 1;
}
footer.section {
  max-width: 960px;
  margin: 40px auto 80px;
  padding: 48px 40px;
  position: relative;
  z-index: 1;
  /* override main flex layout */
}
.eyebrow {
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--pipe);
  margin-bottom: 16px;
  line-height: 1.8;
}
.section h2 {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: normal;
  margin-bottom: 28px;
  max-width: 600px;
  color: var(--black);
  line-height: 1.6;
  letter-spacing: 0.02em;
}
.section > p {
  color: var(--ink-dim);
  max-width: 640px;
  margin-bottom: 16px;
  font-size: 16px;
  font-family: var(--font-body);
}
.section > p:last-of-type { margin-bottom: 0; }

/* ============ Stack ============ */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 28px;
}
.stack-group h3 {
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: normal;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 14px;
  line-height: 1.8;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 7px 10px;
  background: var(--coin);
  border: 2px solid var(--black);
  box-shadow: var(--shadow-sm);
  color: var(--black);
  letter-spacing: 0.04em;
  transition: transform 0.06s, box-shadow 0.06s;
  cursor: default;
}
.tag:hover {
  transform: translate(3px, 3px);
  box-shadow: none;
}

/* ============ Projects ============ */
.project-grid { display: grid; gap: 20px; }
.project-card { padding: 24px; cursor: pointer; transition: transform 0.06s, box-shadow 0.06s; }
.project-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.project-head h3 {
  font-family: var(--font-pixel);
  font-size: 11px;
  font-weight: normal;
  line-height: 1.7;
  color: var(--black);
  letter-spacing: 0.02em;
  max-width: 480px;
}
.project-card p {
  color: var(--ink-dim);
  font-size: 15px;
  margin-bottom: 16px;
  font-family: var(--font-body);
}

/* ============ Side processes ============ */
.process-list { display: flex; flex-direction: column; gap: 16px; }
.process-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  flex-wrap: wrap;
}
.powerup-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}
.process-name {
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: normal;
  min-width: 220px;
  color: var(--black);
  letter-spacing: 0.02em;
  line-height: 1.8;
}
.process-status {
  color: var(--ink-dim);
  font-size: 14px;
  flex: 1;
  min-width: 200px;
  font-family: var(--font-body);
}

/* ============ Footer ============ */
.contact-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.contact-links a {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--white);
  background: var(--pipe);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  transition: transform 0.06s, box-shadow 0.06s, background 0.06s;
}
.contact-links a:hover  { background: var(--pipe-dark); transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--black); }
.contact-links a:active { transform: translate(5px, 5px); box-shadow: none; }
.footer-note {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--ink-muted);
  margin-top: 32px;
  letter-spacing: 0.05em;
  line-height: 2;
}

/* ============ ? Block orb ============ */
#orb {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--coin);
  border: var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: transform 0.08s, box-shadow 0.08s;
}
#orb:hover  { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--black); }
#orb:active { transform: translate(5px, 5px); box-shadow: none; }
#orb.hidden { opacity: 0; pointer-events: none; transform: scale(0.85); }
.orb-label {
  font-family: var(--font-pixel);
  font-size: 26px;
  color: var(--black);
  line-height: 1;
  user-select: none;
}

/* ============ Hint bubble ============ */
.hint-bubble {
  position: fixed;
  bottom: 96px;
  right: 24px;
  max-width: 240px;
  background: var(--black);
  border: 3px solid var(--white);
  padding: 12px 14px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--white);
  line-height: 2;
  letter-spacing: 0.05em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 999;
}
.hint-bubble.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.hint-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  right: 22px;
  width: 8px;
  height: 8px;
  background: var(--black);
  border-right: 3px solid var(--white);
  border-bottom: 3px solid var(--white);
  transform: rotate(45deg);
}

/* ============ Chat panel ============ */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 48px);
  background: var(--black);
  border: 3px solid var(--white);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  overflow: hidden;
}
.chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 3px solid var(--white);
  background: var(--brick);
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--white);
  letter-spacing: 0.04em;
}
.chat-icon { font-size: 14px; flex-shrink: 0; }
.chat-header .chat-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.6;
}
.chat-header button {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 4px 6px;
  line-height: 1;
  transition: color 0.1s;
}
.chat-header button:hover { color: var(--coin); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--black);
}
.chat-msg { font-size: 13px; line-height: 1.6; max-width: 90%; }
.chat-msg.bot {
  font-family: var(--font-pixel);
  font-size: 9px;
  align-self: flex-start;
  color: var(--white);
  line-height: 2;
}
.chat-msg.bot::before { content: '▶ '; color: var(--coin); }
.chat-msg.user {
  align-self: flex-end;
  color: var(--coin);
  font-family: var(--font-pixel);
  font-size: 9px;
  text-align: right;
  line-height: 2;
}
.chat-msg.system {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--ink-muted);
  align-self: flex-start;
  max-width: 100%;
  line-height: 2;
}
.chat-msg.system::before { content: '# '; color: var(--pipe-light); }

/* Model loading progress */
.model-progress {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--ink-muted);
  align-self: flex-start;
  max-width: 100%;
  line-height: 2;
}
.model-progress .bar {
  display: inline-block;
  width: 80px;
  height: 8px;
  background: #333;
  vertical-align: middle;
  overflow: hidden;
  margin: 0 6px;
  border: 2px solid #555;
}
.model-progress .bar-fill {
  height: 100%;
  background: var(--coin);
  transition: width 0.3s;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 16px 12px;
  background: var(--black);
}
.chat-suggestions button {
  font-family: var(--font-pixel);
  font-size: 8px;
  text-align: left;
  background: none;
  border: 2px solid #444;
  color: var(--coin);
  padding: 9px 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  line-height: 1.8;
  transition: border-color 0.1s, color 0.1s;
}
.chat-suggestions button:hover { border-color: var(--coin); color: var(--white); }
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 3px solid var(--white);
  background: var(--black);
}
.chat-input-row .prompt-char {
  font-family: var(--font-pixel);
  color: var(--coin);
  font-size: 14px;
  flex-shrink: 0;
}
.chat-input-row input {
  flex: 1;
  background: none;
  border: none;
  color: var(--white);
  font-family: var(--font-pixel);
  font-size: 9px;
  outline: none;
  min-width: 0;
  letter-spacing: 0.04em;
}
.chat-input-row input::placeholder { color: #555; font-size: 8px; }
.chat-input-row input:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-input-row button {
  background: var(--pipe);
  border: 2px solid var(--white);
  color: var(--white);
  font-family: var(--font-pixel);
  font-size: 8px;
  cursor: pointer;
  padding: 7px 12px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  transition: background 0.1s;
}
.chat-input-row button:hover:not(:disabled) { background: var(--pipe-dark); }
.chat-input-row button:disabled { opacity: 0.4; cursor: not-allowed; }


/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: var(--coin); }
::-webkit-scrollbar-thumb:hover { background: var(--coin-dark); }

/* ============ Project modal ============ */
.project-card:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--black); }
.view-infra {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--coin);
  margin-top: 12px;
  display: inline-block;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--panel);
  border: var(--border);
  box-shadow: var(--shadow);
  border-radius: 0;
  max-width: 860px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: var(--border);
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}
.modal-title-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-title-text .val { color: var(--ink); }
.modal-close {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-img {
  width: 100%;
  border-radius: 0;
  border: var(--border);
  display: block;
}
.modal-img-placeholder {
  border: 2px dashed var(--black);
  border-radius: 0;
  padding: 56px 24px;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--ink-muted);
  line-height: 2;
}
.modal-img-placeholder .path { color: var(--ink-dim); margin-top: 8px; word-break: break-all; }

.modal-meta {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  line-height: 1.8;
  margin-bottom: 16px;
}
.modal-detail-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.modal-detail-list li {
  position: relative;
  padding-left: 20px;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
}
.modal-detail-list li::before {
  content: '▶';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--coin);
  font-size: 10px;
}
.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

/* ============ History timeline ============ */
.dot-dim { background: var(--ink-muted); border: 2px solid var(--black); }

.timeline {
  position: relative;
  margin-top: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--ink-muted);
  z-index: 0;
}
.timeline-entry {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  background: none;
  border: none;
  padding: 0 0 28px;
  cursor: pointer;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}
.timeline-entry:last-child { padding-bottom: 0; }
.timeline-entry .dot { margin-top: 4px; flex-shrink: 0; }
.tl-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-role {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--black);
  letter-spacing: 0.02em;
  line-height: 1.6;
  transition: color 0.1s;
}
.tl-meta {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  line-height: 1.8;
}
.tl-summary {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-dim);
  line-height: 1.6;
  margin-top: 2px;
}
.tl-view {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--ink-muted);
  margin-top: 4px;
  transition: color 0.1s;
}
.timeline-entry:hover .tl-view,
.timeline-entry:focus-visible .tl-view { color: var(--coin); }
.timeline-entry:hover .tl-role { color: var(--coin); }

/* ============ Animations ============ */
@media (prefers-reduced-motion: no-preference) {
  #orb { animation: block-bob 0.7s ease-in-out infinite alternate; }
  .dot-green { animation: pixel-blink 1.2s step-end infinite; }
}
@keyframes block-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-8px); box-shadow: 5px 13px 0 var(--black); }
}
@keyframes pixel-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
  .nav-links { display: none; }
  .hero { padding: 60px 16px 48px; }
  .status-box { padding: 20px; }
  main { padding: 24px 16px; gap: 20px; }
  .section { padding: 32px 20px; }
  footer.section { margin: 20px 16px 80px; padding: 32px 20px; }
  .process-row { flex-direction: column; align-items: flex-start; }
  .process-name { min-width: auto; }
  .chat-panel { width: calc(100vw - 32px); height: 60vh; }
  .hero h1 { font-size: 28px; }
}
