/**
 * PRISM Custom Styles
 * Only for things Web Awesome doesn't handle
 */

/* ============================================================================
   Sync Status Indicator
   ============================================================================ */

.sync-status-indicator {
  font-size: var(--wa-font-size-s);
  color: var(--wa-color-neutral-text-subtle);
  white-space: nowrap;
}

.sync-status-indicator.sync-status-ok {
  color: var(--wa-color-success-text);
}

.sync-status-indicator.sync-status-failed {
  color: var(--wa-color-warning-text);
  font-weight: 600;
}

/* ============================================================================
   Mobile Navigation Toggle
   ============================================================================ */

wa-page[view='desktop'] [data-toggle-nav] {
  display: none;
}

/* ============================================================================
   Color Swatches (for deck color selection)
   ============================================================================ */

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--wa-border-radius-s);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  border-color: var(--wa-color-brand-fill);
  box-shadow: 0 0 0 2px var(--wa-color-brand-fill-subtle);
}

/* ============================================================================
   Deck Color Indicators
   ============================================================================ */

.deck-color-indicator {
  width: 24px;
  height: 24px;
  border-radius: var(--wa-border-radius-s);
  border: 1px solid var(--wa-color-neutral-stroke);
  flex-shrink: 0;
}

.deck-color-indicator.small {
  width: 18px;
  height: 18px;
}

/* ============================================================================
   Results Table
   ============================================================================ */

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--wa-font-size-m);
}

.results-table th,
.results-table td {
  padding: var(--wa-space-s) var(--wa-space-m);
  text-align: left;
  border-bottom: 1px solid var(--wa-color-surface-border);
}

.results-table th {
  background: var(--wa-color-surface-2);
  font-weight: 600;
  white-space: nowrap;
}

.results-table tbody tr:hover {
  background: var(--wa-color-surface-2);
}

.results-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.results-table tbody tr:nth-child(even):hover {
  background: var(--wa-color-surface-2);
}

.results-table .shared-row {
  background: var(--wa-color-warning-surface-subtle);
}

.results-table .shared-row:hover {
  background: var(--wa-color-warning-surface);
}

.results-table .mark-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--wa-color-brand-fill);
}

.results-table .marked-row {
  opacity: 0.45;
}

.results-table .marked-row td:first-child {
  text-decoration: line-through;
}

.results-table .basic-land {
  font-style: italic;
}

.results-table .basic-tag {
  color: var(--wa-color-neutral-text-subtle);
  font-size: var(--wa-font-size-s);
}

/* ============================================================================
   Stripe Indicators (in results table)
   ============================================================================ */

.stripe-indicators {
  display: flex;
  gap: var(--wa-space-2xs);
  flex-wrap: wrap;
}

.stripe-indicator {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: var(--wa-border-radius-s);
  border: 1px solid var(--wa-color-neutral-stroke);
}

/* Counting-aid slot number overlaid on an anchor stripe (every 5th slot/side) */
.stripe-pos-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
  pointer-events: none;
}

/* On empty/unfilled anchor slots there is no colored fill — use neutral text */
.stripe-pos-num.stripe-pos-num-muted {
  color: var(--wa-color-neutral-text);
  text-shadow: none;
}

.stripe-empty {
  background-color: transparent;
  border: 1px dashed var(--wa-color-surface-border);
}

/* ============================================================================
   Stripe Position List Items
   ============================================================================ */

.position-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wa-space-s);
  padding: var(--wa-space-s) var(--wa-space-m);
  background: var(--wa-color-surface-2);
  border-radius: var(--wa-border-radius-m);
  border: 1px solid var(--wa-color-surface-border);
}

.position-item-info {
  flex: 1;
  min-width: 0;
}

.position-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-item-controls {
  flex-shrink: 0;
}

.position-select {
  width: 160px;
}

@media (max-width: 768px) {
  .position-item {
    flex-wrap: wrap;
  }
  .position-item-controls {
    width: 100%;
    justify-content: flex-end;
  }
  .position-select {
    flex: 1;
    min-width: 0;
    width: auto;
  }
}

/* ============================================================================
   Dark Mode Overrides
   ============================================================================ */

.wa-dark .color-swatch {
  border-color: transparent;
}

.wa-dark .color-swatch.selected {
  border-color: var(--wa-color-brand-fill);
}

/* Theme-aware logo swap: -Invert (white facets) for dark, -Main (dark facets) for light */
.theme-logo-dark { display: none; }
.wa-dark .theme-logo-dark { display: inline-block; }
.wa-dark .theme-logo-light { display: none; }

