/* Goobi-to-go start page.
 *
 * On top of site.css, which carries goobi-ui's look (Tabler values under
 * --gw-* names), the top bar, buttons, status, pills and fields. This file
 * lays out the page: a title, two app cards and a row of link cards.
 *
 * Whatever the CLI stripped from index.html is handled here through :has() --
 * one app card instead of two, fewer extras, none at all. Everything fits
 * 1280 x 800 without scrolling with both apps and every extra.
 */

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--gw-body-bg);
    color: var(--gw-text);
    font-family: var(--gw-font);
    font-weight: 400;
    font-size: 14px;
    line-height: 1.4286;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Page ---------- */

.start {
    flex: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.start code { font-family: var(--gw-mono); }

/* ---------- Page header: title and one muted line, left-aligned ---------- */

.start-hello { display: block; }

.start-hello h1 {
    margin: 0;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.4;
    color: var(--gw-heading);
}

.start-hello h1 em { font-style: normal; }

.start-sub { margin: 2px 0 0; color: var(--gw-muted); font-size: 14px; }

/* ---------- App cards: one grid of seven shared rows ---------- */

.start-apps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(7, auto);
    column-gap: 16px;
}

/* One card left: limited width, centred, and the extras row follows suit. */
.start-apps:not(:has(> article ~ article)) {
    grid-template-columns: minmax(0, 640px);
    justify-content: center;
}

.start:not(:has(.start-apps > article ~ article)) .start-extras {
    width: 100%;
    max-width: 640px;
    margin-inline: auto;
}

/* A Tabler card. It has no padding of its own: every row carries its own.
   Each app has a colour of its own (--app): a stripe along the top, the
   icon, the button and the chosen account. The workflow keeps goobi-ui's
   blue, the viewer is a dark green; white on it is 6.4:1. */
.start-app {
    --app: var(--gw-primary);
    --app-hover: var(--gw-primary-hover);
    --app-lt: var(--gw-primary-lt);
    grid-row: span 7;
    display: grid;
    grid-template-rows: subgrid;
    row-gap: 0;
    min-width: 0;
    background: var(--gw-surface);
    border: 1px solid var(--gw-border);
    border-top: 4px solid var(--app);
    border-radius: var(--gw-radius-lg);
    box-shadow: var(--gw-shadow);
}

.start-app[data-instance="viewer"] {
    --app: #1e6b45;
    --app-hover: #1a5b3b;
    --app-lt: #e9f0ec;
}

/* Row 1, the card header: icon, title and line, status on the right (and the
   viewer's Solr link). */
.start-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gw-border);
}

/* Tabler's avatar in the app's light tint. */
.start-mark {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--gw-radius);
    background: var(--app-lt);
    color: var(--app);
}

.start-mark svg { width: 22px; height: 22px; }

.start-title { flex: 1; min-width: 0; }

.start-title h2 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gw-heading);
}

.start-title p { margin: 0; color: var(--gw-muted); font-size: 14px; text-wrap: pretty; }

.start-side {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status: a Tabler badge in the state's light tint, a dot and the word. */
.start-head .start-status {
    gap: 6px;
    padding: 2px 8px;
    border-radius: var(--gw-radius-sm);
    background: var(--gw-gray-100);
    color: var(--gw-muted);
    font-weight: 500;
    font-size: 12px;
    line-height: 20px;
    white-space: nowrap;
}

.start-head .start-status::before { width: 6px; height: 6px; background: var(--gw-gray-500); }
.start-head .start-status.is-ok { background: var(--gw-green-lt); color: var(--gw-green-text); }
.start-head .start-status.is-ok::before { background: var(--gw-green); }
.start-head .start-status.is-wait { background: var(--gw-yellow-lt); color: var(--gw-yellow-text); }
.start-head .start-status.is-wait::before { background: var(--gw-yellow); }
.start-head .start-status.is-down { background: var(--gw-red-lt); color: var(--gw-red-text); }
.start-head .start-status.is-down::before { background: var(--gw-red); }

/* A small secondary button. */
.start-solr {
    min-height: 0;
    box-shadow: none;
    gap: 4px;
    padding: 1px 8px;
    background: var(--gw-surface);
    border: 1px solid var(--gw-border);
    border-radius: var(--gw-radius);
    color: var(--gw-text);
    font-weight: 500;
    font-size: 12px;
    line-height: 20px;
}

.start-solr:hover { background: var(--gw-gray-50); border-color: var(--gw-gray-300); color: var(--gw-heading); }
.start-solr svg { width: 12px; height: 12px; }

/* Row 2: stays as an empty shared row, no height of its own. */
.start-meta { margin: 0; }

/* Row 3: the one primary action, and below it at most one muted line. */
.start-act { display: grid; gap: 8px; align-content: start; padding: 16px 20px 0; }

/* Tabler's btn-primary, in the app's colour once the app answers. */
.start-act a.g2g-open {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    padding: 0 16px;
}

.start-act a.g2g-open:not([aria-disabled="true"]) { background: var(--app); }
.start-act a.g2g-open:not([aria-disabled="true"]):hover { background: var(--app-hover); }
.start-act a.g2g-open:focus-visible { outline: 2px solid var(--app); outline-offset: 2px; }

.start-act .g2g-btn svg { width: 16px; height: 16px; }

/* The cup shows only while the app brews, in place of the arrow. */
.start-act .g2g-btn svg.start-brew { display: none; width: 14px; height: 16px; }
.start-act a.is-brewing svg.start-brew { display: block; }
.start-act a.is-brewing svg.start-arrow { display: none; }

.start-hint { margin: 0; text-align: center; font-size: 13px; color: var(--gw-muted); }
.start-hint code { font-size: 12px; color: var(--gw-text); }

/* Rows 4 to 7, the login: Tabler's subheader, a line above. */
.start-sign-h {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 16px 0 0;
    padding: 16px 20px 0;
    border-top: 1px solid var(--gw-border);
    font-weight: 600;
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gw-muted);
}

