/* Wieselportal — the wall of services */

:root {
    color-scheme: dark;

    --bg: #0e1117;
    --bg-soft: #151a23;
    --panel: #1b212c;
    --panel-hi: #232b38;
    --line: #2b3444;
    --ink: #e7ecf4;
    --ink-dim: #96a1b4;
    --ink-faint: #64708a;
    --accent: #5b8def;

    --up: #3ddc84;
    --degraded: #f0b429;
    --down: #ef5f5f;
    --unknown: #6b7688;
    --unconfigured: #8b6fd1;

    --radius: 16px;
    --tile-h: 200px;
    --gap: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(1100px 600px at 12% -12%, #1b2740 0%, transparent 60%),
        radial-gradient(900px 500px at 100% 0%, #241c36 0%, transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── chrome ──────────────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(14, 17, 23, .72);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 650;
    letter-spacing: .2px;
    color: var(--ink);
}

.brand:hover {
    text-decoration: none;
}

.brand .mark {
    font-size: 22px;
}

.topbar nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.topbar nav a,
.topbar nav button {
    color: var(--ink-dim);
    padding: 7px 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: none;
    font: inherit;
    cursor: pointer;
}

.topbar nav a:hover,
.topbar nav button:hover {
    color: var(--ink);
    background: var(--panel);
    border-color: var(--line);
    text-decoration: none;
}

.whoami {
    color: var(--ink-faint);
    font-size: 13px;
    padding-right: 4px;
}

main {
    padding: 26px 28px 60px;
    max-width: 1500px;
    margin: 0 auto;
}

h1 {
    font-size: 22px;
    margin: 0 0 4px;
}

.subtitle {
    color: var(--ink-faint);
    margin: 0 0 24px;
    font-size: 14px;
}

.category {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 30px 0 14px;
    color: var(--ink-dim);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.category::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ── the wall ────────────────────────────────────────────────────────────── */

.wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
    grid-auto-rows: var(--tile-h);
    gap: var(--gap);
}

.tile {
    perspective: 1400px;
    position: relative;
}

/* The grow happens at the flip's halfway point, while the card is edge-on and
   the reflow behind it is invisible — see portal.js. */
.tile.expanded {
    grid-column: span 2;
    grid-row: span 2;
}

.tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform .62s cubic-bezier(.4, .16, .2, 1);
    transform-style: preserve-3d;
}

.tile.flipped .tile-inner {
    transform: rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(160deg, var(--panel-hi), var(--panel));
    box-shadow: 0 10px 30px rgba(0, 0, 0, .34);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.face::before {
    /* the service's accent, as a light from the top-left corner */
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(420px 220px at 0% 0%, var(--tile-accent, var(--accent)), transparent 70%);
    opacity: .16;
    pointer-events: none;
}

.back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #202836, #171d27);
}

/* front ------------------------------------------------------------------- */

.tile-open {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 0;
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.tile-open:hover {
    text-decoration: none;
}

.tile-open:hover .tile-name {
    color: #fff;
}

.tile-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 12px;
}

.tile-name {
    font-size: 17px;
    font-weight: 620;
    margin: 0;
    transition: color .15s;
}

.tile-desc {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--ink-dim);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tile-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 16px;
    font-size: 12.5px;
    color: var(--ink-dim);
    position: relative;
}

.tile-foot .ms {
    margin-left: auto;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--unknown);
    flex: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .04);
}

.dot.up {
    background: var(--up);
    box-shadow: 0 0 0 3px rgba(61, 220, 132, .16);
}

.dot.degraded {
    background: var(--degraded);
    box-shadow: 0 0 0 3px rgba(240, 180, 41, .16);
}

.dot.down {
    background: var(--down);
    box-shadow: 0 0 0 3px rgba(239, 95, 95, .16);
}

.dot.unconfigured {
    background: var(--unconfigured);
    box-shadow: 0 0 0 3px rgba(139, 111, 209, .16);
}

.dot.unknown {
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: .35; }
    50% { opacity: 1; }
}

/* the folded corner that turns the card ----------------------------------- */

.corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 52px;
    height: 52px;
    border: 0;
    padding: 0;
    cursor: pointer;
    background: linear-gradient(225deg, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, .05) 48%, transparent 49%);
    color: var(--ink-dim);
    z-index: 3;
    transition: color .15s, background .15s;
}

