/* Gamehole additions on top of the vendored Bulma stylesheet. */

:root {
  /* Dark is the fallback when the system reports no preference; a real system
     preference still wins. A theme cookie pins one scheme instead. */
  color-scheme: dark light;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Bulma 1.0.4 quirk: a plain `is-light` class also satisfies Bulma's
   `.is-light.is-light` colour-combination selectors for tags and
   notifications. Those rules resolve the text colour through
   --bulma-light-light-invert-l, a token Bulma references but never defines, so
   the colour declaration is invalid and the text inherits the page colour
   instead: near-white text on a near-white tag or notification in dark mode.
   Point the missing token at the invert colour the base `is-light` rules use. */
:root {
  --bulma-light-light-invert-l: var(--bulma-light-invert-l);
}

/* Bulma paints placeholders with the text colour at 30% opacity, about 1.8:1
   on white and 2.5:1 on the dark surface. The colour is declared on the
   controls themselves, so override it there; opacity: 1 also covers browsers
   that fade placeholders on their own. */
.input::placeholder,
.select select::placeholder,
.textarea::placeholder {
  color: var(--bulma-text-weak, #6b7280);
  opacity: 1;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
}

main {
  min-height: 50vh;
}

.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  color: var(--bulma-text, #1b1f24);
  background: var(--bulma-scheme-main, #ffffff);
  border: 2px solid var(--bulma-primary, #00d1b2);
  border-radius: 0.5rem;
}

.skip-link:focus {
  inset-block-start: 1rem;
}

:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid var(--bulma-primary, #00d1b2);
  outline-offset: 2px;
}

/* Keep the navigation usable on small screens without JavaScript. */
@media (max-width: 1023px) {
  .site-header .navbar-menu {
    display: block;
  }

  .site-header .navbar-start,
  .site-header .navbar-end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .site-header .navbar-item {
    width: auto;
  }
}

.site-header .navbar {
  border-block-end: 1px solid var(--bulma-border-weak, #e5e5e5);
}

/* Secondary navigation for the selected game server. */
.site-subnav .navbar {
  border-block-end: 1px solid var(--bulma-border-weak, #e5e5e5);
  background: var(--bulma-scheme-main-ter, #f5f5f5);
}

.site-subnav .navbar-item[aria-current="page"] {
  font-weight: 700;
  box-shadow: inset 0 -3px 0 0 currentColor;
}

@media (max-width: 1023px) {
  .site-subnav .navbar-menu {
    display: block;
  }

  .site-subnav .navbar-start,
  .site-subnav .navbar-end {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .site-subnav .navbar-item {
    width: auto;
  }
}

@media (forced-colors: active) {
  .site-subnav .navbar-item[aria-current="page"] {
    border: 1px solid;
    box-shadow: none;
  }
}

.site-header form {
  margin: 0;
}

.site-header .navbar-item form .button {
  margin: 0;
}

/* Theme toggle. Both icons and labels are in the markup and CSS picks the one
   for the current scheme, so the control is right before any script runs.
   display:none keeps the inactive label out of the accessibility tree, which
   leaves the visible label as the button's accessible name. */
.theme-toggle[hidden] {
  display: none;
}

.theme-toggle-icon,
.theme-toggle-label {
  display: none;
}

.theme-toggle [data-theme-icon="moon"],
.theme-toggle [data-theme-label="dark"] {
  display: inline-flex;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle [data-theme-icon="moon"],
  :root:not([data-theme="light"]) .theme-toggle [data-theme-label="dark"] {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle [data-theme-icon="sun"],
  :root:not([data-theme="light"]) .theme-toggle [data-theme-label="light"] {
    display: inline-flex;
  }
}

[data-theme="dark"] .theme-toggle [data-theme-icon="sun"],
[data-theme="dark"] .theme-toggle [data-theme-label="light"] {
  display: inline-flex;
}

[data-theme="dark"] .theme-toggle [data-theme-icon="moon"],
[data-theme="dark"] .theme-toggle [data-theme-label="dark"] {
  display: none;
}

[data-theme="light"] .theme-toggle [data-theme-icon="moon"],
[data-theme="light"] .theme-toggle [data-theme-label="dark"] {
  display: inline-flex;
}

[data-theme="light"] .theme-toggle [data-theme-icon="sun"],
[data-theme="light"] .theme-toggle [data-theme-label="light"] {
  display: none;
}

/* Login page */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 1.5rem;
  background: var(--bulma-scheme-main-ter, #f5f5f5);
}

.login-theme {
  position: fixed;
  inset-block-start: 1rem;
  inset-inline-end: 1rem;
}

.login-card {
  width: min(100%, 26rem);
}

.login-card .title {
  margin-block-end: 0.25rem;
}

/* Server table */
.table-wrapper {
  container-type: inline-size;
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(70vh, 48rem);
}

.table-wrapper thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.table-wrapper thead th {
  background: var(--bulma-scheme-main, #ffffff);
}

.server-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--bulma-scheme-main, #ffffff);
}

.action-buttons {
  flex-wrap: wrap;
}

.action-buttons form {
  margin: 0;
}

/* Management status tracks and grouped actions. */
.build-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.status-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  margin-block-end: 0.75rem;
}

.status-group {
  flex: 1 1 14rem;
  min-inline-size: 0;
}

.status-heading {
  margin-block-end: 0.35rem;
  color: var(--bulma-text-weak, #4a4a4a);
  font-size: var(--bulma-size-small, 0.75rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-track {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-step {
  flex: 1 1 auto;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--bulma-border, #dbdbdb);
  border-radius: var(--bulma-radius, 0.375rem);
  background: transparent;
  color: var(--bulma-text-weak, #4a4a4a);
  font-size: var(--bulma-size-small, 0.75rem);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.status-step[data-state="not_created"][aria-current="true"],
.status-step[data-auto-start="disabled"][aria-current="true"] {
  border-color: var(--bulma-grey-dark, #404654);
  background: var(--bulma-grey, #69748c);
  color: #ffffff;
}

.status-step[data-state="not_present"][aria-current="true"],
.status-step[data-state="building"][aria-current="true"] {
  border-color: var(--bulma-info, #3e8ed0);
  background: var(--bulma-info, #3e8ed0);
  color: var(--bulma-info-invert, #ffffff);
}

.status-step[data-state="stopped"][aria-current="true"] {
  border-color: var(--bulma-warning, #ffe08a);
  background: var(--bulma-warning, #ffe08a);
  color: var(--bulma-warning-invert, #3d3d00);
}

.status-step[data-state="running"][aria-current="true"],
.status-step[data-auto-start="enabled"][aria-current="true"] {
  border-color: var(--bulma-success, #48c78e);
  background: var(--bulma-success, #48c78e);
  color: var(--bulma-success-invert, #ffffff);
}

@media (forced-colors: active) {
  .status-step[aria-current="true"] {
    border-color: Highlight;
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

.action-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1.5rem;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.action-group--primary {
  flex: 1 0 100%;
}

.action-group form {
  margin: 0;
}

.settings-summary {
  font-size: var(--bulma-size-small, 0.75rem);
  /* text-weak drops to ~4.4:1 on the striped row background in dark mode. */
  color: var(--bulma-text, #4a4a4a);
}

/* Home page server selector */
.server-list {
  list-style: none;
  margin-inline-start: 0;
  margin-block-start: 0;
}

.server-group-heading {
  margin-block-end: 1rem;
}

.server-group + .server-group {
  margin-block-start: 2.5rem;
}

.server-card {
  display: block;
  block-size: 100%;
}

.server-card-image {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 920 / 430;
  object-fit: cover;
  margin-block-end: 0.75rem;
  border-radius: var(--bulma-radius, 0.375rem);
  background: var(--bulma-scheme-main-ter, #f5f5f5);
}

/* Name on the left, status dot pinned to the right edge across from it. */
.server-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.server-card .title {
  margin-block: 0;
}

/* Keep a long server name from pushing the dot out of the card. */
.server-card-heading .title {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* The group heading already names the state and the dot carries a visually
   hidden label inside the link, so colour is never the only signal. */
.server-status {
  display: inline-flex;
  flex: none;
  align-items: center;
}

.server-status-dot {
  display: block;
  inline-size: 0.75rem;
  block-size: 0.75rem;
  border-radius: 50%;
  background: var(--bulma-danger, #f14668);
}

.server-card[data-status="online"] .server-status-dot {
  background: var(--bulma-success, #48c78e);
}

@keyframes server-status-pulse {
  50% {
    opacity: 0.35;
  }
}

/* A slow opacity pulse stays on the compositor, and it is opt-in so
   reduced-motion users keep a solid (static) green dot. */
@media (prefers-reduced-motion: no-preference) {
  .server-card[data-status="online"] .server-status-dot {
    animation: server-status-pulse 2.8s ease-in-out infinite;
  }
}

/* Forced-colors mode drops the hue, so distinguish online (filled) from
   offline (hollow) with shapes built from system colours. */
@media (forced-colors: active) {
  .server-status-dot {
    forced-color-adjust: none;
    background: CanvasText;
  }

  .server-card[data-status="offline"] .server-status-dot {
    background: Canvas;
    border: 2px solid CanvasText;
  }
}

/* Placeholder main page for one server. */
.server-hero {
  max-inline-size: 920px;
}

.server-hero-image {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 920 / 430;
  object-fit: cover;
  margin-block-end: 1.25rem;
  border-radius: var(--bulma-radius-large, 0.5rem);
  background: var(--bulma-scheme-main-ter, #f5f5f5);
}

/* Turn the table into cards when the container is narrow. Labels come from
   data-label attributes so the table keeps its semantic header cells. */
@container (width < 760px) {
  .server-table,
  .server-table thead,
  .server-table tbody,
  .server-table tr,
  .server-table th,
  .server-table td {
    display: block;
  }

  .server-table thead {
    display: none;
  }

  .server-table tr {
    margin-block-end: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--bulma-border, #dbdbdb);
    border-radius: 0.5rem;
  }

  .server-table tbody th {
    position: static;
    padding: 0 0 0.5rem;
    background: transparent;
    font-size: 1.1rem;
  }

  .server-table td {
    padding: 0.25rem 0;
    border: 0;
  }

  .server-table td::before {
    content: attr(data-label) ": ";
    font-weight: 600;
  }

  .server-table td[data-label="Actions"] {
    padding-block-start: 0.5rem;
  }
}

/* Game Config file list */
.config-file-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.config-file {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.config-file-details {
  min-inline-size: 0;
}

.config-file .title {
  margin-block-end: 0.25rem;
}

.config-file-path {
  margin-block-end: 0.5rem;
  color: var(--bulma-text-weak, #4a4a4a);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.config-file-meta {
  margin-block-end: 0;
}

.config-file-action {
  flex: 0 0 auto;
}

.config-help {
  margin-block-start: 1.5rem;
}

kbd {
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--bulma-border, #b5b5b5);
  border-radius: 0.25rem;
  background: var(--bulma-scheme-main-ter, #f5f5f5);
  box-shadow: inset 0 -1px 0 var(--bulma-border, #b5b5b5);
  font-family: inherit;
  font-size: 0.875em;
}

/* Game Config editor.
   The real control is the textarea; the <pre> behind it only paints tokens.
   Both layers share every metric that affects text layout.
   Colours are declared once and resolved by light-dark(), which follows the
   page's used color scheme, so the editor needs no per-theme rules. The plain
   values are the fallback for browsers without light-dark(): they keep today's
   light editor instead of pairing dark browser UI with a white surface. */
.code-editor {
  --editor-border: #b5b5b5;
  --editor-surface: #ffffff;
  --editor-text: #1b1f24;
  --editor-selection: #b3d4ff;
  --tok-comment: #5f6b7a;
  --tok-key: #0b5cad;
  --tok-string: #0a6b47;
  --tok-number: #9a4a00;
  --tok-boolean: #6b2fb3;
  color-scheme: light;
  display: grid;
  block-size: min(65vh, 44rem);
  min-block-size: 18rem;
  max-block-size: 90vh;
  overflow: hidden;
  resize: vertical;
  border: 1px solid var(--editor-border);
  border-radius: 0.5rem;
  background: var(--editor-surface);
}

@supports (color: light-dark(white, black)) {
  .code-editor {
    color-scheme: inherit;
    --editor-border: light-dark(#b5b5b5, #3b414d);
    --editor-surface: light-dark(#ffffff, #181b20);
    --editor-text: light-dark(#1b1f24, #e6edf3);
    --editor-selection: light-dark(#b3d4ff, #264f78);
    --tok-comment: light-dark(#5f6b7a, #8b95a7);
    --tok-key: light-dark(#0b5cad, #79b8ff);
    --tok-string: light-dark(#0a6b47, #7ee787);
    --tok-number: light-dark(#9a4a00, #ffa657);
    --tok-boolean: light-dark(#6b2fb3, #d2a8ff);
  }
}

.code-editor-highlight,
.code-editor-input {
  grid-area: 1 / 1;
  box-sizing: border-box;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  margin: 0;
  padding: 1rem;
  border: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: normal;
  font-variant-ligatures: none;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}

.code-editor-input {
  position: relative;
  z-index: 1;
  resize: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--editor-text);
  background: transparent;
  background-image: none;
  caret-color: var(--editor-text);
  overflow: auto;
}

.code-editor-highlight {
  z-index: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  color: var(--editor-text);
  background: transparent;
}

/* Bulma gives bare <pre> and <pre><code> their own font-size, padding, and
   colors. The highlight layer must use exactly the textarea's metrics. */
.code-editor-highlight code {
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-style: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  font-variant-ligatures: inherit;
  tab-size: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
  word-break: inherit;
}

.code-editor:focus-within {
  border-color: var(--bulma-primary, #00d1b2);
  box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.35);
}

.code-editor.is-highlighting .code-editor-highlight {
  visibility: visible;
}

.code-editor.is-highlighting .code-editor-input {
  color: transparent;
}

.code-editor.is-highlighting .code-editor-input::selection {
  color: var(--editor-text);
  background: var(--editor-selection);
}

/* Token colours, chosen for at least 4.5:1 contrast on the editor surface in
   both schemes (light on white, dark on #181b20). */
.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

.tok-key {
  color: var(--tok-key);
}

.tok-string {
  color: var(--tok-string);
}

.tok-number {
  color: var(--tok-number);
}

.tok-boolean {
  color: var(--tok-boolean);
}

.tok-section {
  color: var(--tok-key);
  font-weight: 600;
}

.tok-date {
  color: var(--tok-number);
}

.tok-meta {
  color: var(--tok-boolean);
}

.tok-anchor {
  color: var(--tok-boolean);
}

.tok-tag {
  color: var(--tok-key);
}

.tok-attr {
  color: var(--tok-number);
}

.tok-punctuation {
  color: var(--tok-comment);
}

/* Highlighting is decorative; forced-colors mode needs readable real text. */
@media (forced-colors: active) {
  .code-editor:focus-within {
    outline: 2px solid CanvasText;
    outline-offset: 2px;
  }

  .code-editor-highlight {
    visibility: hidden;
  }

  .code-editor.is-highlighting .code-editor-input {
    color: CanvasText;
  }
}

@media (max-width: 768px) {
  .config-file {
    align-items: flex-start;
  }

  .code-editor {
    block-size: 60vh;
  }
}

/* Log viewer. The server streams text into this element; wrapping long lines
   keeps them reachable on narrow screens without hiding them off-screen. */
.log-view {
  block-size: min(70vh, 48rem);
  min-block-size: 18rem;
  max-block-size: 90vh;
  margin: 0 0 0.75rem;
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--bulma-border, #dbdbdb);
  border-radius: 0.5rem;
  background: var(--bulma-scheme-main-ter, #f5f5f5);
  color: var(--bulma-text, #1b1f24);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.log-view:focus-visible {
  outline: 3px solid var(--bulma-primary, #00d1b2);
  outline-offset: 2px;
}

.log-view-help {
  margin-block-start: 0.75rem;
}

[data-log-status][data-state="live"] {
  color: #257953;
  font-weight: 600;
}

[data-log-status][data-state="error"] {
  color: #cc0f35;
  font-weight: 600;
}

@media (forced-colors: active) {
  .log-view {
    border: 1px solid CanvasText;
  }
}

@media (max-width: 768px) {
  .log-view {
    block-size: 60vh;
  }
}

/* Minecraft modpack cards and detail hero. */
.modpack-grid {
  list-style: none;
  margin-inline-start: 0;
  margin-block-start: 0;
}

.modpack-card {
  display: block;
  block-size: 100%;
}

.modpack-card .title {
  display: block;
  margin-block: 0.75rem 0.25rem;
}

.modpack-card-image,
.modpack-hero-image {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 920 / 430;
  object-fit: cover;
  border-radius: var(--bulma-radius, 0.375rem);
  background: var(--bulma-scheme-main-ter, #f5f5f5);
}

.modpack-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--bulma-text-weak, #4a4a4a);
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  background:
    linear-gradient(
      135deg,
      var(--bulma-scheme-main-ter, #f5f5f5),
      var(--bulma-border-weak, #e5e5e5)
    );
}

.modpack-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.modpack-hero-body {
  min-inline-size: 0;
}

@media (max-width: 900px) {
  .modpack-hero {
    grid-template-columns: minmax(0, 1fr);
  }
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.prompt-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
}

/* The memory help text doubles as the live error message. */
.help.is-danger {
  color: var(--bulma-danger, #f14668);
  font-weight: 600;
}

@media (forced-colors: active) {
  .modpack-placeholder {
    border: 1px solid CanvasText;
  }
}