/* Ensure white swatches stay visible against the surface in both themes */
.color-swatch[data-color="#FFFFFF" i],
.deck-color-indicator[style*="#FFFFFF" i],
.stripe-indicator[style*="#FFFFFF" i] {
  border-color: var(--wa-color-neutral-stroke);
}

/* ============================================================================
   Loading Skeletons
   ============================================================================ */

/* Card-shaped placeholder approximating a rendered deck card */
.skeleton-deck-card {
  display: flex;
  flex-direction: column;
  gap: var(--wa-space-m);
  padding: var(--wa-space-l);
  border: 1px solid var(--wa-color-surface-border);
  border-radius: var(--wa-border-radius-l);
  background: var(--wa-color-surface-default);
}

.skeleton-line-title {
  width: 40%;
  height: 1.5rem;
}

.skeleton-line {
  width: 90%;
  height: 1rem;
}

.skeleton-line-short {
  width: 60%;
  height: 1rem;
}

/* Matches the height of the outlined nav auth button it stands in for */
.nav-auth-skeleton {
  width: 100%;
  height: 2.5rem;
}

/* Second bar when a stored session exists — stands in for the small plain
   Log Out button below the Profile button */
.nav-auth-skeleton-secondary {
  width: 100%;
  height: 2.5rem;
}

.nav-auth-skeleton::part(indicator),
.skeleton-avatar::part(indicator) {
  border-radius: var(--wa-border-radius-m);
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
}

/* ============================================================================
   Deck Cards
   ============================================================================ */

.deck-card {
  transition: box-shadow 0.15s ease;
}

.deck-card:hover {
  box-shadow: var(--wa-shadow-m);
}

/* Deck action buttons: inline cluster on desktop, kebab dropdown on mobile */
.deck-actions-kebab {
  display: none;
}

.deck-actions-kebab-menu {
  min-width: 12rem;
  padding: var(--wa-space-2xs);
}

.deck-actions-kebab-menu .kebab-item::part(base) {
  width: 100%;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .deck-actions-inline {
    display: none;
  }
  .deck-actions-kebab {
    display: inline-flex;
  }
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 768px) {
  /* Tighten main content gutters on mobile (WA default padding is desktop-sized) */
  wa-page > main {
    padding-inline: var(--wa-space-s);
  }
}

@media (max-width: 600px) {
  .results-table th,
  .results-table td {
    padding: var(--wa-space-xs) var(--wa-space-s);
    font-size: var(--wa-font-size-s);
  }

  .stripe-indicator {
    width: 14px;
    height: 14px;
  }
}

/* Toast styles handled by <wa-toast> component */

/* ============================================================================
   Sortable Table Headers
   ============================================================================ */

.results-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.results-table th.sortable:hover {
  background: var(--wa-color-surface-3);
}

.results-table th .sort-icon {
  margin-left: var(--wa-space-2xs);
  opacity: 0.4;
  font-size: 0.85em;
}

.results-table th.sorted .sort-icon {
  opacity: 1;
}

/* ============================================================================
   Deck Filter Dropdown
   ============================================================================ */

/* Deck filter menu mirrors the deck-actions kebab menu styling */
.deck-filter-menu {
  min-width: 14rem;
  padding: var(--wa-space-2xs);
}

.deck-filter-menu wa-button::part(base) {
  width: 100%;
  justify-content: flex-start;
}

.deck-filter-menu wa-divider {
  margin: var(--wa-space-2xs) 0;
}

.deck-filter-menu .deck-color-indicator {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  margin-inline-end: var(--wa-space-2xs);
}

/* ============================================================================
   Removed Cards View
   ============================================================================ */

.results-table .removed-row {
  background: var(--wa-color-danger-surface-subtle);
}

.results-table .removed-row:hover {
  background: var(--wa-color-danger-surface);
}

.btn-clear-all-removed {
  background: none;
  border: 1px solid var(--wa-color-surface-border);
  border-radius: var(--wa-border-radius-medium);
  color: var(--wa-color-neutral-text);
  font-size: var(--wa-font-size-x-small);
  padding: var(--wa-space-2x-small) var(--wa-space-x-small);
  cursor: pointer;
  white-space: nowrap;
}

.btn-clear-all-removed:hover {
  background: var(--wa-color-danger-surface-subtle);
  border-color: var(--wa-color-danger-border);
  color: var(--wa-color-danger-text);
}

.removed-deck-label {
  font-size: var(--wa-font-size-s);
  color: var(--wa-color-danger-text);
}

/* ============================================================================
   Deck Overlap Matrix
   ============================================================================ */

