/* Match The Ranger App (rangertrac.net) public-page branding. */

:root {
  --brand-blue: #004088;
  --brand-blue-hover: #00336d;
  --brand-gold: #ffd920;
  --brand-red: #dc2230;
  --brand-brown: #4e3c2e;
  --brand-light-gray: #f4f4f4;
  --background: #ffffff;
  --foreground: #111827;
  --muted: #6b7280;
  --muted-foreground: #4b5563;
  --border: #e5e7eb;
  --card: #ffffff;
  --ring: color-mix(in srgb, var(--brand-blue) 45%, transparent);
  --danger: #dc2230;
  --danger-bg: #fef2f2;
  --ok-bg: #eff6ff;
  --radius: 0.625rem;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 8px 24px rgba(17, 24, 39, 0.06);
  /* One shared column width for header + body (fixes misalignment) */
  --page-max: 36rem;
  --page-pad: 1rem;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

@media (min-width: 640px) {
  :root {
    --page-pad: 1.5rem;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--foreground);
  background: var(--brand-light-gray);
  -webkit-font-smoothing: antialiased;
}

.app-root {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* ── Brand header ── */
.brand-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

.brand-stripe {
  display: flex;
  height: 4px;
  width: 100%;
}

.brand-stripe span {
  flex: 1;
  height: 100%;
}

.brand-stripe .gold {
  background: var(--brand-gold);
}

.brand-stripe .red {
  background: var(--brand-red);
}

.brand-stripe .blue {
  background: var(--brand-blue);
}

.brand-header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.875rem var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
}

.brand-wordmark {
  height: 2.5rem;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-tagline {
  display: none;
  border-left: 1px solid var(--border);
  padding-left: 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand-brown);
  line-height: 1.25;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .brand-tagline {
    display: inline-flex;
    align-items: center;
  }
}

/* ── Page shell: same width as header ── */
.shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.75rem var(--page-pad) 2.5rem;
  min-width: 0;
}

/* Signed-out: center the gate like RangerTrac PublicPageShell centered */
body.mode-auth .shell {
  justify-content: center;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

body.mode-auth .page-intro {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  max-width: 28rem;
}

body.mode-auth main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.mode-auth #gate {
  width: 100%;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

/* Signed-in: normal top-aligned tool layout, slightly more room */
body.mode-app {
  --page-max: 40rem;
}

body.mode-app .shell {
  justify-content: flex-start;
  padding-top: 2rem;
}

.page-intro {
  margin-bottom: 1.25rem;
  width: 100%;
}

body.mode-auth .page-intro .lede {
  margin-left: auto;
  margin-right: auto;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.65rem, 4vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--foreground);
}

.lede {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 36rem;
}

.lede strong {
  color: var(--foreground);
  font-weight: 600;
}

main {
  width: 100%;
  min-width: 0;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.4rem;
  margin-bottom: 1rem;
  width: 100%;
}

/* Auth gate: light shell so Clerk is the primary card (no double chrome) */
body.mode-auth #gate.card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  text-align: center;
}

body.mode-auth #gate h2 {
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}

body.mode-auth #gate-help {
  margin: 0 auto 1rem;
  max-width: 22rem;
}

.card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--foreground);
}

.step-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  margin-right: 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-blue) 10%, white);
  color: var(--brand-blue);
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 0.05em;
}

.muted {
  color: var(--muted-foreground);
}

.small {
  font-size: 0.875rem;
  line-height: 1.5;
}

.upload-note {
  margin-top: -0.25rem;
  margin-bottom: 1rem;
}

code {
  background: #f3f4f6;
  color: var(--brand-blue);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ── Dropzone ── */
.dropzone {
  border: 2px dashed #d1d5db;
  border-radius: var(--radius);
  background: #fafafa;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  margin: 1rem 0;
}

.dropzone:hover,
.dropzone:focus {
  border-color: var(--brand-blue);
  background: color-mix(in srgb, var(--brand-blue) 4%, white);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.dropzone.dragover {
  border-color: var(--brand-blue);
  background: color-mix(in srgb, var(--brand-blue) 8%, white);
  box-shadow: 0 0 0 3px var(--ring);
}

.dropzone .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 auto 0.65rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-blue) 10%, white);
  color: var(--brand-blue);
  font-size: 1.25rem;
  font-weight: 700;
}

.dropzone p {
  margin: 0.15rem 0;
}

.file-label {
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--foreground);
  word-break: break-word;
}

/* ── Buttons ── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--brand-blue);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--brand-blue-hover);
}

.btn.primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand-blue);
}

.btn.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--foreground);
  margin-top: 0.75rem;
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: color-mix(in srgb, var(--brand-blue) 4%, white);
}

/* ── Progress ── */
.progress {
  width: 100%;
  height: 0.5rem;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.85rem 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--brand-blue);
  transition: width 0.35s ease;
}

.progress-bar.queued {
  background: linear-gradient(90deg, var(--brand-gold), #f5c518);
  animation: pulse-bar 1.4s ease-in-out infinite;
}

@keyframes pulse-bar {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

.status-message {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--foreground);
}

.log-list {
  margin: 0.85rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.8125rem;
  max-height: 10rem;
  overflow: auto;
  line-height: 1.45;
  text-align: left;
}

.success {
  border-color: color-mix(in srgb, var(--brand-blue) 25%, var(--border));
  background: linear-gradient(180deg, #fff, var(--ok-bg));
}

.error-card {
  border-color: color-mix(in srgb, var(--brand-red) 30%, var(--border));
  background: linear-gradient(180deg, #fff, var(--danger-bg));
}

.error {
  color: var(--danger);
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
}

/* ── Forms ── */
.password-gate {
  margin-top: 1rem;
  text-align: left;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}

.password-gate label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
  color: var(--foreground);
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.row input {
  flex: 1 1 12rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
}

.row input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 1px var(--brand-blue);
}

/* ── Auth chip in header ── */
.auth-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  max-width: 14rem;
  text-align: right;
  flex-shrink: 0;
}

.auth-box strong {
  display: block;
  color: var(--foreground);
  font-weight: 600;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-box span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-box .btn.ghost {
  margin-top: 0.35rem;
  min-height: 1.85rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
}

/* ── Footer ── */
.footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
  width: 100%;
  text-align: left;
}

body.mode-auth .footer {
  text-align: center;
  border-top: none;
  margin-top: 2rem;
  padding-top: 0;
}

.footer p {
  margin: 0 0 0.35rem;
}

.footer a {
  color: var(--brand-blue);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

#version-line {
  margin-top: 0.35rem;
}

/* ── Details / errors ── */
details {
  margin: 1rem 0;
  font-size: 0.875rem;
  text-align: left;
}

details summary {
  cursor: pointer;
  color: var(--muted-foreground);
  font-weight: 500;
}

pre {
  white-space: pre-wrap;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  max-height: 12rem;
  overflow: auto;
  color: var(--foreground);
  text-align: left;
}

/* Clerk: full width of gate column, centered */
#clerk-mount {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem;
  min-height: 1rem;
}

/* Clerk injects its own card; keep host clean */
#clerk-mount > * {
  margin-left: auto !important;
  margin-right: auto !important;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ring);
}
