/*
 * entry.css — entry page component styles (login, workspace selection).
 *
 * Cascade order: tokens.css -> base.css -> components.css -> entry.css
 */

/* ── Design tokens (entry-page scope) ────────────────────────────── */
:root {
  --surface: #131313;
  --surface-lowest: #0e0e0e;
  --surface-low: #1c1b1b;
  --surface-container: #201f1f;
  --surface-high: #2a2a2a;
  --on-surface: #e5e2e1;
  --on-surface-variant: #d4c4b7;
  --primary: #eebd8e;
  --primary-container: #b4885d;
  --primary-light: #f0c496;
  --primary-mid: #e4ad77;
  --primary-dark: #bd8150;
  --on-primary: #472a06;
  --on-primary-dark: #342006;
  --secondary: #e9c176;
  --outline: #9c8e83;
  --outline-variant: #50453b;
  --color-success: #4caf50;
}

* {
  box-sizing: border-box;
}

/* ── Page wrapper ────────────────────────────────────────────────── */
.login-page {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background: var(--surface-lowest);
}

/* Layer 1 — background art: two-column composition
 * ponytail: no precomposed widescreen asset available; using gradient+square fallback.
 * Upgrade to .webp widescreen image when exported (swap url() only).
 */
.login-background {
  position: absolute;
  z-index: -3;
  inset: 0;
  background: url("/static/img/trapitan_bg.png") center center / cover no-repeat;
  filter: saturate(0.88) contrast(1.03) brightness(0.88);
}

/* Layer 2 — localized overlay gradients (not uniform black) */
.login-overlay {
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    radial-gradient(
      ellipse at 50% 48%,
      rgb(8 8 8 / 38%) 0%,
      rgb(8 8 8 / 22%) 45%,
      transparent 70%
    ),
    linear-gradient(
      180deg,
      rgb(0 0 0 / 8%),
      rgb(0 0 0 / 28%)
    );
  pointer-events: none;
}

/* Layer 3 — subtle command-center grid */
.login-grid {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(rgb(238 189 142 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(238 189 142 / 4%) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
}

/* ── Login panel ─────────────────────────────────────────────────── */
.login-panel {
  position: relative;
  width: min(calc(100vw - 48px), 435px);
  padding: 28px 30px 24px;
  border: 1px solid rgb(238 189 142 / 26%);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgb(25 24 23 / 95%),
      rgb(13 13 13 / 97%)
    );
  box-shadow:
    0 0 0 1px rgb(255 255 255 / 2%) inset,
    0 18px 60px rgb(0 0 0 / 38%);
  backdrop-filter: blur(10px);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgb(238 189 142 / 7%), transparent 42%);
}

/* ── Header ──────────────────────────────────────────────────────── */
.login-header {
  position: relative;
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 14px;
  /* ponytail: padding-right = logo-width + gap shifts the flex center so the
     title midpoint lands at 50% of the card regardless of title width */
  padding-right: calc(84px + 12px);
}

.login-logo {
  display: block;
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  margin: 0;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgb(238 189 142 / 16%));
}

.login-title {
  margin: 0;
  color: var(--primary);
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.access-label {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 18px 0 22px;
  color: rgb(212 196 183 / 72%);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  white-space: nowrap;
}

.access-label span {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(238 189 142 / 32%));
}

.access-label span:last-child {
  background: linear-gradient(90deg, rgb(238 189 142 / 32%), transparent);
}

/* ── Auth buttons ────────────────────────────────────────────────── */
.login-actions {
  display: grid;
  gap: 10px;
}

.auth-button {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.auth-button::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 15%, rgb(255 255 255 / 9%) 45%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 420ms ease;
}

.auth-button:hover::before { transform: translateX(120%); }

.auth-button__icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  justify-self: start;
}

.auth-button__label {
  position: relative;
  z-index: 1;
  justify-self: center;
  white-space: nowrap;
}

.auth-button__arrow {
  position: relative;
  z-index: 1;
  justify-self: end;
  font-size: 20px;
  font-weight: 400;
  transition: transform 160ms ease;
}

.auth-button:hover { transform: translateY(-1px); }
.auth-button:hover .auth-button__arrow { transform: translateX(3px); }
.auth-button:active { transform: translateY(0); }
.auth-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.auth-button--primary {
  color: var(--on-primary-dark);
  border: 1px solid rgb(255 220 189 / 54%);
  background:
    linear-gradient(
      180deg,
      var(--primary-light) 0%,
      var(--primary-mid) 52%,
      var(--primary-dark) 100%
    );
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 24%),
    inset 0 -1px 0 rgb(71 42 6 / 28%),
    0 8px 20px rgb(180 136 93 / 10%);
}

