/* ========================================
   DIRTY TAG LINKTREE — STYLES
   ======================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Colors - Light Theme */
  /* Palette extracted from photo */
  --dt-red: #E31B23;
  --dt-red-dark: #B51516;
  --dt-red-light: #FF5B5B;
  --dt-white: #FFFFFF;
  --dt-ink: #1A1A1A;
  --dt-muted: #F6F6F6;

  --color-primary: var(--dt-red);
  --color-bg: var(--dt-white);
  --color-surface: var(--dt-white);
  --color-text: var(--dt-ink);
  --color-text-muted: #9CA3AF;
  --color-border: var(--dt-muted);
  
  /* Typography */
  --font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.75rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Effects */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s ease;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --color-bg: #121212;
  --color-surface: #1E1E1E;
  --color-text: #F5F5F5;
  --color-text-muted: #9CA3AF;
  --color-border: #374151;
}

/* --- Brand Theme (from photo) --- */
body.brand {
  /* Override core color tokens with the extracted palette so the rest of the stylesheet adapts */
  --color-bg: var(--dt-red);
  --color-surface: var(--dt-red);
  --color-text: var(--dt-white);
  --color-text-muted: rgba(255,255,255,0.85);
  --color-border: rgba(255,255,255,0.12);

  /* Background images (fallback to PNG — WebP conversion not available in this environment) */
  --bg-mobile: url('images/bg-1x.png');
  --bg-2x: url('images/bg-2x.png');
  --bg-overlay: rgba(0, 0, 0, 0.35);
  --bg-blur: 6px;
}

/* Blurred background layer (separate pseudo-element) */
body.brand::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--bg-mobile);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(var(--bg-blur));
  transform: scale(1.04);
  z-index: -3;
  will-change: transform, filter;
  pointer-events: none;
}

/* High-res displays use the 2x asset */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body.brand::before {
    background-image: var(--bg-2x);
  }
}

/* overlay for contrast */
body.brand::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: -2;
  pointer-events: none;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Container --- */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Loading State --- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding-top: var(--space-2xl);
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-border) 25%,
    var(--color-surface) 50%,
    var(--color-border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
}

.skeleton-text {
  height: 20px;
}

.skeleton-title {
  width: 120px;
}

.skeleton-bio {
  width: 200px;
}

.skeleton-card {
  width: 100%;
  height: 56px;
  border-radius: var(--radius-md);
}

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

/* --- Content --- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* --- Profile Header --- */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: var(--space-xl);
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--color-primary);
  object-fit: cover;
  background-color: var(--color-surface);
}

.profile-name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin-top: var(--space-md);
  letter-spacing: -0.02em;
}

.profile-bio {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  max-width: 280px;
  margin-top: var(--space-xs);
}

/* --- Category Filter --- */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
}

.category-chip {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.category-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

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

.category-chip.active,
.category-chip[aria-pressed="true"] {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

/* --- Links Container --- */
.links-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* --- Link Card --- */
.link-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--color-text);
  min-height: 56px;
  position: relative;
  transition: var(--transition);
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.link-card:active {
  transform: scale(0.98);
}

.link-card-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--color-primary);
}

.link-card-label {
  flex: 1;
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
}

.link-card-arrow {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.link-card-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-2xl) var(--space-md);
  color: var(--color-text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* --- Footer --- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding-top: var(--space-xl);
  margin-top: auto;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-text);
  transition: var(--transition);
}

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

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

.theme-icon {
  width: 24px;
  height: 24px;
}

.footer-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  background-color: #DC2626;
  color: #FFFFFF;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.toast.visible {
  opacity: 1;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .container {
    padding: var(--space-md);
  }
  
  .avatar {
    width: 80px;
    height: 80px;
  }
  
  .profile-name {
    font-size: var(--font-size-lg);
  }
  
  .skeleton-avatar {
    width: 80px;
    height: 80px;
  }
}

@media (min-width: 768px) {
  .link-card:hover {
    transform: translateY(-3px);
  }
}
