/* ==========================================================================
   DSEG14 PLAY FONT — Patched Command Prompt / PowerShell (Consolas) +
   1-Bit LCD Pixel-Matrix Play States & 4-Frame Blink Animation Rules
   --------------------------------------------------------------------------
   - Family Name: 'DSEG14 PLAY FONT'
   - Source Binary: ../fonts/DSEG14-Play-Font.woff2 (.ttf also included)
   - Base Glyphs: Windows Command Prompt / PowerShell Monospace (Consolas)
   - States baked into the font binary (all 1126u fixed width):
       * State 0 (NORMAL): Crisp Command Prompt / PowerShell characters
       * State 1 (NUL):    1-bit 9x11 LCD pixel-matrix box (U+E000 + code)
       * State 2 (PLAY 1): 1-bit 9x11 LCD pixel emoji #1 (U+E100 + code)
       * State 3 (PLAY 2): 1-bit 9x11 LCD pixel emoji #2 (U+E200 + code)
       * State 4 (PLAY 3): 1-bit 9x11 LCD pixel emoji #3 (U+E300 + code)
   ========================================================================== */

@font-face {
  font-family: 'Departure Mono';
  src:
    url('../fonts/DepartureMono-Regular.woff2?v=20261111f') format('woff2'),
    url('../fonts/DepartureMono-Regular.ttf?v=20261111f') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'DSEG14 PLAY FONT';
  src:
    url('../fonts/DepartureMono-Regular.woff2?v=20261111f') format('woff2'),
    url('../fonts/DepartureMono-Regular.ttf?v=20261111f') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --dseg14-play-font: 'Departure Mono', 'DSEG14 PLAY FONT', monospace;
  --seg-font: var(--dseg14-play-font);

  /* Play Coefficient: Default 7%, +10% per completed mission (purely mission-based) */
  --dseg-play-coefficient: 7;

  /* Duration of 1 discrete LCD frame in the 4-frame blink transition */
  --dseg-frame-ms: 45ms;
}

