/* ==========================================================================
   HTG portal — shared styles
   Cast iron, porcelain and brass: a clawfoot tub, more or less.
   ========================================================================== */

:root {
  /* cast iron */
  --bg: #111314;
  --surface: #181b1d;
  --surface-2: #1f2326;
  --surface-3: #282d31;
  --line: #2c3237;
  --line-strong: #414950;

  /* porcelain */
  --text: #f2eee6;
  --text-dim: #bdb7ab;
  --text-mute: #858a8f;

  /* fixtures */
  --brass: #d8a548;
  --brass-hi: #f0c46c;
  --brass-ink: #1d1503;
  --aqua: #74d4d6;
  --aqua-deep: #1c5d65;
  --danger: #e2674f;
  --ok: #7fcf8f;
  --warn: #e8b64c;

  --radius: 12px;
  --radius-sm: 8px;
  --top-h: 56px;

  --font-ui: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-tile: "Barlow Condensed", "Arial Narrow", "Figtree", sans-serif;

  --shadow-pop: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

/* Reserve the scrollbar's space so pages don't shift sideways when their
   height changes (a toast, a new row of tiles, the trimmer appearing). */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font: 15px/1.45 var(--font-ui);
  background-color: var(--bg);
  /* faint grout lines: the whole page is a tiled wall */
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 64px 64px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--brass-hi); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em;
       background: var(--surface-3); padding: .1em .4em; border-radius: 5px; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; border-radius: 6px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.icon--fill { fill: currentColor; stroke: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: rgba(17, 19, 20, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand-name { font: 600 21px/1 var(--font-display); letter-spacing: .01em; }

/* The portrait, cropped to a cameo. */
.cameo {
  width: 36px; height: 36px; flex: none; display: block;
  border-radius: 50%;
  background: #fff url("../img/htg.png") no-repeat 80% 8% / 300%;
  box-shadow: 0 0 0 2px var(--brass), 0 0 0 4px rgba(216, 165, 72, .18);
}
.cameo--xl { width: 168px; height: 168px; background-size: 250%; background-position: 82% 12%;
             box-shadow: 0 0 0 4px var(--brass), 0 0 0 10px rgba(216, 165, 72, .16), 0 24px 60px rgba(0, 0, 0, .5); }

.tabs { display: flex; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--text-dim); text-decoration: none; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: var(--brass-hi); background: rgba(216, 165, 72, .1); }

.status {
  margin-left: auto; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim); font-size: 13.5px;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-mute); }
.status[data-state="live"] .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(127, 207, 143, .18); }
.status[data-state="idle"] .status-dot { background: var(--warn); }
.status[data-state="offline"] .status-dot { background: var(--danger); }
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px; }
.status-text strong { color: var(--text); font-weight: 600; }
.status-now { display: inline-flex; align-items: center; gap: 6px; min-width: 0;
              padding-left: 10px; border-left: 1px solid var(--line); color: var(--aqua); }
.status-now span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.status-stop {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--danger); color: #1c0803;
}
.status-stop:hover { filter: brightness(1.12); }
.status-stop .icon { width: 14px; height: 14px; }

.avatar-btn { flex: none; width: 36px; height: 36px; padding: 0; border-radius: 50%;
              border: 2px solid var(--line-strong); background: var(--surface-3); overflow: hidden; }
.avatar-btn:hover { border-color: var(--brass); }
.avatar-btn img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-initial { font-weight: 700; color: var(--brass-hi); }

/* --------------------------------------------------------------------------
   Buttons, fields
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); border-color: #55606a; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.btn--primary:hover { background: var(--brass-hi); border-color: var(--brass-hi); }
.btn--danger { background: transparent; border-color: rgba(226, 103, 79, .55); color: #f0907c; }
.btn--danger:hover { background: rgba(226, 103, 79, .14); border-color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn--lg { min-height: 48px; padding: 12px 22px; font-size: 16px; border-radius: 12px; }
.btn--sm { min-height: 32px; padding: 5px 10px; font-size: 13.5px; border-radius: 8px; }
.btn--icon { padding: 0; width: 38px; }
.btn--sm.btn--icon { width: 32px; }

.field {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.field::placeholder { color: var(--text-mute); }
.field:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(216, 165, 72, .2); }
select.field { padding-right: 30px; }

.label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.hint { font-size: 13px; color: var(--text-mute); }
.hint--error { color: #f0907c; }
.hint--ok { color: var(--ok); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3);
                border: 1px solid var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
                       border-radius: 50%; background: var(--text-dim); transition: transform .15s, background .15s; }
.switch input:checked + .switch-track { background: rgba(216, 165, 72, .35); border-color: var(--brass); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--brass-hi); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Notices, toasts
   -------------------------------------------------------------------------- */
