/* General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
}

.presentation-container {
    width: 100%;
    height: calc(100vh - 80px);
    position: relative;
    overflow: hidden;
}

/* Slide Styles */
.slide {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.6s ease;
    padding: 40px;
}

.slide.active {
    opacity: 1;
    transform: translateX(0);
}

.slide.prev {
    transform: translateX(-100%);
}

.slide-content {
    background: white;
    border-radius: 30px;
    padding: 40px;
    max-width: 1200px;
    width: 100%;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.6s ease;
}

/* Custom scrollbar for slide content */
.slide-content::-webkit-scrollbar {
    width: 8px;
}

.slide-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.slide-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.slide-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

@keyframes slideIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Title */
#slide1 .slide-content {
    max-width: 900px;
}

.title-main {
    font-size: 2.8em;
    color: #667eea;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    line-height: 1.3;
}

.subtitle {
    font-size: 1.6em;
    color: #764ba2;
    text-align: center;
    margin-top: 20px;
    font-weight: 500;
}

.invisible-waves {
    position: relative;
    height: 150px;
    margin: 40px 0;
}

.wave {
    position: absolute;
    width: 100%;
    height: 50px;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
    border-radius: 50%;
    animation: waveAnimation 3s infinite;
}

.wave:nth-child(1) {
    animation-delay: 0s;
}

.wave:nth-child(2) {
    animation-delay: 1s;
}

.wave:nth-child(3) {
    animation-delay: 2s;
}

@keyframes waveAnimation {
    0% {
        transform: scaleX(0.5) translateY(50px);
        opacity: 0;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        transform: scaleX(2) translateY(0);
        opacity: 0;
    }
}

/* What Are Radio Waves */
h2 {
    font-size: 2.3em;
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 600;
}

.explanation-box {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
}

.explanation-box p {
    font-size: 1.3em;
    margin: 20px 0;
    line-height: 1.7;
}

.ripple-demo {
    position: relative;
    height: 200px;
    margin: 30px 0;
}

.stone {
    position: absolute;
    width: 30px;
    height: 30px;
    background: #764ba2;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.ripple {
    position: absolute;
    border: 3px solid #667eea;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: rippleAnimation 3s infinite;
}

.ripple.r1 {
    animation-delay: 0s;
}

.ripple.r2 {
    animation-delay: 1s;
}

.ripple.r3 {
    animation-delay: 2s;
}

