/* =====================================================================
   FARGONE — design system
   Grunge industrial theme: near-black backgrounds, steel greys, hazard
   yellow accents. Mirrors the Official Launcher styling.
   ===================================================================== */

:root {
    /* Surfaces */
    --fg-bg-0: #0b0b0b;        /* page background */
    --fg-bg-1: #111111;        /* app shell */
    --fg-bg-2: #161616;        /* panels */
    --fg-bg-3: #1c1c1c;        /* raised panels / rows */
    --fg-bg-4: #232323;        /* hover rows, inputs */

    /* Lines */
    --fg-line-0: #1f1f1f;
    --fg-line-1: #2a2a2a;
    --fg-line-2: #3a3a3a;

    /* Text */
    --fg-text-0: #f2f2f2;
    --fg-text-1: #cfcfcf;
    --fg-text-2: #8a8a8a;
    --fg-text-3: #5e5e5e;

    /* Accent — hazard yellow */
    --fg-yellow: #e9b826;
    --fg-yellow-hi: #f4cb3f;
    --fg-yellow-lo: #b8901c;
    --fg-yellow-dim: rgba(233, 184, 38, 0.14);
    --fg-yellow-glow: rgba(233, 184, 38, 0.35);

    /* Status */
    --fg-green: #4caf50;
    --fg-red: #c9452f;
    --fg-blue: #4fb3ff;   /* the blue of the asteroid fragments */

    /* Type */
    --fg-font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --fg-font-body: "Barlow", "Segoe UI", sans-serif;
    --fg-font-mono: "JetBrains Mono", "Consolas", monospace;

    /* Layout */
    --fg-max-w: 1240px;
    --fg-gutter: 24px;
    --fg-header-h: 64px;
    --fg-radius: 2px;

    color-scheme: dark;
}

/* Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--fg-bg-0);
    color: var(--fg-text-1);
    font-family: var(--fg-font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--fg-yellow); text-decoration: none; }
a:hover { color: var(--fg-yellow-hi); }
button { font: inherit; cursor: pointer; }
h1:focus { outline: none; }
::selection { background: var(--fg-yellow); color: #000; }

/* Grunge textures --------------------------------------------------- */
/* Film-grain noise overlay across the whole page. Pointer-events off. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: screen;
}
/* Faint vignette so panels sit "in" the page. */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* Utility: scratched / weathered surface for hero panels */
.fg-grunge {
    position: relative;
    isolation: isolate;
}
.fg-grunge::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.12;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.012 0.03' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.9 0 0 0 0 0.7 0 0 0 0 0.15 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

/* Layout helpers ---------------------------------------------------- */
.fg-container {
    width: 100%;
    max-width: var(--fg-max-w);
    margin: 0 auto;
    padding: 0 var(--fg-gutter);
}
.fg-page { position: relative; z-index: 1; padding: 48px 0 96px; }
.fg-stack > * + * { margin-top: 24px; }

/* Typography -------------------------------------------------------- */
.fg-eyebrow {
    font-family: var(--fg-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--fg-text-2);
}
.fg-eyebrow.is-yellow { color: var(--fg-yellow); }

.fg-title {
    font-family: var(--fg-font-display);
    font-weight: 700;
    font-size: clamp(32px, 4vw, 48px);
    line-height: 1;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--fg-text-0);
    margin: 4px 0 0;
}
.fg-title.is-hero {
    font-size: clamp(48px, 9vw, 120px);
    letter-spacing: 0.04em;
    font-weight: 800;
}

/* "| SECTION" heading — yellow bar + mono label, as on the launcher */
.fg-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    font-family: var(--fg-font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-text-0);
}
.fg-section-label::before {
    content: "";
    width: 3px;
    height: 14px;
    background: var(--fg-yellow);
    flex: none;
}

.fg-mono { font-family: var(--fg-font-mono); }
.fg-muted { color: var(--fg-text-2); }
.fg-yellow { color: var(--fg-yellow); }
.fg-lead { font-size: 18px; color: var(--fg-text-1); max-width: 68ch; }
.fg-prose p { margin: 0 0 1em; max-width: 72ch; }
.fg-prose p:last-child { margin-bottom: 0; }

/* Panels ------------------------------------------------------------ */
.fg-panel {
    background: var(--fg-bg-2);
    border: 1px solid var(--fg-line-1);
    border-radius: var(--fg-radius);
}
.fg-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--fg-line-1);
}
.fg-panel-body { padding: 24px; }
.fg-panel.is-raised { background: var(--fg-bg-3); }

/* Stat block (INSTALLED / ENABLED / ISSUES pattern) */
.fg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    border: 1px solid var(--fg-line-1);
    background: var(--fg-bg-2);
}
.fg-stat {
    padding: 14px 16px;
    border-right: 1px solid var(--fg-line-1);
}
.fg-stat:last-child { border-right: 0; }
.fg-stat-label {
    font-family: var(--fg-font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-text-2);
}
.fg-stat-value {
    font-family: var(--fg-font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--fg-text-0);
    margin-top: 4px;
}