/* ── System status footer ────────────────────────────────────────── */
.system-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 16px 16px 0;
  border-top: 1px solid rgb(80 69 59 / 40%);
  color: var(--outline);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.system-status__state {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

/* ── Command Center workspace selector ───────────────────────────── */
.rp-command-center {
  align-items: start;
  place-items: stretch center;
  overflow-y: auto;
  padding: 32px 24px 84px;
}

.rp-command-center__panel {
  width: min(100%, 1280px);
  display: grid;
  gap: 24px;
  align-content: start;
}

.rp-command-center__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding-top: 8px;
}

.rp-command-center__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  color: var(--primary);
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.rp-command-center__icon {
  width: 84px;
  height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgb(238 189 142 / 16%));
}

.rp-command-center__eyebrow {
  margin: 0 0 4px;
  color: var(--on-surface-variant);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 16px;
  letter-spacing: 0;
}

.rp-command-center h1 {
  margin: 0;
  color: var(--on-surface);
  font-size: 32px;
  line-height: 40px;
  font-weight: 600;
  letter-spacing: 0;
}

.rp-workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 190px);
  justify-content: center;
  gap: 24px;
}

.rp-workspace-card {
  width: 190px;
  height: 190px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  color: var(--on-surface);
  background:
    linear-gradient(
      180deg,
      rgb(32 31 31 / 96%),
      rgb(28 27 27 / 98%)
    );
  text-decoration: none;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 4%),
    0 16px 42px rgb(0 0 0 / 26%);
}

.rp-workspace-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.rp-workspace-card--active {
  border-color: rgb(238 189 142 / 42%);
}

.rp-workspace-card--active:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  transition:
    border-color 160ms ease,
    transform 160ms ease;
}

.rp-workspace-card--create {
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: rgb(180 136 93 / 50%);
}

.rp-workspace-card__plus {
  font-size: 64px;
  line-height: 1;
  color: var(--primary);
}

.rp-workspace-card--disabled {
  opacity: 0.68;
  border-color: color-mix(in srgb, var(--outline) 42%, transparent);
  background: color-mix(in srgb, var(--surface-low) 82%, var(--outline));
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.rp-workspace-card__name {
  min-width: 0;
  color: var(--on-surface);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.rp-workspace-card__server {
  min-width: 0;
  color: var(--on-surface-variant);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 16px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.rp-workspace-card__status {
  align-self: start;
  width: fit-content;
  color: var(--outline);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 16px;
  letter-spacing: 0;
}

.rp-workspace-card--active .rp-workspace-card__status,
.rp-workspace-card--create .rp-workspace-card__status {
  color: var(--primary);
}

.rp-workspace-card__action,
.rp-workspace-card__create-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgb(238 189 142 / 38%);
  border-radius: 8px;
  color: var(--on-primary-dark);
  background: var(--primary);
  font-size: 13px;
  line-height: 16px;
  font-weight: 600;
}

.rp-workspace-empty {
  max-width: 680px;
  color: var(--on-surface-variant);
}

.rp-workspace-empty h2,
.rp-inactive-workspaces h2 {
  margin: 0 0 8px;
  color: var(--on-surface);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: 0;
}

.rp-workspace-empty p {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

.rp-inactive-workspaces {
  display: grid;
  gap: 16px;
  margin-top: 8px;
  padding-top: 32px;
  border-top: 1px solid rgb(80 69 59 / 40%);
}

.rp-entry__signout {
  position: fixed;
  bottom: 16px;
  left: 16px;
}

.rp-entry__signout .rp-btn {
  white-space: nowrap;
}

.rp-entry__statusbar--workspace .rp-entry__signout {
  left: 50%;
  transform: translateX(-50%);
}

.rp-entry__statusbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  color: var(--on-surface-variant);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 16px;
  pointer-events: none;
}

@media (max-width: 720px) {
  .rp-command-center {
    padding: 20px 16px 84px;
  }

.rp-command-center h1 {
    font-size: 32px;
    line-height: 40px;
  }

  .login-panel {
    width: calc(100vw - 32px);
    padding: 20px 16px;
  }
}

/* ── Workspace creation form ─────────────────────────────────────── */
.rp-form-field {
  display: flex;
  flex-direction: column;
  gap: var(--rp-space-xs, 4px);
  margin-bottom: var(--rp-space-md, 16px);
}

.rp-form-field label {
  font-size: var(--rp-body-md-size);
  color: var(--rp-on-surface-variant);
  font-weight: 500;
}

.rp-form-label {
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-md-size);
  font-weight: 500;
}

/* Error modifier for .rp-input */
.rp-input--error {
  border-color: var(--rp-error);
}

.rp-input--error:focus,
.rp-input--error:active {
  border-color: var(--rp-error);
}

/* Inline field error text */
.rp-field-error {
  color: var(--rp-error);
  font-size: var(--rp-body-md-size);
  margin: 0;
}

/* Extension-installed gate banner on the workspace create form */
.rp-extension-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rp-space-md, 16px);
  padding: var(--rp-space-md, 16px);
  margin-bottom: var(--rp-space-md, 16px);
  border-radius: var(--rp-radius, 8px);
  background: var(--rp-surface-container-high);
  box-shadow: inset 3px 0 0 var(--rp-outline-variant);
}