.start-sign-h svg { width: 14px; height: 14px; flex: none; }

/* The accounts as a row of small buttons, the chosen one in the app's tint. */
.start-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 20px 0; }

.start-pills .g2g-pill { white-space: nowrap; }
.start-pills .g2g-pill[disabled] { cursor: default; }

.start-pills .g2g-pill[aria-pressed="true"] { background: var(--app-lt); color: var(--app); border-color: var(--app); }

.start-pills .g2g-pill:focus-visible { outline: 2px solid var(--app); outline-offset: 2px; }

.start-note { margin: 0; padding: 8px 20px 0; align-self: start; font-size: 13px; color: var(--gw-muted); }

.start-cred {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 20px 20px;
    align-self: end;
}

/* ---------- Extras: small link cards in one row ---------- */

.start-extras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 16px;
}

.start-extras:not(:has(a)) { display: none; }

.start-x-slot { display: grid; min-width: 0; }

/* Tabler's card-sm card-link: hover lifts the shadow, nothing moves. */
.start-x {
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    min-width: 0;
    padding: 16px;
    background: var(--gw-surface);
    border: 1px solid var(--gw-border);
    border-radius: var(--gw-radius-lg);
    box-shadow: var(--gw-shadow);
    color: var(--gw-text);
    text-decoration: none;
}

.start-x:hover { color: var(--gw-text); text-decoration: none; box-shadow: rgba(23, 23, 23, .16) 0 2px 16px 0; }
.start-x:focus-visible { outline: 2px solid var(--gw-primary); outline-offset: 2px; }

.start-x-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--gw-radius);
    background: var(--gw-primary-lt);
    color: var(--gw-primary);
}

.start-x-icon svg { width: 22px; height: 22px; }

.start-x-text { flex: 1; min-width: 0; display: grid; }

.start-x-text b { font-weight: 600; font-size: 14px; color: var(--gw-heading); }

.start-x-text small {
    overflow: hidden;
    font-size: 13px;
    color: var(--gw-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.start-drop { border-style: dashed; border-color: var(--gw-gray-300); box-shadow: none; }
.start-drop.is-hot { border-color: var(--gw-primary); background: var(--gw-primary-lt); }

/* A service that does not answer: the card stays, its text goes quiet. */
.start-x-slot.is-unavailable .start-x { cursor: not-allowed; }
.start-x-slot.is-unavailable .start-x:hover { box-shadow: var(--gw-shadow); }
.start-x-slot.is-unavailable .start-drop:hover,
.start-x-slot.is-unavailable .start-drop.is-hot { border-color: var(--gw-gray-300); background: var(--gw-surface); box-shadow: none; }
.start-x-slot.is-unavailable b,
.start-x-slot.is-unavailable small { color: var(--gw-muted); font-weight: 400; }
.start-x-slot.is-unavailable .start-x-icon { background: var(--gw-gray-100); color: var(--gw-muted); }

/* The guide's progress: a 40 px ring, --p percent of it drawn. */
.start-ring {
    --p: 0;
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: conic-gradient(var(--gw-primary) calc(var(--p) * 1%), var(--gw-border) 0);
}

.start-ring-pct {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gw-surface);
    font-weight: 600;
    font-size: 11px;
    color: var(--gw-heading);
}

/* ---------- Footer: Tabler's transparent footer ---------- */

.start-foot {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 20px;
    padding: 20px 16px;
    font-size: 13px;
}

.start-vers { display: flex; gap: 6px; }
.start-vers:empty { display: none; }
.start-ver {
    font-family: var(--gw-mono);
    font-size: 11px;
    line-height: 18px;
    color: var(--gw-muted);
    background: var(--gw-gray-100);
    border-radius: 4px;
    padding: 0 6px;
}

.start-foot a { color: var(--gw-muted); text-decoration: none; }
.start-foot a:hover { color: var(--gw-heading); text-decoration: underline; }
.start-foot a:focus-visible { outline: 2px solid var(--gw-primary); outline-offset: 2px; border-radius: 3px; }

/* ---------- Narrow screens: one column, the page scrolls ---------- */

@media (max-width: 900px) {
    .start { padding: 16px 16px 0; }
    .start-apps,
    .start-apps:not(:has(> article ~ article)) {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        row-gap: 16px;
    }
    .start-app { grid-row: auto; grid-template-rows: none; }
    /* Status and Solr drop below the title, lined up with it. */
    .start-head { flex-wrap: wrap; row-gap: 8px; }
    .start-title { flex-basis: calc(100% - 52px); }
    .start-side { margin-left: 52px; }
    .start-cred { grid-template-columns: minmax(0, 1fr); }
    .start-extras { grid-template-columns: minmax(0, 1fr); }
}