@keyframes rippleAnimation {
    0% {
        width: 30px;
        height: 30px;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* Spectrum */
.spectrum-container {
    margin: 40px 0;
}

.spectrum-bar {
    display: flex;
    height: 120px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.spectrum-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.spectrum-section:hover {
    transform: translateY(-10px);
    z-index: 10;
}

.spectrum-section span {
    font-size: 1.2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.spectrum-section.radio {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
}

.spectrum-section.microwave {
    background: linear-gradient(135deg, #ff6a00 0%, #ee0979 100%);
}

.spectrum-section.infrared {
    background: linear-gradient(135deg, #fc4a1a 0%, #f7b733 100%);
}

.spectrum-section.visible {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.spectrum-section.ultraviolet {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.spectrum-section.xray {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.spectrum-section.gamma {
    background: linear-gradient(135deg, #360033 0%, #0b8793 100%);
}

.frequency-labels {
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
    color: #666;
    font-weight: bold;
}

/* Frequency Cards */
.frequency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: 30px;
}

.frequency-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.frequency-card:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.frequency-card .icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.frequency-card h3 {
    font-size: 1.4em;
    margin-bottom: 10px;
    font-weight: 600;
}

.frequency-card .freq {
    font-size: 1.2em;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.3);
    padding: 8px;
    border-radius: 10px;
    margin: 10px 0;
}

.frequency-card p:last-child {
    font-size: 1.1em;
    margin-top: 10px;
}

/* Interactive Demo */
.interactive-demo {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 40px;
    border-radius: 20px;
}

.frequency-visualizer {
    text-align: center;
    margin-bottom: 40px;
}

.wave-display {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

#waveSvg {
    display: block;
    margin: 0 auto;
}

.frequency-info h3 {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 10px;
}

.frequency-info p {
    font-size: 1.5em;
    color: #764ba2;
    font-weight: bold;
}

.slider-container {
    text-align: center;
}

.slider-container label {
    font-size: 1.3em;
    color: #333;
    display: block;
    margin-bottom: 20px;
    font-weight: bold;
}

#freqSlider {
    width: 80%;
    height: 15px;
    border-radius: 10px;
    outline: none;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    -webkit-appearance: none;
    cursor: pointer;
}

#freqSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#freqSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#freqSlider::-moz-range-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: none;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 1.1em;
    font-weight: bold;
    color: #666;
    padding: 0 10%;
}

/* Communication Flow */
.communication-flow {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin: 40px 0;
}

.flow-step {
    text-align: center;
    flex: 1;
}

.step-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.flow-step h3 {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 15px;
}

.flow-step p {
    font-size: 1.2em;
    color: #666;
    line-height: 1.5;
}

.arrow {
    font-size: 3em;
    color: #764ba2;
    font-weight: bold;
}

.fun-fact {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 30px;
    border-radius: 20px;
    margin-top: 40px;
    text-align: center;
}

.fun-fact p {
    font-size: 1.3em;
    color: #333;
}

/* Chaos Demo */
.chaos-demo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 30px;
}

.scenario {
    padding: 30px;
    border-radius: 20px;
    text-align: center;
}

.scenario.bad {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.scenario.good {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    color: white;
}

.scenario h3 {
    font-size: 2em;
    margin-bottom: 25px;
}

.overlapping-signals {
    position: relative;
    height: 150px;
    margin: 30px 0;
}

.overlapping-signals .signal {
    position: absolute;
    font-size: 3em;
    animation: chaos 2s infinite;
}

.overlapping-signals .s1 {
    left: 10%;
    top: 10%;
    animation-delay: 0s;
}

.overlapping-signals .s2 {
    left: 40%;
    top: 40%;
    animation-delay: 0.5s;
}

.overlapping-signals .s3 {
    left: 60%;
    top: 20%;
    animation-delay: 1s;
}

.overlapping-signals .s4 {
    left: 30%;
    top: 60%;
    animation-delay: 1.5s;
}

@keyframes chaos {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
}

.organized-signals {
    margin: 30px 0;
}

.signal-lane {
    background: rgba(255, 255, 255, 0.3);
    padding: 15px;
    margin: 10px 0;
    border-radius: 10px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideRight 1s ease;
}

@keyframes slideRight {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.scenario p {
    font-size: 1.3em;
    margin-top: 20px;
}

/* ITU */
.itu-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
    align-items: center;
}

.itu-logo {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    color: white;
}

.globe {
    font-size: 6em;
    margin-bottom: 20px;
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.itu-logo h3 {
    font-size: 3em;
    margin-bottom: 10px;
    color: white;
}

.full-name {
    font-size: 1.2em;
    font-style: italic;
}

.itu-info h3 {
    font-size: 2em;
    color: #667eea;
    margin-bottom: 25px;
}

.itu-roles {
    display: grid;
    gap: 20px;
}

.role {
    display: flex;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 15px;
}

.role-icon {
    font-size: 2.5em;
    flex-shrink: 0;
}

.role p {
    font-size: 1.2em;
    color: #333;
    line-height: 1.5;
}

.itu-summary {
    font-size: 1.4em;
    color: #764ba2;
    font-weight: bold;
    margin-top: 25px;
    text-align: center;
}

/* Highway */
.highway-analogy {
    margin-top: 30px;
}

.highway {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 30px;
    border-radius: 20px;
    position: relative;
}

.lane {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.1) 100%);
    height: 60px;
    margin: 5px 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: relative;
    overflow: hidden;
}

.lane-label {
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    z-index: 1;
}

.car {
    font-size: 2em;
    position: absolute;
    right: 20px;
    animation: drive 8s linear infinite;
}

@keyframes drive {
    0% {
        right: -100px;
    }
    100% {
        right: calc(100% + 100px);
    }
}

/* Different delays for multiple cars in same lane */
.lane .car1 {
    animation-delay: 0s;
}

.lane .car2 {
    animation-delay: 2.7s;
}

.lane .car3 {
    animation-delay: 5.4s;
}

/* Stagger start times between lanes */
.lane1 .car {
    animation-delay: 0s;
}

.lane1 .car2 {
    animation-delay: 2.7s;
}

.lane1 .car3 {
    animation-delay: 5.4s;
}

.lane2 .car1 {
    animation-delay: 0.5s;
}

.lane2 .car2 {
    animation-delay: 3.2s;
}

.lane2 .car3 {
    animation-delay: 5.9s;
}

.lane3 .car1 {
    animation-delay: 1s;
}

.lane3 .car2 {
    animation-delay: 3.7s;
}

.lane3 .car3 {
    animation-delay: 6.4s;
}

.lane4 .car1 {
    animation-delay: 1.5s;
}

.lane4 .car2 {
    animation-delay: 4.2s;
}

.lane4 .car3 {
    animation-delay: 6.9s;
}

.lane5 .car1 {
    animation-delay: 2s;
}

.lane5 .car2 {
    animation-delay: 4.7s;
}

.lane5 .car3 {
    animation-delay: 7.4s;
}

.lane6 .car1 {
    animation-delay: 2.5s;
}

.lane6 .car2 {
    animation-delay: 5.2s;
}

.lane6 .car3 {
    animation-delay: 7.9s;
}

.highway-explanation {
    font-size: 1.4em;
    text-align: center;
    margin-top: 30px;
    color: #333;
    font-weight: bold;
}

/* Fun Facts */
.facts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: 30px;
}

.fact-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 28px;
    border-radius: 15px;
    text-align: center;
    color: white;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fact-card:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.fact-icon {
    font-size: 3.5em;
    margin-bottom: 18px;
}

.fact-card p {
    font-size: 1.15em;
    line-height: 1.6;
    font-weight: 400;
}

/* Summary */
.summary-box {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 40px;
    border-radius: 20px;
}

.summary-point {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 25px 0;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.check {
    font-size: 2.5em;
    flex-shrink: 0;
}

.summary-point p {
    font-size: 1.3em;
    color: #333;
    line-height: 1.6;
}

.final-message {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 40px;
    border-radius: 20px;
    margin-top: 30px;
    text-align: center;
}

.final-message h3 {
    font-size: 2em;
    color: #333;
    margin-bottom: 20px;
}

.final-message p {
    font-size: 1.3em;
    color: #666;
}

/* Thank You */
.thank-you {
    font-size: 3.5em;
    text-align: center;
    color: #667eea;
    margin-bottom: 50px;
    font-weight: 600;
}

.thank-you-animation {
    position: relative;
    height: 300px;
    margin: 50px 0;
}

.floating-icon {
    position: absolute;
    font-size: 4em;
    animation: float 3s ease-in-out infinite;
}

.floating-icon:nth-child(1) {
    left: 10%;
    top: 20%;
    animation-delay: 0s;
}

.floating-icon:nth-child(2) {
    left: 30%;
    top: 60%;
    animation-delay: 0.5s;
}

.floating-icon:nth-child(3) {
    left: 50%;
    top: 10%;
    animation-delay: 1s;
}

.floating-icon:nth-child(4) {
    left: 70%;
    top: 50%;
    animation-delay: 1.5s;
}

.floating-icon:nth-child(5) {
    left: 85%;
    top: 25%;
    animation-delay: 2s;
}

.floating-icon:nth-child(6) {
    left: 15%;
    top: 70%;
    animation-delay: 2.5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-30px) rotate(10deg);
    }
}

.final-note {
    font-size: 1.8em;
    text-align: center;
    color: #764ba2;
    font-weight: bold;
}

/* Navigation Controls */
.controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 30px;
    background: white;
    padding: 15px 40px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.nav-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    font-size: 1.1em;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.nav-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.slide-counter {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

/* Slide Indicators */
.slide-indicators {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator.active {
    background: white;
    transform: scale(1.5);
}

.indicator:hover {
    background: white;
    transform: scale(1.2);
}

/* Specific slides optimization for landscape screens */
#slide6 .slide-content,
#slide7 .slide-content,
#slide10 .slide-content,
#slide11 .slide-content,
#slide13 .slide-content,
#slide14 .slide-content,
#slide15 .slide-content,
#slide16 .slide-content,
#slide17 .slide-content,
#slide18 .slide-content,
#slide19 .slide-content,
#slide20 .slide-content,
#slide21 .slide-content {
    max-width: 1400px;
    padding: 35px 60px;
}

#slide6 h2,
#slide7 h2,
#slide10 h2,
#slide11 h2,
#slide13 h2,
#slide14 h2,
#slide15 h2,
#slide16 h2,
#slide17 h2,
#slide18 h2,
#slide19 h2,
#slide20 h2,
#slide21 h2 {
    font-size: 2.2em;
    margin-bottom: 20px;
}

/* Slide 6 & 7 - Modulation slides - optimize for landscape */
#slide6 .slide-content > div:first-child,
#slide7 .slide-content > div:first-child {
    padding: 20px !important;
    margin-bottom: 20px !important;
}

#slide7 .slide-content > div:nth-child(2) {
    padding: 25px !important;
}

/* Make GNSS grid more compact and horizontal (slide 14) */
#slide14 .gnss-grid {
    grid-template-columns: repeat(4, 1fr) !important;
}

