/* 4orma design system: the terminal/tmux look shared by auth.4orma.uk, home.4orma.uk and the owner's own apps.
   Tokens come from the previous Homepage skin (custom.css) so the look is unchanged; everything else is new.
   Accent themes: <html data-theme="pink|green|amber|ice">. Motion: <html data-motion="off"> or prefers-reduced-motion. */

@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/JetBrainsMono-Regular.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 600 800; font-display: swap; src: url('fonts/JetBrainsMono-Bold.woff2') format('woff2'); }

:root {
  --bg: #0b0e13; --card: #0b0e13; --card-hi: #11131a; --card-hi2: #171a22;
  --fg: #e9dfe6; --bright: #fff4fa; --mut: #aaa0ae; --dim: #6f6774;
  --line: #322a37; --edge: #6e5873;
  --acc: #ffc1e1; --acc-2: #ffd9ef; --acc-rgb: 255 193 225;
  --ok: #8fe3bd; --warn: #f2b45b; --bad: #f28b8b;
  --term-font: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
  --t-fast: .12s; --t-med: .25s; --t-slow: .5s;
  color-scheme: dark;
}
:root[data-theme="green"] { --acc: #a8f0c6; --acc-2: #cdf7df; --acc-rgb: 168 240 198; --edge: #4f7a62; --line: #28372e; --card-hi: #0f1512; --card-hi2: #141c17; }
:root[data-theme="amber"] { --acc: #ffd08a; --acc-2: #ffe3b3; --acc-rgb: 255 208 138; --edge: #7a6240; --line: #372f24; --card-hi: #14120e; --card-hi2: #1b1812; }
:root[data-theme="ice"]   { --acc: #a9dcff; --acc-2: #cfeaff; --acc-rgb: 169 220 255; --edge: #4f6a7a; --line: #27313a; --card-hi: #0e1317; --card-hi2: #131a20; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); }
body { font: 14px/1.5 var(--term-font); -webkit-font-smoothing: antialiased; padding: 0 16px; }
::selection { background: rgb(var(--acc-rgb) / .25); color: var(--bright); }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-size: inherit; margin: 0; font-weight: 700; color: var(--bright); }
small, .mut { color: var(--mut); }
.dim { color: var(--dim); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
code, kbd { font-family: inherit; background: var(--card-hi); padding: 0 .4em; border: 1px solid var(--line); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 1px solid var(--acc-2); outline-offset: 3px; }

/* layout: fixed top + bottom bars, content in the middle */
.term-topbar, .term-statusbar {
  position: fixed; left: 0; right: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 3px 14px; background: var(--card-hi); color: var(--mut); font-size: 12px; line-height: 24px; white-space: nowrap; min-height: 32px;
}
.term-topbar { top: 0; border-bottom: 1px solid var(--line); }
.term-statusbar { bottom: 0; border-top: 1px solid var(--line); padding-bottom: max(3px, env(safe-area-inset-bottom)); }
.term-top-left, .term-status-left { display: flex; align-items: center; gap: 20px; min-width: 0; }
.term-brand { color: var(--bright); font-weight: 700; }
.term-brand::before { content: '▌'; color: var(--acc); margin-right: 4px; }
.term-nav { display: flex; gap: 12px; }
.term-nav a, .term-nav button { color: var(--mut); padding: 0 6px; border: 0; background: transparent; cursor: pointer; }
.term-nav a:hover, .term-nav button:hover, .term-nav a:focus-visible, .term-nav button:focus-visible { color: var(--acc); }
.term-nav [aria-selected='true'], .term-nav .active { color: var(--bg); background: var(--acc); font-weight: 700; }
.term-mode { background: var(--acc); color: var(--bg); padding: 0 8px; font-weight: 700; }
.term-keyhint { color: var(--mut); }
.term-count { color: var(--acc-2); }
.term-main { max-width: 1180px; margin: 0 auto; padding: 60px 8px 56px; min-height: 100dvh; }
.term-main.narrow { max-width: 520px; }

/* panels: a bordered window with its title sitting in the top border */
.panel { position: relative; border: 1px solid var(--edge); padding: 16px 14px 12px; margin: 0 0 20px; background: var(--bg); }
.panel > .panel-title { position: absolute; top: -11px; left: 14px; background: var(--bg); padding: 0 7px; color: var(--bright); font-weight: 700; font-size: 13px; text-transform: lowercase; }
.panel > .panel-title .n { color: var(--mut); font-weight: 400; }
.panel.quiet { border-color: var(--line); }

/* forms */
.field { display: grid; gap: 4px; margin: 0 0 14px; }
.field label { color: var(--mut); font-size: 12px; text-transform: lowercase; }
.field label .req { color: var(--acc); }
.input, input[type=text], input[type=password], input[type=email], input[type=search], select, textarea {
  width: 100%; background: var(--card-hi); border: 1px solid var(--line); padding: 7px 10px; color: var(--bright); border-radius: 0; outline: none;
  transition: border-color var(--t-fast);
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--acc); outline: none; }
input::placeholder { color: var(--dim); }
.prompt { display: flex; align-items: center; gap: 8px; }
.prompt::before { content: '$'; color: var(--acc); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--acc); color: var(--bg); border: 1px solid var(--acc); padding: 6px 14px; font-weight: 700; cursor: pointer; border-radius: 0; text-transform: lowercase; transition: background var(--t-fast), color var(--t-fast); }
.btn:hover { background: var(--acc-2); border-color: var(--acc-2); }
.btn.ghost { background: transparent; color: var(--acc); }
.btn.ghost:hover { background: rgb(var(--acc-rgb) / .12); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: rgb(242 139 139 / .12); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.notice { border: 1px solid var(--line); border-left: 3px solid var(--acc); padding: 8px 12px; margin: 0 0 14px; color: var(--fg); background: var(--card-hi); }
.notice.bad { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--ok); }
.notice.warn { border-left-color: var(--warn); }
.log-line { color: var(--mut); }
.log-line .ok::before { content: '[ ok ] '; color: var(--ok); }
.log-line .fail::before { content: '[fail] '; color: var(--bad); }
.log-line .info::before { content: '[info] '; color: var(--mut); }

/* tables and lists */
table.t { width: 100%; border-collapse: collapse; font-size: 12px; }
table.t th { text-align: left; color: var(--mut); font-weight: 400; border-bottom: 1px solid var(--line); padding: 4px 8px; text-transform: lowercase; }
table.t td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.t tr:hover td { background: var(--card-hi); }
.tag { display: inline-block; border: 1px solid var(--line); color: var(--mut); padding: 0 6px; font-size: 11px; margin-right: 4px; }
.tag.acc { color: var(--acc); border-color: var(--edge); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; font-size: 14px; color: var(--bright); padding: 10px 14px; border: 1px dashed var(--edge); user-select: all; }
.qr { background: #fff; padding: 10px; width: 180px; display: block; margin: 8px 0; }
.qr svg { display: block; width: 100%; height: auto; }

/* tiles (home) */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 14px; }
.tile { position: relative; border: 1px solid transparent; padding: 3px 4px; transition: background var(--t-fast), border-color var(--t-fast); }
.tile:hover, .tile:focus-within, .tile.selected { background: var(--card-hi); border-color: var(--line); }
.tile a.name { display: block; color: var(--acc); font-weight: 600; padding: 4px 22px 4px 8px; line-height: 1.6; text-transform: lowercase; }
.tile a.name::before { content: '> '; color: var(--edge); }
.tile.selected a.name::before { content: '> '; color: var(--acc); }
.tile .desc { color: var(--mut); font-size: 12px; line-height: 1.7; margin: 3px 0 0 2ch; overflow-wrap: anywhere; }
.tile .dot { position: absolute; top: 12px; right: 9px; width: 5px; height: 5px; background: var(--dim); }
.tile .dot.up { background: var(--ok); } .tile .dot.down { background: var(--bad); } .tile .dot.warn { background: var(--warn); }
.tile .cursor { display: none; }
.tile.selected a.name::after { content: '▌'; color: var(--acc); margin-left: 4px; animation: blink 1s steps(1) infinite; }

/* status bars (system row) */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; }
.stat { min-width: 0; font-size: 12px; color: var(--mut); }
.stat .row { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.stat .v { color: var(--bright); }
.stat .bar { height: 3px; background: var(--line); margin-top: 4px; overflow: hidden; }
.stat .bar > i { display: block; height: 100%; width: 0; background: var(--acc); transition: width var(--t-slow) ease-out; }
.stat .bar.hot > i { background: var(--warn); }

/* popover card (e.g. game servers) */
.pop { position: absolute; left: 0; right: 0; top: calc(100% - 1px); z-index: 30; background: var(--card-hi); border: 1px solid var(--edge); padding: 12px; font-size: 11px; color: var(--fg);
  opacity: 0; visibility: hidden; transform: translateY(-3px); pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast); box-shadow: 0 10px 22px #0005; }
.tile:is(:hover, :focus-within, .selected) .pop { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.tile:is(:hover, :focus-within, .selected) { z-index: 31; }
.pop .row + .row { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.pop .name { color: var(--acc-2); font-weight: 600; }
.pop .d { color: var(--mut); margin-top: 5px; line-height: 1.6; }

/* splash line: dim, quoted, centred, under a rule */
.splash { text-align: center; color: var(--dim); font-size: 12px; margin: 28px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); cursor: pointer; user-select: none; }
.splash::before { content: '"'; } .splash::after { content: '"'; }
.splash:hover { color: var(--mut); }

/* command palette */
.palette { position: fixed; inset: 0; z-index: 60; display: none; background: #0008; }
.palette.open { display: block; }
.palette .box { max-width: 520px; margin: 14vh auto 0; background: var(--bg); border: 1px solid var(--edge); box-shadow: 0 20px 60px #000a; }
.palette input { border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 14px; }
.palette ul { list-style: none; margin: 0; padding: 6px 0; max-height: 50vh; overflow: auto; }
.palette li { padding: 5px 14px; color: var(--mut); display: flex; justify-content: space-between; gap: 12px; cursor: pointer; }
.palette li .k { color: var(--acc); }
.palette li.sel { background: var(--card-hi); color: var(--bright); }
.palette li .hint { color: var(--dim); font-size: 11px; }

/* boot overlay */
.boot { position: fixed; inset: 0; z-index: 70; background: var(--bg); padding: 60px 24px; color: var(--mut); font-size: 12px; }
.boot .l { opacity: 0; animation: fadein .08s forwards; }
.boot .hint { position: absolute; bottom: 16px; right: 16px; color: var(--dim); }
.wipe { position: fixed; inset: 0; z-index: 80; background: var(--bg); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.wipe.go { animation: wipe var(--t-med) ease-in forwards; }

/* motion */
@keyframes blink { 50% { opacity: 0; } }
@keyframes fadein { to { opacity: 1; } }
@keyframes wipe { to { transform: scaleX(1); } }
@keyframes draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.anim .panel { animation: draw var(--t-slow) ease-out both; }
.anim .panel > .panel-title { animation: rise var(--t-med) .3s ease-out both; }
.anim .tile { animation: rise var(--t-med) ease-out both; }
.anim .tile:nth-child(2) { animation-delay: .04s; } .anim .tile:nth-child(3) { animation-delay: .08s; }
.anim .tile:nth-child(4) { animation-delay: .12s; } .anim .tile:nth-child(5) { animation-delay: .16s; } .anim .tile:nth-child(n+6) { animation-delay: .2s; }
.typing::after { content: '▌'; color: var(--acc); animation: blink .8s steps(1) infinite; }
.pulse { animation: pulse .6s ease-out; }
@keyframes pulse { 0% { color: var(--acc); } 100% { color: inherit; } }
.shake { animation: shake .3s; }
@keyframes shake { 20% { transform: translateX(-4px); } 60% { transform: translateX(4px); } 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0s; --t-med: 0s; --t-slow: 0s; } .anim .panel, .anim .panel > .panel-title, .anim .tile, .boot .l, .typing::after, .tile.selected a.name::after, .wipe.go, .pulse, .shake { animation: none !important; } }
:root[data-motion="off"] { --t-fast: 0s; --t-med: 0s; --t-slow: 0s; }
:root[data-motion="off"] .anim .panel, :root[data-motion="off"] .anim .panel > .panel-title, :root[data-motion="off"] .anim .tile, :root[data-motion="off"] .boot .l, :root[data-motion="off"] .typing::after, :root[data-motion="off"] .tile.selected a.name::after, :root[data-motion="off"] .wipe.go, :root[data-motion="off"] .pulse, :root[data-motion="off"] .shake { animation: none !important; }

/* responsive */
@media (max-width: 899px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 559px) {
  body { font-size: 12px; }
  .term-main { padding-top: 70px; }
  .term-topbar { align-items: flex-start; flex-wrap: wrap; min-height: 44px; }
  .term-keyhint { display: none; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
  .codes { grid-template-columns: 1fr; }
}
