/* CardDemo 3270 terminal — vanilla-JS port of dashboard/src/components/terminal/terminal-emulator.tsx */

:root {
  --t-fg:     #33ff33;
  --t-bg:     #0a0f0a;
  --t-dim:    #1a7a1a;
  --t-bright: #66ff66;
  --t-cursor: #33ff33;
}

[data-theme="amber"] {
  --t-fg:     #ffb000;
  --t-bg:     #1a1000;
  --t-dim:    #805800;
  --t-bright: #ffd060;
  --t-cursor: #ffb000;
}

[data-theme="white"] {
  --t-fg:     #c0c0c0;
  --t-bg:     #0a0a0a;
  --t-dim:    #606060;
  --t-bright: #ffffff;
  --t-cursor: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: var(--t-fg);
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--t-fg) 30%, transparent);
  background: #000;
}

.brand {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--t-fg) 75%, #fff);
  text-shadow: 0 0 6px var(--t-fg);
}

.theme-toggle { display: flex; gap: 4px; }

.theme-btn {
  background: #000;
  color: color-mix(in srgb, var(--t-fg) 50%, #fff 10%);
  border: 1px solid color-mix(in srgb, var(--t-fg) 40%, transparent);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.theme-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--t-fg) 15%, #000);
  color: var(--t-bright);
  border-color: var(--t-bright);
  box-shadow: 0 0 6px color-mix(in srgb, var(--t-fg) 40%, transparent);
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.terminal-outer {
  width: 100%;
  max-width: 1200px;
  container-type: inline-size;
  position: relative;
  outline: none;
}

.terminal-inner {
  background: var(--t-bg);
  border: 1px solid color-mix(in srgb, var(--t-fg) 30%, transparent);
  border-radius: 8px;
  padding: clamp(8px, 1.5cqw, 20px);
  font-family: inherit;
  /* 80 cols * 0.6em glyph + (clamp 16..40)px total side padding, solved so 80 cols fill 100cqw */
  font-size: calc((100cqw - clamp(16px, 3cqw, 40px)) / 48);
  line-height: 1.4;
  cursor: text;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 20px color-mix(in srgb, var(--t-fg) 15%, transparent),
    inset 0 0 60px var(--t-bg);
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 1px,
    color-mix(in srgb, var(--t-bg) 75%, #000) 1px,
    color-mix(in srgb, var(--t-bg) 75%, #000) 2px
  );
}

.processing {
  position: absolute;
  top: 4px;
  right: 12px;
  color: var(--t-bright);
  font-size: 12px;
  z-index: 3;
  text-shadow: 0 0 6px var(--t-bright);
  animation: pulse 1s ease-in-out infinite;
}

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

.grid {
  position: relative;
  z-index: 2;
}

.row {
  height: 1.4em;
  white-space: pre;
  display: block;
}

.cell {
  display: inline;
  color: var(--t-fg);
  text-shadow: 0 0 2px color-mix(in srgb, var(--t-fg) 25%, transparent);
}

.cell.bright {
  color: var(--t-bright);
  font-weight: 700;
  text-shadow: 0 0 6px var(--t-bright);
}

.cell.dim {
  color: var(--t-dim);
}

.cell.cursor {
  background: var(--t-fg);
  color: #000;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to { visibility: hidden; }
}

/* Invisible mobile-IME overlay on top of the terminal */
#term-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;   /* prevents iOS Safari zoom-on-focus */
  padding: 0;
  margin: 0;
  z-index: 10;
}

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid color-mix(in srgb, var(--t-fg) 20%, transparent);
  background: #000;
  color: color-mix(in srgb, var(--t-fg) 55%, #fff);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.foot code {
  color: var(--t-bright);
  text-shadow: 0 0 4px var(--t-bright);
}

@media (max-width: 640px) {
  .brand { display: none; }
}
