/* ============================================
   Speed Test Hacker - Stylesheet
   ハッカー風デザイン
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

:root {
    --primary-green: #00ff41;
    --secondary-green: #00ff00;
    --dark-green: #003b00;
    --bg-black: #0a0e0a;
    --terminal-green: #0dff00;
    --error-red: #ff0040;
    --warning-yellow: #ffff00;
}

/* コンテナ */
.sth-container {
    position: relative;
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px;
    background: var(--bg-black);
    border: 2px solid var(--primary-green);
    border-radius: 0;
    box-shadow: 
        0 0 20px rgba(0, 255, 65, 0.3),
        inset 0 0 40px rgba(0, 255, 65, 0.05);
    font-family: 'Share Tech Mono', monospace;
    color: var(--primary-green);
    overflow: hidden;
}

/* スキャンライン効果 */
.sth-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

/* ノイズ効果 */
.sth-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"/></svg>');
    pointer-events: none;
    z-index: 2;
    opacity: 0.3;
    animation: noise 0.2s infinite;
}

@keyframes noise {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5%, -5%); }
    20% { transform: translate(-10%, 5%); }
    30% { transform: translate(5%, -10%); }
    40% { transform: translate(-5%, 15%); }
    50% { transform: translate(-10%, 5%); }
    60% { transform: translate(15%, 0); }
    70% { transform: translate(0, 10%); }
    80% { transform: translate(-15%, 0); }
    90% { transform: translate(10%, 5%); }
}

/* ヘッダー */
.sth-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--primary-green);
}

.sth-header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sth-title {
    font-family: 'Orbitron', monospace;
    font-size: 2.5em;
    font-weight: 900;
    margin: 0;
    color: var(--primary-green);
    text-shadow: 
        0 0 10px var(--primary-green),
        0 0 20px var(--primary-green),
        0 0 30px var(--primary-green);
    letter-spacing: 3px;
    animation: glitch 3s infinite;
}

@keyframes glitch {
    0%, 90%, 100% {
        transform: translate(0);
    }
    92% {
        transform: translate(-2px, 2px);
    }
    94% {
        transform: translate(2px, -2px);
    }
    96% {
        transform: translate(-2px, -2px);
    }
    98% {
        transform: translate(2px, 2px);
    }
}

.sth-subtitle {
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 5px;
    letter-spacing: 2px;
}

/* ステータス */
.sth-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sth-status-indicator {
    width: 12px;
    height: 12px;
    background: var(--primary-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.sth-status-text {
    font-size: 0.9em;
    letter-spacing: 1px;
}

/* フルスクリーンボタン */
.sth-fullscreen-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--primary-green);
    color: var(--primary-green);
    padding: 8px 16px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85em;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sth-fullscreen-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 65, 0.2), transparent);
    transition: left 0.5s ease;
}

.sth-fullscreen-btn:hover {
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
    transform: translateY(-2px);
}

.sth-fullscreen-btn:hover::before {
    left: 100%;
}

.sth-fullscreen-btn:active {
    transform: translateY(0);
}

.sth-fullscreen-icon {
    font-size: 1.2em;
    line-height: 1;
}

.sth-fullscreen-text {
    font-weight: 600;
}

/* フルスクリーン時のスタイル */
.sth-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 40px;
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sth-container.fullscreen .sth-header {
    margin-bottom: 20px;
}

.sth-container.fullscreen .sth-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    align-content: center;
}

.sth-container.fullscreen .sth-metric {
    padding: 40px;
}

.sth-container.fullscreen .sth-metric-value {
    font-size: 3em;
}

.sth-container.fullscreen .sth-terminal {
    min-height: 120px;
    font-size: 1em;
}

.sth-container.fullscreen .sth-fullscreen-icon::before {
    content: '⛶';
}

/* Webkit フルスクリーン対応 */
.sth-container:-webkit-full-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 40px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sth-container:-webkit-full-screen .sth-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    align-content: center;
}

.sth-container:-webkit-full-screen .sth-metric {
    padding: 40px;
}

.sth-container:-webkit-full-screen .sth-metric-value {
    font-size: 3em;
}

.sth-container:-webkit-full-screen .sth-terminal {
    min-height: 120px;
    font-size: 1em;
}

/* Mozilla フルスクリーン対応 */
.sth-container:-moz-full-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 40px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sth-container:-moz-full-screen .sth-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    align-content: center;
}

.sth-container:-moz-full-screen .sth-metric {
    padding: 40px;
}

