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

:root {
  --bg:        #24292E;
  --bg-panel:  #1F2428;
  --bg-header: #1B1F23;
  --border:    #30363D;
  --text:      #E1E4E8;
  --dim:       #6A737D;
  --accent:    #79B8FF;
  --func:      #B392F0;
  --kw:        #F97583;
  --str:       #9ECBFF;
  --orange:    #F9826C;
  --font: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

html, body {
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
}

.layout {
  width: min(100vw, 1024px);
  height: min(100vh, 760px);
  margin: 20px auto;
  border-radius: 22px;
  overflow: hidden;
  background: #1F2428;
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: none;
  position: relative;
  display: block;
}

/* Main screen that holds logo + views */
.screen {
  position: relative;
  width: 100%;
  height: calc(100% - 56px); /* reserve space for input row */
  overflow: hidden;
}

.title-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
}

.window-controls {
  position: absolute;
  top: 8px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 45;
  align-items: center;
}
.window-controls .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset; }

/* Top bar background to differentiate the window chrome */
.terminal-top-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.title-indicator {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
}
.window-controls {
  position: absolute;
  top: 18px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 45;
  align-items: center;
}

.title-indicator .tab {
  background: rgba(255,255,255,0.03);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--dim);
  border: 1px solid var(--border);
}

.home-btn {
  margin-left: 10px;
  background: rgba(255,255,255,0.02);
  color: var(--dim);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.home-btn:hover { color: var(--text); background: rgba(121,184,255,0.06); }

.logo-bg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.logo-bg img {
  width: 340px;
  height: 340px;
  opacity: 0.06;
  border-radius: 6px;
  object-fit: cover;
  transition: opacity 180ms ease;
}

@media (max-width: 900px) {
  .logo-bg img { width: 220px; height: 220px; opacity: 0.06; }
}

/* hide centered background logo when certain views are open */
.layout.view-open-about .logo-bg,
.layout.view-open-portfolio .logo-bg {
  display: none;
}

/* reserve top space under the fixed title bar for all screen content */
.screen {
  position: relative;
  width: 100%;
  height: calc(100% - 56px); /* reserve space for input row */
  overflow: hidden;
  padding-top: 56px;
}

/* Terminal output overlay */
.terminal-output {
  position: absolute;
  top: 56px; /* align with the top bar height */
  left: 12px;
  right: 12px;
  bottom: 12px;
  margin-bottom: 64px; /* leave space for input */
  overflow-y: auto;
  padding: 18px 20px;
  padding-top: 6px; /* small inner top padding for first line */
  font-size: 13px;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: transparent;
  z-index: 20;
}

.terminal-output::-webkit-scrollbar { width: 8px; }
.terminal-output::-webkit-scrollbar-thumb { background: var(--border); }

/* Terminal input row pinned to bottom of the layout */
.terminal-input-row.bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 8px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  z-index: 30;
}

.terminal-input-row.bottom .terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}

/* ── TERMINAL ─────────────────────────────── */
.terminal-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot-r { background: #ff5f56; }
.dot-y { background: #ffbd2e; }
.dot-g { background: #27c93f; }

.bar-title {
  font-size: 11px;
  color: var(--dim);
  margin-left: 6px;
  letter-spacing: 0.5px;
}

/* terminal-output is defined earlier as overlay */

.ln      { color: var(--text); margin: 1px 0; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; }
.ln-dim  { color: var(--dim); }
.ln-info { color: #8B949E; }
.ln-cmd  { color: var(--func); }
.ln-err  { color: var(--kw); }
.ln-sep  { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  gap: 6px;
  flex-shrink: 0;
}

.prompt-label {
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.terminal-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  caret-color: var(--orange);
}

/* ── CONTENT PANEL ────────────────────────── */
.content-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.content-titlebar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: 40px;
  flex-shrink: 0;
  gap: 4px;
}

.tab {
  font-size: 12px;
  color: var(--dim);
  padding: 2px 12px;
  border-radius: 2px;
}

.tab.active {
  color: var(--text);
  background: rgba(121, 184, 255, 0.08);
  border: 1px solid var(--border);
}

.content-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.content-body::-webkit-scrollbar { width: 4px; }
.content-body::-webkit-scrollbar-thumb { background: var(--border); }

/* ── MATRIX ──────────────────────────────── */
#view-matrix,
#view-train {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  display: none;
  overflow: hidden;
}
#view-matrix {
  z-index: 10;
}
#view-matrix canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#view-train {
  z-index: 11;
  padding: 18px 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#train-display {
  white-space: pre;
  font: 13px/1.2 monospace;
  color: #0f0;
  max-width: 100%;
  overflow-x: auto;
}
.matrix-msg {
  position: absolute;
  bottom: 24px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  color: rgba(0,255,65,0.4);
  font-family: var(--font);
  pointer-events: none;
}