/* Base typographic helper for DSEG14 PLAY FONT elements */
.dseg14-play-font {
  font-family: var(--dseg14-play-font);
  font-style: normal;
  font-weight: 400;
  text-transform: uppercase;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   CHARACTER CELL & 4-FRAME BLINK STATE MACHINE
   Each animated character is wrapped in .dseg-char with data-glyph="..."
   visibility:hidden keeps native layout & DOM textContent intact, while
   ::after renders the active state glyph (Normal, Nul Box, or Play 1..3)
   ========================================================================== */

.dseg-text-run {
  display: inline;
}

/* Whole-word wrapper: guarantees words never split across lines */
.dseg-word {
  display: inline-block !important;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  word-wrap: normal !important;
  hyphens: none !important;
}

.dseg-char {
  position: relative;
  display: inline-block;
  visibility: hidden;
  vertical-align: baseline;
}

.dseg-char::after {
  content: attr(data-glyph);
  visibility: visible;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  pointer-events: none;
  will-change: opacity, content;
}

.dseg-punct {
  display: inline;
}

/* Typewriter unrevealed character state (zero-reflow: layout stays locked) */
.dseg-char[data-type-hidden="1"]::after,
.dseg-punct[data-type-hidden="1"] {
  opacity: 0 !important;
}

/* Crisp 1-step LCD crystal charge when a character is first typed out */
.dseg-char[data-type-just-typed="1"]::after {
  opacity: 0.55;
}

/* 4-Frame Discrete Blink Opacity States:
   Frames 1 & 2 fade the outgoing state from 100% -> 45% -> 0%
   Frames 3 & 4 fade the incoming state from 0% -> 45% -> 100% */
.dseg-char[data-blink-frame="1"]::after {
  opacity: 0.45;
}

.dseg-char[data-blink-frame="2"]::after {
  opacity: 0.04;
}

.dseg-char[data-blink-frame="3"]::after {
  opacity: 0.48;
}

.dseg-char[data-blink-frame="4"]::after {
  opacity: 1;
}

/* ==========================================================================
   BLINKING COMMAND PROMPT / LCD TYPING CURSOR LINE (.lcd-typing-caret)
   Appears immediately when user double-taps to reply, even before typing
   ========================================================================== */

@keyframes dseg14-caret-blink {
  0%, 49.9% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

.lcd-typing-caret {
  display: inline-block;
  width: 2.5px;
  height: 1.18em;
  background-color: var(--ink);
  box-shadow: 1px 1px 0 var(--ink-shadow);
  vertical-align: text-bottom;
  margin: 0 1px;
  animation: dseg14-caret-blink 0.9s steps(1, end) infinite;
  pointer-events: none;
}

.reply-editor-wrap.caret-hidden .lcd-typing-caret {
  display: none;
}

/* Live Mirrored User Typing Layer (.reply-editor-wrap + .reply-mirror) */
.reply-editor-wrap {
  position: relative;
  width: calc(100% - 62px);
  max-width: 340px;
  min-height: 28px;
  margin: 0 auto;
  display: block;
}

.reply-textarea.dseg-mirrored-textarea {
  position: relative;
  z-index: 2;
  color: transparent !important;
  text-shadow: none !important;
  caret-color: transparent !important;
  background: transparent;
}

.reply-mirror {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  width: 100%;
  max-width: 100%;
  min-height: 28px;
  margin: 0 auto;
  font-family: var(--seg-font);
  font-style: normal;
  font-size: 13.5px;
  line-height: 1.45;
  letter-spacing: 0.03em;
  word-spacing: 0.08em;
  color: var(--ink);
  text-shadow: 1px 1px 0 var(--ink-shadow);
  text-transform: none !important;
  text-align: center;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: normal;
  word-wrap: normal;
  hyphens: none;
  overflow: hidden;
}

[data-text-align="justify"] .reply-mirror {
  text-align: justify;
  text-justify: inter-word;
  text-align-last: left;
}

.reply-mirror *,
.reply-mirror .dseg-char::after,
.emulator-preview-text,
.emulator-preview-text *,
.emulator-preview-text .dseg-char::after {
  text-transform: none !important;
}

/* Startup PLAY PLAY Hero Typography */
.startup-play-block .prompt-text {
  font-size: 28px;
  line-height: 1.5;
  letter-spacing: 0.14em;
  text-align: center !important;
  text-align-last: center !important;
}

/* ==========================================================================
   4-FRAME LCD CAMERA FLASH ENTRANCE TRANSITION
   ========================================================================== */

@keyframes dseg14-camera-flash-dark {
  0% {
    opacity: 0;
  }
  24% {
    opacity: 1;
    background-color: var(--bg-glow);
    color: var(--ink);
    border-color: var(--ink);
    box-shadow:
      0 0 22px rgba(168, 242, 68, 0.9),
      inset 0 0 12px rgba(255, 255, 200, 0.55);
    filter: brightness(1.45) contrast(1.35);
  }
  50% {
    opacity: 0.16;
    background-color: var(--ink);
    color: var(--bg-glow);
    filter: none;
  }
  76% {
    opacity: 1;
    background-color: var(--bg-glow);
    color: var(--ink);
    box-shadow: 0 0 12px rgba(146, 212, 54, 0.65);
    filter: brightness(1.2);
  }
  100% {
    opacity: 1;
    background-color: var(--ink);
    color: var(--bg-glow);
    box-shadow: 2px 2px 0 var(--ink-shadow);
    filter: none;
  }
}

@keyframes dseg14-camera-flash-outline {
  0% {
    opacity: 0;
  }
  24% {
    opacity: 1;
    background-color: var(--ink);
    color: var(--bg-glow);
    box-shadow:
      0 0 18px rgba(168, 242, 68, 0.85),
      inset 0 0 10px rgba(146, 212, 54, 0.45);
    filter: brightness(1.35) contrast(1.25);
  }
  50% {
    opacity: 0.16;
    background-color: transparent;
    color: var(--ink);
    filter: none;
  }
  76% {
    opacity: 1;
    background-color: rgba(146, 212, 54, 0.55);
    color: var(--ink);
    box-shadow: 0 0 10px rgba(146, 212, 54, 0.6);
  }
  100% {
    opacity: 1;
    background-color: transparent;
    color: var(--ink);
    box-shadow: 1px 1px 0 var(--ink-shadow);
    filter: none;
  }
}

.btn-primary {
  animation: dseg14-camera-flash-dark calc(var(--dseg-frame-ms) * 4) steps(1, end) both;
}

.btn-outline {
  animation: dseg14-camera-flash-outline calc(var(--dseg-frame-ms) * 4) steps(1, end) both;
}

.btn-stack > .btn-outline:nth-child(2),
.btn-stack > .btn-primary:nth-child(2) {
  animation-delay: var(--dseg-frame-ms);
}

.btn-stack.dseg-awaiting-typewriter > .btn-primary,
.btn-stack.dseg-awaiting-typewriter > .btn-outline {
  opacity: 0 !important;
  animation: none !important;
}
