/* =====================================================================
   Speedtest – Light Theme
   Palette:  bg #F2F6FC · surface #FFFFFF · ink #0F1B2D · muted #5A6B82
             accent #2563EB → #06B6D4 · fast #10B981 · border #E2E8F0
   ===================================================================== */
:root {
    --bg:            #f2f6fc;
    --bg-tint-a:     rgba(37, 99, 235, 0.06);
    --bg-tint-b:     rgba(6, 182, 212, 0.07);
    --surface:       #ffffff;
    --surface-2:     #f7fafd;
    --ink:           #0f1b2d;
    --muted:         #5a6b82;
    --faint:         #94a3b8;
    --border:        #e2e8f0;
    --border-strong: #cbd8e8;

    --accent:        #2563eb;
    --accent-2:      #06b6d4;
    --accent-grad:   linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    --fast:          #10b981;
    --warn:          #f59e0b;
    --slow:          #ef4444;

    --shadow-sm:     0 1px 2px rgba(15, 27, 45, 0.04), 0 2px 8px rgba(15, 27, 45, 0.05);
    --shadow:        0 4px 14px rgba(15, 27, 45, 0.07), 0 12px 36px rgba(15, 27, 45, 0.06);
    --shadow-accent: 0 10px 28px rgba(37, 99, 235, 0.28);

    --radius:        18px;
    --radius-sm:     12px;
    --radius-pill:   999px;
    --transition:    0.25s ease;

    /* safe-area helpers for installed PWA / notched devices */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100svh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background-image:
        radial-gradient(ellipse 70% 50% at 15% -5%,  var(--bg-tint-a) 0%, transparent 60%),
        radial-gradient(ellipse 60% 45% at 95% 5%,   var(--bg-tint-b) 0%, transparent 55%);
    background-attachment: fixed;
}

/* ===== Container ===== */
.container {
    max-width: 760px;
    margin: 0 auto;
    padding:
        calc(16px + var(--safe-top))
        calc(16px + var(--safe-right))
        calc(40px + var(--safe-bottom))
        calc(16px + var(--safe-left));
}

/* ===== Header ===== */
header { text-align: center; padding: 28px 0 12px; }

header h1 {
    font-size: clamp(1.9rem, 6vw, 2.9rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
}
header h1 .rocket {
    -webkit-text-fill-color: initial; /* keep emoji colored */
}
header h1 .word {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.subtitle { color: var(--muted); font-size: 1rem; margin-top: 6px; }

/* ===== Cards (shared) ===== */
.ip-card,
.speedtest-panel,
.share-section,
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ===== IP-Karte ===== */
.ip-card {
    padding: 18px 22px;
    margin: 18px 0;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.ip-card:hover { border-color: var(--border-strong); }

.ip-label {
    display: flex; align-items: center; gap: 8px;
    color: var(--muted); font-size: 0.875rem; font-weight: 600;
    min-width: 150px;
}
.ip-icon { font-size: 1.15rem; }

.ip-address {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    font-weight: 700;
    font-family: ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, monospace;
    color: var(--accent);
    letter-spacing: 0.3px;
    flex: 1;
    word-break: break-all;
    line-height: 1.4;
}
.ip-info {
    color: var(--muted);
    font-size: 0.82rem;
    width: 100%;
    padding-left: 27px;
}

/* ===== Speedtest Panel ===== */
.speedtest-panel { padding: 30px 24px; margin: 18px 0; }

/* ===== Gauge ===== */
.gauge-container { text-align: center; margin-bottom: 26px; }
.gauge {
    width: min(320px, 100%);
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(37, 99, 235, 0.18));
}

.speed-display { margin-top: -14px; }
.speed-value {
    font-size: clamp(2.6rem, 9vw, 4.2rem);
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
    transition: color var(--transition);
    font-variant-numeric: tabular-nums;
}
.speed-unit { font-size: 1rem; color: var(--muted); margin-left: 6px; font-weight: 500; }

.test-phase {
    margin-top: 6px;
    font-size: 0.92rem;
    color: var(--muted);
    min-height: 1.4em;
    transition: color var(--transition);
    font-weight: 500;
}
.test-phase.active { color: var(--accent); }

/* ===== Ergebnis-Grid ===== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.result-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 10px;
    text-align: center;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.result-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.result-card.has-value {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.result-icon  { font-size: 1.35rem; margin-bottom: 6px; }
.result-label {
    font-size: 0.7rem; color: var(--muted); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.result-value {
    font-size: 1.5rem; font-weight: 700; color: var(--ink);
    font-variant-numeric: tabular-nums; transition: color var(--transition);
}
.result-card.has-value .result-value { color: var(--accent); }
.result-unit { font-size: 0.68rem; color: var(--faint); margin-top: 2px; }
.result-sub {
    font-size: 0.66rem; color: var(--muted); margin-top: 6px; line-height: 1.3;
    font-variant-numeric: tabular-nums;
}
.result-sub[hidden] { display: none; }

/* ===== Progress Bar ===== */
.progress-container { margin-bottom: 22px; }
.progress-bar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    height: 9px;
    overflow: hidden;
    margin-bottom: 6px;
}
.progress-fill {
    height: 100%;
    background: var(--accent-grad);
    border-radius: var(--radius-pill);
    width: 0%;
    transition: width 0.3s ease;
}
.progress-label { font-size: 0.78rem; color: var(--muted); text-align: right; }

/* ===== Start / Stop Button ===== */
.start-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent-grad);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.08rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-family: inherit;
    letter-spacing: 0.2px;
    box-shadow: var(--shadow-accent);
}
.start-btn:hover:not(:disabled)  { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(37, 99, 235, 0.34); }
.start-btn:active:not(:disabled) { transform: translateY(0); }
.start-btn:disabled { opacity: 0.65; cursor: not-allowed; box-shadow: none; }
.start-btn.running {
    background: #fff;
    color: var(--slow);
    border: 1.5px solid color-mix(in srgb, var(--slow) 40%, var(--border));
    box-shadow: var(--shadow-sm);
}

