/* cloudkeep — single stylesheet for the landing page and the gateway SPA.
   Kept deliberately small: tokens, primitives (btn/card/field/badge), then
   the three SPA views. */

/* ---------- reset + tokens ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1c2128;
    --border: #30363d; --border-soft: #21262d;
    --text: #e6edf3; --text-muted: #8b949e;
    --danger: #f85149; --success: #3fb950; --warn: #d29922;
    --radius: 6px; --container: 1100px;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
html, body { height: 100%; }
body {
    background: var(--bg); color: var(--text);
    font: 14px/1.5 var(--mono);
    min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--border); }
a:hover { text-decoration-color: var(--text); }
h1, h2, h3 { font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
main { flex: 1; padding: 40px 0; }
.site-header { border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
              border: 1px solid var(--border); border-radius: 5px; background: var(--surface); font-size: 12px; }
.brand-name { font-size: 13px; }
.section-header { padding-bottom: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--border-soft); }
.section-header--row { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 15px; }

/* ---------- primitives ---------- */
.btn { font: 13px var(--mono); color: var(--text); background: var(--surface-2);
       border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; cursor: pointer;
       transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .08s ease; }
.btn:hover:not(:disabled) { border-color: var(--text-muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }   /* tactile press */
.btn:disabled { color: var(--text-muted); cursor: not-allowed; }

/* Visible keyboard focus on every interactive control (mouse clicks stay clean
   via :focus-visible). */
.btn:focus-visible, .step:focus-visible, .field-input:focus-visible,
.slider:focus-visible, a:focus-visible { outline: 2px solid var(--text-muted); outline-offset: 2px; }
.btn--card { flex: 1; text-align: center; text-decoration: none; display: block; }
.btn--ghost { background: transparent; padding: 4px 10px; font-size: 12px; }
.btn--danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
        transition: border-color .15s ease, transform .15s ease; }
.card:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-title { font-size: 14px; overflow-wrap: anywhere; }
.card-body { color: var(--text-muted); font-size: 13px; }
.card-err { font-size: 12px; color: var(--text-muted); border: 1px solid var(--border);
            border-radius: var(--radius); background: var(--surface-2); padding: 6px 8px; margin-top: 8px; }
.card-progress { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.card > .btn--card { margin-top: 12px; }   /* landing page: button without an actions row */

/* Status pill with a leading colour dot, so VM health is scannable at a glance.
   The dot colour is the only semantic add; the pill itself stays monochrome. */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 2px 8px;
         border: 1px solid var(--border); border-radius: 10px; color: var(--text-muted); white-space: nowrap; }
.badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.badge--active { color: var(--text); border-color: var(--text-muted); }
.badge--active::before { background: var(--success); }
.badge--pending { background: var(--surface-2); }
.badge--pending::before { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.badge--down { background: var(--surface-2); border-style: dashed; }
.badge--error::before { background: var(--danger); }   /* pairs with badge--down for the box */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-muted); }
.field-input { font: 13px var(--mono); color: var(--text); background: var(--bg);
               border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 10px; }
.field-input:focus { outline: none; border-color: var(--text-muted); }
.form-error { color: var(--text); font-size: 12px; border: 1px solid var(--text-muted);
              border-radius: var(--radius); background: var(--surface-2); padding: 8px 10px; }
.empty { color: var(--text-muted); font-size: 13px; padding: 24px 0; }

.slider { appearance: none; -webkit-appearance: none; height: 4px; border-radius: 2px;
          background: var(--surface-2); border: 1px solid var(--border); }
.slider::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
                                border-radius: 50%; background: var(--text); cursor: pointer; }
.slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%;
                            background: var(--text); border: none; cursor: pointer; }

/* ---------- login ---------- */
#view-login { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.auth-card { width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-title { font-size: 16px; margin-bottom: 6px; }

/* ---------- dashboard: resource meters ---------- */
.res { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
       gap: 16px 32px; margin-bottom: 24px; }
