:root {
  --green: #00ff41;
  --dark-green: #006622;
  --mid-green: #00aa33;
  --teal: #4ecdc4;
  --light-teal: #8eddd8;
  --dark-teal: #2a9d8f;
  --dim: #7f8ea3;
  --body: #c8d6e5;
  --white: #ffffff;
  --warn: #ffe66d;
  --bg: #0a0a0a;
}

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

body {
  background: var(--bg);
  color: var(--body);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  height: 100dvh;
  height: 100vh; /* fallback for older browsers */
  overflow: hidden;
}

@supports (height: 100dvh) {
  body, #terminal, #split-container, #preview-panel { height: 100dvh; }
}

/* Particle background canvas */
#particle-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* 3D ASCII hero */
#hero-3d {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s ease;
}

#hero-3d.visible {
  opacity: 1;
}

#hero-3d.faded {
  opacity: 0.15;
  transition: opacity 2s ease;
}

/* Inline 3D hero in the boot output */
.inline-hero {
  width: 100%;
  position: relative;
  margin: 4px 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Color utility classes */
.green      { color: var(--green); text-shadow: 0 0 5px rgba(0, 255, 65, 0.3); }
.dark-green  { color: var(--dark-green); }
.mid-green   { color: var(--mid-green); }
.teal        { color: var(--teal); text-shadow: 0 0 5px rgba(78, 205, 196, 0.2); }
.light-teal  { color: var(--light-teal); }
.dim         { color: var(--dim); }
.body        { color: var(--body); }
.white       { color: var(--white); font-weight: bold; text-shadow: 0 0 3px rgba(255, 255, 255, 0.15); }
.warn        { color: var(--warn); }

/* Split container */
#split-container {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Terminal layout */
#terminal {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px 28px;
  max-width: 960px;
  flex: 1;
  min-width: 0;
}

#split-container.split-active #terminal {
  max-width: none;
  flex: 0 0 45%;
}

/* ── Preview panel (fake browser) ─────────────────────────────────── */
#preview-panel {
  flex: 0 0 55%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--dim);
  background: #111;
}

/* Loading state — shows spinner before content */
#preview-panel .preview-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-family: inherit;
  font-size: 12px;
  gap: 8px;
}

#preview-panel .preview-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--dim);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Browser chrome */
#preview-chrome {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #1a1a2e;
  border-bottom: 1px solid var(--dim);
  flex-shrink: 0;
}

#preview-dots {
  display: flex;
  gap: 6px;
}

#preview-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

#preview-dots .dot.red { background: #ff5f57; }
#preview-dots .dot.yellow { background: #febc2e; }
#preview-dots .dot.green { background: #28c840; }

#preview-url-bar {
  flex: 1;
  background: #0d0d0d;
  border: 1px solid rgba(127, 142, 163, 0.3);
  border-radius: 4px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 11px;
  color: var(--dim);
}

#preview-close {
  background: none;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-family: inherit;
  font-size: 14px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

#preview-close:hover {
  border-color: var(--warn);
  color: var(--warn);
}

/* Preview content area */
#preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: none;
  background: #fafafa;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

#preview-content::-webkit-scrollbar { display: none; }

/* ── Case study page styles (inside preview) ──────────────────────── */
.cs-page { padding: 0; }

.cs-hero {
  width: 100%;
  height: 280px;
  object-fit: cover;
  display: block;
}

.cs-header {
  padding: 32px 40px 24px;
  border-bottom: 1px solid #e5e5e5;
}

.cs-title {
  font-size: 28px;
  font-weight: 700;
  color: #111;
  margin: 0 0 8px;
}

.cs-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: #f0f0f0;
  color: #555;
  font-weight: 500;
}

.cs-body { padding: 24px 40px 40px; }

.cs-section { margin-bottom: 28px; }

.cs-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin: 0 0 8px;
}

.cs-section-text {
  font-size: 15px;
  color: #333;
  margin: 0;
}

.cs-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 32px;
  padding: 0 40px 40px;
}

.cs-gallery-item {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e5e5;
  background: #fff;
}

.cs-gallery-item img {
  width: 100%;
  display: block;
}

.cs-gallery-item p {
  padding: 10px 14px;
  font-size: 12px;
  color: #666;
  margin: 0;
  border-top: 1px solid #f0f0f0;
}

.cs-nav {
  display: flex;
  justify-content: space-between;
  padding: 20px 40px;
  border-top: 1px solid #e5e5e5;
}

.cs-nav-btn {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 20px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
}

.cs-nav-btn:hover {
  border-color: #4ecdc4;
  color: #4ecdc4;
}

/* Output area */
#output {
  flex: 1;
  overflow-y: auto;
}

/* Spacer pushes initial content to bottom, shrinks as output grows */
#output::before {
  content: '';
  display: block;
  min-height: 0;
  flex: 1;
}

/* When output has content, use flex to push it down */
#output {
  display: flex;
  flex-direction: column;
}

