/* Teletexto Corporate Site - Authentic 80s/90s Teletext CSS */

/* === TELETEXT FONT FACE === */
/* Import authentic teletext-style fonts */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

@font-face {
  font-family: 'EuropeanTeletext';
  src: url('../../fonts/EuropeanTeletext.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'EuropeanTeletextNuevo';
  src: url('../../fonts/EuropeanTeletextNuevo.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* === RESET AND BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #000000;
    font-family: 'EuropeanTeletext', 'VT323', 'Orbitron', 'Share Tech Mono', 'Courier New', 'Monaco', monospace;
    font-size: 28px; /* Increased again for better visibility */
    line-height: 1.0; /* Even tighter for more authentic teletext feel */
    font-weight: normal;
    letter-spacing: 0.05em; /* Slightly more spacing for retro feel */
    text-rendering: optimizeSpeed; /* Crisp pixelated rendering */
}

/* === TELETEXT COLORS === */
:root {
    --tt-black: #000000;
    --tt-white: #FFFFFF;
    --tt-red: #FF0000;
    --tt-green: #00FF00;
    --tt-yellow: #FFFF00;
    --tt-blue: #0000FF;
    --tt-magenta: #FF00FF;
    --tt-cyan: #00FFFF;
    
    /* Grid dimensions - adjusted for larger font */
    --tt-cols: 40;
    --tt-rows: 25;
    --tt-char-width: 1ch;
    --tt-char-height: 1.0em; /* Adjusted to match new line-height */
    
    /* Font sizing */
    --tt-font-size: 28px;
    --tt-large-font: 28px;
    --tt-medium-font: 28px;
    --tt-small-font: 24px;
}

/* === COLOR UTILITY CLASSES === */
.fg-black { color: var(--tt-black) !important; }
.fg-white { color: var(--tt-white) !important; }
.fg-red { color: var(--tt-red) !important; }
.fg-green { color: var(--tt-green) !important; }
.fg-yellow { color: var(--tt-yellow) !important; }
.fg-blue { color: var(--tt-blue) !important; }
.fg-magenta { color: var(--tt-magenta) !important; }
.fg-cyan { color: var(--tt-cyan) !important; }

.bg-black { background-color: var(--tt-black) !important; }
.bg-white { background-color: var(--tt-white) !important; }
.bg-red { background-color: var(--tt-red) !important; }
.bg-green { background-color: var(--tt-green) !important; }
.bg-yellow { background-color: var(--tt-yellow) !important; }
.bg-blue { background-color: var(--tt-blue) !important; }
.bg-magenta { background-color: var(--tt-magenta) !important; }
.bg-cyan { background-color: var(--tt-cyan) !important; }

/* === BLINK ANIMATION === */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.blink {
    animation: blink 1s infinite;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .blink {
        animation: none;
    }
}

/* === SCANLINE EFFECT === */
@keyframes scanlines {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* === MAIN SCREEN CONTAINER === */
.teletext-screen {
    width: 100vw;
    height: 100vh;
    background: var(--tt-black);
    display: flex;
    flex-direction: column;
    position: relative;
    
    /* Authentic CRT proportions - 4:3 aspect ratio with padding */
    max-width: calc(100vh * 4/3);
    max-height: calc(100vw * 3/4);
    margin: 0 auto;
    
    /* Subtle CRT glow effect */
    box-shadow: 
        inset 0 0 50px rgba(0, 255, 255, 0.1),
        0 0 20px rgba(0, 255, 255, 0.2);
    
    /* Anti-aliasing for pixel-perfect text */
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

/* Scanline overlay effect */
.teletext-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(255, 255, 255, 0.03) 2px,
        rgba(255, 255, 255, 0.03) 4px
    );
    pointer-events: none;
    z-index: 1000;
}

/* === HEADER === */
.teletext-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--tt-black);
    color: var(--tt-white);
    border-bottom: 1px solid var(--tt-white);
    font-weight: bold;
    font-size: var(--tt-medium-font);
    height: 3rem; /* Increased for larger font */
    flex-shrink: 0;
}

.clock {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
    color: var(--tt-white);
}

.page-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-page {
    color: var(--tt-cyan);
    font-weight: bold;
}

