/* ============================================================
   ROOT
   ============================================================ */

:root {
  --c-bg:      #0a0e27;
  --c-action:  #4fc3f7;
  --c-date:    #69f0ae;
  --c-airport: #ffd740;
  --c-text:    #e0e0e0;
  --c-muted:   #6b6b85;
  --c-dim:     #2a2f55;
  --c-surface: #0f1335;
  --c-border:  #1a2050;
  --c-error:   #ff6b6b;

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', Consolas, monospace;
}

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

html, body {
  overflow: hidden;
  height: 100%;
  background: var(--c-bg);
}

body {
  color: #d4d4d4;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* ============================================================
   ENTRANCE ANIMATION
   ============================================================ */

.anim {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp 0.7s ease both;
  animation-delay: calc(var(--d, 0) * 0.13s);
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   HERO / LANDING
   ============================================================ */

#hero {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  height: 100dvh;
  padding: 24px;
  overflow: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#hero.fade-out {
  opacity: 0;
  transform: translateY(-24px);
  pointer-events: none;
}

.hero-content {
  text-align: center;
  max-width: 720px;
  width: 100%;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--c-action);
  border: 1px solid rgba(79, 195, 247, 0.25);
  padding: 5px 16px;
  border-radius: 20px;
  margin-bottom: 24px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 700;
  color: #f0f0f0;
  margin-bottom: 12px;
  letter-spacing: -1.5px;
  line-height: 1.1;
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: clamp(14px, 2.2vw, 17px);
  font-weight: 300;
  color: var(--c-muted);
  line-height: 1.6;
  margin-bottom: 48px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   DECODER — command breakdown display
   ============================================================ */

.decoder {
  position: relative;
  margin-bottom: 40px;
}

/* subtle radial glow behind the command */
.decoder::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 500px;
  height: 200px;
  background: radial-gradient(ellipse, rgba(79, 195, 247, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.decoder-command {
  position: relative;
  z-index: 1;
  font-size: 0; /* kill whitespace between inline-block segments */
  padding-bottom: 36px; /* room for absolute labels */
  display: inline-block;
}

/* ---- Segment base ---- */

.seg {
  display: inline-block;
  position: relative;
  vertical-align: top;
  transition: opacity 0.3s ease;
}

.seg-chars {
  font-family: var(--font-mono);
  font-size: clamp(28px, 8vw, 54px);
  font-weight: 700;
  letter-spacing: 0.12em;
  display: block;
  padding-bottom: 8px;
  border-bottom: 2px solid currentColor;
  opacity: 0.65;
  transition: opacity 0.3s, text-shadow 0.3s, border-color 0.3s;
}

.seg-label {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(10px, 1.6vw, 12px);
  font-weight: 400;
  letter-spacing: 0.3px;
  white-space: nowrap;
  opacity: 0.55;
  transition: opacity 0.3s;
}

/* ---- Segment colors ---- */

.seg[data-segment="action"] .seg-chars,
.seg[data-segment="action"] .seg-label { color: var(--c-action); }

.seg[data-segment="day"] .seg-chars,
.seg[data-segment="day"] .seg-label { color: var(--c-date); }

.seg[data-segment="month"] .seg-chars,
.seg[data-segment="month"] .seg-label { color: var(--c-date); }

.seg[data-segment="origin"] .seg-chars,
.seg[data-segment="origin"] .seg-label { color: var(--c-airport); }

.seg[data-segment="dest"] .seg-chars,
.seg[data-segment="dest"] .seg-label { color: var(--c-airport); }

/* ---- Interactive mode (user is typing) ---- */

.decoder.interactive .seg-chars {
  opacity: 0.18;
  border-color: transparent;
  text-shadow: none;
}

.decoder.interactive .seg-label {
  opacity: 0.12;
}

/* Segment partially typed */
.decoder.interactive .seg.seg-partial .seg-chars {
  opacity: 0.5;
  border-color: currentColor;
}

.decoder.interactive .seg.seg-partial .seg-label {
  opacity: 0.4;
}

/* Segment fully typed */
.decoder.interactive .seg.seg-complete .seg-chars {
  opacity: 1;
  text-shadow: 0 0 24px currentColor;
  border-color: currentColor;
}

.decoder.interactive .seg.seg-complete .seg-label {
  opacity: 1;
}

/* Segment pop when completed */
@keyframes segPop {
  0%  { transform: scale(1); }
  40% { transform: scale(1.12); }
  100%{ transform: scale(1); }
}

.seg-chars.seg-pop {
  animation: segPop 0.3s ease !important;
}

/* Segment error flash */
.decoder.interactive .seg.seg-error .seg-chars {
  opacity: 0.85 !important;
  color: var(--c-error) !important;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.4) !important;
  border-color: var(--c-error) !important;
}

.decoder.interactive .seg.seg-error .seg-label {
  opacity: 0.6 !important;
  color: var(--c-error) !important;
}

/* ============================================================
   EFFECTS — sparkles, quake, error shake
   ============================================================ */

/* Sparkle particles */
.sparkle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  animation: sparkleFloat var(--dur, 500ms) ease-out forwards;
}

@keyframes sparkleFloat {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--sx, 0px), var(--sy, -40px)) scale(0);
  }
}

