/**
 * Connected Tab System - Tome of Tales
 * 
 * Visual design: Bookmarks physically connected to their content pages
 * Reference: TOME_OF_TALES_DESIGN_PHILOSOPHY.md - Visual Metaphor System
 * 
 * Features:
 * - Connected tabs feel like bookmarks protruding from pages
 * - Active tab has visual connection line to content
 * - Smooth transitions and hover effects
 * - Supports SelectionComponent integration
 */

/* ===================================================================
   TAB CONTAINER
   =================================================================== */

.connected-tabs {
  position: relative;
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  margin-bottom: 2rem;
  padding: 0 1rem;
}

/* ===================================================================
   TAB ITEMS (BOOKMARKS)
   =================================================================== */

.tab-item {
  position: relative;
  padding: 1rem 2rem;
  background: var(--glass-bg, rgba(255, 255, 255, 0.05));
  border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  color: var(--text-color, #fdf6e3);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 1;
  user-select: none;
}

/* Tab emoji/icon */
.tab-item .tab-icon {
  margin-right: 0.5rem;
  font-size: 1.25em;
}

/* Tab hover effect (lift like lifting a bookmark) */
.tab-item:hover {
  background: var(--glass-hover, rgba(255, 255, 255, 0.08));
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Tab focus (keyboard navigation) */
.tab-item:focus-visible {
  outline: 2px solid var(--gold, #ffa500);
  outline-offset: 4px;
}

/* Active tab (currently selected bookmark) */
.tab-item.active {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.1);
  border-color: var(--dice, #ff6b35);
  transform: translateY(-2px);
  z-index: 2;
  box-shadow: 0 0 20px rgba(var(--dice-rgb, 255, 107, 53), 0.3);
}

/* Active tab connection line to content */
.tab-item.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.2);
  z-index: 3;
  box-shadow: 0 0 10px rgba(var(--dice-rgb, 255, 107, 53), 0.4);
}

/* Disabled tab */
.tab-item[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===================================================================
   TAB CONTENT PANEL
   =================================================================== */

.tab-content {
  position: relative;
  padding: 2rem;
  background: var(--glass-bg, rgba(255, 255, 255, 0.05));
  border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-radius: 0 12px 12px 12px;
  margin-top: -2px; /* Overlap with tab border for connection */
  min-height: 200px;
}

/* Content panel connected to active tab (visual flow) */
.tab-content::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.1) 10%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.1) 90%,
    transparent 100%
  );
  z-index: 0;
}

/* Content panel with animation on switch */
.tab-content.switching {
  animation: pageFlip 0.3s ease-out;
}

/* Page flip animation (like turning a page in a book) */
@keyframes pageFlip {
  0% {
    opacity: 0;
    transform: perspective(800px) rotateY(-15deg);
  }
  100% {
    opacity: 1;
    transform: perspective(800px) rotateY(0deg);
  }
}

/* Accessibility: Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .tab-item,
  .tab-content {
    transition: none;
  }

  .tab-item:hover {
    transform: none;
  }

  .tab-item.active {
    transform: none;
  }

  .tab-content.switching {
    animation: none;
  }
}

/* ===================================================================
   RESPONSIVE DESIGN
   =================================================================== */

/* Tablets (768px and below) */
@media (max-width: 768px) {
  .connected-tabs {
    gap: 0.25rem;
    padding: 0 0.5rem;
  }

  .tab-item {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }

  .tab-content {
    padding: 1.5rem;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  .connected-tabs {
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: none;
    margin-bottom: 1rem;
  }

  .tab-item {
    flex: 1 1 calc(50% - 0.5rem);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    text-align: center;
    border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
  }

  .tab-item .tab-icon {
    display: block;
    margin: 0 auto 0.25rem;
  }

  .tab-item:hover {
    transform: scale(1.05);
  }

  .tab-item.active {
    transform: scale(1.05);
  }

  .tab-item.active::after {
    display: none;
  }

  .tab-content {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0;
  }

  .tab-content::before {
    display: none;
  }
}

/* ===================================================================
   INTEGRATION WITH SELECTION-COMPONENT
   =================================================================== */

/* When using SelectionComponent in tab mode */
.selection-component[data-mode="tab"] .selection-option {
  /* Inherit tab-item styles */
  position: relative;
  padding: 1rem 2rem;
  background: var(--glass-bg, rgba(255, 255, 255, 0.05));
  border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  transition: all 0.2s ease;
}

.selection-component[data-mode="tab"] .selection-option:hover {
  background: var(--glass-hover, rgba(255, 255, 255, 0.08));
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.selection-component[data-mode="tab"] .selection-option.selected {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.1);
  border-color: var(--dice, #ff6b35);
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(var(--dice-rgb, 255, 107, 53), 0.3);
}

/* Connection line for selected tab */
.selection-component[data-mode="tab"] .selection-option.selected::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.2);
  box-shadow: 0 0 10px rgba(var(--dice-rgb, 255, 107, 53), 0.4);
}

/* Responsive for SelectionComponent tabs */
@media (max-width: 480px) {
  .selection-component[data-mode="tab"] .selection-option {
    border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
  }

  .selection-component[data-mode="tab"] .selection-option.selected::after {
    display: none;
  }
}

/* ===================================================================
   THEME SUPPORT
   =================================================================== */

/* Tome of Tales themes can override these variables:
   --glass-bg
   --glass-border
   --glass-hover
   --dice
   --dice-rgb
   --text-color
   --gold
*/
