/*!
 * ReTech Portal — public landing.
 *
 * Browser support is the constraint here, not fashion: this page is opened on
 * whatever machine a client owns, including years-old Safari. So no color-mix(),
 * no dvh units, no :has(), no nesting — plain custom properties, rgba overlays
 * and flex/grid only. Every colour is declared statically so a single
 * unsupported function can never blank the page (that is exactly what happened
 * before: color-mix() dropped the backgrounds and left white on white).
 */

:root {
    --accent: #147d92;
    --bg: #123a46;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 14px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
}

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

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

body {
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- theme ---------------------------------------------------------------
   Two flat, self-contained palettes. The gradient is a progressive extra: the
   solid background-color underneath always paints, so an unsupported gradient
   degrades to a plain dark (or light) page rather than to white.             */

body.portal-dark {
    color: #eaf3f1;
    background-color: var(--bg);
    background-image: radial-gradient(900px 520px at 12% -10%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;

    --fg-muted: rgba(234, 243, 241, .72);
    --fg-faint: rgba(234, 243, 241, .52);
    --surface: rgba(255, 255, 255, .07);
    --surface-2: rgba(255, 255, 255, .12);
    --line: rgba(255, 255, 255, .16);
    --line-strong: rgba(255, 255, 255, .3);
    --on-accent: #ffffff;
}

body.portal-light {
    color: #14211f;
    background-color: #f4f7f9;
    background-image: radial-gradient(900px 520px at 12% -10%, rgba(20, 125, 146, .14), rgba(20, 125, 146, 0) 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;

    --fg-muted: rgba(20, 33, 31, .72);
    --fg-faint: rgba(20, 33, 31, .55);
    --surface: rgba(255, 255, 255, .8);
    --surface-2: #ffffff;
    --line: rgba(20, 33, 31, .14);
    --line-strong: rgba(20, 33, 31, .28);
    --on-accent: #ffffff;
}

/* ---- shell ---------------------------------------------------------------
   Normal document flow. The previous version pinned the page to one viewport
   height and hid the overflow, which cut off content on short/landscape
   screens and made a dropdown impossible to fit.                             */

.portal {
    max-width: 1180px;
    margin: 0 auto;
    padding:
        calc(18px + var(--safe-t))
        calc(clamp(16px, 4vw, 44px) + var(--safe-r))
        calc(24px + var(--safe-b))
        calc(clamp(16px, 4vw, 44px) + var(--safe-l));
}

.portal-i { width: 22px; height: 22px; flex: none; }
.portal-i-sm { width: 17px; height: 17px; }

/* ---- top bar ------------------------------------------------------------- */

.portal-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: clamp(24px, 5vh, 56px);
}

.portal-logo { height: 34px; width: auto; display: block; }
.portal-brand { font-size: 1.4rem; font-weight: 700; }

.portal-top-right { display: flex; align-items: center; gap: 10px; }

.portal-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--fg-muted);
}

.portal-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #3ddc97;
    box-shadow: 0 0 0 3px rgba(61, 220, 151, .22);
}

.portal-signin {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: 999px;
    font-weight: 600;
    font-size: .92rem;
    border: 1px solid var(--line-strong);
}
.portal-signin:hover { background: var(--surface); }

/* ---- lead: hero + device panel ------------------------------------------ */

.portal-lead {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    gap: clamp(24px, 4vw, 48px);
    align-items: start;
    margin-bottom: clamp(36px, 7vh, 72px);
}

.portal-eyebrow {
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: .74rem;
    font-weight: 700;
    color: var(--fg-faint);
    margin-bottom: 14px;
}

.portal-heading {
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1.06;
}

.portal-subtext {
    margin-top: 16px;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    color: var(--fg-muted);
    max-width: 46ch;
}

.portal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 650;
    font-size: .96rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
}
.portal-btn--primary {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 14px 30px -16px rgba(0, 0, 0, .8);
}
.portal-btn--primary:hover { filter: brightness(1.08); }
.portal-btn--ghost { border-color: var(--line-strong); color: inherit; }
.portal-btn--ghost:hover { background: var(--surface); }
.portal-btn--small { padding: 9px 15px; font-size: .88rem; }

.portal-server {
    margin-top: 16px;
    font-size: .85rem;
    color: var(--fg-faint);
}
.portal-server code {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 2px 8px;
    font-size: .85rem;
}

/* ---- cards --------------------------------------------------------------- */

.portal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}

