/* ==========================================================================
   PSQL Resume — Catppuccin Mocha–inspired terminal
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* --------------------------------------------------------------------------
   Palette — Catppuccin Mocha with custom accent tuning
   -------------------------------------------------------------------------- */
:root {
  --crust:     #11111b;
  --mantle:    #181825;
  --base:      #1e1e2e;
  --surface0:  #313244;
  --surface1:  #45475a;
  --surface2:  #585b70;
  --overlay0:  #6c7086;
  --overlay1:  #7f849c;
  --overlay2:  #9399b2;
  --subtext0:  #a6adc8;
  --subtext1:  #bac2de;
  --text:      #cdd6f4;

  --lavender:  #b4befe;
  --blue:      #89b4fa;
  --sapphire:  #74c7ec;
  --sky:       #89dceb;
  --teal:      #94e2d5;
  --green:     #a6e3a1;
  --yellow:    #f9e2af;
  --peach:     #fab387;
  --maroon:    #eba0ac;
  --red:       #f38ba8;
  --mauve:     #cba6f7;
  --pink:      #f5c2e7;
  --flamingo:  #f2cdcd;
  --rosewater: #f5e0dc;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code',
               'Source Code Pro', Menlo, monospace;
  --font-size: 13.5px;
  --line-height: 1.65;

  --glow-color: rgba(137, 180, 250, 0.06);
  --scanline-opacity: 0.03;

  --window-radius: 10px;
  --window-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(205, 214, 244, 0.04);
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--crust);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle background texture — diagonal grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(205, 214, 244, 0.008) 2px,
      rgba(205, 214, 244, 0.008) 3px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(205, 214, 244, 0.008) 2px,
      rgba(205, 214, 244, 0.008) 3px
    );
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.page-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* --------------------------------------------------------------------------
   Terminal window
   -------------------------------------------------------------------------- */
.terminal-window {
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 40px);
  max-height: 800px;
  display: flex;
  flex-direction: column;
  border-radius: var(--window-radius);
  box-shadow: var(--window-shadow);
  overflow: hidden;
  position: relative;
}

/* CRT scanline overlay */
.terminal-window::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, var(--scanline-opacity)) 1px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px
  );
  pointer-events: none;
  z-index: 10;
  border-radius: var(--window-radius);
}

/* --------------------------------------------------------------------------
   Title bar
   -------------------------------------------------------------------------- */
.title-bar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

.window-buttons {
  display: flex;
  gap: 8px;
  margin-right: 16px;
}

.window-buttons span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}

