/* Webcam Test - Mobile-First Stylesheet */

/* Base Styles */
html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Header & Navigation */
header {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding: 0.75rem 0;
    align-items: center;
}

.nav-top {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a73e8;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links a {
    color: #333;
    text-decoration: none;
    padding: 0.5rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-links a:hover {
    color: #1a73e8;
}

.lang-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
    font-size: 0.85rem;
}

.lang-links a {
    padding: 0.25rem 0.5rem;
    border-right: 1px solid #ddd;
}

.lang-links a:last-child {
    border-right: none;
}

/* Buttons */
.btn {
    font-family: inherit;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: #1a73e8;
}

.btn-primary {
    background: #1a73e8;
}

.btn-secondary {
    background: #5f6368;
}

.btn-secondary:hover {
    background: #3c4043;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn img {
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* Hero */
.subtitle {
    color: #5f6368;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.inline-icon {
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
}

/* Privacy Notice */
.privacy-notice {
    background: #e8f5e9;
    border: 1px solid #81c784;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
}

/* Panels */
.panel {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.panel h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #1a73e8;
}

.panel h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

/* Device Selection */
.device-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.device-group {
    flex: 1;
    min-width: 200px;
}

.device-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.device-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: #fff;
}

.device-group select:focus {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* Video Panel */
.video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

#video {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#video.active {
    display: block;
}

#video.flipped {
    transform: scaleX(-1);
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #888;
    text-align: center;
    padding: 2rem;
}

.video-placeholder.hidden {
    display: none;
}

.controls {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stats {
    margin-top: 1rem;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 4px;
}

.stats ul {
    list-style: none;
}

.stats li {
    padding: 0.25rem 0;
}

/* Microphone Panel */
.mic-meter-container {
    margin-bottom: 1rem;
}

#micMeter {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f5f5f5;
    display: block;
}

.mic-level {
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

#micRMS {
    font-weight: bold;
    color: #1a73e8;
}

/* Diagnostics */
.diagnostics-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.diag-item {
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 4px;
}

.status {
    font-weight: bold;
}

.status.ok {
    color: #2e7d32;
}

.status.warn {
    color: #f57c00;
}

.status.error {
    color: #c62828;
}

/* Result Banner */
.result-banner {
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.result-banner.ok {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    color: #2e7d32;
}

.result-banner.warn {
    background: #fff3e0;
    border: 2px solid #ff9800;
    color: #e65100;
}

.result-banner.fail {
    background: #ffebee;
    border: 2px solid #f44336;
    color: #c62828;
}

/* Tips Section */
.tips-grid {
    display: grid;
    gap: 1rem;
}

.tip-card {
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
}

.tip-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: #333;
}

.tip-card ul {
    margin-left: 1.5rem;
}

.tip-card li {
    margin-bottom: 0.5rem;
}

/* Privacy Panel */
.privacy-content {
    line-height: 1.8;
}

.privacy-content p {
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background: #333;
    color: #fff;
    padding: 2rem 0;
    margin-top: 2rem;
}

.footer-content {
    text-align: center;
}

.footer-content a {
    color: #fff;
    text-decoration: underline;
}

.footer-content a:hover {
    color: #1a73e8;
}

/* Responsive Design */
@media (min-width: 640px) {
    .tips-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }

    .diagnostics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    .container {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .diagnostics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Accessibility */
:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .btn, .controls, .video-container {
        display: none;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .panel {
        border: 1px solid #000;
    }
}

/* Part 1: Polish Features */

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

/* Part 1C: Affiliate hint */
.affiliate-hint {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #e3f2fd;
    border-left: 3px solid #1a73e8;
    border-radius: 4px;
    font-size: 0.9rem;
}

.affiliate-hint p {
    margin: 0;
}

.affiliate-hint a {
    color: #1a73e8;
    text-decoration: underline;
    font-weight: 500;
}

.affiliate-hint a:hover {
    color: #1557b0;
}

/* Part 1E: Inline help toggle */
.help-toggle {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #1a73e8;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.help-toggle:hover {
    background: #e8e8e8;
}

.help-toggle:focus {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.help-content {
    margin-top: 0.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.help-content dl {
    margin: 0;
}

.help-content dt {
    font-weight: 600;
    color: #333;
    margin-top: 0.75rem;
}

.help-content dt:first-child {
    margin-top: 0;
}

.help-content dd {
    margin: 0.25rem 0 0 0;
    color: #666;
}

/* Part 1F: Prefilled diagnostics */
.prefilled-diag {
    padding: 1rem;
    background: #fff3cd;
    border-left: 3px solid #ff9800;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.prefilled-diag h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #f57c00;
}

.prefilled-diag ul {
    margin: 0;
    padding-left: 1.5rem;
}

.prefilled-diag li {
    margin: 0.25rem 0;
}

/* Result banner: hidden by default (Part 1A) */
.result-banner {
    display: none;
}

/* Homepage Styles */

.trust-chips {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.chip {
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.tools-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.tool-card {
    display: block;
    padding: 2rem;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
    text-align: center;
}

.tool-card:hover {
    border-color: #1a73e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(26, 115, 232, 0.1);
}

.tool-card:focus {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

.tool-card img {
    margin-bottom: 1rem;
}

.tool-card h3 {
    color: #1a73e8;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.tool-card p {
    color: #5f6368;
    font-size: 0.95rem;
    line-height: 1.5;
}

.tool-card-soon {
    opacity: 0.7;
    cursor: default;
}

.tool-card-soon:hover {
    border-color: transparent;
    transform: none;
    box-shadow: none;
}

.badge-soon {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #ff9800;
    color: #fff;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.fixes-list {
    display: grid;
    gap: 1rem;
}

.fix-item {
    padding: 1rem;
    background: #f9f9f9;
    border-left: 3px solid #1a73e8;
    border-radius: 4px;
}

.fix-item strong {
    display: block;
    color: #1a73e8;
    margin-bottom: 0.25rem;
}

.fix-item p {
    margin: 0;
    color: #5f6368;
    font-size: 0.95rem;
}

.fix-link {
    margin-top: 1.5rem;
    text-align: center;
}

.fix-link a {
    color: #1a73e8;
    text-decoration: underline;
    font-weight: 500;
}

.fix-link a:hover {
    color: #1557b0;
}

@media (min-width: 640px) {
    .fixes-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Simplified Navigation - Single Row */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}

.nav-top {
    display: flex;
    gap: 2rem;
    align-items: center;
}

/* Remove lang-links from header (now in footer) */
.lang-links {
    display: none;
}

/* Language links in footer */
.lang-footer {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.lang-footer a {
    color: #fff;
    text-decoration: none;
    padding: 0.25rem;
}

.lang-footer a:hover {
    text-decoration: underline;
}

.lang-footer .lang-active {
    font-weight: 600;
}