/* Input quake (correct keystroke) */
@keyframes quake {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-3px); }
  55%  { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

.hero-input-wrapper.quake {
  animation: quake 0.15s ease;
}

/* Input error shake (wrong keystroke) */
@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-5px); }
  30%  { transform: translateX(5px); }
  45%  { transform: translateX(-4px); }
  60%  { transform: translateX(3px); }
  80%  { transform: translateX(-1px); }
}

.hero-input-wrapper.error-shake {
  animation: errorShake 0.4s ease;
}

.hero-input-wrapper.error {
  border-color: var(--c-error) !important;
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.12) !important;
}

/* ============================================================
   HERO ARROW — visual connector
   ============================================================ */

.hero-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  animation-name: fadeUp, gentleBounce;
  animation-duration: 0.7s, 2.5s;
  animation-timing-function: ease, ease-in-out;
  animation-delay: calc(var(--d, 0) * 0.13s), 1s;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: both, none;
}

.hero-chevron {
  display: block;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--c-muted);
  border-bottom: 2px solid var(--c-muted);
  transform: rotate(45deg);
  margin-top: -4px;
}

.hero-arrow-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--c-muted);
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* ============================================================
   HERO INPUT AREA
   ============================================================ */

.hero-input-area {
  max-width: 500px;
  margin: 0 auto;
}

.hero-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-dim);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 0 auto;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.hero-input-wrapper:focus-within {
  border-color: rgba(105, 240, 174, 0.4);
  box-shadow: 0 0 20px rgba(105, 240, 174, 0.08);
}

.hero-input-wrapper.ready {
  border-color: var(--c-date);
  box-shadow: 0 0 28px rgba(105, 240, 174, 0.15);
}

.hero-prompt {
  color: var(--c-date);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  margin-right: 12px;
  line-height: 1;
}

#hero-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--c-date);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  caret-color: var(--c-date);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#hero-input::placeholder {
  color: #252a4a;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hero-hint {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--c-muted);
  margin-top: 10px;
}

/* ---- Features bar ---- */

.hero-features {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 56px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 400;
  color: #3d3d55;
}

.hero-dot {
  width: 3px;
  height: 3px;
  background: #2a2a40;
  border-radius: 50%;
  display: inline-block;
}

/* ============================================================
   TERMINAL
   ============================================================ */

#terminal {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 8px 12px;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#terminal.visible {
  opacity: 1;
}

#output {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--c-dim) transparent;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

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

#output pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  padding: 0;
  font: inherit;
}

#output .command  { color: #f0f0f0; }
#output .response { color: var(--c-text); }
#output .system   { color: var(--c-airport); }
#output .error    { color: #ff6b6b; }
#output .success  { color: var(--c-date); }

/* --- Input line --- */

#input-line {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--c-border);
  padding-top: 6px;
  flex-shrink: 0;
}

.prompt {
  color: var(--c-date);
  margin-right: 6px;
  font-weight: bold;
}

#command-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--c-date);
  font: inherit;
  caret-color: var(--c-date);
  text-transform: uppercase;
}

#command-input::placeholder {
  color: #3a3f65;
  text-transform: none;
}

/* ============================================================
   HELP PANEL
   ============================================================ */

#help-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #3a3f65;
  background: #141830;
  color: var(--c-airport);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  transition: background 0.2s;
}

#help-toggle:hover {
  background: #1e2450;
}

#help-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 350px;
  height: 100vh;
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  z-index: 200;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#help-panel.open { right: 0; }

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
}

.help-header h3 {
  color: var(--c-airport);
  font-size: 13px;
  letter-spacing: 1px;
}

