/* backend/apps/core/static/core/css/public.css */

/* ========================================
   Base reset
======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ========================================
   Design Tokens (Shared with workspace)
   Keep these identical across public/workspace.
======================================== */

:root {
  /* Surfaces */
  --bg: #fbfdff;
  --surface: #ffffff;
  --surface-2: #f8fafc; /* slate-50 */
  --surface-hover: #f1f5f9; /* slate-100 */

  /* Text */
  --text: #0f172a; /* slate-900 */
  --text-secondary: #475569; /* slate-600 */
  --muted: #94a3b8; /* slate-400 */

  /* Borders */
  --border: #f1f5f9; /* slate-100 */
  --border-strong: #cbd5e1; /* slate-300 */

  /* Brand (Emerald) */
  --brand: #10b981; /* emerald-500 */
  --brand-600: #059669; /* emerald-600 */
  --brand-700: #047857; /* emerald-700 */
  --brand-50: #ecfdf5; /* emerald-50 */
  --brand-100: #d1fae5; /* emerald-100 */

  /* Accents */
  --accent-warning: #f59e0b;
  --accent-error: #ef4444;
  --accent-info: #3b82f6;
  --accent-success: #10b981;

  /* Focus ring */
  --ring: rgba(16, 185, 129, 0.35);
  --ring-offset: 2px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.12),
    0 10px 10px -5px rgba(15, 23, 42, 0.06);
}

/* ========================================
   Base
======================================== */

html {
  /* Reserve scrollbar space so centered public containers do not shift. */
  scrollbar-gutter: stable;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
}

h1,
h2,
h3,
h4,
h5,
h6,
.font-outfit {
  font-family: "Outfit", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.font-display,
.font-serif {
  font-family: "Playfair Display", Georgia, serif;
}

/* Alpine */
[x-cloak] {
  display: none !important;
}

/* ========================================
   Legacy utility classes still used by public templates
======================================== */

/* Backgrounds */
.bg-app {
  background-color: var(--bg);
}

.bg-surface {
  background-color: var(--surface);
}

.bg-surface-hover {
  background-color: var(--surface-hover);
}

.bg-brand {
  background-color: var(--brand);
}

.bg-brand-50 {
  background-color: var(--brand-50) !important;
}

.bg-brand-100 {
  background-color: var(--brand-100) !important;
}

/* Text */
.text-app {
  color: var(--text);
}

.text-secondary {
  color: var(--text-secondary);
}

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

.text-brand {
  color: var(--brand);
}

.text-primary {
  color: var(--brand);
}

.text-brand-700 {
  color: var(--brand-700);
}

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

/* Borders */
.border-app {
  border-color: var(--border);
}

.border-light {
  border-color: var(--border-strong);
}

/* ========================================
   Focus ring helper
======================================== */

.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--ring-offset) var(--surface),
    0 0 0 calc(var(--ring-offset) + 2px) var(--ring);
}

/* ========================================
   Buttons (aligned with workspace)
======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;

  padding: 0.75rem 1.5rem; /* px-6 py-3 */
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25rem;

  border-radius: 1.25rem; /* rounded-2xl */
  transition: transform 120ms ease, background-color 120ms ease,
    box-shadow 120ms ease, border-color 120ms ease, color 120ms ease;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 var(--ring-offset) var(--surface),
    0 0 0 calc(var(--ring-offset) + 2px) var(--ring);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn svg,
.btn i {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
}

.btn-primary {
  background-color: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.12);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-600);
  box-shadow: 0 10px 22px rgba(16, 185, 129, 0.16);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--surface-2);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--text);
}

.btn-demo {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--text-muted);
  box-shadow: none;
}

.btn-demo:hover:not(:disabled) {
  /* background-color: rgba(16, 185, 129, 0.08); */
  background-color: var(--brand);
  border-color: var(--brand-700);
  color: #fff;
  box-shadow: none;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--surface-2);
  color: var(--text);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  box-shadow: var(--shadow-sm);
}

/* ========================================
   Inputs + labels (kept for public templates)
   Note: Tailwind forms plugin will style most inputs anyway,
   but these classes are used in your public templates.
======================================== */

.input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;

  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.875rem;

  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input::placeholder {
  color: var(--muted);
}

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

.input:disabled {
  background-color: var(--surface-2);
  cursor: not-allowed;
}

.input--icon-left {
  padding-left: 3rem;
}

.input--action-right {
  padding-right: 3.25rem;
}

.input-icon {
  color: var(--muted);
  pointer-events: none;
}

.input-action {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  color: var(--muted);
  transition: background-color 150ms ease, color 150ms ease,
    box-shadow 150ms ease;
}

