/* ============================================
   UNIFIED CSS VARIABLES
   Shared across all pages - Japandi aesthetic
   ============================================ */

:root {
  /* Background colors */
  --color-bg: #faf8f5;
  --color-bg-card: rgba(255, 255, 255, 0.7);
  --color-bg-sidebar: rgba(250, 248, 245, 0.85);
  
  /* Text colors */
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-text-muted: #757575; /* Improved contrast: 4.6:1 on #faf8f5 */
  
  /* Stone palette - warm neutrals */
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  
  /* Accent colors */
  --accent-clay: #c4a77d;
  --accent-primary: #11212D;
  --accent-secondary: #4A5C6A;
  --accent-link: #5483B3;
  --accent-heart: #e25555;
  --accent-rating: #f5c518;
  
  /* Badge colors for drink categories */
  --badge-cocktail: #b5651d;
  --badge-cocktail-bg: rgba(254, 243, 226, 0.85);
  --badge-wine: #8e3a59;
  --badge-wine-bg: rgba(252, 228, 236, 0.85);
  --badge-mocktail: #2e7d32;
  --badge-mocktail-bg: rgba(232, 245, 233, 0.85);
  --badge-coffee: #5d4037;
  --badge-coffee-bg: rgba(239, 235, 233, 0.85);
  
  /* Logo gradient colors */
  --logo-gradient-light: linear-gradient(145deg, #9BA8AB, #CCD0CF);
  --logo-gradient-dark: linear-gradient(145deg, #253745, #9BA8AB);
  
  /* Tag colors for categories */
  --tag-color-1: #e07b53;
  --tag-color-2: #6b8e6b;
  --tag-color-3: #7b8ccc;
  --tag-color-4: #c4a77d;
  --tag-color-5: #9b7db8;
  
  /* Typography */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: Georgia, 'Times New Roman', serif;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  --font-ui: 'Inter', -apple-system, sans-serif;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  
  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 50;
  --z-sticky: 100;
  --z-modal: 1000;
  --z-tooltip: 1100;
  
  /* Focus ring for accessibility */
  --focus-ring: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--accent-link);
  --focus-ring-inset: inset 0 0 0 2px var(--accent-link);
  
  /* Theme transition */
  --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] {
  /* Background colors - deep navy */
  --color-bg: #11212D;
  --color-bg-card: rgba(21, 39, 54, 0.9);
  --color-bg-sidebar: rgba(17, 33, 45, 0.95);
  
  /* Text colors - cool tones for dark mode */
  --color-text: #E8EDF0;
  --color-text-secondary: #A8B8C5;
  --color-text-muted: #8B9EAD; /* Improved contrast: 4.7:1 on #11212D */
  
  /* Stone palette - navy blue tones */
  --stone-50: #0D1B24;
  --stone-100: #11212D;
  --stone-200: #1A3040;
  --stone-300: #253D50;
  --stone-400: #4A6175;
  --stone-500: #7A92A5;
  --stone-600: #A8B8C5;
  --stone-700: #C8D4DD;
  --stone-800: #E0E8ED;
  --stone-900: #F0F4F7;
  
  /* Accent colors - brighter for dark navy mode */
  --accent-clay: #D4B78D;
  --accent-primary: #5DADE2;
  --accent-secondary: #85C1E9;
  --accent-link: #5DADE2;
  --accent-heart: #F06B6B;
  --accent-rating: #FFD54F;
  
  /* Badge colors - navy-based backgrounds */
  --badge-cocktail: #E5A554;
  --badge-cocktail-bg: rgba(30, 50, 65, 0.9);
  --badge-wine: #D474A0;
  --badge-wine-bg: rgba(35, 45, 60, 0.9);
  --badge-mocktail: #6ECF72;
  --badge-mocktail-bg: rgba(25, 50, 55, 0.9);
  --badge-coffee: #B8A090;
  --badge-coffee-bg: rgba(30, 45, 55, 0.9);
  
  /* Logo gradient colors - navy tones */
  --logo-gradient-light: linear-gradient(145deg, #4A6175, #7A92A5);
  --logo-gradient-dark: linear-gradient(145deg, #C8D4DD, #A8B8C5);
  
  /* Tag colors - vibrant on navy */
  --tag-color-1: #F09878;
  --tag-color-2: #7DD87D;
  --tag-color-3: #8BB8E8;
  --tag-color-4: #E5D4A8;
  --tag-color-5: #C4A8E0;
  
  /* Shadows - deeper for navy */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* Auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Background colors - deep navy */
    --color-bg: #11212D;
    --color-bg-card: rgba(21, 39, 54, 0.9);
    --color-bg-sidebar: rgba(17, 33, 45, 0.95);
    
    /* Text colors - cool tones for dark mode */
    --color-text: #E8EDF0;
    --color-text-secondary: #A8B8C5;
    --color-text-muted: #8B9EAD; /* Improved contrast: 4.7:1 on #11212D */
    
    /* Stone palette - navy blue tones */
    --stone-50: #0D1B24;
    --stone-100: #11212D;
    --stone-200: #1A3040;
    --stone-300: #253D50;
    --stone-400: #4A6175;
    --stone-500: #7A92A5;
    --stone-600: #A8B8C5;
    --stone-700: #C8D4DD;
    --stone-800: #E0E8ED;
    --stone-900: #F0F4F7;
    
    /* Accent colors - brighter for dark navy mode */
    --accent-clay: #D4B78D;
    --accent-primary: #5DADE2;
    --accent-secondary: #85C1E9;
    --accent-link: #5DADE2;
    --accent-heart: #F06B6B;
    --accent-rating: #FFD54F;
    
    /* Badge colors - navy-based backgrounds */
    --badge-cocktail: #E5A554;
    --badge-cocktail-bg: rgba(30, 50, 65, 0.9);
    --badge-wine: #D474A0;
    --badge-wine-bg: rgba(35, 45, 60, 0.9);
    --badge-mocktail: #6ECF72;
    --badge-mocktail-bg: rgba(25, 50, 55, 0.9);
    --badge-coffee: #B8A090;
    --badge-coffee-bg: rgba(30, 45, 55, 0.9);
    
    /* Logo gradient colors - navy tones */
    --logo-gradient-light: linear-gradient(145deg, #4A6175, #7A92A5);
    --logo-gradient-dark: linear-gradient(145deg, #C8D4DD, #A8B8C5);
    
    /* Tag colors - vibrant on navy */
    --tag-color-1: #F09878;
    --tag-color-2: #7DD87D;
    --tag-color-3: #8BB8E8;
    --tag-color-4: #E5D4A8;
    --tag-color-5: #C4A8E0;
    
    /* Shadows - deeper for navy */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

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

/* Disable transitions on initial load to prevent flash */
.no-transitions,
.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
  transition: none !important;
}

/* ============================================
   GLOBAL FOCUS STYLES FOR ACCESSIBILITY
   ============================================ */

/* Remove default outline and use custom focus ring */
:focus {
  outline: none;
}

/* Visible focus ring for keyboard navigation */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Links with focus */
a:focus-visible {
  border-radius: var(--radius-sm);
  box-shadow: var(--focus-ring);
}

/* Buttons with focus */
button:focus-visible,
.tab:focus-visible,
.tag:focus-visible,
.view-btn:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Input elements */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  box-shadow: var(--focus-ring-inset);
}

/* Navigation links */
.nav__link:focus-visible {
  border-radius: var(--radius-full);
  box-shadow: var(--focus-ring);
}

/* Sidebar links */
.sidebar__link:focus-visible {
  border-radius: var(--radius-sm);
  box-shadow: var(--focus-ring);
}

/* Cards and interactive elements */
.book-card:focus-visible,
.vinyl-card:focus-visible,
.drink-card:focus-visible,
.book-cover-card:focus-visible,
.book-list-item:focus-visible,
.post-list-item:focus-visible {
  border-radius: var(--radius-md);
  box-shadow: var(--focus-ring);
}

/* Modal close button */
.modal__close:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Hamburger menu */
.nav__hamburger:focus-visible {
  border-radius: var(--radius-md);
  box-shadow: var(--focus-ring);
}

/* Skip to content link (add to HTML if needed) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 12px 24px;
  background: var(--stone-800);
  color: var(--stone-50);
  font-family: var(--font-ui);
  font-size: 14px;
  text-decoration: none;
  border-radius: var(--radius-md);
  z-index: var(--z-tooltip);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 16px;
}

/* ============================================
   SKELETON LOADING ANIMATIONS
   ============================================ */

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

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Base skeleton styles */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--stone-100) 0%,
    var(--stone-200) 20%,
    var(--stone-100) 40%,
    var(--stone-100) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton--pulse {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Skeleton text lines */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: var(--radius-sm);
}

.skeleton-text--title {
  height: 1.5em;
  width: 60%;
}

.skeleton-text--subtitle {
  height: 1em;
  width: 40%;
}

.skeleton-text--short {
  width: 30%;
}

.skeleton-text--medium {
  width: 60%;
}

.skeleton-text--long {
  width: 90%;
}

/* Skeleton shapes */
.skeleton-circle {
  border-radius: 50%;
}

.skeleton-rect {
  border-radius: var(--radius-md);
}

/* ============================================
   BOOK SKELETON
   ============================================ */

.skeleton-book {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--stone-100);
  align-items: center;
}

.skeleton-book__cover {
  width: 44px;
  height: 66px;
  border-radius: 2px 4px 4px 2px;
  flex-shrink: 0;
}

.skeleton-book__info {
  flex: 1;
  min-width: 0;
}

.skeleton-book__title {
  height: 16px;
  width: 70%;
  margin-bottom: 8px;
}

.skeleton-book__author {
  height: 12px;
  width: 45%;
}

.skeleton-book__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.skeleton-book__category {
  height: 22px;
  width: 60px;
  border-radius: 10px;
}

.skeleton-book__rating {
  height: 14px;
  width: 80px;
}

/* ============================================
   BOOK COVER SKELETON (Grid view)
   ============================================ */

.skeleton-cover-group {
  margin-bottom: 48px;
}

.skeleton-cover-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.skeleton-cover-year {
  height: 28px;
  width: 60px;
}

.skeleton-cover-line {
  flex: 1;
  height: 1px;
  background: var(--stone-200);
}

.skeleton-cover-count {
  height: 14px;
  width: 20px;
}

.skeleton-covers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 32px 24px;
}

.skeleton-cover-card {
  position: relative;
}

.skeleton-cover-card__cover {
  aspect-ratio: 2/3;
  border-radius: 2px 6px 6px 2px;
  box-shadow: 4px 4px 12px rgba(0,0,0,0.1);
}

/* ============================================
   POST SKELETON
   ============================================ */

.skeleton-post {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dotted var(--stone-200);
}

.skeleton-post__title {
  flex: 1;
  height: 16px;
  max-width: 70%;
}

.skeleton-post__date {
  height: 14px;
  width: 60px;
  flex-shrink: 0;
}

/* ============================================
   YEAR GROUP SKELETON
   ============================================ */

.skeleton-year-group {
  display: flex;
  gap: 32px;
  margin-bottom: 56px;
}

.skeleton-year-sidebar {
  flex-shrink: 0;
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.skeleton-year-title {
  height: 80px;
  width: 28px;
}

.skeleton-year-line {
  flex: 1;
  width: 1px;
  background: linear-gradient(to bottom, var(--stone-300) 0%, transparent 100%);
  margin-top: 20px;
  min-height: 40px;
}

.skeleton-year-count {
  height: 12px;
  width: 20px;
  margin-top: 16px;
}

.skeleton-year-books {
  flex: 1;
  min-width: 0;
}

/* ============================================
   VINYL SKELETON
   ============================================ */

.skeleton-vinyl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 32px;
}

.skeleton-vinyl-card {
  display: flex;
  flex-direction: column;
}

.skeleton-vinyl-card__cover {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.skeleton-vinyl-card__title {
  height: 14px;
  width: 80%;
  margin-bottom: 6px;
}

.skeleton-vinyl-card__artist {
  height: 12px;
  width: 60%;
}

/* ============================================
   MONTH GROUP SKELETON (Blog)
   ============================================ */

.skeleton-month-group {
  margin-bottom: 40px;
}

.skeleton-month-header {
  height: 16px;
  width: 100px;
  margin-left: auto;
  margin-bottom: 16px;
}

.skeleton-month-posts {
  display: flex;
  flex-direction: column;
}

/* ============================================
   RESPONSIVE SKELETONS
   ============================================ */

@media (max-width: 640px) {
  .skeleton-year-group {
    flex-direction: column;
    gap: 16px;
  }
  
  .skeleton-year-sidebar {
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  
  .skeleton-year-title {
    height: 24px;
    width: 50px;
  }
  
  .skeleton-year-line {
    flex: 1;
    height: 1px;
    width: auto;
    margin-top: 0;
    min-height: 0;
    background: linear-gradient(to right, var(--stone-300) 0%, transparent 100%);
  }
  
  .skeleton-year-count {
    margin-top: 0;
  }
  
  .skeleton-covers-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 12px;
  }
  
  .skeleton-vinyl-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}