.portal-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.portal-card-head h2 { font-size: 1.05rem; }
.portal-card-head h3 { font-size: .98rem; }
.portal-card-head p { font-size: .82rem; color: var(--fg-faint); margin-top: 2px; }
.portal-card-head .portal-i { color: var(--accent); margin-top: 2px; }
body.portal-dark .portal-card-head .portal-i { color: #7fd6e4; }

/* ---- device facts -------------------------------------------------------- */

.portal-facts { margin: 0; }

.portal-fact {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 7px 0;
    border-top: 1px solid var(--line);
    font-size: .88rem;
}
.portal-fact:first-child { border-top: 0; }
.portal-fact dt { color: var(--fg-faint); }
.portal-fact dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.portal-card-note {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: .8rem;
    color: var(--fg-faint);
}

/* ---- sections ------------------------------------------------------------ */

.portal-section { margin-bottom: clamp(30px, 6vh, 60px); }

.portal-section-title {
    font-size: 1.15rem;
    margin-bottom: 16px;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
}
.portal-grid--links { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.portal-grid--stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* One card per platform; architectures are rows inside it, so the grid stays a
   tidy single row instead of orphaning a fifth card. The badge is positioned,
   not in the flow, so it cannot push the heading onto a second line. */

.portal-agent-card { position: relative; display: flex; flex-direction: column; }
.portal-agent-card.is-detected { border-color: var(--accent); background: var(--surface-2); }
.portal-agent-card.is-todo { opacity: .55; }
.portal-agent-card .portal-card-head { padding-right: 84px; }

.portal-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
}

.portal-builds {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    width: 100%;
}

.portal-build {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
}
.portal-build:first-child { border-top: 0; }

.portal-build-name {
    font-size: .85rem;
    color: var(--fg-muted);
}

.portal-build-actions { display: flex; align-items: center; gap: 8px; }

.portal-todo { font-size: .8rem; color: var(--fg-faint); }

/* The install command is long by nature (package + config + restart). Showing
   it raw made every card grow a scrollbar, so it lives behind a copy button
   with the full text in the tooltip. */
.portal-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--fg-faint);
    cursor: pointer;
    padding: 7px 12px;
    font: inherit;
    font-size: .8rem;
}
.portal-copy:hover { color: inherit; border-color: var(--line-strong); }
.portal-copy.is-done { color: #3ddc97; border-color: #3ddc97; }

.portal-section-note {
    font-size: .85rem;
    color: var(--fg-faint);
    max-width: 78ch;
    margin: -6px 0 16px;
}

.portal-link-card { display: block; }
.portal-link-card:hover { background: var(--surface-2); border-color: var(--line-strong); }

.portal-stat { text-align: left; }
.portal-stat .portal-stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.portal-stat .portal-stat-label { font-size: .82rem; color: var(--fg-faint); margin-top: 4px; }

/* ---- footer -------------------------------------------------------------- */

.portal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    justify-content: space-between;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: .8rem;
    color: var(--fg-faint);
}

/* ---- sign-in modal ------------------------------------------------------- */

.portal-modal {
    position: fixed;
    inset: 0;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.portal-modal[hidden] { display: none; }

.portal-modal-backdrop {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(4, 16, 20, .72);
}

.portal-modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--bg);
    color: #eaf3f1;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 16px;
    padding: 26px 24px 22px;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9);
    margin: auto;
}
body.portal-light .portal-modal-card { background: #ffffff; color: #14211f; border-color: rgba(20, 33, 31, .14); }

.portal-modal-close {
    position: absolute;
    top: 10px; right: 12px;
    background: none; border: 0;
    font-size: 1.6rem; line-height: 1;
    color: inherit; opacity: .55;
    cursor: pointer;
}
.portal-modal-close:hover { opacity: 1; }

.portal-modal-brand { margin-bottom: 18px; }
.portal-modal-brand .portal-logo { height: 30px; }

.portal-field { display: block; margin-bottom: 13px; }
.portal-field span { display: block; font-size: .8rem; color: var(--fg-faint); margin-bottom: 5px; }
.portal-field input {
    width: 100%;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: inherit;
    font: inherit;
}
.portal-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.portal-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    color: var(--fg-muted);
    margin-bottom: 16px;
}

.portal-modal-submit {
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.portal-modal-submit:hover { filter: brightness(1.08); }

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
    .portal-lead { grid-template-columns: 1fr; }
    .portal-heading { font-size: clamp(1.9rem, 8vw, 2.6rem); }
}

@media (max-width: 560px) {
    .portal-copy-label { display: none; }        /* icon-only copy on phones */
    .portal-build { justify-content: flex-start; }
    .portal-status { display: none; }          /* keeps the top bar on one line */
    .portal-actions .portal-btn { width: 100%; justify-content: center; }
    .portal-fact { font-size: .84rem; }
}

/* Cards can opt into one form factor (e.g. the phone-only capture app). */
@media (max-width: 700px) { .portal-only-desktop { display: none; } }
@media (min-width: 701px) { .portal-only-mobile { display: none; } }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