.input-action:hover {
  background-color: var(--surface-hover);
  color: var(--brand-700);
}

.input-action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.input-error {
  border-color: var(--accent-error);
}

.input-error:focus {
  border-color: var(--accent-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.help-text {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.error-text {
  font-size: 0.75rem;
  color: var(--accent-error);
  margin-top: 0.25rem;
}

.link {
  color: var(--brand-600);
  text-decoration: none;
  transition: color 150ms ease;
}

.link:hover {
  color: var(--brand-700);
  text-decoration: underline;
}

/* ========================================
   Badges
======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 9999px;
}

.badge-brand {
  background-color: var(--brand-100);
  color: var(--brand-700);
}

/* Divider */
.divider {
  border-top: 1px solid var(--border);
}

/* ========================================
   Toast
======================================== */

.toast {
  padding: 1rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.toast-success {
  background-color: var(--brand-50);
  border-left: 4px solid var(--accent-success);
}

.toast-error {
  background-color: #fef2f2;
  border-left: 4px solid var(--accent-error);
}

.toast-warning {
  background-color: #fffbeb;
  border-left: 4px solid var(--accent-warning);
}

.toast-info {
  background-color: #eff6ff;
  border-left: 4px solid var(--accent-info);
}

/* ========================================
   Homepage-specific public effects
======================================== */

.public-home .homepage-preview-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  animation: homepage-preview-ping 1.9s ease-out infinite;
  background: rgba(16, 185, 129, 0.42);
}

.public-home .homepage-preview-presence {
  animation: homepage-preview-presence 2.8s ease-in-out infinite;
}

.public-home [data-reveal] {
  opacity: 0;
  transform: translateY(34px);
  transition:
    opacity 680ms cubic-bezier(.2,.8,.2,1),
    transform 680ms cubic-bezier(.2,.8,.2,1);
  transition-delay: var(--reveal-delay, 0ms);
}

.public-home [data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes homepage-preview-presence {
  0%,
  100% {
    opacity: 0.85;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

@keyframes homepage-preview-ping {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }

  70% {
    transform: scale(2.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-home .homepage-preview-dot::after,
  .public-home .homepage-preview-presence,
  .public-home [data-reveal] {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ========================================
   Error pages
======================================== */

.error-body {
  background:
    radial-gradient(circle at top, rgba(15, 23, 42, 0.035), transparent 30rem),
    var(--bg);
  color: var(--text);
}

.error-page {
  --error-accent: var(--brand);
  --error-accent-strong: var(--brand-600);
  --error-accent-soft: rgba(16, 185, 129, 0.1);
  --error-accent-border: rgba(16, 185, 129, 0.18);

  position: relative;
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
  padding: 3rem 1.25rem;
}

.error-page--purple {
  --error-accent: #8b5cf6;
  --error-accent-strong: #7c3aed;
  --error-accent-soft: rgba(139, 92, 246, 0.08);
  --error-accent-border: rgba(139, 92, 246, 0.18);
}

.error-page--warning {
  --error-accent: #f59e0b;
  --error-accent-strong: #ea580c;
  --error-accent-soft: rgba(245, 158, 11, 0.09);
  --error-accent-border: rgba(245, 158, 11, 0.2);
}

.error-page--danger {
  --error-accent: #ef8e92;
  --error-accent-strong: #dc6d74;
  --error-accent-soft: rgba(239, 142, 146, 0.09);
  --error-accent-border: rgba(239, 142, 146, 0.2);
}

.error-page__content {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 46rem);
  min-height: min(48rem, calc(100svh - 6rem));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-page__icon {
  position: relative;
  display: inline-flex;
  width: 6.25rem;
  height: 6.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--error-accent-border);
  border-radius: 1.5rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--error-accent-soft) 100%);
  color: var(--error-accent);
}

.error-page__icon svg {
  width: 3.5rem;
  height: 3.5rem;
  stroke-width: 1.8;
}

.error-page__sparkle {
  position: absolute;
  color: color-mix(in srgb, var(--error-accent), #ffffff 45%);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.error-page__sparkle--one {
  right: 1.25rem;
  top: 1rem;
}

.error-page__sparkle--two {
  bottom: 1.45rem;
  left: 1.15rem;
  font-size: 0.75rem;
}

.error-page__code {
  margin-top: 3.5rem;
  font-family: "Outfit", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: clamp(6rem, 16vw, 9.75rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.8;
  color: #071226;
}

.error-page__title {
  margin-top: 2rem;
  font-family: "Outfit", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.05;
  color: var(--text);
}

.error-page__message {
  margin-top: 1.25rem;
  color: #64748b;
  font-size: clamp(1.0625rem, 2vw, 1.5rem);
  font-weight: 500;
  line-height: 1.55;
}

.error-page__actions {
  display: flex;
  width: min(100%, 36rem);
  justify-content: center;
  margin-top: 2.5rem;
}

.error-page__button {
  display: inline-flex;
  min-height: 5rem;
  min-width: min(100%, 18rem);
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  border: 1px solid transparent;
  border-radius: 1.25rem;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.error-page__button svg {
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 auto;
  stroke-width: 2.1;
}

.error-page__button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.error-page__button:hover {
  transform: translateY(-1px);
}

.error-page__button--primary {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-600) 100%);
  color: #ffffff;
  box-shadow: 0 1rem 2rem rgba(16, 185, 129, 0.18);
}

.error-page__button--primary:hover {
  background: linear-gradient(180deg, var(--brand-600) 0%, var(--brand-700) 100%);
}

.error-page__button--secondary {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: 0 0.75rem 1.5rem rgba(15, 23, 42, 0.06);
}

.error-page__button--secondary svg {
  color: var(--brand);
}

.error-page__button--secondary:hover {
  border-color: rgba(16, 185, 129, 0.35);
  background: #ffffff;
}

.error-page__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 4rem;
  color: #1e293b;
  font-family: "Outfit", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.error-page__brand-mark {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background-color: var(--brand);
  flex: 0 0 auto;
}

.error-page__brand img {
  width: 1.25rem;
  height: 1.25rem;
}

.error-page__dots {
  position: absolute;
  z-index: 0;
  width: 4.5rem;
  height: 4.5rem;
  opacity: 0.42;
  background-image: radial-gradient(var(--brand) 1.5px, transparent 1.5px);
  background-size: 1rem 1rem;
}

.error-page__dots--left {
  bottom: 6.5rem;
  left: 1.75rem;
}

.error-page__dots--right {
  right: 3rem;
  top: 63%;
}

.error-page__wave {
  position: absolute;
  z-index: 0;
  bottom: -12rem;
  width: min(46vw, 42rem);
  height: 22rem;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), transparent);
  filter: blur(0.2px);
}

.error-page__wave--left {
  left: -8rem;
  transform: rotate(18deg);
}

.error-page__wave--right {
  right: -7rem;
  transform: rotate(-18deg);
}

@media (max-width: 640px) {
  .error-page {
    padding: 2rem 1rem;
  }

  .error-page__content {
    min-height: calc(100svh - 4rem);
  }

  .error-page__icon {
    width: 5rem;
    height: 5rem;
    border-radius: 1.25rem;
  }

  .error-page__icon svg {
    width: 2.9rem;
    height: 2.9rem;
  }

  .error-page__code {
    margin-top: 2.5rem;
  }

  .error-page__title {
    margin-top: 1.5rem;
  }

  .error-page__message {
    margin-top: 1rem;
  }

  .error-page__actions {
    margin-top: 2rem;
  }

  .error-page__button {
    width: 100%;
    min-height: 4rem;
  }

  .error-page__brand {
    margin-top: 2.5rem;
    font-size: 1.25rem;
  }

  .error-page__brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.65rem;
  }

  .error-page__brand img {
    width: 1.1rem;
    height: 1.1rem;
  }

  .error-page__dots--left {
    bottom: 3rem;
    left: 0.75rem;
  }

  .error-page__dots--right {
    display: none;
  }
}

@media (max-height: 760px) and (min-width: 641px) {
  .error-page {
    padding-block: 2rem;
  }

  .error-page__content {
    min-height: calc(100svh - 4rem);
  }

  .error-page__icon {
    width: 5.25rem;
    height: 5.25rem;
    border-radius: 1.35rem;
  }

  .error-page__icon svg {
    width: 3rem;
    height: 3rem;
  }

  .error-page__code {
    margin-top: 2.35rem;
    font-size: clamp(5.5rem, 14vw, 7.75rem);
  }

  .error-page__title {
    margin-top: 1.55rem;
    font-size: clamp(1.85rem, 3.5vw, 2.35rem);
  }

  .error-page__message {
    margin-top: 1rem;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
  }

  .error-page__actions {
    margin-top: 2rem;
  }

  .error-page__button {
    min-height: 4.25rem;
  }

  .error-page__brand {
    margin-top: 2.5rem;
  }
}

@supports not (color: color-mix(in srgb, #000000, #ffffff)) {
  .error-page__sparkle {
    color: var(--error-accent);
  }
}
