/* Carlos Computer Club — variante MINITEL (3615 CCC)
 * Aesthetic Minitel / Teletext français.
 * Palette : noir absolu, primaires saturées, glitch chromatique.
 */

:root {
  --mt-bg: #000000;
  --mt-ink: #ffffff;
  --mt-cyan: #00f0ff;
  --mt-mag: #ff2bd6;
  --mt-yel: #ffd400;
  --mt-grn: #00ff66;
  --mt-red: #ff3366;
}

body[data-variant="minitel"] {
  background: var(--mt-bg);
  color: var(--mt-ink);
  font-family: 'VT323', monospace;
  letter-spacing: 0.02em;
  overflow: hidden;
}

/* ─── Fullscreen layout ─────────────────────────────────────────── */
.mt-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: max(env(safe-area-inset-top, 0px), 8px);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
  overflow: hidden;
}

/* ─── Overlays (CRT + vignette) ─────────────────────────────────── */
.mt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
    transparent 0,
    transparent 2px,
    rgba(0,0,0,0.16) 2px,
    rgba(0,0,0,0.16) 3px);
  mix-blend-mode: multiply;
  z-index: 5;
}
.mt-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 70%, rgba(0,0,0,0.45) 100%);
  z-index: 4;
}

/* ─── Status bar magenta ────────────────────────────────────────── */
.mt-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 12px;
  background: var(--mt-mag);
  color: #000;
  font-size: 22px;
  letter-spacing: 0.08em;
  line-height: 1;
}
.mt-status .led {
  animation: cccBreath 1s ease-in-out infinite;
}

/* ─── Header zone ───────────────────────────────────────────────── */
.mt-header { padding: 8px 14px 0; }

.mt-title {
  font-size: 36px;
  line-height: 0.9;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: letter-spacing 0.05s, transform 0.05s;
}
.mt-title.glitch {
  letter-spacing: 0.12em;
  transform: translateX(2px) skewX(-1.5deg);
}
.mt-title .w-yel  { color: var(--mt-yel); text-shadow: 0 0 12px rgba(255,212,0,0.66); }
.mt-title .w-cyan { color: var(--mt-cyan); text-shadow: 0 0 12px rgba(0,240,255,0.66); }
.mt-title .w-grn  { color: var(--mt-grn); text-shadow: 0 0 12px rgba(0,255,102,0.66); }