.rp-extension-gate[data-state="missing"] {
  box-shadow: inset 3px 0 0 var(--rp-error);
}

.rp-extension-gate[data-state="present"] {
  display: none;
}

.rp-extension-gate__msg {
  margin: 0;
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-md-size);
}

.rp-extension-gate[data-state="missing"] .rp-extension-gate__msg {
  color: var(--rp-error);
}

.rp-extension-gate__retry {
  flex: none;
}

/* Field hint text (secondary) */
.rp-field-hint {
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-md-size);
  margin: 0;
}

.rp-workspace-roster-update {
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-sm-size, 12px);
  line-height: 1.35;
  margin: 0;
}

.rp-autofill-widget {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 52px;
  padding: 10px 12px 10px 16px;
  background: var(--rp-surface-container-high);
  border-radius: var(--rp-radius);
  box-shadow: inset 3px 0 0 var(--rp-outline-variant);
}

.rp-autofill-widget.is-filled {
  background: color-mix(in srgb, var(--primary) 9%, var(--rp-surface-container-high));
  box-shadow: inset 3px 0 0 var(--primary);
}

.rp-autofill-widget--error {
  box-shadow: inset 3px 0 0 var(--rp-error);
}

.rp-autofill-widget__value {
  color: var(--rp-on-surface-variant);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

.rp-autofill-widget.is-filled .rp-autofill-widget__value {
  color: var(--rp-on-surface);
}

/* Form actions row */
.form-actions {
  display: flex;
  align-items: center;
  gap: var(--rp-space-md, 16px);
  margin-top: var(--rp-space-lg, 24px);
}

/* Cancel link — secondary text affordance */
.rp-form-cancel {
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-md-size);
  text-decoration: none;
}

.rp-form-cancel:hover {
  color: var(--rp-on-surface);
  text-decoration: underline;
}

.rp-form-cancel:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ── Roster account typeahead dropdown ───────────────────────────── */
.rp-typeahead {
  position: relative;
}

.rp-typeahead__input {
  width: 100%;
  box-sizing: border-box;
}

/* Floating menu anchored under the input; hidden while empty */
.rp-typeahead__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  background: var(--rp-surface-container-high);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 45%);
}

.rp-typeahead__menu:empty {
  display: none;
}

/* Option row — full-width clickable, reset native button chrome */
.rp-typeahead__option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: var(--rp-space-sm) var(--rp-space-md);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rp-surface-border-soft);
  color: var(--rp-on-surface);
  font-family: var(--rp-font-sans);
  text-align: left;
  cursor: pointer;
}

.rp-typeahead__option:last-child {
  border-bottom: 0;
}

.rp-typeahead__option:hover,
.rp-typeahead__option:focus-visible {
  background: var(--rp-surface-container-highest);
  outline: none;
}

.rp-typeahead__name {
  font-weight: 500;
}

.rp-typeahead__meta {
  font-size: var(--rp-body-md-size);
  color: var(--rp-on-surface-variant);
}

/* Hints (min-chars / empty-state / refine) shown inside the menu */
.rp-typeahead__hint {
  margin: 0;
  padding: var(--rp-space-sm) var(--rp-space-md);
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-body-md-size);
}
