/*
  NET/CHECK — Swiss Industrial Precision
  Aesthetic: Print layout, strict grids, high contrast, brutalist typography.
  Fixed viewport layout — no scrolling.
*/

:root {
    /* Colors - Dark Mode (Refined) */
    --paper: #252525;
    --paper-dark: #1e1e1e;
    --ink: #c4b5a0;

    /* Semantic Colors */
    --accent: var(--ink);
    --state-online: #1d4ed8;
    --state-offline: #dc2626;
    --state-check: #d97706;
    --state-standby: #525252;

    /* Typography */
    --font-display: "Syne", sans-serif;
    --font-mono: "IBM Plex Mono", monospace;

    /* Layout */
    --border-w: 1.5px;
}

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

html,
body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-mono);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Subtle organic grain */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.5'/%3E%3C/svg%3E");
}

/*
  GRID ARCHITECTURE — Fixed to viewport
  No scrolling, everything fits in 100vh
*/
.viewport-grid {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    background: var(--paper);
    border: var(--border-w) solid var(--ink);
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 50px 1fr 100px 120px;
    position: relative;
    z-index: 1;
}

.cell {
    border-bottom: var(--border-w) solid var(--ink);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

/* Header */
.header-cell {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ink);
    color: var(--paper);
    padding: 0 1rem;
    border-bottom: var(--border-w) solid var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    line-height: 1;
}

.meta-info {
    display: flex;
    gap: 1.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Main Status */
.status-cell {
    grid-column: 1 / 2;
    grid-row: 2 / 4;
    border-right: var(--border-w) solid var(--ink);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background-color: var(--paper);
    transition: background-color 0.4s ease, color 0.4s ease;
    padding: 1.5rem;
}

.status-label {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.status-value-wrapper {
    overflow: hidden;
    flex: 1;
    display: flex;
    align-items: center;
}

.super-status {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2rem, 6vh, 4rem);
    line-height: 0.9;
    letter-spacing: -0.04em;
    margin-left: -0.05em;
}

.latency-display {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: auto;
}

.latency-val {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 5vh, 3.5rem);
    line-height: 1;
}

.latency-unit {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Chart */
.chart-cell {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chart-header {
    padding: 0.5rem 0.75rem;
    border-bottom: var(--border-w) solid var(--ink);
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper-dark);
}

.blinking-dot {
    width: 6px;
    height: 6px;
    background: var(--ink);
    border-radius: 50%;
    opacity: 0.2;
}
.blinking-dot.active {
    animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 19px,
        rgba(255, 255, 255, 0.05) 20px
    );
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Metrics */
.metrics-cell {
    grid-column: 2 / 4;
    grid-row: 3 / 4;
    display: flex;
    flex-direction: row;
    gap: 2rem;
    align-items: center;
    border-bottom: var(--border-w) solid var(--ink);
}

.metric-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.m-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--state-standby);
}

.m-val {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Controls */
.controls-cell {
    grid-column: 1 / 2;
    grid-row: 4 / 5;
    border-right: var(--border-w) solid var(--ink);
    border-bottom: none;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
}

.btn {
    appearance: none;
    background: transparent;
    border: var(--border-w) solid var(--ink);
    color: var(--ink);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    text-transform: uppercase;
    flex: 1;
}

.btn.primary {
    background: var(--ink);
    color: var(--paper);
}

.btn.primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn.secondary:hover {
    background: var(--paper-dark);
}

.btn:active {
    transform: translate(1px, 1px);
}

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

/* Log Cell */
.log-cell {
    grid-column: 2 / 4;
    grid-row: 4 / 5;
    border-bottom: none;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.log-header-bar {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: var(--border-w) solid var(--ink);
    background: var(--paper-dark);
    font-size: 0.7rem;
    font-weight: 600;
}

.text-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
}
.text-btn:hover {
    color: var(--state-offline);
}

.log-table {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.log-th,
.log-row {
    display: grid;
    grid-template-columns: 80px 1fr 70px;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.75rem;
}

.log-th {
    font-weight: 600;
    color: var(--state-standby);
    border-bottom: var(--border-w) solid var(--ink);
}

.log-tbody {
    flex: 1;
    overflow: hidden;
}

.log-row {
    font-weight: 500;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.log-row .right {
    text-align: right;
}

.log-row .state-online {
    color: var(--state-online);
}
.log-row .state-offline {
    color: var(--state-offline);
}
.log-row .state-checking {
    color: var(--state-check);
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Scrollbar removal — no scrolling allowed */
::-webkit-scrollbar {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .viewport-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 45px 1fr 150px 80px 100px;
    }
    .header-cell,
    .status-cell,
    .chart-cell,
    .metrics-cell,
    .controls-cell,
    .log-cell {
        grid-column: 1 / -1;
        border-right: none;
    }
    .status-cell {
        grid-row: 2;
        border-right: none;
        border-bottom: var(--border-w) solid var(--ink);
    }
    .chart-cell {
        grid-row: 3;
    }
    .metrics-cell {
        grid-row: 4;
        border-bottom: var(--border-w) solid var(--ink);
    }
    .controls-cell {
        grid-row: 5;
        border-right: none;
    }
    .log-cell {
        display: none;
    }
}