.overlap-matrix-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--wa-font-size-s);
}

.overlap-matrix-table th,
.overlap-matrix-table td {
  padding: var(--wa-space-xs) var(--wa-space-s);
  text-align: center;
  border: 1px solid var(--wa-color-surface-border);
  white-space: nowrap;
}

.overlap-matrix-table thead th {
  background: var(--wa-color-surface-raised);
  font-weight: var(--wa-font-weight-semibold);
  position: sticky;
  top: 0;
  z-index: 2;
}

.overlap-matrix-table tbody th {
  background: var(--wa-color-surface-raised);
  font-weight: var(--wa-font-weight-semibold);
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
}

.overlap-matrix-table thead th:first-child {
  z-index: 3;
}

.overlap-cell {
  min-width: 48px;
  transition: background 0.15s ease;
}

.overlap-cell.overlap-self {
  background: var(--wa-color-surface-3);
}

.overlap-cell.overlap-has-value {
  font-weight: var(--wa-font-weight-semibold);
  cursor: default;
}

.overlap-header {
  display: flex;
  align-items: center;
  gap: var(--wa-space-2xs);
}

.deck-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================================
   What-If Analysis
   ============================================================================ */

.what-if-panel {
  margin-top: var(--wa-space-m);
  padding: var(--wa-space-m);
  background: var(--wa-color-surface-2);
  border-radius: var(--wa-border-radius-m);
  border: 1px solid var(--wa-color-surface-border);
}

.what-if-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--wa-space-s);
  margin-bottom: var(--wa-space-m);
}

.what-if-stat {
  text-align: center;
  padding: var(--wa-space-s);
  background: var(--wa-color-surface-1);
  border-radius: var(--wa-border-radius-s);
}

.what-if-stat .stat-value {
  font-size: var(--wa-font-size-xl);
  font-weight: var(--wa-font-weight-bold);
}

.what-if-stat .stat-label {
  font-size: var(--wa-font-size-s);
  color: var(--wa-color-neutral-text-subtle);
}

.what-if-card-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.what-if-card-list li {
  padding: var(--wa-space-2xs) 0;
  border-bottom: 1px solid var(--wa-color-surface-border);
  font-size: var(--wa-font-size-s);
}

.what-if-card-list li:last-child {
  border-bottom: none;
}

/* ============================================================================
   Card Preview Tooltip
   ============================================================================ */

.card-preview-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--wa-color-surface-1);
  border: 1px solid var(--wa-color-neutral-stroke);
  border-radius: var(--wa-border-radius-m);
  box-shadow: var(--wa-shadow-xl);
  padding: var(--wa-space-xs);
}

.card-preview-tooltip[hidden] {
  display: none;
}

.card-preview-container {
  position: relative;
  width: 244px;
  height: 340px;
}

.card-preview-loading,
.card-preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--wa-color-surface-2);
  border-radius: var(--wa-border-radius-s);
}

.card-preview-image {
  width: 100%;
  height: 100%;
  border-radius: var(--wa-border-radius-s);
  object-fit: cover;
}

.card-preview-stripes {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stripe-mark {
  position: absolute;
  right: 0px;
  width: 24px;
  height: 5px;
  border-radius: 2px;
  box-shadow: 0 0 3px rgba(1,1,1, .8);
}

.stripe-mark-left {
  right: auto;
  left: 0px;
}

/* Counting-aid slot number beside a card-preview stripe */
.stripe-mark-num {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 3px #000;
  pointer-events: none;
}

.stripe-dot-mark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(1,1,1, .8);
}

.stripe-dot-mark-right {
  right: auto;
}

/* Reference ruler — faint tick + number at every 5th slot down a card edge,
   drawn even on empty slots so any lone stripe can be located by eye. */
