/* ==========================================================================
   Typewriter — Typing Animation Generator
   Design tokens
   ========================================================================== */
:root {
  /* Surfaces */
  --bg-base: #0e1015;
  --bg-glow-1: #1a1f2e;
  --bg-glow-2: #14181f;
  --bg-panel: #171a21;
  --bg-card: #1b1f28;
  --bg-card-raised: #20242e;
  --bg-input: #12151b;

  /* Borders */
  --border: #272c38;
  --border-soft: #1f232d;
  --border-focus: #f5a623;

  /* Text */
  --text-primary: #edeef2;
  --text-secondary: #a9adba;
  --text-muted: #6e7383;

  /* Accents */
  --accent: #f5a623;
  --accent-soft: rgba(245, 166, 35, 0.14);
  --accent-2: #6c8ef5;
  --accent-2-soft: rgba(108, 142, 245, 0.14);

  /* Type */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255,255,255,0.02) inset;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(245,166,35,0.15), 0 8px 30px rgba(245,166,35,0.08);

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Reset
   ========================================================================== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background:
    radial-gradient(1100px 600px at 15% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 100% 10%, var(--bg-glow-2), transparent 55%),
    var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, p { margin: 0; }

button { font-family: inherit; }

textarea, input {
  font-family: inherit;
  color: inherit;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  padding: 26px 0 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.logo-mark {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(245, 166, 35, 0.25);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 600;
}

.header-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.header-link:hover {
  color: var(--text-primary);
  border-color: rgba(245, 166, 35, 0.35);
  background: var(--accent-soft);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding: 88px 32px 56px;
  text-align: center;
  max-width: 760px;
}

.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(245, 166, 35, 0.22);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 22px;
}

.hero h1 {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #ffffff;
}

.hero-sub {
  margin: 20px auto 0;
  max-width: 560px;
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ==========================================================================
   Workspace layout
   ========================================================================== */
.workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  padding-bottom: 100px;
  align-items: start;
}

.card {
  background: linear-gradient(180deg, var(--bg-card-raised), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.panel {
  padding: 28px;
}

.panel-heading { margin-bottom: 22px; }

.panel-heading h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-hint {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* Fields */
.field { margin-bottom: 24px; }

.field label,
.slider-label-row label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

textarea#textInput {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14.5px;
  color: var(--text-primary);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

textarea#textInput::placeholder { color: var(--text-muted); }

textarea#textInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.char-count {
  margin-top: 8px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Sliders */
.slider-group { margin-bottom: 22px; }
.slider-row { margin-bottom: 20px; }
.slider-row:last-child { margin-bottom: 0; }

.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.slider-label-row label { margin-bottom: 0; }

.value-badge {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(245, 166, 35, 0.2);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  min-width: 52px;
  text-align: center;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0e1015;
  box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.5), 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #0e1015;
  box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.5);
  cursor: pointer;
}

/* Checkbox */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 26px;
  user-select: none;
}

.checkbox-row input { position: absolute; opacity: 0; width: 0; height: 0; }

.checkbox-custom {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
  flex-shrink: 0;
}

.checkbox-custom::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #0e1015;
  border-bottom: 2px solid #0e1015;
  transform: rotate(-45deg) scale(0);
  transition: transform 0.15s var(--ease);
  margin-top: -2px;
}

.checkbox-row input:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-row input:checked + .checkbox-custom::after {
  transform: rotate(-45deg) scale(1);
}

.checkbox-row input:focus-visible + .checkbox-custom {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  font-size: 14.5px;
  color: #14100a;
  background: linear-gradient(180deg, #ffc25c, var(--accent));
  box-shadow: 0 8px 22px rgba(245, 166, 35, 0.28), inset 0 1px 0 rgba(255,255,255,0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(245, 166, 35, 0.4), inset 0 1px 0 rgba(255,255,255,0.4);
  transform: translateY(-1px);
}

.control-actions { margin-top: 4px; }

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.btn-ghost {
  padding: 11px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: rgba(255,255,255,0.02);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-card-raised);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent-2);
  color: #cfd8ff;
  background: var(--accent-2-soft);
}

.copy-icon { flex-shrink: 0; }

/* ==========================================================================
   Preview panel / terminal
   ========================================================================== */
.panel-preview {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.terminal-window {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), var(--shadow-sm);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.015);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

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

.terminal-title {
  margin-left: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.terminal-body {
  flex: 1;
  padding: 32px;
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 1.5;
  flex-wrap: wrap;
  word-break: break-word;
}

.prompt {
  color: var(--accent-2);
  margin-right: 14px;
  font-weight: 600;
  user-select: none;
}

.preview-text {
  color: var(--text-primary);
  white-space: pre-wrap;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  background: var(--accent);
  margin-left: 3px;
  vertical-align: text-bottom;
  border-radius: 1px;
}

.cursor.blink { animation: cursor-blink 1s step-end infinite; }

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

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-soft);
  padding: 26px 0 60px;
}

.footer-inner {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 24px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  background: #1b1f28;
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.35s var(--ease);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   Shake (validation)
   ========================================================================== */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

.shake { animation: shake 0.5s var(--ease); }

/* ==========================================================================
   Fade-in on load
   ========================================================================== */
.fade-in {
  opacity: 0;
  animation: fade-up 0.7s var(--ease) forwards;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.14s; }
.delay-3 { animation-delay: 0.22s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
