/* TELETEST/Teletext Styling */

/* 
 * =================================================================
 * CRICKET TEXT - TELETEST STYLE GUIDE
 * =================================================================
 * 
 * This stylesheet defines all styles for the cricket text application
 * using authentic TELETEST/Teletext aesthetics.
 * 
 * USAGE GUIDE:
 * - All styles use CSS custom properties (variables) for colors
 * - Font: VT323 (imported from Google Fonts) for authentic teletext look
 * - Base font size set in body, all elements inherit unless overridden
 * 
 * COLOR PALETTE (CSS Variables):
 * - --teletext-black: #000000 (background)
 * - --teletext-red: #FF0000 (errors, wickets)
 * - --teletext-green: #00FF00 (success, boundaries)
 * - --teletext-yellow: #FFFF00 (highlights, team scores)
 * - --teletext-blue: #0000FF (headers, containers)
 * - --teletext-magenta: #FF00FF (links)
 * - --teletext-cyan: #00FFFF (info, labels)
 * - --teletext-white: #FFFFFF (primary text)
 * 
 * =================================================================
 */

/* Import VT323 Font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* Hide Scrollbar */
::-webkit-scrollbar {
  display: none;
}

/* Firefox scrollbar */
* {
  scrollbar-width: none;
}

/* Teletext color palette */
:root {
  --teletext-black: #000000;
  --teletext-red: #FF0000;
  --teletext-green: #00FF00;
  --teletext-yellow: #FFFF00;
  --teletext-blue: #0000FF;
  --teletext-magenta: #FF00FF;
  --teletext-cyan: #00FFFF;
  --teletext-white: #FFFFFF;
  --font-teletext: 'VT323', 'Courier New', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Re-enable selection for input fields if needed */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* ========================================
   UTILITY CLASSES - Text Colors
   ======================================== */

.text-red { color: var(--teletext-red); }
.text-green { color: var(--teletext-green); }
.text-yellow { color: var(--teletext-yellow); }
.text-blue { color: var(--teletext-blue); }
.text-magenta { color: var(--teletext-magenta); }
.text-cyan { color: var(--teletext-cyan); }
.text-white { color: var(--teletext-white); }

/* CRT Scanline Effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  z-index: 9999;
  opacity: 0.3;
}

body {
  font-family: var(--font-teletext);
  background-color: var(--teletext-black);
  color: var(--teletext-cyan);
  line-height: 1.2;
  padding: 0;
  margin: 0;
  font-size: 24px; /* Base font size - all elements inherit this */
  height: 100vh;
  overflow: hidden;
}

