/* =============================================
   Teletext-95 AI — Base Stylesheet
   ============================================= */

/* --- Palette Variables --- */
:root {
  --tt-black:   #000000;
  --tt-white:   #ffffff;
  --tt-red:     #ff0000;
  --tt-green:   #00ff00;
  --tt-blue:    #0000ff;
  --tt-yellow:  #ffff00;
  --tt-cyan:    #00ffff;
  --tt-magenta: #ff00ff;
}

/* --- Base Body --- */
body {
  background:   var(--tt-black);
  color:        var(--tt-white);
  font-family:  'Courier New', monospace;
  font-size:    16px;
  margin:       0;
  padding:      0;
  overflow-x:   hidden;
}

/* --- Teletext Grid (40 col × 24 row) --- */
.tt-grid {
  width:      40ch;
  min-height: 24em;
  margin:     0 auto;
  position:   relative;
}

/* --- Teletext Row --- */
.tt-row {
  display:    block;
  width:      40ch;
  white-space: pre;
  overflow:   hidden;
  line-height: 1em;
  min-height:  1em;
}

/* --- Foreground Color Utilities --- */
.tt-white   { color: var(--tt-white);   }
.tt-red     { color: var(--tt-red);     }
.tt-green   { color: var(--tt-green);   }
.tt-blue    { color: var(--tt-blue);    }
.tt-yellow  { color: var(--tt-yellow);  }
.tt-cyan    { color: var(--tt-cyan);    }
.tt-magenta { color: var(--tt-magenta); }
.tt-black   { color: var(--tt-black);   }

/* --- Background Color Utilities --- */
.tt-bg-black   { background: var(--tt-black);   }
.tt-bg-white   { background: var(--tt-white);   }
.tt-bg-red     { background: var(--tt-red);     }
.tt-bg-green   { background: var(--tt-green);   }
.tt-bg-blue    { background: var(--tt-blue);    }
.tt-bg-yellow  { background: var(--tt-yellow);  }
.tt-bg-cyan    { background: var(--tt-cyan);    }
.tt-bg-magenta { background: var(--tt-magenta); }

/* --- Text Modifiers --- */
.tt-bold     { font-weight: bold; }
.tt-fallback { opacity: 0.7;      }
/* =============================================
   Task 2.2 — CRT Scanline Overlay & Phosphor Glow
   Requirements: 2.4, 2.5
   ============================================= */

/* CRT scanline overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.25) 1px,
    rgba(0, 0, 0, 0.25) 2px
  );
}

/* Phosphor glow on each teletext row */
.tt-row {
  text-shadow: 0 0 8px rgba(0, 255, 0, 0.15);
}

/* Screen phosphor glow + inner vignette */
#tt-screen,
.tt-grid {
  box-shadow:
    0 0 32px rgba(0, 255, 0, 0.08),
    inset 0 0 32px rgba(0, 0, 0, 0.5);
}

/* Screen wrapper */
#tt-screen {
  background: #000;
  border-radius: 8px;
  padding: 1em 2em;
  max-width: 720px;
  margin: 2em auto;
  position: relative;
  overflow: hidden;
}

/* =============================================
   Task 2.3 — Header Bar, Fastext Bar, On-Screen Remote
   Requirements: 2.6, 2.7, 3.5
   ============================================= */

/* --- Header Bar (#tt-header) --- */
#tt-header {
  display:          flex;
  justify-content:  space-between;
  align-items:      center;
  background:       #000;
  color:            #fff;
  font-family:      'Courier New', monospace;
  padding:          0.25em 0.5em;
  border-bottom:    2px solid #ffff00;
  font-size:        1em;
  width:            100%;
  box-sizing:       border-box;
}

#tt-page-number {
  font-weight: bold;
  color:       #ffff00;
  min-width:   4ch;
}

#tt-title {
  text-align:     center;
  flex:           1;
  font-weight:    bold;
  color:          #fff;
  letter-spacing: 0.1em;
}

#tt-header-right {
  display:     flex;
  gap:         1em;
  align-items: center;
}

#tt-sound-toggle {
  background:  #000;
  color:       #0f0;
  border:      1px solid #0f0;
  font-family: 'Courier New', monospace;
  cursor:      pointer;
  padding:     0.1em 0.5em;
}

#tt-digit-buffer {
  color:          #ffff00;
  min-width:      3ch;
  letter-spacing: 0.2em;
}

/* --- Fastext Bar (#tt-fastext) --- */
#tt-fastext {
  display:    flex;
  width:      100%;
  margin-top: 0.5em;
}

.fastext-btn {
  flex:        1;
  padding:     0.3em;
  border:      none;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size:   0.9em;
  cursor:      pointer;
}

.fastext-red    { background: #ff0000; color: #fff; }
.fastext-green  { background: #00ff00; color: #000; }
.fastext-yellow { background: #ffff00; color: #000; }
.fastext-blue   { background: #0000ff; color: #fff; }

/* --- On-Screen Remote (#tt-remote) --- */
#tt-remote {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   4px;
  max-width:             150px;
  margin:                1em auto;
}

.remote-btn {
  background:  #000;
  color:       #ffff00;
  border:      1px solid #ffff00;
  font-family: 'Courier New', monospace;
  padding:     0.4em;
  cursor:      pointer;
  font-size:   0.9em;
  text-align:  center;
}

.remote-btn:hover {
  background: #ffff00;
  color:      #000;
}

#tt-remote-back {
  grid-column:  span 2;
  color:        #ff0000;
  border-color: #ff0000;
}

/* --- Page Sections --- */
section.tt-page        { display: none;  }
section.tt-page.active { display: block; }

/* =============================================
   Task 2.4 — Blink Animations
   Requirements: 4.4
   ============================================= */

/* Blink keyframe — toggles visibility on a 1 s cycle */
@keyframes tt-blink {
  0%, 49%  { visibility: visible; }
  50%, 100% { visibility: hidden;  }
}

/* Utility class: apply to any element that should blink */
.tt-blink {
  animation: tt-blink 1s step-end infinite;
}

/* Cursor-blink keyframe — fades opacity for the AI oracle input */
@keyframes tt-cursor {
  0%, 49%  { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Pseudo-element block cursor appended to .tt-cursor elements */
.tt-cursor::after {
  content: '█';
  animation: tt-cursor 1s step-end infinite;
  color: #fff;
}