.res-group { display: flex; flex-direction: column; gap: 9px; }
.res-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.meter-head b { color: var(--text); font-weight: 600; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2);
         border: 1px solid var(--border); overflow: hidden; display: flex; }
.meter > span { height: 100%; transition: width .4s ease; }   /* bars glide on refresh */
.meter-fill { background: var(--text-muted); }
.meter-fill--warn { background: var(--danger); }
.meter-seg--alloc { background: var(--text-muted); }     /* host: in use by VMs */
.meter-seg--reserve { background: var(--border); }       /* host: reserved for the host itself */

/* ---------- dashboard ---------- */
.builder { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
           padding: 20px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 520px; }

/* ---------- viewer (full-bleed) ---------- */
body[data-view="viewer"] { height: 100vh; overflow: hidden; }
body[data-view="viewer"] .site-header, body[data-view="viewer"] main { display: none !important; }
.view-viewer { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px;
              border-bottom: 1px solid var(--border); flex-shrink: 0; }
.viewer-status { flex: 1; font-size: 12px; color: var(--text-muted); }
.viewer-screen { flex: 1; min-height: 0; background: #000; overflow: hidden; position: relative; }
.viewer-screen > :first-child { width: 100% !important; height: 100% !important; }

/* ---------- console (live boot log — its own pop-up window, app/console.html) ----------
   The pop-up <body> carries data-view="console", so it fills the window and the
   log scrolls inside; .viewer-bar + .console-log are reused as the body's flex children. */
body[data-view="console"] { height: 100vh; overflow: hidden; }
.console-log { flex: 1; min-height: 0; margin: 0; padding: 12px 16px; overflow: auto;
               background: #000; color: var(--text); font: 12px/1.45 var(--mono);
               white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 600px) { main { padding: 28px 0; } .landing-banner-title { font-size: 19px; } }

/* ---------- landing page ---------- */
.landing-banner { border-bottom: 1px solid var(--border); padding: 16px 24px;
                  display: flex; align-items: center; justify-content: center; gap: 12px; }
.landing-banner-title { font-size: 22px; letter-spacing: -0.02em; }
.landing-main { flex: 1; display: flex; flex-direction: column; align-items: center;
                justify-content: center; gap: 24px; text-align: center; padding: 24px; }
.landing-tagline { color: var(--text-muted); font-size: 15px; }
.btn--hero { font-size: 16px; padding: 16px 40px; background: var(--surface); }
.btn--learn { position: fixed; right: 16px; bottom: 16px; font-size: 12px; }

/* ---------- modal (pure CSS :target — no JS) ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 10;
         align-items: center; justify-content: center; padding: 24px; }
.modal:target { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.modal-box { position: relative; z-index: 1; width: 100%; max-width: 560px;
             max-height: 82vh; overflow: auto; background: var(--surface);
             border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.modal-title { font-size: 18px; margin-bottom: 12px; }
.modal-box p { font-size: 13px; margin-bottom: 8px; }
.modal-h { font-size: 11px; color: var(--text-muted); margin: 16px 0 4px;
           text-transform: uppercase; letter-spacing: 0.05em; }
.modal-box .btn { margin-top: 18px; text-decoration: none; }
.modal-close { position: absolute; top: 10px; right: 16px; font-size: 22px;
               line-height: 1; color: var(--text-muted); text-decoration: none; }
.modal-close:hover { color: var(--text); }

/* Request-access form: stack the reused .field rows; .hp hides the honeypot
   from people (off-screen) while bots still fill it. */
.req-form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 16px; }
.req-form .btn { margin-top: 4px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- builder steppers ---------- */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row .slider { flex: 1; }
.step { flex: none; width: 28px; height: 28px; font: 15px var(--mono); line-height: 1;
        color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
        border-radius: var(--radius); cursor: pointer; }
.step { transition: border-color .15s ease, transform .08s ease; }
.step:hover { border-color: var(--text-muted); }
.step:active { transform: translateY(1px); }

/* Honour users who prefer less motion: drop the build pulse, hovers, presses. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
                             transition-duration: 0.001ms !important; }
}