/* ===== Share Bereich ===== */
.share-section { padding: 26px 24px; margin: 18px 0; }
.share-section h3 { font-size: 1.2rem; margin-bottom: 4px; font-weight: 700; }
.share-subtitle { color: var(--muted); font-size: 0.875rem; margin-bottom: 18px; }

/* native share – the recommended path */
.native-share {
    width: 100%;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--accent-grad);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 700;
    cursor: pointer;
    display: none;            /* shown by JS when navigator.share exists */
    align-items: center; justify-content: center; gap: 9px;
    font-family: inherit;
    box-shadow: var(--shadow-accent);
    transition: transform var(--transition), box-shadow var(--transition);
}
.native-share:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(37, 99, 235, 0.34); }
.native-share svg { width: 19px; height: 19px; fill: currentColor; }

.share-divider {
    display: none; /* shown with native share */
    align-items: center; gap: 12px;
    color: var(--faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px;
    margin: 14px 0;
}
.share-divider::before, .share-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

.share-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.share-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem; font-weight: 600;
    text-decoration: none; color: #fff; border: none; cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
    font-family: inherit;
}
.share-btn svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); filter: brightness(1.05); }
.share-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.share-btn.whatsapp { background: #25d366; }
.share-btn.telegram { background: #0088cc; }
.share-btn.signal   { background: #3a76f0; }
.share-btn.threema  { background: #2b2b2b; }
.share-btn.rcs      { background: #1a7a1a; }
.share-btn.email    { background: #ea4335; }
.share-btn.copy {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink);
}
.share-btn.copy:hover { border-color: var(--accent); }

/* ===== Ergebnis-Zusammenfassung ===== */
.result-summary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.82rem; color: var(--muted);
    font-family: ui-monospace, monospace;
    word-break: break-word;
    text-align: left; line-height: 1.6;
}

/* ===== Info Section ===== */
.info-section { margin: 18px 0; }
.info-card { padding: 16px 20px; display: flex; gap: 12px; align-items: flex-start; }
.info-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.info-card strong { display: block; margin-bottom: 4px; font-size: 0.92rem; }
.info-card p { font-size: 0.83rem; color: var(--muted); line-height: 1.55; }

/* ===== Install hint (PWA) ===== */
.install-card {
    display: none;
    align-items: center; gap: 12px;
    background: color-mix(in srgb, var(--accent) 6%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    border-radius: var(--radius);
    padding: 14px 18px;
    margin: 18px 0;
    box-shadow: var(--shadow-sm);
}
.install-card .install-text { flex: 1; font-size: 0.86rem; color: var(--ink); }
.install-card .install-text small { display: block; color: var(--muted); margin-top: 2px; }
.install-btn {
    padding: 9px 16px; border-radius: var(--radius-sm);
    background: var(--accent-grad); color: #fff; border: none;
    font-weight: 700; font-size: 0.85rem; cursor: pointer; font-family: inherit;
    flex-shrink: 0;
}
.install-dismiss {
    background: none; border: none; color: var(--faint);
    font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 4px;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 22px 0 0;
    color: var(--muted); font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 22px;
}
footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
footer a:hover { text-decoration: underline; }

/* ===== Loading dots ===== */
.loading-dots::after { content: ''; animation: dots 1.5s infinite; }
@keyframes dots {
    0% { content: ''; } 25% { content: '.'; }
    50% { content: '..'; } 75% { content: '...'; } 100% { content: ''; }
}

/* ===== Focus visibility (a11y floor) ===== */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.start-btn:focus-visible { outline-offset: 3px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .ip-card       { flex-direction: column; align-items: flex-start; gap: 8px; }
    .ip-label      { min-width: unset; }
    .ip-info       { padding-left: 0; }
    .results-grid  { grid-template-columns: repeat(2, 1fr); }
    .speedtest-panel, .share-section { padding: 24px 18px; }
    .share-btn     { padding: 9px 13px; font-size: 0.8rem; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    #gaugeArc, #gaugeNeedle { transition: none !important; }
}