/* ── VIEWS ────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view { animation: fadeUp 0.18s ease; }

/* Add inner padding and scrolling for views so content isn't flush to edges */
.view {
  padding: 32px 32px 28px;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Constrain content width and center to avoid text touching edges */
.view > * {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* welcome */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 18px;
  opacity: 0.5;
  user-select: none;
  text-align: center;
}

.welcome-code {
  font-size: 13px;
  line-height: 1.8;
  text-align: left;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
}
.kw  { color: var(--kw); }
.var { color: var(--accent); }
.str { color: var(--str); }
.key { color: var(--text); }

.avatar {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--border);
  box-shadow: 0 0 0 4px rgba(121, 184, 255, 0.08);
  display: block;
}

.welcome-name {
  font-size: 15px;
  color: var(--text);
  letter-spacing: 0.5px;
}

.welcome-hint { font-size: 12px; color: #8B949E; }
.welcome-hint span { color: var(--str); }

/* about */
.about-header {
  display: block;
  position: relative;
  margin-bottom: 36px;
  padding-right: 160px; /* room for avatar */
}
.about-header-text { flex: 1; }
.about h1 { font-size: 22px; color: var(--text); margin-bottom: 4px; margin-top: 14px; }
.about .sub { font-size: 13px; color: var(--dim); margin-bottom: 0; }
.about-avatar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--border);
  box-shadow: 0 0 0 4px rgba(121, 184, 255, 0.08);
}
.about section { margin-bottom: 30px; }

.section-label {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 3px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.about p { font-size: 14px; color: var(--text); line-height: 1.85; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 2px;
  background: rgba(121, 184, 255, 0.07);
}

.links { display: flex; gap: 16px; flex-wrap: wrap; }
.links a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.links a:hover { color: var(--str); border-color: var(--str); }

/* portfolio */
.portfolio h1 { font-size: 22px; color: var(--text); margin-bottom: 4px; margin-top: 14px; }
.portfolio .sub { font-size: 13px; color: var(--dim); margin-bottom: 24px; }

.gh-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  background: rgba(121,184,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 22px;
  text-decoration: none;
  margin-bottom: 28px;
  transition: background 0.15s, border-color 0.15s;
}
.gh-link:hover { background: rgba(121,184,255,0.08); border-color: var(--accent); }
.gh-link svg { flex-shrink: 0; }

.project-grid { display: flex; flex-direction: column; gap: 8px; }

.card {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
.card:hover {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

.card-name {
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.card-name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.card-name a:hover { border-color: var(--accent); }
.card-name .ext { font-size: 11px; color: var(--dim); }

.card-desc { font-size: 13px; color: var(--text); line-height: 1.65; margin-bottom: 12px; }

/* help */
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table tr { border-bottom: 1px solid var(--border); }
.help-table td { padding: 10px 14px; vertical-align: top; }
.help-table td:first-child { color: var(--accent); width: 130px; white-space: nowrap; }
.help-table td:last-child { color: var(--text); }

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    width: 100vw;
    height: auto;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
    border: none;
  }

  .terminal-panel,
  .content-panel {
    border-radius: 0;
  }

  .terminal-panel {
    border-right: none;
  }

  .content-panel {
    border-top: 1px solid var(--border);
  }

  .content-body {
    padding: 24px 18px 32px;
  }

  .about-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-right: 0;
  }

  .about-avatar,
  .avatar {
    width: 110px;
    height: 110px;
  }

  .welcome {
    gap: 14px;
  }

  .titlebar,
  .content-titlebar {
    padding: 0 12px;
    height: 40px;
  }

  .terminal-output,
  .terminal-input-row {
    padding-left: 14px;
    padding-right: 14px;
  }

  .terminal-input-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .prompt-label {
    font-size: 12px;
  }

  .terminal-input {
    font-size: 14px;
  }

  .about h1,
  .portfolio h1 {
    font-size: 20px;
  }

  .about p,
  .card-desc,
  .links a,
  .help-table td {
    font-size: 14px;
  }

  .help-table td:first-child {
    width: auto;
    white-space: normal;
  }
}