#slide14 .gnss-card {
    padding: 20px !important;
}

#slide14 .gnss-intro {
    padding: 20px !important;
    margin-bottom: 20px !important;
}

#slide14 .fun-fact {
    padding: 20px !important;
    margin-top: 20px !important;
}

/* GSO satellites - more horizontal layout (slide 15) */
#slide15 .gso-explanation {
    padding: 25px !important;
    margin-bottom: 20px !important;
}

#slide15 .gso-uses {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
}

#slide15 .fun-fact {
    padding: 20px !important;
    margin-top: 20px !important;
}

/* LEO satellites - more compact (slide 16) */
#slide16 .leo-explanation {
    padding: 25px !important;
    margin-bottom: 20px !important;
}

#slide16 .fun-fact {
    padding: 25px !important;
    margin-top: 20px !important;
}

/* LEO satellite projects (slide 17) */
#slide17 .leo-projects {
    gap: 25px !important;
}

#slide17 .leo-projects > div {
    padding: 30px !important;
}

/* Satellite visualizations (slide 18) */
#slide18 .slide-content {
    max-width: 1400px;
    padding: 30px 40px;
}

/* Evolution slides - optimize for landscape (slide 19) */
#slide19 .evolution-intro {
    padding: 20px !important;
    margin-bottom: 20px !important;
}