.btn-close     { background: #ed6a5e; }
.btn-minimize  { background: #f4bf4f; }
.btn-maximize  { background: #62c554; }

.window-buttons:hover .btn-close     { background: #f37369; }
.window-buttons:hover .btn-minimize  { background: #f7ca64; }
.window-buttons:hover .btn-maximize  { background: #74d164; }

.title-text {
  flex: 1;
  text-align: center;
  color: var(--overlay1);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.title-text .db-name {
  color: var(--lavender);
}

/* --------------------------------------------------------------------------
   Terminal body (scrollable area)
   -------------------------------------------------------------------------- */
.terminal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--base);
  padding: 16px 18px;
  cursor: text;
  position: relative;
}

/* Vignette effect */
.terminal-body::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  display: block;
  height: 0;
  box-shadow: inset 0 20px 40px -20px var(--crust);
  pointer-events: none;
  z-index: 5;
}

/* Scrollbar */
.terminal-body::-webkit-scrollbar {
  width: 6px;
}
.terminal-body::-webkit-scrollbar-track {
  background: transparent;
}
.terminal-body::-webkit-scrollbar-thumb {
  background: var(--surface1);
  border-radius: 3px;
}
.terminal-body::-webkit-scrollbar-thumb:hover {
  background: var(--surface2);
}

/* --------------------------------------------------------------------------
   Output lines
   -------------------------------------------------------------------------- */
.output-line {
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1em;
}

.output-line.boot-dim {
  color: var(--overlay0);
  animation: fadeIn 0.3s ease;
}

.output-line.boot-info {
  color: var(--subtext0);
  animation: fadeIn 0.2s ease;
}

.echo-line {
  color: var(--text);
}

.prompt-echo {
  color: var(--green);
  font-weight: 600;
}

.output-block {
  white-space: pre;
  font-variant-ligatures: none;
  color: var(--subtext1);
  margin-bottom: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.output-block-expanded {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;
}

/* Output block scrollbar (horizontal) */
.output-block::-webkit-scrollbar {
  height: 3px;
}
.output-block::-webkit-scrollbar-thumb {
  background: var(--surface1);
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Input line
   -------------------------------------------------------------------------- */
.input-line {
  display: flex;
  align-items: baseline;
  margin-top: 4px;
  position: relative;
}

#prompt {
  color: var(--green);
  font-weight: 600;
  white-space: pre;
  flex-shrink: 0;
}

#command-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  caret-color: var(--green);
  padding: 0;
  margin: 0;
}

#command-input::placeholder {
  color: var(--surface2);
  font-style: italic;
}

/* Blinking cursor — overridden by native caret but
   provides the right color */
#command-input:focus {
  caret-color: var(--green);
}

/* --------------------------------------------------------------------------
   Autocomplete dropdown
   -------------------------------------------------------------------------- */
.autocomplete {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 180px;
  max-width: 320px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(205, 214, 244, 0.05);
}

.ac-item {
  padding: 4px 12px;
  color: var(--subtext1);
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.ac-item:hover,
.ac-item.ac-active {
  background: var(--surface1);
  color: var(--lavender);
}

/* --------------------------------------------------------------------------
   Status bar
   -------------------------------------------------------------------------- */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 14px;
  background: var(--mantle);
  border-top: 1px solid var(--surface0);
  flex-shrink: 0;
  font-size: 11px;
  -webkit-user-select: none;
  user-select: none;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-tag {
  color: var(--crust);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-tag.tag-db {
  background: var(--green);
}

.status-tag.tag-ro {
  background: var(--yellow);
}

.status-tag.tag-ssl {
  background: var(--blue);
}

.status-right {
  color: var(--overlay0);
  font-size: 11px;
}

.status-right kbd {
  display: inline-block;
  padding: 0 4px;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--subtext0);
  margin: 0 1px;
  vertical-align: baseline;
  line-height: 1.5;
}

.status-link {
  color: var(--blue);
  text-decoration: none;
  font-size: 11px;
}

.status-link:hover {
  color: var(--lavender);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Syntax highlighting (in echoed output)
   -------------------------------------------------------------------------- */
.hl-keyword {
  color: var(--mauve);
  font-weight: 500;
}

.hl-string {
  color: var(--green);
}

.hl-number {
  color: var(--peach);
}

.hl-meta {
  color: var(--sky);
}

/* ANSI helpers */
.ansi-bold {
  font-weight: 700;
  color: var(--text);
}

.ansi-cyan {
  color: var(--sapphire);
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .page-wrapper {
    padding: 0;
  }

  .terminal-window {
    max-width: 100%;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .terminal-window::after {
    border-radius: 0;
  }

  :root {
    --font-size: 13px;
  }

  /* Prevent iOS auto-zoom on input focus */
  #command-input {
    font-size: 16px;
  }

  .title-text { font-size: 11px; }
  .status-right { display: none; }
  .terminal-body { padding: 12px 10px; }
}

@media (max-width: 480px) {
  :root {
    --font-size: 12px;
  }

  .window-buttons { display: none; }
  .title-bar { justify-content: center; }
}

/* --------------------------------------------------------------------------
   Accessibility — respect prefers-reduced-motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   Print styles
   -------------------------------------------------------------------------- */
@media print {
  body { background: white; }
  .terminal-window {
    box-shadow: none;
    border: 1px solid #ccc;
    max-height: none;
    height: auto;
  }
  .terminal-window::after { display: none; }
  .terminal-body { overflow: visible; }
  .status-bar { display: none; }
  .title-bar { background: #f5f5f5; }
  .output-block, .output-line, #command-input { color: #333; }
}

/* --------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */
::selection {
  background: var(--surface1);
  color: var(--text);
}

::-moz-selection {
  background: var(--surface1);
  color: var(--text);
}