.stripe-ruler-tick {
  position: absolute;
  right: 0px;
  width: 10px;
  height: 1px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

.stripe-ruler-tick-left {
  right: auto;
  left: 0px;
}

.stripe-ruler-num {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 2px #000, 0 0 3px #000;
  pointer-events: none;
}

/* Card name hover cursor */
.card-name-cell {
  cursor: pointer;
}

.card-name-cell:hover {
  text-decoration: underline;
  text-decoration-style: dotted;
}

/* ============================================================================
   Split Groups & Side A/B Indicators
   ============================================================================ */

.split-group-card {
  border: 1px solid var(--wa-color-brand-stroke-subtle);
}

.split-group-header {
  padding-bottom: var(--wa-space-s);
  border-bottom: 1px solid var(--wa-color-surface-border);
  margin-bottom: var(--wa-space-s);
}

.split-children {
  display: flex;
  flex-direction: column;
  gap: var(--wa-space-s);
  padding-left: var(--wa-space-m);
  border-left: 2px solid var(--wa-color-brand-stroke-subtle);
}

.split-child-card {
  padding: var(--wa-space-s);
  background: var(--wa-color-surface-2);
  border-radius: var(--wa-border-radius-s);
}

/* Side B stripe indicators - dashed border to distinguish from Side A */
.stripe-indicator.stripe-side-b {
  border-style: dashed;
  border-width: 2px;
}

/* ö-style slot: dot row above square in results table */
.stripe-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.slot-dot-row {
  display: flex;
  gap: 2px;
  min-height: 10px;
  align-items: center;
  justify-content: center;
}

/* Dot variant indicators in results table */
.stripe-indicator.stripe-dot-indicator {
  border-radius: 50%;
  width: 10px;
  height: 10px;
  align-self: center;
  border: 1px solid var(--wa-color-neutral-stroke);
  flex-shrink: 0;
}

/* Printable guide Side B dots */
.stripe-dot.stripe-side-b {
  border-style: dashed;
}

/* ============================================================================
   Stripe Reorder Dialog
   ============================================================================ */

.stripe-reorder-sleeve-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--wa-space-xs);
}

.stripe-reorder-sleeve {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 480px;
  min-height: 320px;
  border: 2px solid var(--wa-color-neutral-stroke);
  border-radius: 12px;
  background: var(--wa-color-surface-1);
  overflow: hidden;
}

.stripe-reorder-edge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: var(--wa-color-surface-3);
  flex-shrink: 0;
}

.stripe-reorder-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wa-color-surface-2);
}

.stripe-reorder-card-hint {
  text-align: center;
  color: var(--wa-color-neutral-text-subtle);
  padding: var(--wa-space-m);
  font-size: var(--wa-font-size-s);
}

.stripe-reorder-slot {
  width: 28px;
  height: 10px;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  position: relative;
}

/* Invisible tap-area extension. The 24-slot column is a to-scale sleeve edge,
   so slots can't be 44px tall — instead each slot's hit area bleeds sideways
   and into the 2px gaps so fingers get a much larger effective target. */
.stripe-reorder-slot::after {
  content: '';
  position: absolute;
  inset: -1px -10px;
}

.stripe-reorder-slot--empty {
  background: transparent;
  border: 1.5px dashed var(--wa-color-neutral-40);
}

.stripe-reorder-slot--occupied {
  border: 1.5px solid;
}

.stripe-reorder-slot--active {
  border: 2px solid var(--wa-color-success-70);
  box-shadow: 0 0 0 2px var(--wa-color-success-70);
}

.stripe-reorder-slot--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Hover state — only on non-active, non-disabled slots */
.stripe-reorder-slot--empty:hover,
.stripe-reorder-slot--occupied:hover {
  border-color: var(--wa-color-warning-70) !important;
  box-shadow: 0 0 0 2px var(--wa-color-warning-70);
}

/* Touch active state (no hover on mobile) */
.stripe-reorder-slot--empty:active,
.stripe-reorder-slot--occupied:active {
  border-color: var(--wa-color-warning-70) !important;
  box-shadow: 0 0 0 2px var(--wa-color-warning-70);
}

.stripe-reorder-edge-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0 4px;
  color: var(--wa-color-neutral-text-subtle);
}

.stripe-reorder-swap-confirm {
  padding: var(--wa-space-s) var(--wa-space-m);
  background: var(--wa-color-warning-surface);
  border: 1px solid var(--wa-color-warning-stroke-subtle);
  border-radius: var(--wa-border-radius-m);
}

.stripe-reorder-legend {
  padding: var(--wa-space-s) var(--wa-space-m);
  background: var(--wa-color-surface-2);
  border: 1px solid var(--wa-color-surface-border);
  border-radius: var(--wa-border-radius-m);
}


/* Wider touch targets on mobile */
@media (max-width: 768px) {
  .stripe-reorder-slot {
    width: 44px;
    height: 14px;
  }

  .stripe-reorder-slot::after {
    inset: -1px -14px;
  }

  .stripe-reorder-sleeve {
    min-height: 400px;
  }

  .results-table .mark-checkbox {
    width: 24px;
    height: 24px;
  }
}

/* Mobile: tap a card name to open the preview overlay (no hover on touch) */
@media (max-width: 768px) {
  .card-name-cell {
    cursor: pointer;
  }
}