.corner::after {
    content: "⇄";
    position: absolute;
    top: 7px;
    right: 8px;
    font-size: 13px;
    line-height: 1;
}

.corner:hover {
    color: #fff;
    background: linear-gradient(225deg, rgba(255, 255, 255, .24) 0%, rgba(255, 255, 255, .09) 48%, transparent 49%);
}

.corner:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -4px;
}

.back .corner::after {
    content: "✕";
}

/* back -------------------------------------------------------------------- */

.back-body {
    flex: 1;
    padding: 18px 20px;
    overflow: auto;
    min-height: 0;
}

.back-head {
    display: flex;
    align-items: baseline;
    gap: 9px;
    margin-bottom: 14px;
    padding-right: 34px;
}

.back-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 620;
}

.back-head .key {
    font-size: 11.5px;
    color: var(--ink-faint);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 7px 14px;
    font-size: 13px;
    margin: 0;
}

.facts dt {
    color: var(--ink-faint);
    white-space: nowrap;
}

.facts dd {
    margin: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.facts dd.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.back-links {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 16px;
}

.chip {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .03);
    color: var(--ink-dim);
    font-size: 12.5px;
}

.chip:hover {
    color: var(--ink);
    border-color: var(--accent);
    text-decoration: none;
}

.back-foot {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 7px;
    font-size: 11.5px;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    background: rgba(255, 255, 255, .03);
}

.badge.sso {
    color: #9ad8ff;
    border-color: #2b4c66;
    background: rgba(60, 150, 220, .12);
}

.badge.replay {
    color: #ffd08a;
    border-color: #6b5326;
    background: rgba(240, 180, 41, .1);
}

.badge.lan {
    color: #d3b7ff;
    border-color: #4d3a73;
    background: rgba(139, 111, 209, .12);
}

/* Only the flipped card shows its back, so the hidden one must not trap the keyboard. */
.tile:not(.flipped) .back {
    visibility: hidden;
}

.tile.flipped .front {
    visibility: hidden;
}

/* ── buttons, forms, tables ──────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--panel-hi);
    color: var(--ink);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.btn:hover {
    border-color: var(--accent);
    background: #2a3444;
    text-decoration: none;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #0b0f16;
    font-weight: 600;
}

.btn.primary:hover {
    background: #74a0f5;
    border-color: #74a0f5;
}

.btn.danger:hover {
    border-color: var(--down);
    color: #ffc9c9;
}

.btn.small {
    padding: 5px 10px;
    font-size: 12.5px;
}

.panel {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.panel h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.panel .panel-note {
    margin: 0 0 18px;
    color: var(--ink-faint);
    font-size: 13px;
}

label {
    display: block;
    font-size: 12.5px;
    color: var(--ink-dim);
    margin-bottom: 5px;
}

input[type=text],
input[type=password],
input[type=number],
input[type=url],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #121721;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

textarea {
    min-height: 82px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    resize: vertical;
}

.field {
    margin-bottom: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 18px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 12px;
    color: var(--ink);
    font-size: 14px;
}

.checkline input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.hint {
    color: var(--ink-faint);
    font-size: 12px;
    margin: 5px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    font-size: 11.5px;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding: 0 12px 10px;
    font-weight: 600;
}

td {
    padding: 11px 12px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.notice,
.error {
    border-radius: 11px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid;
}

.notice {
    background: rgba(61, 220, 132, .08);
    border-color: #2c6a47;
    color: #b6f2d0;
}

.error {
    background: rgba(239, 95, 95, .08);
    border-color: #6e3232;
    color: #ffc9c9;
}

.empty {
    text-align: center;
    padding: 70px 20px;
    color: var(--ink-faint);
}

/* ── the small centred pages ─────────────────────────────────────────────── */

.centred {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 34px 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.card h1 {
    font-size: 21px;
    margin: 0 0 6px;
}

.card .lede {
    color: var(--ink-faint);
    font-size: 13.5px;
    margin: 0 0 24px;
}

.card .btn {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

@media (max-width: 620px) {
    main {
        padding: 20px 16px 48px;
    }

    .topbar {
        padding: 14px 16px;
    }

    .wall {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    /* One column's worth of growth is all there is room for. */
    .tile.expanded {
        grid-column: span 2;
        grid-row: span 2;
    }
}