/* Larger font on desktop */
@media (min-width: 768px) {
  body {
    font-size: 32px;
  }
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1rem 0rem 1rem;
  background-color: var(--teletext-black);
  box-shadow: 
    0 0 20px rgba(0, 255, 255, 0.3),
    inset 0 0 60px rgba(0, 0, 0, 0.8);
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Wider container on desktop */
@media (min-width: 768px) {
  .container {
    max-width: 1200px;
  }
  
  .page-header,
  .main-title-bar,
  .content,
  .live-footer-nav {
    width: 80%;
    margin: 0 auto;
  }
}

/* Content area should be scrollable */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* Subpage indicator */
.subpage-indicator {
  flex-shrink: 0;
}

/* ========================================
   PAGE HEADER (TELETEST Brand Bar)
   ======================================== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--teletext-white);
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ========================================
   CONTENT AREA
   ======================================== */

.main-title-bar {
  overflow: hidden;
  background-color: var(--teletext-black);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ========================================
   LIVE SCORE PAGE
   ======================================== */

.live-match-header {
  display: flex;
  justify-content: space-between;
  color: var(--teletext-green);
  font-family: var(--font-teletext);
}

/* Batting Table */
.live-batting-table {
  width: 100%;
  border-collapse: collapse;
}

.live-batting-table th {
  color: var(--teletext-cyan);
  text-align: left;
  font-weight: normal;
}

.live-batting-table th:nth-child(1) {
  width: 60%;
}

.live-batting-table th:nth-child(2),
.live-batting-table th:nth-child(3),
.live-batting-table th:nth-child(4),
.live-batting-table th:nth-child(5) {
  width: 10%;
}

.live-batting-table td {
  color: var(--teletext-white);
}

/* Bowling Table */
.live-bowling-table {
  width: 100%;
  border-collapse: collapse;
}

.live-bowling-table-header {
  background: var(--teletext-black);
}

.live-bowling-table th {
  color: var(--teletext-cyan);
  text-align: left;
  font-weight: normal;
}

.live-bowling-table th:nth-child(1) {
  width: 60%;
}

.live-bowling-table th:nth-child(2),
.live-bowling-table th:nth-child(3),
.live-bowling-table th:nth-child(4),
.live-bowling-table th:nth-child(5) {
  width: 10%;
}

.live-bowling-table td {
  color: var(--teletext-white);
}

/* Stats Table */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.stats-table th {
  text-align: left;
  font-weight: normal;
  padding: 0;
}

.stats-table td {
  text-align: left;
  padding: 0;
}

/* Batting Stats columns */
.stats-table.batting-stats th:nth-child(1),
.stats-table.batting-stats td:nth-child(1) {
  width: 34%;
}

.stats-table.batting-stats th:nth-child(2),
.stats-table.batting-stats td:nth-child(2) {
  width: 14%;
}

.stats-table.batting-stats th:nth-child(3),
.stats-table.batting-stats td:nth-child(3) {
  width: 20%;
}

.stats-table.batting-stats th:nth-child(4),
.stats-table.batting-stats td:nth-child(4) {
  width: 12%;
}

.stats-table.batting-stats th:nth-child(5),
.stats-table.batting-stats td:nth-child(5) {
  width: 10%;
}

.stats-table.batting-stats th:nth-child(6),
.stats-table.batting-stats td:nth-child(6) {
  width: 10%;
}

/* Bowling Stats columns */
.stats-table.bowling-stats th:nth-child(1),
.stats-table.bowling-stats td:nth-child(1) {
  width: 36%;
}

.stats-table.bowling-stats th:nth-child(2),
.stats-table.bowling-stats td:nth-child(2) {
  width: 12%;
}

.stats-table.bowling-stats th:nth-child(3),
.stats-table.bowling-stats td:nth-child(3) {
  width: 22%;
}

.stats-table.bowling-stats th:nth-child(4),
.stats-table.bowling-stats td:nth-child(4) {
  width: 20%;
}

.stats-table.bowling-stats th:nth-child(5),
.stats-table.bowling-stats td:nth-child(5) {
  width: 10%;
}

/* Promo Bar */
.live-promo-bar {
  background: var(--teletext-blue);
  color: var(--teletext-yellow);
  padding: 10px;
  margin-top: 20px;
  text-align: center;
}

/* Footer Navigation */
.live-footer-nav {
  display: flex;
  justify-content: space-between;
  background-color: var(--teletext-black);
  padding: 5px 0;
  z-index: 500; /* Below keypad (1000) but above content */
}

/* Desktop: sticky footer at bottom of viewport */
@media (min-width: 601px) {
  .live-footer-nav {
    position: sticky;
    bottom: 0;
    margin-top: auto;
  }
}

/* ========================================
   PAGE NAVIGATION
   ======================================== */

.page-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0 2px 0;
  flex-shrink: 0;
}


.nav-btn {
  background: var(--teletext-blue);
  color: var(--teletext-yellow);
  border: 2px solid var(--teletext-cyan);
  padding: 8px 16px;
  font-family: var(--font-teletext);
  cursor: pointer;
  text-transform: uppercase;
}

.nav-btn:hover {
  background: var(--teletext-cyan);
  color: var(--teletext-black);
}

.page-number-input {
  background: var(--teletext-black);
  color: var(--teletext-cyan);
  border: 2px solid var(--teletext-cyan);
  padding: 8px;
  font-family: var(--font-teletext);
  width: 80px;
  text-align: center;
}

/* ========================================
   COMMON COMPONENTS
   ======================================== */

.page-link {
  cursor: pointer;
  text-decoration: none;
}

.subpage-indicator {
  color: var(--teletext-white);
  text-align: right;
  margin: 10px 0;
  flex-shrink: 0;
}

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

/* Desktop: Add padding */
@media (min-width: 769px) {
  .container {
    padding: 3rem 3rem 1rem 3rem;
  }
}

/* Mobile: Keep compact */
@media (max-width: 600px) {
  /* Footer fixed at bottom on mobile, above the keypad toggle */
  .live-footer-nav {
    position: fixed;
    bottom: 40px; /* Positioned above the keypad toggle (30px) with small gap */
    left: 1rem; /* Match container padding */
    right: 1rem; /* Match container padding */
    padding: 8px 0; /* Only vertical padding */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
  }
  
  /* Content needs padding so it doesn't hide behind footer */
  .container {
    padding-bottom: 90px; /* Height of footer nav + keypad toggle + gaps */
  }
  
  .page-header {
    flex-wrap: wrap;
    gap: 5px !important;
  }
  
  .page-header > div {
    gap: 10px !important;
  }
  
  /* Zoom in on banner to crop sides and make CRICKET larger on mobile */
  .main-title-bar {
    height: 60px; /* Fixed height on mobile */
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .main-title-bar img {
    width: auto;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scale(1.0); /* Lighter zoom to keep spacing above/below */
  }
}

/* ========================================
   MOBILE KEYPAD
   ======================================== */

.mobile-keypad {
  display: none; /* Hidden on desktop */
}

@media (max-width: 600px) {
  .mobile-keypad {
    display: block;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border: 3px solid #444;
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 
      inset 0 2px 4px rgba(255, 255, 255, 0.1),
      0 -5px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000; /* Must be above footer nav (500) */
    transition: transform 0.3s ease;
  }

  /* PWA standalone mode - adjust for less chrome */
  @media (display-mode: standalone) {
    .container {
      padding-bottom: 90px; /* Same as regular mobile */
    }
  }

  .mobile-keypad.collapsed {
    transform: translateX(-50%) translateY(calc(100% - 30px));
  }

  .keypad-toggle {
    width: 100%;
    height: 30px;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
    cursor: pointer;
    user-select: none;
    border-radius: 20px 20px 0 0;
    border-bottom: 2px solid #1a1a1a;
  }

  .keypad-toggle span {
    color: #ff6b35;
    font-size: 20px;
    line-height: 1;
    text-shadow: 0 0 5px rgba(255, 107, 53, 0.5);
    transition: transform 0.3s ease;
  }

  .keypad-content {
    padding: 10px 10px 15px 10px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  }

  .keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 8px;
  }

  .keypad-btn {
    background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
    color: #ffffff;
    border: 2px solid #2a2a2a;
    border-bottom: 3px solid #1a1a1a;
    border-radius: 6px;
    font-size: 18px;
    font-family: 'VT323', monospace;
    padding: 10px;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 
      0 3px 0 #1a1a1a,
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .keypad-btn:active {
    transform: translateY(2px);
    box-shadow: 
      0 1px 0 #1a1a1a,
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid #1a1a1a;
  }

  .keypad-clear {
    background: linear-gradient(145deg, #8a3a3a, #6a2a2a);
    border-bottom: 3px solid #4a1a1a;
  }

  .keypad-clear:active {
    background: linear-gradient(145deg, #7a2a2a, #5a1a1a);
  }

  .keypad-back {
    background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
    border-bottom: 3px solid #2a2a2a;
  }

  .keypad-back:active {
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
  }

  .keypad-color-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .keypad-color-btn {
    height: 28px;
    border: 2px solid #2a2a2a;
    border-bottom: 3px solid #1a1a1a;
    border-radius: 6px;
    font-size: 0;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 
      0 2px 0 #1a1a1a,
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }

  .keypad-color-btn:active {
    transform: translateY(2px);
    box-shadow: 
      0 0px 0 #1a1a1a,
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }

  .keypad-red {
    background: linear-gradient(145deg, #d63447, #a82835);
  }

  .keypad-green {
    background: linear-gradient(145deg, #3a8a3a, #2a6a2a);
  }

  .keypad-yellow {
    background: linear-gradient(145deg, #e8b923, #c99a1f);
  }

  .keypad-blue {
    background: linear-gradient(145deg, #4a7ba7, #356089);
  }
}