/* "내 컴퓨터" (views/computers.js) as game-launcher tiles, and the banner
   dialog's preview. At rest a card is only its banner. Pointing at it,
   tabbing into it or opening its ⋯ menu opens it: a panel under the
   banner (name, status, 접속) lies over the cards below, so the grid
   never moves, and the ⋯ button shows on the banner. The details are in
   the ⋯ menu. Touch screens and narrow windows always show the panel, in
   the flow. No outlines: fills, spacing and one shadow on the open card.
   Tokens come from style.css. */

/* ---- grid ---- */
/* An open panel lies over the next row; the bottom padding keeps the last
   row's inside the page (no scroll bar coming and going). */
.computer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  align-items: start;
  gap: 24px 20px;
  padding-bottom: 72px;
}

/* ---- card ---- */
/* Each card is its own layer (z-index), so an open one rises over its
   neighbours whole: a resting card's hidden ⋯ never sits on top of it. */
/* A closing card keeps its layer until its panel has faded (0.18s), so the
   cards after it do not cut the fading panel off at once. */
.computer-card { position: relative; z-index: 0; margin: 0; color: var(--text); text-align: left; transition: z-index 0s linear 0.18s; }

/* Banner: the computer's own picture, or a plain one with the name (white
   to soft grey on a slant, the name in fading black). */
.computer-banner {
  position: relative;
  z-index: 1; /* over the panel, which starts under it */
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--plain-bg);
  container-type: inline-size;
  transition: border-radius 0.18s ease;
}
.computer-banner > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.banner-name {
  position: absolute;
  right: 6cqw;
  bottom: 5cqw;
  left: 6cqw;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  margin: 0;
  background: linear-gradient(90deg, var(--plain-ink-a) 0%, var(--plain-ink-b) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 12cqw;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.computer-banner.has-picture .banner-name { display: none; }

/* A server's banner with its icon: the icon at the right as tall as the banner, fading out
   toward the left; the name stays on that side (bright with a dark name in the light mode, dark with a white one in the dark). */
.server-banner.has-icon { background: var(--sb-bg); }
.server-banner > .banner-icon {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: auto;
  aspect-ratio: 1;
  /* an eased fade (many small steps), so no edge shows where the picture begins */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.012) 8%, rgba(0, 0, 0, 0.05) 18%, rgba(0, 0, 0, 0.13) 28%, rgba(0, 0, 0, 0.27) 38%, rgba(0, 0, 0, 0.46) 49%, rgba(0, 0, 0, 0.68) 60%, rgba(0, 0, 0, 0.86) 72%, rgba(0, 0, 0, 0.96) 86%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.012) 8%, rgba(0, 0, 0, 0.05) 18%, rgba(0, 0, 0, 0.13) 28%, rgba(0, 0, 0, 0.27) 38%, rgba(0, 0, 0, 0.46) 49%, rgba(0, 0, 0, 0.68) 60%, rgba(0, 0, 0, 0.86) 72%, rgba(0, 0, 0, 0.96) 86%, #000 100%);
}
.server-banner > .banner-icon[hidden] { display: none; }
.server-banner.has-icon .banner-name {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--sb-ink);
  text-shadow: var(--sb-shadow);
  right: auto;
  width: 56cqw;
}
/* Under a picture: dark, so no light sliver shows at its edges and a
   faded (offline) picture dims instead of whitening. */
