/* kozachuk.info — Dark amber terminal theme */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg: #0a0e14;
  --bg-alt: #0d1117;
  --text: #b3b1ad;
  --bright: #e6e1cf;
  --accent: #ffb454;
  --cyan: #59c2ff;
  --green: #7fd962;
  --red: #ff6b6b;
  --dim: #626a73;
  --border: #1a1f29;
  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  /* Mobile: use dvh for proper keyboard handling */
  height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Output area */
#output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 0 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  cursor: text;
  -webkit-overflow-scrolling: touch;
}

#output::-webkit-scrollbar {
  width: 6px;
}
#output::-webkit-scrollbar-track {
  background: transparent;
}
#output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Lines */
.line {
  min-height: 1.6em;
}

.line-ok .echo-input {
  color: var(--dim);
}

.line-ok .ok-marker {
  color: var(--green);
  font-weight: bold;
}

.line-error {
  color: var(--red);
}

.line-input {
  color: var(--dim);
}

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

/* Links */
.terminal-link {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.15s;
}
.terminal-link:hover {
  color: var(--bright);
  text-decoration-style: solid;
}

/* Input line */
#input-line {
  display: flex;
  align-items: center;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#prompt {
  color: var(--accent);
  font-weight: bold;
  flex-shrink: 0;
  user-select: none;
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--bright);
  font-family: var(--font);
  /* 16px minimum prevents iOS auto-zoom on focus */
  font-size: max(14px, 16px);
  caret-color: var(--accent);
  /* Larger touch target on mobile */
  padding: 8px 0;
  -webkit-appearance: none;
  border-radius: 0;
}

#input::placeholder {
  color: var(--dim);
}

/* Loading */
.loading {
  color: var(--dim);
  padding: 24px 0;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Noscript fallback */
.noscript-content {
  max-width: 700px;
  margin: 40px auto;
  padding: 20px;
  color: var(--text);
  line-height: 1.8;
}
.noscript-content h1 {
  color: var(--accent);
  margin-bottom: 8px;
}
.noscript-content h2 {
  color: var(--cyan);
  margin-top: 24px;
  margin-bottom: 8px;
}
.noscript-content a {
  color: var(--cyan);
}
.noscript-content li {
  margin-left: 24px;
}

/* Responsive */
@media (max-width: 600px) {
  html {
    /* Scale font to fit ~48 monospace chars in viewport.
       JetBrains Mono is ~0.6em wide, so 1ch ≈ 0.6em.
       48ch = viewport - 20px padding → font = (vw - 20px) / 28.8 */
    font-size: clamp(10px, calc((100vw - 20px) / 32), 14px);
  }
  #app {
    padding: 0 10px;
  }
  #output {
    padding-top: 12px;
  }
  #input {
    font-size: 16px;
  }
  /* Ensure links are tappable */
  .terminal-link {
    display: inline;
    padding: 2px 0;
  }
}

@media (min-width: 1200px) {
  html {
    font-size: 15px;
  }
}

/* Color themes (switched via THEME command in Forth) */
/* html.theme-* specificity (0-1-1) beats :root (0-1-0) */
html.theme-light {
  --bg: #f5f5f0; --bg-alt: #eaeae5; --text: #3c3836;
  --bright: #1d2021; --accent: #d65d0e; --cyan: #076678;
  --green: #79740e; --red: #cc241d; --dim: #928374;
  --border: #d5c4a1;
}
html.theme-light .terminal-link { color: #076678; }
html.theme-light #input { color: #1d2021; }

html.theme-matrix {
  --bg: #000a00; --bg-alt: #001200; --text: #00cc00;
  --bright: #00ff00; --accent: #00ff00; --cyan: #00ff00;
  --green: #00ff00; --red: #ff0000; --dim: #006600;
  --border: #003300;
}
html.theme-matrix .terminal-link { color: #00ff00; }

html.theme-amber {
  --bg: #1a0a00; --bg-alt: #200e00; --text: #cc8800;
  --bright: #ffaa00; --accent: #ffaa00; --cyan: #ffcc44;
  --green: #ffaa00; --red: #ff4400; --dim: #664400;
  --border: #332200;
}
html.theme-amber .terminal-link { color: #ffcc44; }

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  #input-line {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  #app {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}