#help-close {
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

#help-close:hover { color: #ff6b6b; }

.help-content {
  overflow-y: auto;
  padding: 12px 16px 24px;
  flex: 1;
}

.help-content h4 {
  color: var(--c-action);
  font-size: 11px;
  letter-spacing: 1px;
  margin: 16px 0 6px;
}

.help-content h4:first-child { margin-top: 4px; }

.help-content p {
  font-size: 12px;
  color: #b0b0b0;
  margin: 3px 0;
  line-height: 1.5;
}

.help-content code {
  color: var(--c-date);
  background: #151a3a;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* ============================================================
   TRAINING
   ============================================================ */

#output .training {
  color: var(--c-action);
  border-left: 3px solid var(--c-action);
  padding-left: 12px;
  margin: 6px 0;
}

#output .training-success {
  color: var(--c-date);
  border-left: 3px solid var(--c-date);
  padding-left: 12px;
  margin: 6px 0;
}

/* ============================================================
   PAYWALL MODAL
   ============================================================ */

#paywall-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 20, 0.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#paywall-overlay.visible {
  opacity: 1;
}

#paywall-modal {
  background: var(--c-surface);
  border: 1px solid var(--c-dim);
  border-radius: 16px;
  padding: 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

#paywall-modal h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #f0f0f0;
  margin-bottom: 12px;
}

#paywall-modal p {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--c-muted);
  line-height: 1.5;
}

.paywall-price {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--c-date);
  margin: 20px 0 4px;
}

.paywall-price span {
  font-size: 18px;
  color: var(--c-muted);
  font-weight: 400;
}

.paywall-detail {
  font-size: 13px;
  color: #3d3d55;
  margin-bottom: 28px;
}

.paywall-btn {
  display: inline-block;
  background: var(--c-date);
  color: var(--c-bg);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 40px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.paywall-btn:hover {
  background: #5ae09e;
  transform: translateY(-1px);
}

.paywall-btn:active {
  transform: translateY(0);
}

.paywall-close-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: none;
  border: none;
  color: #3d3d55;
  font-family: var(--font-display);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}

.paywall-close-btn:hover {
  color: var(--c-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
  body { font-size: 15px; }

  #hero { padding: 16px; }

  .hero-badge {
    margin-bottom: 12px;
    font-size: 10px;
    padding: 4px 12px;
  }

  .hero-title { margin-bottom: 6px; }

  .hero-subtitle { margin-bottom: 20px; }

  .decoder { margin-bottom: 16px; }
  .decoder-command { padding-bottom: 22px; }

  .hero-arrow {
    margin-bottom: 18px;
    gap: 4px;
  }

  .hero-input-area { max-width: 100%; }
  .hero-input-wrapper { padding: 12px 16px; }
  #hero-input { font-size: 18px; }
  .hero-prompt { font-size: 18px; }

  .hero-hint { margin-top: 8px; }

  .hero-features {
    flex-direction: column;
    gap: 4px;
    margin-top: 24px;
  }

  .hero-dot { display: none; }

  /* Terminal on mobile */
  #terminal { font-size: 13px; padding: 8px 10px; }

  /* Training text: tighten padding */
  #output .training,
  #output .training-success {
    padding-left: 8px;
    border-left-width: 2px;
  }

  #input-line { padding-top: 8px; }

  #command-input {
    font-size: 16px;
    padding: 4px 0;
  }

  .prompt { font-size: 16px; }

  #help-panel {
    width: 280px;
    right: -290px;
  }

  #paywall-modal { padding: 28px 20px; }
  .paywall-price { font-size: 36px; }

  /* Collapse non-essential elements when keyboard is open */
  .hero-badge,
  .hero-title,
  .hero-subtitle,
  .hero-features {
    max-height: 200px;
    transition: max-height 0.25s ease, margin 0.25s ease, opacity 0.15s ease;
    overflow: hidden;
  }

  #hero:focus-within .hero-badge,
  #hero:focus-within .hero-title,
  #hero:focus-within .hero-subtitle,
  #hero:focus-within .hero-features {
    max-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    border: none;
  }

  #hero:focus-within .decoder {
    margin-top: 24px;
    margin-bottom: 10px;
  }

  #hero:focus-within .hero-arrow {
    margin-bottom: 18px;
  }

  #hero:focus-within .hero-hint {
    margin-top: 6px;
  }
}
