/* ============================================
   HACK THE MAINFRAME — Styles
   Easter egg typing game for ianschechter.com
   ============================================ */

/* ── Command Prompt Trigger ── */
.htmf-prompt {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 2rem;
  opacity: 0;
  animation: htmf-fade-in 1.5s ease 1.2s forwards;
}

@keyframes htmf-fade-in {
  to { opacity: 1; }
}

.htmf-prompt-inner {
  display: inline-flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  color: #333;
  font-family: "IBM Plex Mono", "SF Mono", "Monaco", monospace;
  font-size: 0.85rem;
  padding: 4px 0;
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.htmf-prompt-inner:hover {
  color: #555;
}

.htmf-prompt-inner:hover .htmf-cursor {
  background: #555;
}

.htmf-prompt-text {
  white-space: pre;
}

.htmf-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: #333;
  animation: htmf-blink 1s step-end infinite;
  margin-left: 1px;
  vertical-align: middle;
  transition: background 0.3s ease;
}

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

/* Prompt input mode */
.htmf-prompt.active .htmf-prompt-inner {
  color: #666;
}

.htmf-prompt.active .htmf-cursor {
  background: #4ade80;
}

.htmf-prompt-input {
  background: none;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: "IBM Plex Mono", "SF Mono", "Monaco", monospace;
  font-size: 0.85rem;
  width: 0;
  padding: 0;
  caret-color: transparent;
}

.htmf-prompt.active .htmf-prompt-input {
  width: 200px;
}

/* ── Game Overlay ── */
.htmf-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  font-family: "IBM Plex Mono", "SF Mono", "Monaco", monospace;
  overflow: hidden;
}

.htmf-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* CRT Scanline effect */
.htmf-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 0, 0.015) 2px,
    rgba(0, 255, 0, 0.015) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* CRT flicker */
.htmf-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
  z-index: 10;
}

/* ── Top Bar ── */
.htmf-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
  z-index: 20;
  position: relative;
}

.htmf-title {
  color: #4ade80;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.htmf-score-display {
  color: #4ade80;
  font-size: 0.85rem;
  font-weight: 500;
}

.htmf-close {
  background: none;
  border: 1px solid #333;
  color: #666;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.htmf-close:hover {
  color: #fff;
  border-color: #666;
}

/* ── HUD ── */
.htmf-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
  z-index: 20;
  position: relative;
}

.htmf-lives {
  color: #ef4444;
  font-size: 0.8rem;
}

.htmf-lives-icon {
  letter-spacing: 4px;
}

.htmf-combo {
  color: #fbbf24;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.htmf-combo.visible {
  opacity: 1;
}

.htmf-level {
  color: #555;
  font-size: 0.75rem;
}

/* ── Game Area ── */
.htmf-game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  z-index: 5;
}

/* Background scrolling code */
.htmf-bg-line {
  position: absolute;
  color: #0d1a0d;
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  transition: color 0.5s;
}

/* Target words */
.htmf-word {
  position: absolute;
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
  transition: transform 0.1s, opacity 0.3s;
  z-index: 15;
  text-shadow: 0 0 10px currentColor;
}

.htmf-word.green {
  color: #4ade80;
  border-color: #4ade8044;
  background: #4ade8008;
}

.htmf-word.amber {
  color: #fbbf24;
  border-color: #fbbf2444;
  background: #fbbf2408;
}

.htmf-word.cyan {
  color: #22d3ee;
  border-color: #22d3ee44;
  background: #22d3ee08;
}

.htmf-word.matched {
  color: #fff;
  text-shadow: 0 0 20px #4ade80, 0 0 40px #4ade80;
  border-color: #4ade80;
  background: #4ade8022;
}

/* Partial match highlight */
.htmf-word-matched {
  color: #fff;
}

.htmf-word-remaining {
  opacity: 0.7;
}

/* Missed word */
.htmf-word.missed {
  color: #ef4444 !important;
  border-color: #ef444444 !important;
  text-shadow: 0 0 10px #ef4444 !important;
  opacity: 0;
}

