/* Project Avion distribution server: shared base styles for the portal (/) and the dashboard (/admin/).
   Dark only. Everything is same-origin: the server's CSP forbids inline styles, inline scripts and external URLs. */

@font-face {
  font-family: "Kurale";
  /* Kurale by Eduardo Tunni, SIL Open Font License 1.1 (https://openfontlicense.org). The same face as the game UI. */
  src: url("Kurale-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #060a13;
  --bg-soft: #0a1120;
  --bg-raise: #0f182b;
  --card: rgba(22, 34, 60, 0.55);
  --card-solid: #0f1829;
  --modal: #0c1426;
  --line: rgba(140, 180, 255, 0.13);
  --line-strong: rgba(140, 180, 255, 0.26);
  --text: #eaf1fb;
  --text-2: #bccadf;
  --muted: #8395af;
  --accent: #5cc8ff;
  --accent-strong: #2f9bff;
  --accent-ink: #04121f;
  --ivy: #3fe0a8;
  --warm: #ff9d4d;
  --grad: linear-gradient(115deg, #8ae6ff 0%, #4aa8ff 38%, #9a86ff 68%, #ffa06b 100%);
  --grad-ivy: linear-gradient(135deg, #3fe0a8 0%, #4cc3ff 100%);
  --grad-primary: linear-gradient(120deg, #2f9bff, #5b6cff 55%, #8b5cff);
  --glow: rgba(76, 170, 255, 0.35);
  --shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.85);
  --shadow-sm: 0 12px 30px -16px rgba(0, 0, 0, 0.7);
  --glass: rgba(8, 13, 24, 0.66);
  --code-bg: #0a1222;
  --field-bg: rgba(6, 10, 19, 0.72);

  --ok: #3fe0a8;
  --warn: #ffbf5c;
  --danger: #ff6b81;
  --info: #5cc8ff;
  --neutral: #9aa9c1;
  --violet: #b4a3ff;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Kurale", "Georgia", "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  color-scheme: dark;
}

/* ───────────────────────────── Base ───────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: rgba(131, 149, 175, 0.5) transparent; scrollbar-width: thin; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 0.5em; font-weight: 720; text-wrap: balance; }
p { margin: 0 0 1em; }
code, kbd, pre, .mono { font-family: var(--font-mono); }
::selection { background: rgba(92, 200, 255, 0.4); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 2000; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-weight: 650; transition: top 0.2s; }
.skip-link:focus { top: 12px; text-decoration: none; }
.muted { color: var(--muted); }
.brand-font { font-family: var(--font-brand); font-weight: 400; letter-spacing: -0.01em; }
.gradient-text {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% 100%; animation: gradient-pan 9s var(--ease-in-out) infinite alternate;
}
@keyframes gradient-pan { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Icons drawn by the scripts (stroke icons, 24×24 grid). */
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────────────────────────── Buttons ───────────────────────────── */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid rgba(234, 241, 251, 0.18); background: rgba(234, 241, 251, 0.05); color: var(--text);
  font: 620 0.95rem/1 var(--font-sans); letter-spacing: -0.005em; white-space: nowrap; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: transform 0.25s var(--ease), box-shadow 0.3s var(--ease), background-color 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}
.btn:hover { border-color: rgba(234, 241, 251, 0.34); background: rgba(234, 241, 251, 0.09); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline-offset: 2px; border-radius: 999px; }
.btn .i { width: 18px; height: 18px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  color: #fff; border-color: transparent; background: var(--grad-primary);
  box-shadow: 0 10px 30px -12px rgba(76, 120, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { border-color: transparent; background: var(--grad-primary); box-shadow: 0 14px 38px -12px rgba(76, 120, 255, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn-danger { color: #ffd9df; border-color: rgba(255, 107, 129, 0.45); background: rgba(255, 107, 129, 0.12); }
.btn-danger:hover { border-color: rgba(255, 107, 129, 0.75); background: rgba(255, 107, 129, 0.22); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(234, 241, 251, 0.07); border-color: transparent; color: var(--text); }
.btn-lg { min-height: 56px; padding: 0 30px; font-size: 1.05rem; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 0.86rem; gap: 6px; }
.btn-sm .i { width: 16px; height: 16px; }
.btn-xs { min-height: 28px; padding: 0 10px; font-size: 0.8rem; gap: 5px; }
.btn-xs .i { width: 14px; height: 14px; }
.btn-icon { padding: 0; width: 34px; min-height: 34px; }
.btn-block { width: 100%; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ───────────────────────────── Forms ───────────────────────────── */

.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row > * { min-width: 0; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field > label, .label { font-size: 0.85rem; font-weight: 620; color: var(--text-2); }
.req { color: var(--accent); margin-left: 3px; }
.optional { color: var(--muted); font-weight: 500; margin-left: 4px; }
.input,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select,
.field textarea {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: var(--field-bg); color: var(--text);
  font: inherit; font-size: 0.95rem; line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.field textarea { min-height: 110px; resize: vertical; }
select.input, .field select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238395af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
select option { background: var(--card-solid); color: var(--text); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: rgba(131, 149, 175, 0.75); }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: rgba(140, 180, 255, 0.4); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.2);
}
.input:disabled, .field input:disabled, .field select:disabled, .field textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.input[aria-invalid="true"], .field [aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .field [aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.22); }
.input[readonly], .field [readonly] { background: rgba(10, 18, 34, 0.9); }
.hint { font-size: 0.8rem; color: var(--muted); margin: 0; line-height: 1.45; }
.field-error { font-size: 0.82rem; color: var(--danger); margin: 0; line-height: 1.4; }
.counter { font-size: 0.75rem; color: var(--muted); justify-self: end; margin-top: -2px; font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger); }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 0.92rem; color: var(--text-2); line-height: 1.45; }
.check input { flex-shrink: 0; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent-strong); cursor: pointer; }
.check input:disabled, .check input:disabled + span { cursor: not-allowed; opacity: 0.6; }

/* Toggle switch: <label class="switch"><input type="checkbox"><span>Label</span></label> */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.92rem; color: var(--text-2); }
.switch input {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; position: relative; width: 44px; height: 24px; margin: 0;
  border-radius: 999px; background: rgba(131, 149, 175, 0.3); border: 1px solid var(--line-strong); cursor: pointer;
  transition: background-color 0.25s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); transition: transform 0.25s var(--ease);
}
.switch input:checked { background: var(--accent-strong); border-color: transparent; }
.switch input:checked::after { transform: translateX(20px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Form-level status line (errors / successes shown under a form). */
.form-status { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.45; }
.form-status:empty { display: none; }
.form-status.is-error { color: #ffd9df; background: rgba(255, 107, 129, 0.12); border: 1px solid rgba(255, 107, 129, 0.35); }
.form-status.is-ok { color: #c9f7e6; background: rgba(63, 224, 168, 0.1); border: 1px solid rgba(63, 224, 168, 0.35); }
.form-status.is-info { color: #d3eeff; background: rgba(92, 200, 255, 0.1); border: 1px solid rgba(92, 200, 255, 0.3); }
.form-status.is-warn { color: #ffe6bf; background: rgba(255, 191, 92, 0.1); border: 1px solid rgba(255, 191, 92, 0.35); }

/* ───────────────────────────── Status pills ───────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px;
  font: 650 0.74rem/1.55 var(--font-sans); letter-spacing: 0.02em; white-space: nowrap;
  color: var(--neutral); border: 1px solid rgba(154, 169, 193, 0.32); background: rgba(154, 169, 193, 0.08);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-green { color: var(--ok); border-color: rgba(63, 224, 168, 0.36); background: rgba(63, 224, 168, 0.1); }
.pill-amber { color: var(--warn); border-color: rgba(255, 191, 92, 0.38); background: rgba(255, 191, 92, 0.1); }
.pill-red { color: var(--danger); border-color: rgba(255, 107, 129, 0.4); background: rgba(255, 107, 129, 0.1); }
.pill-blue { color: var(--info); border-color: rgba(92, 200, 255, 0.38); background: rgba(92, 200, 255, 0.1); }
.pill-violet { color: var(--violet); border-color: rgba(180, 163, 255, 0.38); background: rgba(180, 163, 255, 0.1); }
.pill-grey { color: var(--neutral); }

/* ───────────────────────────── Secrets & copy boxes ───────────────────────────── */

.secret { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.secret-value {
  flex: 1 1 auto; min-width: 0; margin: 0; padding: 11px 14px; border-radius: 12px;
  background: var(--code-bg); border: 1px solid var(--line-strong); color: #e4f2ff;
  font: 600 1rem/1.45 var(--font-mono); letter-spacing: 0.04em; overflow-wrap: anywhere; user-select: all;
}
.secret .btn { flex-shrink: 0; align-self: center; }
.copy-area {
  width: 100%; margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--code-bg);
  border: 1px solid var(--line-strong); color: #d8e3f5; font: 0.82rem/1.55 var(--font-mono);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; user-select: text;
}

/* ───────────────────────────── Progress ───────────────────────────── */

.meter { position: relative; height: 8px; border-radius: 999px; background: rgba(140, 180, 255, 0.12); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad-ivy); transition: width 0.4s var(--ease); }
.meter.is-warn > span { background: linear-gradient(90deg, #ffbf5c, #ff9d4d); }
.meter.is-danger > span { background: linear-gradient(90deg, #ff8a5c, #ff6b81); }
.meter.is-indeterminate > span { width: 35% !important; animation: indeterminate 1.3s var(--ease-in-out) infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.spinner { width: 28px; height: 28px; border: 3px solid rgba(140, 180, 255, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ───────────────────────────── Toasts ───────────────────────────── */

.toast-stack {
  position: fixed; z-index: 3000; right: 20px; bottom: 20px; display: grid; gap: 10px;
  width: min(400px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
  border-radius: 14px; background: #111c31; border: 1px solid var(--line-strong); color: var(--text);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9); font-size: 0.92rem; line-height: 1.45;
  animation: toast-in 0.35s var(--ease);
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }
.toast .i { margin-top: 1px; }
.toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast-close { flex-shrink: 0; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast-close:hover { color: var(--text); }
.toast-close .i { width: 16px; height: 16px; margin: 0; }
.toast-success { border-color: rgba(63, 224, 168, 0.4); }
.toast-success > .i { color: var(--ok); }
.toast-error { border-color: rgba(255, 107, 129, 0.45); }
.toast-error > .i { color: var(--danger); }
.toast-info > .i { color: var(--info); }
.toast-warn { border-color: rgba(255, 191, 92, 0.45); }
.toast-warn > .i { color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .toast-stack { right: 16px; left: 16px; bottom: 16px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .spinner, .btn[aria-busy="true"]::after { animation-duration: 0.8s !important; animation-iteration-count: infinite !important; }
}