/* Glitch chromatic — 2 absolute layers + 1 normal */
.glitch-span { position: relative; display: inline-block; }
.glitch-span > .g-a, .glitch-span > .g-b {
  position: absolute; inset: 0;
  mix-blend-mode: screen; pointer-events: none;
}
.glitch-span > .g-a { color: #ff003c; animation: cccMTShiftA 4.2s steps(1) infinite; }
.glitch-span > .g-b { color: #00f0ff; animation: cccMTShiftB 4.2s steps(1) infinite; }
.glitch-span .w-cyan ~ .g-b, .glitch-span .w-grn ~ .g-b { color: var(--mt-yel); }

/* Decoder bar — 36 cells, animated hue jitter */
.mt-decoder {
  display: flex;
  height: 14px;
  margin-top: 8px;
  animation: cccMTBarFlick 8s steps(1) infinite;
}
.mt-decoder > div { flex: 1; }

/* Instruction line */
.mt-instr {
  margin-top: 6px;
  font-size: 20px;
  letter-spacing: 0.02em;
  opacity: 0.85;
  animation: cccMTLineFlick 6s steps(1) infinite;
}

/* ─── Prompt input ──────────────────────────────────────────────── */
.mt-input-zone {
  padding: 10px 14px 0;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
.mt-label-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.mt-label {
  display: inline-flex;
  background: var(--mt-cyan);
  color: #000;
  padding: 2px 10px;
  font-size: 22px;
  letter-spacing: 0.1em;
  font-weight: 700;
  gap: 8px;
  align-self: flex-start;
  line-height: 1.15;
  flex: 1;
}
.mt-label .ctr.warn { color: var(--mt-red); }

/* Clear × button — square outline red, only visible when text > 0 */
.mt-clear {
  background: transparent;
  color: var(--mt-red);
  border: 2px solid var(--mt-red);
  font: 700 22px 'VT323', monospace;
  letter-spacing: 0;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  box-shadow: 0 0 10px -3px rgba(255,51,102,0.66);
  text-shadow: 0 0 8px var(--mt-red);
  line-height: 1;
  cursor: pointer;
  display: none;
}
.mt-clear.show { display: inline-flex; align-items: center; justify-content: center; }

.mt-input-frame {
  position: relative;
  margin-top: 4px;
  border: 2px solid var(--mt-cyan);
  background: rgba(0,240,255,0.04);
  padding: 8px 10px;
  flex: 1; min-height: 90px;
  display: flex; flex-direction: column;
  overflow: visible; /* allow fly/flap overlays to escape the frame */
}
.mt-input-frame.warn {
  border-color: var(--mt-red);
  background: rgba(255,51,102,0.07);
}
.mt-input {
  flex: 1;
  background: transparent;
  border: none; outline: none; resize: none;
  color: var(--mt-ink);
  font-family: 'VT323', monospace;
  font-size: 26px; line-height: 1.05;
  letter-spacing: 0.02em;
  caret-color: var(--mt-yel);
}
.mt-input::placeholder { color: rgba(255,255,255,0.3); }
.mt-input:disabled { opacity: 0.6; }
.mt-blink {
  position: absolute; left: 11px; top: 8px;
  color: var(--mt-yel);
  font: 26px/1.05 'VT323', monospace;
  text-shadow: 0 0 10px var(--mt-yel);
  animation: cccMTBlink 1s steps(1) infinite;
  pointer-events: none;
}
.mt-input-frame.has-text .mt-blink,
.mt-input-frame.busy .mt-blink { display: none; }

.mt-enhance-status {
  font-size: 18px;
  letter-spacing: 0.12em;
  color: var(--mt-yel);
  animation: cccBreath 0.9s ease-in-out infinite;
  display: none;
}
.mt-input-frame.enhancing .mt-enhance-status { display: block; }

/* ─── Function keys F1 / F2 ─────────────────────────────────────── */
.mt-fkeys {
  padding: 8px 14px 0;
  display: flex; gap: 8px;
}
.mt-fkey {
  flex: 1;
  background: transparent;
  border: 1.5px solid var(--mt-mag);
  color: var(--mt-mag);
  font: 700 20px 'VT323', monospace;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  text-shadow: 0 0 8px rgba(255,43,214,0.5);
  box-shadow: 0 0 10px -3px rgba(255,43,214,0.5);
}
.mt-fkey.f2 {
  border-color: var(--mt-grn);
  color: var(--mt-grn);
  text-shadow: 0 0 8px rgba(0,255,102,0.5);
  box-shadow: 0 0 10px -3px rgba(0,255,102,0.5);
}
.mt-fkey:disabled {
  color: rgba(255,255,255,0.3);
  border-color: #222;
  background: #0a0a0a;
  text-shadow: none;
  box-shadow: none;
  opacity: 0.6;
  cursor: not-allowed;
}
.mt-fkey .chip {
  background: var(--mt-mag); color: #000;
  font: 700 14px 'VT323', monospace;
  letter-spacing: 0.04em;
  padding: 0 6px; line-height: 1.2;
  text-shadow: none;
  box-shadow: 0 0 8px -2px var(--mt-mag);
}
.mt-fkey.f2 .chip {
  background: var(--mt-grn);
  box-shadow: 0 0 8px -2px var(--mt-grn);
}

/* ─── ENVOI button ──────────────────────────────────────────────── */
.mt-send-wrap { padding: 10px 14px 0; }
.mt-send {
  position: relative;
  width: 100%;
  height: 64px;
  background: var(--mt-yel);
  color: #000;
  border: 2px solid var(--mt-yel);
  font: 700 40px 'VT323', monospace;
  letter-spacing: 0.16em;
  overflow: hidden;
  box-shadow: 0 0 22px -2px rgba(255,212,0,0.66);
  cursor: pointer;
}
.mt-send:disabled,
.mt-send.disabled {
  background: #1a1a1a;
  color: #555;
  border-color: #333;
  box-shadow: none;
  cursor: not-allowed;
}
.mt-send-cooldown {
  position: absolute; top: 0; left: 0; height: 100%;
  width: 0%;
  background: rgba(0,0,0,0.35);
  transition: width 0.1s linear;
}
.mt-send-inner {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  height: 100%;
}
.mt-send-inner .word {
  animation: cccMTCorrupt 7s steps(1) infinite;
}
.mt-send:disabled .mt-send-inner .word { animation: none; }

/* ─── EN COURS + current prompt citation ────────────────────────── */
.mt-current { padding: 10px 14px 0; }
.mt-encours {
  display: inline-block;
  background: var(--mt-grn);
  color: #000;
  padding: 2px 10px;
  font-size: 20px;
  letter-spacing: 0.1em;
  font-weight: 700;
  animation: cccBreath 1.6s ease-in-out infinite;
}
.mt-quote {
  padding: 6px 0 0;
  color: var(--mt-grn);
  font-size: 18px; line-height: 1.16;
  letter-spacing: 0.02em;
  text-shadow: 0 0 10px rgba(0,255,102,0.5);
  min-height: 84px;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.mt-quote.empty { opacity: 0.5; }

/* ─── Footer ────────────────────────────────────────────────────── */
.mt-footer {
  margin-top: auto;
  padding: 8px 14px 4px;
  text-align: center;
  font: 16px 'VT323', monospace;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.mt-footer a {
  color: var(--mt-cyan);
  text-decoration: none;
  border-bottom: 1px solid var(--mt-cyan);
  padding-bottom: 1px;
}

/* ─── Status message inline ─────────────────────────────────────── */
.mt-status-msg {
  padding: 4px 14px 0;
  font-size: 16px;
  color: var(--mt-yel);
  min-height: 18px;
}

/* ─── Keyframes ─────────────────────────────────────────────────── */
@keyframes cccMTShiftA {
  0%, 96%, 100% { transform: translate(0, 0); opacity: 0; }
  97% { transform: translate(-2px, 1px); opacity: 0.85; }
  98% { transform: translate(2px, -1px); opacity: 0.6; }
  99% { transform: translate(-1px, 0); opacity: 0.4; }
}
@keyframes cccMTShiftB {
  0%, 96%, 100% { transform: translate(0, 0); opacity: 0; }
  97% { transform: translate(2px, -1px); opacity: 0.85; }
  98% { transform: translate(-2px, 1px); opacity: 0.6; }
  99% { transform: translate(1px, 0); opacity: 0.4; }
}
@keyframes cccMTBarFlick {
  0%, 98%, 100% { filter: none; }
  99% { filter: hue-rotate(80deg) saturate(1.5); transform: translateX(2px); }
}
@keyframes cccMTLineFlick {
  0%, 49%, 51%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.55; transform: translateY(-1px); }
}
@keyframes cccMTCorrupt {
  0%, 92%, 100% { letter-spacing: 0.16em; transform: skewX(0); }
  93%, 96% { letter-spacing: 0.20em; transform: skewX(-2deg); }
}
@keyframes cccMTBlink {
  0%, 50%  { opacity: 1; }
  51%, 100%{ opacity: 0; }
}