.notice { display: flex; gap: 10px; align-items: flex-start; text-align: left;
          padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line-strong);
          background: var(--surface); }
.notice .icon { margin-top: 2px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice--error { border-color: rgba(226, 103, 79, .6); background: rgba(226, 103, 79, .1); color: #f6b3a5; }
.notice--warn { border-color: rgba(232, 182, 76, .55); background: rgba(232, 182, 76, .09); color: #f1d69a; }

.toasts { position: fixed; z-index: 90; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
          transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center;
          width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
         padding: 11px 14px; border-radius: 12px;
         background: #2a2f33; border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop);
         animation: toast-in .18s ease-out; max-width: 100%; }
.toast--error { border-color: rgba(226, 103, 79, .7); }
.toast--error .icon { color: var(--danger); }
.toast--ok .icon { color: var(--ok); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------------------
   Popovers (menus) and dialogs
   -------------------------------------------------------------------------- */
.pop { position: fixed; z-index: 70; min-width: 200px; max-width: min(92vw, 320px);
       max-height: min(70dvh, 460px); overflow-y: auto;
       padding: 6px; border-radius: 12px;
       background: #24292d; border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop);
       animation: pop-in .1s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%;
            padding: 8px 10px; border: 0; border-radius: 8px;
            background: transparent; color: var(--text); text-align: left; }
.pop-item:hover, .pop-item:focus-visible { background: var(--surface-3); outline: none; }
.pop-item .icon { color: var(--text-dim); }
.pop-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item--danger, .pop-item--danger .icon { color: #f0907c; }
.pop-item:disabled { opacity: .45; cursor: default; background: transparent; }
.pop-item .pop-trail { color: var(--text-mute); font-size: 12.5px; flex: none; }
.pop-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.pop-head { padding: 7px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
            text-transform: uppercase; color: var(--text-mute); }
.pop-note { padding: 6px 10px; font-size: 12.5px; color: var(--text-mute); }

dialog.dlg { width: min(92vw, 420px); padding: 0; border: 1px solid var(--line-strong); border-radius: 16px;
             background: #20252a; color: var(--text); box-shadow: var(--shadow-pop); }
dialog.dlg::backdrop { background: rgba(6, 7, 8, .66); backdrop-filter: blur(2px); }
.dlg-body { padding: 22px 22px 8px; }
.dlg-title { font: 600 21px/1.2 var(--font-display); margin-bottom: 8px; }
.dlg-text { color: var(--text-dim); margin-bottom: 14px; }
.dlg-hint { margin-top: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }

/* --------------------------------------------------------------------------
   Login / error pages
   -------------------------------------------------------------------------- */
.page-center main { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.gate { width: min(100%, 430px); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.gate-title { font: 600 clamp(34px, 8vw, 44px)/1.05 var(--font-display); margin-top: 14px; }
.gate-sub { color: var(--text-dim); font-size: 16.5px; }
.gate-fine { color: var(--text-mute); font-size: 13px; max-width: 36ch; }
.gate-code { font: 700 84px/1 var(--font-display); color: var(--brass); }
.gate .notice { width: 100%; }
.gate-dev { width: 100%; margin-top: 8px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
            color: var(--text-dim); font-size: 14px; }
.gate-dev-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .top { gap: 8px; padding: 0 10px; }
  .brand-name { display: none; }
  .tab { padding: 8px 9px; }
  .tab span { display: none; }
  .tab.is-active span { display: inline; }
  .status { padding: 5px 6px 5px 9px; font-size: 12.5px; }
  .status-now span { max-width: 11ch; }
}
@media (max-width: 420px) {
  .status-text .status-extra { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; }
}