/* ── Access Granted Flash ── */
.htmf-flash {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 222, 128, 0.05);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.htmf-flash.active {
  opacity: 1;
}

.htmf-flash-text {
  color: #4ade80;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-shadow: 0 0 30px #4ade80, 0 0 60px #4ade8066;
  text-transform: uppercase;
}

/* ── Input Area ── */
.htmf-input-area {
  padding: 12px 20px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
  position: relative;
  background: #050505;
}

.htmf-input-prompt {
  color: #4ade80;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.htmf-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: "IBM Plex Mono", "SF Mono", "Monaco", monospace;
  font-size: 16px;
  caret-color: #4ade80;
  min-width: 0;
}

.htmf-input::placeholder {
  color: #333;
}

/* ── Intro Screen ── */
.htmf-intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 2rem;
  text-align: center;
}

.htmf-intro-title {
  color: #4ade80;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-shadow: 0 0 30px #4ade8044;
  margin-bottom: 2rem;
}

.htmf-intro-text {
  color: #666;
  font-size: 0.85rem;
  line-height: 1.8;
  max-width: 400px;
  margin-bottom: 2rem;
}

.htmf-intro-text span {
  color: #4ade80;
}

.htmf-intro-start {
  color: #4ade80;
  font-size: 0.9rem;
  animation: htmf-blink 1.2s step-end infinite;
}

/* ── Game Over Screen ── */
.htmf-gameover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 2rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
}

.htmf-gameover-title {
  color: #ef4444;
  font-size: clamp(1rem, 4vw, 1.5rem);
  letter-spacing: 0.2em;
  margin-bottom: 2rem;
  text-shadow: 0 0 20px #ef444466;
}

.htmf-gameover-score {
  color: #fff;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.htmf-gameover-rank {
  font-size: clamp(1rem, 3vw, 1.3rem);
  letter-spacing: 0.15em;
  margin-bottom: 3rem;
}

.htmf-rank-scriptkiddie { color: #666; }
.htmf-rank-hacker { color: #4ade80; }
.htmf-rank-elite { color: #fbbf24; text-shadow: 0 0 15px #fbbf2444; }
.htmf-rank-root { color: #ef4444; text-shadow: 0 0 20px #ef444444; animation: htmf-root-pulse 1.5s ease infinite; }

@keyframes htmf-root-pulse {
  0%, 100% { text-shadow: 0 0 20px #ef444444; }
  50% { text-shadow: 0 0 40px #ef444488, 0 0 60px #ef444444; }
}

.htmf-gameover-stats {
  color: #555;
  font-size: 0.8rem;
  margin-bottom: 2rem;
  line-height: 1.8;
}

.htmf-gameover-restart {
  color: #4ade80;
  font-size: 0.85rem;
  animation: htmf-blink 1.2s step-end infinite;
  margin-bottom: 1rem;
}

.htmf-gameover-exit {
  color: #333;
  font-size: 0.75rem;
}

/* ── Screen shake ── */
@keyframes htmf-shake {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-3px, -2px); }
  20% { transform: translate(3px, 2px); }
  30% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  50% { transform: translate(-1px, 2px); }
  60% { transform: translate(1px, -1px); }
  70% { transform: translate(-1px, -1px); }
  80% { transform: translate(1px, 1px); }
  90% { transform: translate(0, -1px); }
}

.htmf-overlay.shake {
  animation: htmf-shake 0.3s ease;
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .htmf-topbar {
    padding: 10px 14px;
  }

  .htmf-hud {
    padding: 6px 14px;
  }

  .htmf-input-area {
    padding: 10px 14px;
  }

  .htmf-word {
    padding: 4px 10px;
  }

  .htmf-prompt {
    padding: 0 1.5rem;
  }
}

/* ── Print: hide everything ── */
@media print {
  .htmf-prompt,
  .htmf-overlay,
  .htmf-flash {
    display: none !important;
  }
}

/* ─── TAP MODE (MOBILE) ─── */
.htmf-tappable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: 10px 18px;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
}

.htmf-tappable:active {
  transform: scale(0.92);
  opacity: 0.7;
}