.computer-banner.has-picture { background: #000; }
/* Off, out of reach or waiting for setup: a little faded. */
.computer-card:not([data-state="online"]) .computer-banner > img:not(.banner-icon),
.computer-card:not([data-state="online"]) .banner-name { filter: grayscale(0.6); opacity: 0.75; }

/* Panel: see-through and not hit by the pointer at rest, but still in the
   tab order (Tab to 접속 opens the card). It starts at the card's top,
   under the banner (its top padding is the banner's 16:9 height: 56.25%
   of the width), so one fill and one shadow wrap the whole open card. */
.computer-panel {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(56.25% + 12px) 14px 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.computer-title { flex: 1; min-width: 0; }
.computer-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.computer-status { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.status-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.computer-card[data-state="online"] .status-dot { background: var(--ok); }
.computer-card[data-state="online"] .status-text { color: var(--ok); }
.computer-card.in-use .status-dot { background: var(--warn); }
.computer-card.in-use .status-text { color: var(--warn); }
.computer-card[data-state="noagent"] .status-dot { background: var(--warn); }
.computer-card[data-state="noagent"] .status-text { color: var(--warn); }
.computer-card[data-state="offline"] .status-dot { background: var(--error); }
.computer-card[data-state="setup"] .status-dot { background: var(--accent); }
.computer-card[data-state="setup"] .status-text { color: var(--accent); }
.computer-actions { flex: none; }
.computer-actions .btn { min-width: 84px; }
.computer-actions .btn .icon { width: 14px; height: 14px; fill: currentColor; }

/* ⋯ on the banner's top right; outside the banner, which would clip its
   list. Glass, no outline. The button itself fades (not its wrapper: an
   ancestor with opacity would cut off its blur, and the open list's). */
.computer-card > .menu-wrap { position: absolute; top: 8px; right: 8px; z-index: 2; }
.computer-card > .menu-wrap > .btn {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glass);
  color: var(--text);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  opacity: 0;
  transition: opacity 0.18s ease, background-color 0.15s, transform 0.1s;
}
.computer-card > .menu-wrap > .btn:hover { background: var(--glass-strong); }
/* The focus ring goes on the dark glass, not on the light banner around it. */
.computer-card > .menu-wrap > .btn:focus-visible { outline-offset: -2px; }
/* The details at the top of the menu (computers.js infoLines): one block. */
.computer-card .menu-head { padding-top: 2px; padding-bottom: 2px; }
.computer-card .menu-head:first-child { padding-top: 8px; }
.computer-card .menu-head:last-child { padding-bottom: 8px; }
.computer-card .menu-head + .menu-sep { margin-top: 10px; }

/* Open: keyboard focus inside, pointed at, or its ⋯ menu open. Focus a
   mouse click left behind (no :focus-visible) does not keep a card open
   once the pointer leaves. Layers: a card only focused (2) stays under the
   one pointed at (3), and that under one whose menu is open (4). The :has()
   rules stand alone, so a browser without :has() drops only them; it gets
   :focus-within instead (at the end). */
.computer-card:has(:focus-visible) { z-index: 2; transition-delay: 0s; }
.computer-card:has(:focus-visible) > .computer-banner { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.computer-card:has(:focus-visible) > .computer-panel { opacity: 1; pointer-events: auto; }
.computer-card:has(:focus-visible) > .menu-wrap > .btn { opacity: 1; }
.computer-card:hover { z-index: 3; transition-delay: 0s; }
.computer-card:hover > .computer-banner { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.computer-card:hover > .computer-panel { opacity: 1; pointer-events: auto; }
.computer-card:hover > .menu-wrap > .btn { opacity: 1; }
.computer-card:has(> .menu-wrap > [aria-expanded="true"]) { z-index: 4; transition-delay: 0s; }
.computer-card:has(> .menu-wrap > [aria-expanded="true"]) > .computer-banner { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.computer-card:has(> .menu-wrap > [aria-expanded="true"]) > .computer-panel { opacity: 1; pointer-events: auto; }
.computer-card:has(> .menu-wrap > [aria-expanded="true"]) > .menu-wrap > .btn { opacity: 1; }

/* Touch screens (nothing to point with) and narrow windows: the panel
   always shows, in the flow under the banner. */
@media (hover: none), (max-width: 600px) {
  .computer-grid { padding-bottom: 0; }
  .computer-card > .computer-banner { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
  .computer-panel {
    position: static;
    padding-top: 12px;
    border-radius: 0 0 var(--radius-card) var(--radius-card);
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
  }
  .computer-card > .menu-wrap > .btn { opacity: 1; }
}

/* ---- 컴퓨터 추가 (administrators): a filled tile the size of a banner ---- */
.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 16px;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.add-card:hover { background-color: var(--surface-2); }
.add-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.add-icon .icon { width: 20px; height: 20px; }
.add-label { color: var(--text); font-size: 15px; font-weight: 700; }
.add-help { color: var(--faint); font-size: 13px; }

/* ---- banner dialog ---- */
.banner-preview { margin: 0 0 14px; }
.banner-file { display: block; margin: 0 0 6px; color: var(--muted); font-size: 14px; }
/* The browser's own "choose file" button, drawn like .btn (no outline). */
.banner-file::file-selector-button {
  margin: 0 10px 0 0;
  padding: 7px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.banner-file::file-selector-button:hover { background: var(--fill-strong); }

/* Browsers without :has(): focus inside opens the card (mouse focus too). */
@supports not selector(:has(*)) {
  .computer-card:focus-within { z-index: 2; transition-delay: 0s; }
  .computer-card:focus-within > .computer-banner { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
  .computer-card:focus-within > .computer-panel { opacity: 1; pointer-events: auto; }
  .computer-card:focus-within > .menu-wrap > .btn { opacity: 1; }
}

/* Forced colors (Windows contrast themes) drop fills, gradients and
   shadows: the tiles, the open panel and the buttons get system-colour
   edges back. */
@media (forced-colors: active) {
  .computer-banner, .computer-panel { border: 1px solid CanvasText; }
  .add-card, .computer-card > .menu-wrap > .btn, .banner-file::file-selector-button { border: 1px solid ButtonText; }
}

@media (prefers-reduced-motion: reduce) {
  .computer-banner, .computer-panel, .computer-card > .menu-wrap > .btn, .add-card, .banner-file::file-selector-button { transition: none; }
  .computer-card { transition: none; }
}