.sth-container:-moz-full-screen .sth-metric-value {
    font-size: 3em;
}

.sth-container:-moz-full-screen .sth-terminal {
    min-height: 120px;
    font-size: 1em;
}

/* MS フルスクリーン対応 */
.sth-container:-ms-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 40px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sth-container:-ms-fullscreen .sth-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    align-content: center;
}

.sth-container:-ms-fullscreen .sth-metric {
    padding: 40px;
}

.sth-container:-ms-fullscreen .sth-metric-value {
    font-size: 3em;
}

.sth-container:-ms-fullscreen .sth-terminal {
    min-height: 120px;
    font-size: 1em;
}

/* 標準フルスクリーン対応 */
.sth-container:fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    margin: 0;
    padding: 40px;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sth-container:fullscreen .sth-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    align-content: center;
}

.sth-container:fullscreen .sth-metric {
    padding: 40px;
}

.sth-container:fullscreen .sth-metric-value {
    font-size: 3em;
}

.sth-container:fullscreen .sth-terminal {
    min-height: 120px;
    font-size: 1em;
}

/* ターミナル */
.sth-terminal {
    position: relative;
    z-index: 10;
    background: rgba(0, 59, 0, 0.3);
    border: 1px solid var(--dark-green);
    padding: 20px;
    margin-bottom: 30px;
    min-height: 80px;
    font-size: 0.9em;
    line-height: 1.8;
}

.sth-terminal-line {
    color: var(--terminal-green);
    animation: terminal-flicker 0.1s infinite alternate;
}

@keyframes terminal-flicker {
    0% { opacity: 0.95; }
    100% { opacity: 1; }
}

.sth-cursor {
    animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* メトリクス */
.sth-metrics {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sth-metric {
    background: rgba(0, 59, 0, 0.2);
    border: 1px solid var(--dark-green);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.sth-metric::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-green), transparent);
    animation: metric-scan 3s linear infinite;
}

@keyframes metric-scan {
    0% { left: -100%; }
    100% { left: 100%; }
}

.sth-metric-label {
    font-size: 0.8em;
    opacity: 0.7;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.sth-metric-value {
    font-family: 'Orbitron', monospace;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.sth-value {
    text-shadow: 0 0 10px var(--primary-green);
}

.sth-unit {
    font-size: 0.5em;
    opacity: 0.7;
}

.sth-metric-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 255, 65, 0.1);
    position: relative;
    overflow: hidden;
}

.sth-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--dark-green), var(--primary-green));
    width: 0;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--primary-green);
    position: relative;
}

.sth-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: bar-shine 2s linear infinite;
}

@keyframes bar-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* コントロール */
.sth-controls {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.sth-button {
    position: relative;
    background: transparent;
    border: 2px solid var(--primary-green);
    color: var(--primary-green);
    padding: 15px 40px;
    font-family: 'Orbitron', monospace;
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sth-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary-green), transparent);
    transition: left 0.5s ease;
}

.sth-button:hover {
    box-shadow: 
        0 0 20px var(--primary-green),
        inset 0 0 20px rgba(0, 255, 65, 0.2);
    transform: scale(1.05);
}

.sth-button:hover::before {
    left: 100%;
}

.sth-button:active {
    transform: scale(0.95);
}

.sth-button-glitch {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    clip-path: inset(0);
    animation: button-glitch 5s infinite;
}

@keyframes button-glitch {
    0%, 90%, 100% {
        opacity: 0;
        transform: translate(0);
    }
    92% {
        opacity: 1;
        transform: translate(-3px, 2px);
        clip-path: inset(0 0 80% 0);
    }
    94% {
        opacity: 1;
        transform: translate(3px, -2px);
        clip-path: inset(80% 0 0 0);
    }
}

.sth-button.testing {
    pointer-events: none;
    opacity: 0.7;
    animation: testing-pulse 1s ease-in-out infinite;
}

@keyframes testing-pulse {
    0%, 100% { border-color: var(--primary-green); }
    50% { border-color: var(--dark-green); }
}

/* 自動更新トグル */
.sth-auto-refresh-container {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 20px;
    background: rgba(0, 59, 0, 0.2);
    border: 1px solid var(--dark-green);
}

.sth-auto-refresh-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    cursor: pointer;
}

.sth-auto-refresh-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sth-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 59, 0, 0.5);
    border: 1px solid var(--dark-green);
    transition: 0.3s;
    cursor: pointer;
}