.service-name {
    color: var(--tt-white);
    font-weight: bold;
}

.target-page {
    color: var(--tt-yellow);
    font-weight: bold;
    min-width: 3ch; /* Ensure space for 3 digits */
}

.page-number {
    color: var(--tt-cyan);
    font-weight: bold;
}

.page-title {
    color: var(--tt-yellow);
    font-weight: bold;
    max-width: 20ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === CODE INPUT OVERLAY === */
.code-input {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--tt-black);
    color: var(--tt-yellow);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--tt-yellow);
    font-weight: bold;
    font-size: var(--tt-medium-font);
    z-index: 100;
    display: none;
}

.code-input.active {
    display: block;
}

.code-digits {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2em;
    color: var(--tt-white);
    background: var(--tt-blue);
    padding: 0 0.25rem;
    margin-left: 0.5rem;
}

/* === MAIN CONTENT === */
.teletext-content {
    flex: 1;
    padding: 1rem;
    background: var(--tt-black);
    color: var(--tt-white);
    font-family: inherit; /* Use same font as body */
    font-size: inherit; /* Use same size as body */
    line-height: inherit; /* Use same line-height as body */
    
    /* Enable scroll for the entire content area */
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 8rem); /* Height for header and footer */
    max-height: calc(100vh - 8rem);
    position: relative;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
    
    /* Flexbox layout for ads and content */
    display: flex;
    flex-direction: column;
    
    /* Ensure monospace consistency */
    letter-spacing: 0;
    word-spacing: 0;
}

/* Hide scrollbar */
.teletext-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Content should be flexible */
.teletext-content > * {
    flex-shrink: 0;
}

/* === CONTENT CONTAINERS === */
.advertisements-container {
    width: 100%;
    margin-bottom: 0.1rem; /* Minimal separation from content */
    flex-shrink: 0; /* Don't shrink ads */
    line-height: 1; /* Tight line height to eliminate gaps */
}

.page-content-container {
    flex: 0 0 auto; /* Don't grow or shrink, use natural height */
    width: 100%;
    position: relative;
}

/* === SCROLL INDICATOR === */
.scroll-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #00FFFF !important; /* Force cyan color */
    background: #FF0000 !important; /* Red background for debugging */
    font-size: 2em !important; /* Larger for visibility */
    font-weight: bold;
    pointer-events: none;
    z-index: 9999 !important; /* Very high z-index */
    opacity: 1 !important; /* Full opacity */
    padding: 0.2rem;
    border: 2px solid #FFFFFF;
    /* animation: pulse 2s infinite; */ /* Disable animation for now */
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}

/* === PAGE CONTENT STYLING === */
.page-content {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    min-height: 100%;
    overflow: visible;
    padding: 0;
    margin: 0;
}

/* === TELETEXT LINKS === */
.teletext-link {
    color: var(--tt-cyan) !important;
    font-weight: bold;
    cursor: pointer;
    text-decoration: underline;
    transition: all 0.2s ease;
}

.teletext-link:hover {
    color: var(--tt-white) !important;
    background-color: var(--tt-cyan);
    text-decoration: none;
}

/* === ADVERTISEMENT SECTIONS === */
.advertisement-section {
    /* white-space: pre-wrap; */
    font-family: inherit;
    font-size: inherit;
    line-height: 1; /* Compact line height */
    font-weight: bold;
    padding: 0; /* Reduced vertical padding */
    margin: 0; /* Eliminate all margins between ads */
    border: 1px solid currentColor;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.advertisement-section:hover {
    opacity: 0.8;
}

/* Advertisement positioning */
.advertisement-section.section-1 {
    /* Top section - prominent display */
    border-width: 2px;
}

.advertisement-section.section-2,
.advertisement-section.section-3 {
    /* Middle sections - standard display */
    font-size: 0.9em;
    padding: 0; /* Even more compact */
}

.advertisement-section.section-4 {
    /* Bottom section - compact display */
    font-size: 0.8em;
    padding: 0; /* Ultra compact */
}

/* Advertisement background colors - specific to ads only */
.ad-bg-red { background-color: var(--tt-red) !important; }
.ad-bg-green { background-color: var(--tt-green) !important; }
.ad-bg-yellow { background-color: var(--tt-yellow) !important; }
.ad-bg-blue { background-color: var(--tt-blue) !important; }
.ad-bg-magenta { background-color: var(--tt-magenta) !important; }
.ad-bg-cyan { background-color: var(--tt-cyan) !important; }
.ad-bg-white { background-color: var(--tt-white) !important; }
.ad-bg-black { background-color: var(--tt-black) !important; }

/* Advertisement text colors - specific to ads only */
.ad-fg-red { color: var(--tt-red) !important; }
.ad-fg-green { color: var(--tt-green) !important; }
.ad-fg-yellow { color: var(--tt-yellow) !important; }
.ad-fg-blue { color: var(--tt-blue) !important; }
.ad-fg-magenta { color: var(--tt-magenta) !important; }
.ad-fg-cyan { color: var(--tt-cyan) !important; }
.ad-fg-white { color: var(--tt-white) !important; }
.ad-fg-black { color: var(--tt-black) !important; }

/* === LOADING SCREEN === */
.loading-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--tt-cyan);
}

