/* ==========================================================================
   PEXAFY DESIGN SYSTEM — main.css
   Futuristic dark-first design system. Zero external dependencies.
   ========================================================================== */

/* --- A. RESET --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
}

ul, ol {
  list-style: none;
}

/* --- B. CSS VARIABLES ------------------------------------------------------- */
:root {
  /* Palette */
  --color-bg: #0a0a0f;
  --color-surface: #12121a;
  --color-surface-hover: #1a1a2e;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-text: #e4e4e7;
  --color-text-muted: #a1a1aa;
  --color-primary: #8b5cf6;
  --color-primary-hover: #7c3aed;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);

  /* Motion */
  --transition: 200ms ease;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-24: 96px;

  /* Spacing aliases (--space-N) used by component CSS */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Font size scale */
  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */

  /* Extra colour aliases for component CSS */
  --color-surface-2: rgba(255, 255, 255, 0.04);
  --color-text-primary: var(--color-text);
  --color-text-secondary: var(--color-text-muted);
}

/* --- B2. LIGHT MODE --------------------------------------------------------- */
[data-theme="light"] {
  --color-bg: #f8f8fc;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f0f6;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-text: #18181b;
  --color-text-muted: #52525b;
  --color-primary: #7c3aed;
  --color-primary-hover: #6d28d9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.1);
  --color-surface-2: rgba(0, 0, 0, 0.03);
}

/* --- C. TYPOGRAPHY ---------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--sp-4);
  color: var(--color-text-muted);
}

small {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.875em;
  padding: 2px 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* --- D. LAYOUT UTILITIES ---------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.grid {
  display: grid;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }

.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

/* --- E. COMPONENTS ---------------------------------------------------------- */

/* ---- E1. Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 20px;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  color: #fff;
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
}

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

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

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.0625rem;
}

/* ---- E2. Card (Glassmorphism) ---- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card:hover {
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border);
}

.card-body {
  flex: 1;
}

.card-footer {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--color-border);
}

/* ---- E3. Form Inputs ---- */
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

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

.textarea {
  min-height: 100px;
  resize: vertical;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-inline-end: 36px;
}

.form-group {
  margin-bottom: var(--sp-4);
}

.form-label {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

/* ---- E4. Badge / Tag ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-xl);
  background: rgba(139, 92, 246, 0.15);
  color: var(--color-primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-error);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 12px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

.tag:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

/* ---- E5. Alerts ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.alert-success {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
  color: var(--color-success);
}

.alert-warning {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
  color: var(--color-warning);
}

.alert-error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-error);
}

.alert-info {
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.08);
  color: var(--color-accent);
}

.alert-close {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  margin-inline-start: auto;
  opacity: 0.45;
  color: inherit;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.alert-close:hover {
  opacity: 1;
}

/* ---- E6. Skeleton Loader ---- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-hover) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: var(--sp-2);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-title {
  height: 1.5rem;
  width: 50%;
  margin-bottom: var(--sp-4);
}

.skeleton-img {
  height: 200px;
  margin-bottom: var(--sp-4);
}

/* ---- E7. Divider ---- */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-6) 0;
}

/* ---- E8. Avatar ---- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }

/* --- F. ACCESSIBILITY ------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  z-index: 9999;
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 500;
}

.skip-link:focus {
  top: var(--sp-4);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- G. THEME TOGGLE -------------------------------------------------------- */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-2);
  cursor: pointer;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: 18px;
  height: 18px;
}

html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }
html:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
html:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }

/* --- H. RESPONSIVE ---------------------------------------------------------- */
.show-mobile { display: none; }
@media (max-width: 640px) {
  .container { padding-inline: var(--sp-3); }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: inline-flex !important; }
}

@media (min-width: 641px) and (max-width: 768px) {
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .container { padding-inline: var(--sp-8); }
}

/* --- I. PAGE LAYOUT --------------------------------------------------------- */
/* .site-header and .site-logo rules moved to layout.css (canonical source) */

.site-footer {
  margin-top: auto;
  padding: var(--sp-8) 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* --- J. DJANGO MESSAGES ----------------------------------------------------- */
.messages-container {
  padding: var(--sp-3) 0;
}

.messages-container .alert {
  margin-bottom: var(--sp-2);
}

.messages-container .alert:last-child {
  margin-bottom: 0;
}

/* --- K. COOKIE BANNER ------------------------------------------------------- */
/* While the banner shows, its script (components/cookie_banner.html) sets
   --cookie-banner-space on <html>: the room it takes at the bottom of the window.
   Every page keeps that room free at its end, so its last lines scroll clear of the
   banner, and focus or an anchor never lands underneath it. A page whose content is
   itself fixed to the bottom of the window uses the variable too (plugin.css). */
body {
  padding-bottom: var(--cookie-banner-space, 0px);
}

html {
  scroll-padding-bottom: var(--cookie-banner-space, 0px);
}

.cookie-banner {
  position: fixed;
  bottom: var(--sp-4, 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: max-content;
  max-width: calc(100% - 2rem);
  animation: cookie-slide-up 0.35s ease-out;
}

@keyframes cookie-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cookie-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 9999px;
  padding: 10px 12px 10px 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10), 0 1px 4px rgba(0, 0, 0, 0.06);
  font-size: 0.8125rem;
  color: var(--color-text-muted, #64748b);
  line-height: 1.4;
}

.cookie-banner-content p {
  margin: 0;
  white-space: nowrap;
}

.cookie-icon {
  flex-shrink: 0;
  color: var(--color-text-muted, #94a3b8);
}

.cookie-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cookie-learn-more {
  font-size: 0.8125rem;
  color: var(--color-text-muted, #64748b);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.cookie-learn-more:hover {
  color: var(--color-text, #1e293b);
}

.cookie-accept-btn {
  border-radius: 9999px !important;
  padding: 6px 18px !important;
  font-size: 0.8125rem !important;
  font-weight: 600;
}

@media (max-width: 600px) {
  .cookie-banner-content {
    flex-wrap: wrap;
    border-radius: var(--radius-lg, 12px);
    padding: 14px 18px;
    justify-content: center;
    text-align: center;
  }
  .cookie-banner-content p {
    white-space: normal;
  }
  .cookie-icon {
    display: none;
  }
}


/* ── Blurhash placeholders (global — applies on all pages with photo cards) ── */
/* Parent anchor receives the decoded blurhash canvas as background-image via JS */
.photo-card__link {
  background-size: cover;
  background-position: center;
}
/* Image hidden while blurhash placeholder is visible */
@media (prefers-reduced-motion: no-preference) {
  .photo-card__img.bh-pending {
    opacity: 0;
    transition: opacity 0.4s ease-out;
  }
}
@media (prefers-reduced-motion: reduce) {
  .photo-card__img.bh-pending {
    opacity: 0;
  }
}

/* cache-bust 2026-06-16: force new content-hash after the redeploy unstyle window (issue #1) */