#output > * {
  flex-shrink: 0;
}

#output > :first-child {
  margin-top: auto;
}

#output pre {
  white-space: pre-wrap;
}

#output .result-block {
  margin-bottom: 20px;
}

/* Spacing between echoed command and response */
#output .dim + .result-block {
  margin-top: 4px;
}

/* Hint bar */
#hint {
  color: var(--dim);
  font-size: 13px;
  padding: 6px 0 4px;
  border-top: 1px solid rgba(127, 142, 163, 0.12);
  margin-top: 8px;
}

.hint-cmd {
  cursor: pointer;
  transition: color 0.1s;
}

.hint-cmd:hover {
  color: var(--teal);
  text-shadow: 0 0 5px rgba(78, 205, 196, 0.2);
}

/* Prompt line */
#prompt-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  white-space: pre;
  padding: 4px 0;
}

#prompt-label {
  color: var(--teal);
  text-shadow: 0 0 5px rgba(78, 205, 196, 0.2);
}

#input-display {
  color: var(--body);
}

/* Blinking block cursor */
.cursor {
  color: var(--teal);
  animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Hidden real input — off-screen but focusable */
#input {
  position: absolute;
  left: -9999px;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Inline autocomplete ghost text */
#ghost-text {
  color: var(--dim);
  opacity: 0.5;
}

/* Boot animation classes */
.boot-tagline {
  opacity: 0;
  animation: fadeIn 0.3s ease-out forwards;
  margin: 0;
}

.check-line {
  opacity: 0;
  animation: fadeIn 0.15s ease-out forwards;
}

.ascii-line {
  opacity: 0;
  animation: fadeIn 0.2s ease-out forwards;
}

.gradient-bar {
  overflow: hidden;
}

.gradient-bar span.bar-inner {
  display: inline-block;
  transform: scaleX(0);
  transform-origin: left center;
  animation: sweepIn 0.4s ease-out forwards;
}

.gradient-bar.right span.bar-inner {
  transform-origin: right center;
}

/* Skip boot: reset all animations immediately */
.skip-boot * {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes sweepIn {
  to {
    transform: scaleX(1);
  }
}

/* ── Retro window manager ─────────────────────────────────────────────────── */
.retro-window {
  position: fixed;
  background: #0d0d0d;
  border: 1px solid var(--dim);
  border-radius: 0;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6), 1px 1px 0 var(--dim);
  font-family: inherit;
  font-size: inherit;
  min-width: 200px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.retro-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #1a1a2e 0%, #0d1117 100%);
  border-bottom: 1px solid var(--dim);
  padding: 4px 8px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.retro-titlebar:active {
  cursor: grabbing;
}

.retro-title-text {
  color: var(--teal);
  font-size: 12px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 5px rgba(78, 205, 196, 0.3);
}

.retro-close-btn {
  background: none;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-family: inherit;
  font-size: 14px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.retro-close-btn:hover {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(255, 230, 109, 0.1);
}

.retro-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
}

.retro-body::-webkit-scrollbar {
  display: none;
}

.retro-content {
  font-size: 13px;
  line-height: 1.5;
}

.retro-nav {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(127, 142, 163, 0.2);
}

.retro-nav-btn {
  background: none;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
}

.retro-nav-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

/* Close All floating button */
.retro-close-all {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9999;
  background: #1a1a2e;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
}

.retro-close-all:hover {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(255, 230, 109, 0.1);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-entry {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-left: 1px solid var(--dim);
  margin-left: 6px;
  padding-left: 16px;
  position: relative;
}

.timeline-entry::before {
  content: '●';
  position: absolute;
  left: -4px;
  top: 14px;
  color: var(--teal);
  font-size: 8px;
  line-height: 1;
}

.timeline-entry:first-child::before {
  color: var(--green);
  text-shadow: 0 0 5px rgba(0, 255, 65, 0.4);
}

.timeline-period {
  color: var(--teal);
  font-weight: bold;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  min-width: 70px;
  padding-top: 1px;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-role {
  color: var(--white);
  font-weight: bold;
  margin-bottom: 2px;
}

.timeline-company {
  color: var(--teal);
  font-size: 12px;
  margin-bottom: 6px;
}

.timeline-desc {
  color: var(--body);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.8;
}

/* Browse items */
.browse-item {
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

.browse-item:hover {
  color: var(--teal);
  border-bottom-color: var(--dim);
}

.browse-item.selected {
  color: var(--teal);
}

/* Hide scrollbar but keep scrolling */
::-webkit-scrollbar {
  display: none;
}

#output {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

/* CRT vignette — darken edges */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
  z-index: 999;
}

/* Subtle scanlines */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.03) 1px,
    rgba(0, 0, 0, 0.03) 2px
  );
  pointer-events: none;
  z-index: 1000;
}