/* Buttons ----------------------------------------------------------- */
.fg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 18px;
    border: 1px solid var(--fg-line-2);
    border-radius: var(--fg-radius);
    background: var(--fg-bg-3);
    color: var(--fg-text-0);
    font-family: var(--fg-font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.fg-btn:hover { background: var(--fg-bg-4); border-color: var(--fg-text-3); color: var(--fg-text-0); }
.fg-btn:active { transform: translateY(1px); }
.fg-btn:focus-visible { outline: 2px solid var(--fg-yellow); outline-offset: 2px; }

.fg-btn.is-primary {
    background: var(--fg-yellow);
    border-color: var(--fg-yellow);
    color: #0b0b0b;
    box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 8px 24px -8px var(--fg-yellow-glow);
}
.fg-btn.is-primary:hover { background: var(--fg-yellow-hi); border-color: var(--fg-yellow-hi); color: #000; }

/* Big PLAY-style button: display font, sub-label underneath */
.fg-btn.is-lg {
    flex-direction: column;
    gap: 0;
    padding: 16px 40px;
    font-family: var(--fg-font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.28em;
    line-height: 1;
}
.fg-btn.is-lg .fg-btn-sub {
    display: block;
    font-family: var(--fg-font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    opacity: .75;
    margin-top: 6px;
}

.fg-btn.is-ghost { background: transparent; }

/* Tags / pills ------------------------------------------------------ */
.fg-tag {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--fg-line-2);
    border-radius: var(--fg-radius);
    background: var(--fg-bg-3);
    font-family: var(--fg-font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg-text-2);
    line-height: 1.4;
}
.fg-tag.is-yellow { background: var(--fg-yellow-dim); border-color: var(--fg-yellow-lo); color: var(--fg-yellow); }
.fg-tag.is-green { color: var(--fg-green); border-color: rgba(76,175,80,.4); background: rgba(76,175,80,.08); }
.fg-tag.is-red { color: #ff7a66; border-color: rgba(201,69,47,.5); background: rgba(201,69,47,.1); }
.fg-tag.is-blue { color: var(--fg-blue); border-color: rgba(79,179,255,.4); background: rgba(79,179,255,.08); }

/* Status dot ("● READY") */
.fg-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--fg-green);
    box-shadow: 0 0 8px var(--fg-green);
    vertical-align: middle;
    margin-right: 8px;
}
.fg-dot.is-yellow { background: var(--fg-yellow); box-shadow: 0 0 8px var(--fg-yellow); }

/* Dividers ---------------------------------------------------------- */
.fg-rule { border: 0; border-top: 1px solid var(--fg-line-1); margin: 32px 0; }
.fg-rule.is-dashed { border-top-style: dashed; border-color: var(--fg-line-2); }

/* Inputs ------------------------------------------------------------ */
.fg-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--fg-bg-1);
    border: 1px solid var(--fg-line-1);
    border-radius: var(--fg-radius);
    color: var(--fg-text-0);
    font-family: var(--fg-font-mono);
    font-size: 13px;
}
.fg-input::placeholder { color: var(--fg-text-3); }
.fg-input:focus { outline: none; border-color: var(--fg-yellow-lo); box-shadow: 0 0 0 2px var(--fg-yellow-dim); }

/* Scrollbars (match launcher) -------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--fg-bg-1); }
::-webkit-scrollbar-thumb { background: var(--fg-yellow); border: 2px solid var(--fg-bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-yellow-hi); }

/* Blazor plumbing --------------------------------------------------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 10000;
    padding: 12px 24px;
    background: var(--fg-bg-3);
    border-top: 2px solid var(--fg-red);
    color: var(--fg-text-0);
    font-family: var(--fg-font-mono);
    font-size: 12px;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }
#blazor-error-ui .reload { margin-left: 12px; }
.blazor-error-boundary { padding: 1rem; background: rgba(201,69,47,.15); border: 1px solid var(--fg-red); color: var(--fg-text-0); }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Responsive -------------------------------------------------------- */
@media (max-width: 640px) {
    :root { --fg-gutter: 16px; }
    .fg-page { padding: 32px 0 64px; }
    .fg-panel-head, .fg-panel-body { padding: 16px; }
}

/* Boot screen (index.html, shown until the WebAssembly runtime starts) --- */
.fg-boot {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--fg-bg-0);
}
.fg-boot-word {
    font-family: var(--fg-font-display);
    font-weight: 800;
    font-size: clamp(40px, 8vw, 72px);
    letter-spacing: 0.12em;
    color: var(--fg-text-0);
    line-height: 1;
}
.fg-boot-bar {
    width: min(260px, 60vw);
    height: 3px;
    background: var(--fg-line-1);
    overflow: hidden;
}
.fg-boot-fill {
    width: 40%;
    height: 100%;
    background: var(--fg-yellow);
    animation: fg-boot-slide 1.1s ease-in-out infinite;
}
.fg-boot-label {
    font-family: var(--fg-font-mono);
    font-size: 10px;
    letter-spacing: 0.24em;
    color: var(--fg-text-2);
}
@keyframes fg-boot-slide {
    from { transform: translateX(-100%); }
    to   { transform: translateX(260%); }
}