.loading-text {
    font-size: var(--tt-large-font);
    font-weight: bold;
    margin-bottom: 1rem;
}

.loading-dots {
    font-size: var(--tt-medium-font);
    animation: blink 1s infinite;
}

/* === FOOTER === */
.teletext-footer {
    background: var(--tt-black);
    color: var(--tt-white);
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--tt-white);
    height: 2.5rem;
    flex-shrink: 0;
}

.color-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    gap: 1rem;
}

.color-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.color-btn:hover {
    opacity: 0.8;
}

.color-btn:active {
    opacity: 0.6;
}

.btn-color {
    font-weight: bold;
    padding: 0.125rem 0.25rem;
    border: 1px solid currentColor;
}

.color-btn.red .btn-color {
    background: var(--tt-red);
    color: var(--tt-white);
}

.color-btn.green .btn-color {
    background: var(--tt-green);
    color: var(--tt-black);
}

.color-btn.blue .btn-color {
    background: var(--tt-blue);
    color: var(--tt-white);
}

.color-btn.yellow .btn-color {
    background: var(--tt-yellow);
    color: var(--tt-black);
}

.btn-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
}

/* === ERROR MODAL === */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.error-content {
    background: var(--tt-black);
    border: 2px solid var(--tt-red);
    padding: 2rem;
    text-align: center;
    color: var(--tt-white);
    max-width: 80%;
    font-family: inherit;
}

.error-title {
    color: var(--tt-red);
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.error-message {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.error-instructions {
    color: var(--tt-yellow);
    font-size: 0.9rem;
}

/* === ACCESSIBILITY === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -50px;
    left: 6px;
    background: var(--tt-black);
    color: var(--tt-white);
    padding: 8px;
    text-decoration: none;
    border: 1px solid var(--tt-white);
    z-index: 1001;
}

.skip-link:focus {
    top: 6px;
}

/* Focus styles */
*:focus {
    outline: 2px solid var(--tt-yellow);
    outline-offset: 2px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .teletext-screen {
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .teletext-content {
        font-size: 0.8rem;
        padding: 0.5rem;
        grid-template-columns: repeat(32, 1fr);
        grid-template-rows: repeat(20, 1fr);
    }
    
    .teletext-header,
    .teletext-footer {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        height: 2rem;
    }
    
    .color-buttons {
        gap: 0.5rem;
    }
    
    .btn-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .teletext-content {
        font-size: 0.7rem;
        grid-template-columns: repeat(28, 1fr);
        grid-template-rows: repeat(18, 1fr);
    }
    
    .page-title {
        max-width: 15ch;
    }
}

/* === HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
    .teletext-screen {
        box-shadow: none;
    }
    
    .teletext-screen::before {
        display: none;
    }
}

/* === PRINT STYLES === */
@media print {
    .teletext-screen {
        box-shadow: none;
        max-width: none;
        max-height: none;
        height: auto;
    }
    
    .teletext-screen::before {
        display: none;
    }
    
    .teletext-header,
    .teletext-footer,
    .code-input,
    .error-modal {
        display: none !important;
    }
    
    .teletext-content {
        display: block;
        height: auto;
        overflow: visible;
    }
}