/* ── Mobile responsive ────────────────────────────────────────────────────── */
/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body {
    font-size: 13px;
    line-height: 1.65;
    word-break: break-word;
  }

  /* More spacing between output blocks */
  #output .result-block { margin-bottom: 20px; }

  /* Space after titles and subtitles */
  .white { margin-bottom: 2px; }
  .dim + .body { margin-top: 6px; }

  /* More padding on browse items (work list) */
  .browse-item { padding: 12px 0; border-bottom: 1px solid rgba(127,142,163,0.1); }

  /* Disable heavy effects */
  #particle-bg, #hero-bg { display: none; }
  body::before, body::after { display: none; }

  /* Full-height container — height set by JS via --app-height */
  #split-container {
    flex-direction: column;
    height: var(--app-height, 100vh);
  }

  /* Terminal fills the screen, flex column */
  #terminal {
    padding: 10px 10px;
    max-width: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: var(--app-height, 100vh);
  }

  /* Output scrolls, content stacks from bottom */
  #output {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  #output > :first-child { margin-top: 0; }

  /* Hint pinned above prompt */
  #hint {
    font-size: 13px;
    overflow-x: auto;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 0 4px;
    border-top: 1px solid rgba(127, 142, 163, 0.15);
  }

  /* Prompt line with visible input */
  #prompt-line {
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    padding: 6px 0;
    padding-bottom: env(safe-area-inset-bottom, 6px);
    gap: 2px;
    border-top: 1px solid rgba(127, 142, 163, 0.1);
  }

  /* Show real input inline — visible and usable */
  /* font-size must be 16px+ to prevent iOS Safari auto-zoom */
  #input {
    position: static !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    flex: 1;
    background: rgba(78, 205, 196, 0.05);
    border: 1px solid rgba(78, 205, 196, 0.2);
    border-radius: 3px;
    outline: none;
    color: var(--body);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    caret-color: var(--teal);
    padding: 6px 8px;
    margin: 0;
  }

  #input:focus {
    border-color: var(--teal);
    background: rgba(78, 205, 196, 0.08);
  }

  /* Hide fake cursor/display/ghost — real input is visible */
  #input-display, .cursor, #ghost-text { display: none !important; }

  /* Scale ASCII logo */
  .ascii-line, .gradient-bar {
    font-size: 9px !important;
    line-height: 10px !important;
  }

  .check-line {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Mobile tabs ──────────────────────────────────────────────────────── */
  #mobile-tabs {
    display: flex;
    background: #1a1a2e;
    border-bottom: 1px solid var(--dim);
    flex-shrink: 0;
    z-index: 50;
  }

  #mobile-tabs .mobile-tab {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--dim);
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
  }

  #mobile-tabs .mobile-tab.active {
    color: var(--teal);
    border-bottom-color: var(--teal);
    text-shadow: 0 0 5px rgba(78, 205, 196, 0.2);
  }

  /* ── Tab switching: show/hide terminal vs browser ─────────────────── */
  #split-container.split-active.show-browser #terminal { display: none; }
  #split-container.split-active.show-browser #preview-panel {
    display: flex !important;
    flex: 1;
  }

  #split-container.split-active:not(.show-browser) #preview-panel { display: none !important; }
  #split-container.split-active:not(.show-browser) #terminal {
    display: flex;
    flex: 1;
  }

  /* ── Preview panel on mobile ──────────────────────────────────────── */
  #preview-panel {
    flex: 1 !important;
    height: auto !important;
    overflow-y: auto;
  }

  #preview-chrome {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 12px;
  }

  #preview-url-bar {
    font-size: 12px;
    padding: 5px 10px;
  }

  #preview-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hero image must fit mobile width */
  .cs-hero {
    height: 200px;
    object-fit: cover;
    width: 100%;
  }

  .cs-header { padding: 20px 16px 16px; }
  .cs-title { font-size: 22px; margin-bottom: 10px; }
  .cs-tags { gap: 6px; }
  .cs-tag { font-size: 12px; padding: 4px 10px; }

  .cs-body { padding: 16px 16px 24px; }
  .cs-section { margin-bottom: 24px; }
  .cs-section-title { font-size: 11px; margin-bottom: 6px; }
  .cs-section-text { font-size: 14px; line-height: 1.7; }

  .cs-gallery { padding: 0 16px 24px; grid-template-columns: 1fr; gap: 14px; }
  .cs-gallery-item img { max-width: 100%; height: auto; }
  .cs-gallery-item p { font-size: 13px; padding: 10px 12px; line-height: 1.5; }

  .cs-nav { padding: 16px 16px 60px; }
  .cs-nav-btn { font-size: 14px; padding: 10px 16px; }

  /* Retro windows — full width, stack vertically */
  .retro-window {
    width: calc(100vw - 20px) !important;
    left: 10px !important;
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  body { font-size: 12px; }
  #terminal { padding: 8px 8px; }
  .ascii-line, .gradient-bar {
    font-size: 7px !important;
    line-height: 8px !important;
  }
}