#slide19 .evolution-section h3 {
    font-size: 1.8em !important;
    margin-bottom: 20px !important;
}

#slide19 .evolution-section > div > div {
    padding: 25px !important;
}

#slide19 .evolution-section > div > div > div {
    padding: 15px !important;
}


/* LeoLabs Link Slide */
.leolabs-preview-container {
    margin: 30px 0;
}

.leolabs-link:hover .leolabs-preview-container > div {
    transform: scale(1.02);
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.5);
    border-color: #764ba2;
}

@keyframes pulseBackground {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.leolabs-intro {
    animation: fadeInScale 0.6s ease forwards;
}

.visualization-info {
    animation: fadeInUp 0.6s ease forwards;
    animation-delay: 0.3s;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .slide-content {
        padding: 30px;
    }
    
    .title-main {
        font-size: 2.5em;
    }
    
    .frequency-grid,
    .facts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .itu-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .slide-content {
        padding: 20px;
    }
    
    .title-main {
        font-size: 2em;
    }
    
    h2 {
        font-size: 1.8em;
    }
    
    .frequency-grid,
    .facts-grid,
    .chaos-demo {
        grid-template-columns: 1fr;
    }
    
    .communication-flow {
        flex-direction: column;
    }
    
    .arrow {
        transform: rotate(90deg);
    }
}


/*
 * Phone layout fixes.
 *
 * The grid templates on this page are inline attributes in the markup, so the
 * media queries above cannot reach them -- an inline style beats any selector.
 * That is why several slides kept a two or three column grid at 375px, where
 * each track then grew to its content's min-content width and pushed the card
 * wider than the screen. Slides 17 and 19 were the worst, at 437px and 393px
 * of track inside a 287px card.
 *
 * !important is not decoration here: it is the only thing that outranks an
 * inline style.
 */
@media (max-width: 768px) {
    [style*="repeat(2"],
    [style*="repeat(3"],
    [style*="1fr 1fr"],
    [style*="1fr auto 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* A 1fr track is min-width:auto by default, so one long unbreakable child
       widens the whole track. Letting children shrink is what actually stops
       the overflow; collapsing to one column alone does not. */
    [style*="grid-template-columns"] > * { min-width: 0; }
}

/*
 * The wave on slide 5 is drawn by script.js in a fixed 600 x 200 coordinate
 * space. With a viewBox on the element it can now be scaled by CSS, which it
 * could not before: at 375px it was a 600px drawing in a 287px card.
 */
#waveSvg { max-width: 100%; height: auto; }

.slide-content img { max-width: 100%; height: auto; }

/*
 * Padding on a phone. The boxes nest three and four deep, and each level
 * carries a desktop padding of 25 to 40px inline, so on a 375px screen the
 * innermost content had 135px left of the 295px card -- the wave on slide 5
 * being the clearest case. These are the five values that actually occur in
 * the markup, so the selectors are a closed set rather than a guess.
 */
@media (max-width: 768px) {
    .slide-content [style*="padding: 25"],
    .slide-content [style*="padding: 28"],
    .slide-content [style*="padding: 30"],
    .slide-content [style*="padding: 35"],
    .slide-content [style*="padding: 40"] {
        padding: 15px !important;
    }

    .frequency-card,
    .fact-card,
    .summary-point,
    .scenario,
    .role,
    .lane,
    .quiz-option {
        padding: 15px !important;
    }

    /* The same again for the boxes padded from this stylesheet rather than
       inline. .interactive-demo at 40px was the worst of them: with
       .wave-display's 20px inside it, the wave on slide 5 got 135px of a
       295px card. */
    .explanation-box,
    .interactive-demo,
    .itu-logo,
    .highway,
    .summary-box,
    .final-message {
        padding: 15px !important;
    }

    .wave-display { padding: 10px !important; }
}

/*
 * The navigation pill, and the height the page is laid out in. Both of these
 * are about a phone specifically.
 *
 * The pill measured 382px wide on a 375px screen and 112px tall, because
 * 40px of side padding and a 30px gap do not fit, and "Previous" then wrapped
 * onto a second line. It also sat over the slide content. Narrower padding, a
 * smaller gap and nowrap put it back inside the screen on one line, and the
 * content gets bottom room so it no longer scrolls underneath.
 *
 * env(safe-area-inset-bottom) keeps it clear of the home indicator on a
 * notched iPhone, where "bottom: 20px" alone puts it partly underneath.
 */
@media (max-width: 768px) {
    .controls {
        gap: 10px !important;
        padding: 8px 12px !important;
        max-width: calc(100vw - 16px);
        bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .nav-btn {
        padding: 9px 14px !important;
        font-size: 0.95em !important;
        white-space: nowrap;
    }

    .slide-counter {
        font-size: 1em !important;
        white-space: nowrap;
    }

    /* room for the pill, so the last line of a slide is not hidden by it */
    .slide-content { padding-bottom: 76px !important; }
}

/*
 * Viewport height on iOS. 100vh there is the height with the browser chrome
 * HIDDEN, which is taller than what is actually visible, so a layout sized to
 * it overhangs the screen -- and with overflow:hidden on the body, the overhang
 * cannot be scrolled to. dvh is the visible height. The vh line stays first as
 * the fallback for anything that does not know dvh.
 */
body {
    height: 100vh;
    height: 100dvh;
}

.presentation-container {
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
}

.slide-content {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
}

/*
 * Two things that still did not fit on a phone, found by walking all 29 slides
 * rather than looking at the first one.
 *
 * THE SPECTRUM BAR ON SLIDE 3 WAS LOSING CONTENT. It is a flex row of seven
 * bands in a 255px box, and its sections total 399px: flex:1 cannot shrink them
 * because a flex item defaults to min-width:auto, and the bar has
 * overflow:hidden, so Light, UV, X-Ray and Gamma were clipped away entirely --
 * 144px of the electromagnetic spectrum simply not there. Stacked into a column
 * on a phone, where all seven are visible and their labels stay readable.
 * Shrinking them to fit instead would have made seven 36px slivers.
 *
 * THE MODULATION ROW ON SLIDE 7 overflowed both edges, -48 to 415 on a 375px
 * screen: an inline flex row of 100px items, centred and set to nowrap, so it
 * spilled symmetrically. Allowed to wrap.
 */
@media (max-width: 768px) {
    .spectrum-bar {
        flex-direction: column;
        height: auto;
    }

    .spectrum-section {
        min-height: 44px;
        padding: 10px 14px;
        justify-content: flex-start;
    }

    .spectrum-section span { font-size: 1em; }

    /* Inline flex rows in the markup cannot be reached by a plain selector. */
    .slide-content [style*="display: flex"] {
        flex-wrap: wrap !important;
    }
}

/*
 * Phone in landscape. This is its own case, not a narrow one: an iPhone on its
 * side is 812 x 375, so it is WIDER than the 768px the phone rules key on and
 * gets none of them, while having barely half the height. It was landing on the
 * desktop layout -- 35px/60px padding and a 101px control pill sitting on top of
 * the content -- with 235px of usable height and three quarters of the median
 * slide out of reach.
 *
 * Keyed on height rather than width, because height is what is scarce. There is
 * plenty of horizontal room at 812px, so the multi-column grids stay as they
 * are; everything here buys back vertical space.
 *
 * A tall slide will still scroll inside its card. Some of these hold 1300px of
 * content and no amount of trimming fits that into 375px. What this does is stop
 * the page spending a third of the screen on padding and chrome, and stop the
 * controls covering the text.
 */
@media (max-height: 500px) and (orientation: landscape) {
    .presentation-container {
        height: calc(100vh - 52px);
        height: calc(100dvh - 52px);
    }

    .slide-content {
        max-height: calc(100vh - 72px);
        max-height: calc(100dvh - 72px);
        padding: 14px 22px !important;
        padding-bottom: 58px !important;
    }

    h2 { font-size: 1.35em !important; margin-bottom: 8px !important; }
    .title-main { font-size: 1.6em !important; }
    .subtitle { font-size: 1em !important; }

    .controls {
        gap: 10px !important;
        padding: 6px 12px !important;
        bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .nav-btn {
        padding: 6px 13px !important;
        font-size: 0.85em !important;
        white-space: nowrap;
    }

    .slide-counter { font-size: 0.9em !important; white-space: nowrap; }

    /* the same padding trim the portrait rules make, since none of them apply
       at this width */
    .explanation-box,
    .interactive-demo,
    .itu-logo,
    .highway,
    .summary-box,
    .final-message,
    .frequency-card,
    .fact-card,
    .summary-point,
    .scenario,
    .role,
    .quiz-option {
        padding: 12px !important;
    }

    .slide-content [style*="padding: 25"],
    .slide-content [style*="padding: 28"],
    .slide-content [style*="padding: 30"],
    .slide-content [style*="padding: 35"],
    .slide-content [style*="padding: 40"] {
        padding: 12px !important;
    }
}