.sth-toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--dark-green);
    transition: 0.3s;
    box-shadow: 0 0 5px rgba(0, 255, 65, 0.3);
}

.sth-auto-refresh-toggle input:checked + .sth-toggle-slider {
    background-color: rgba(0, 255, 65, 0.3);
    border-color: var(--primary-green);
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.sth-auto-refresh-toggle input:checked + .sth-toggle-slider::before {
    transform: translateX(24px);
    background-color: var(--primary-green);
    box-shadow: 0 0 10px var(--primary-green);
}

.sth-auto-refresh-toggle:hover .sth-toggle-slider {
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
}

.sth-auto-refresh-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.sth-auto-text {
    font-size: 0.85em;
    letter-spacing: 2px;
    opacity: 0.7;
}

.sth-auto-countdown {
    font-family: 'Orbitron', monospace;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--primary-green);
    text-shadow: 0 0 5px var(--primary-green);
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px var(--primary-green);
    }
    50% {
        opacity: 0.7;
        text-shadow: 0 0 10px var(--primary-green);
    }
}

.sth-auto-countdown.waiting {
    color: var(--terminal-green);
    animation: countdown-active 0.5s ease-in-out infinite;
}

@keyframes countdown-active {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* プログレスバー */
.sth-progress {
    position: relative;
    z-index: 10;
    margin-bottom: 30px;
    text-align: center;
}

.sth-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 255, 65, 0.1);
    position: relative;
    overflow: hidden;
    margin-bottom: 10px;
}

.sth-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--dark-green), var(--primary-green), var(--terminal-green));
    box-shadow: 0 0 15px var(--primary-green);
    transition: width 0.3s ease;
}

.sth-progress-bar.active::after {
    animation: progress-pulse 1s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { box-shadow: 0 0 15px var(--primary-green); }
    50% { box-shadow: 0 0 25px var(--primary-green); }
}

.sth-progress-text {
    font-size: 0.9em;
    opacity: 0.8;
    letter-spacing: 1px;
}

/* 情報 */
.sth-info {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--dark-green);
}

.sth-info-item {
    display: flex;
    gap: 10px;
    font-size: 0.85em;
}

.sth-info-label {
    opacity: 0.7;
    letter-spacing: 1px;
}

.sth-info-value {
    font-weight: 700;
    animation: info-flicker 3s infinite;
}

@keyframes info-flicker {
    0%, 98%, 100% { opacity: 1; }
    99% { opacity: 0.8; }
}

/* レスポンシブ */
@media (max-width: 768px) {
    .sth-container {
        padding: 20px;
    }
    
    .sth-title {
        font-size: 1.5em;
    }
    
    .sth-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .sth-header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .sth-fullscreen-text {
        display: none;
    }
    
    .sth-controls {
        gap: 15px;
    }
    
    .sth-auto-refresh-container {
        width: 100%;
        justify-content: center;
    }
    
    .sth-metrics {
        grid-template-columns: 1fr;
    }
    
    .sth-metric-value {
        font-size: 1.5em;
    }
    
    .sth-button {
        padding: 12px 30px;
        font-size: 1em;
    }
    
    /* フルスクリーン時のモバイル対応 */
    .sth-container.fullscreen,
    .sth-container:fullscreen,
    .sth-container:-webkit-full-screen,
    .sth-container:-moz-full-screen,
    .sth-container:-ms-fullscreen {
        padding: 20px;
    }
    
    .sth-container.fullscreen .sth-metrics,
    .sth-container:fullscreen .sth-metrics,
    .sth-container:-webkit-full-screen .sth-metrics,
    .sth-container:-moz-full-screen .sth-metrics,
    .sth-container:-ms-fullscreen .sth-metrics {
        grid-template-columns: 1fr;
    }
    
    .sth-container.fullscreen .sth-metric-value,
    .sth-container:fullscreen .sth-metric-value,
    .sth-container:-webkit-full-screen .sth-metric-value,
    .sth-container:-moz-full-screen .sth-metric-value,
    .sth-container:-ms-fullscreen .sth-metric-value {
        font-size: 2em;
    }
}

/* アニメーション - テスト実行時 */
.sth-container.testing .sth-metric {
    animation: metric-active 0.5s ease-in-out infinite alternate;
}

@keyframes metric-active {
    0% {
        border-color: var(--dark-green);
        box-shadow: none;
    }
    100% {
        border-color: var(--primary-green);
        box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
    }
}
