/* ============================================================================
   Deck Switcher — design "1a": Framed deck-plate → bottom-sheet grid.
   Renders into every [data-deck-switch] mount (the reading-board deck label).
   All strings come from js/common.js i18n; markup is built in js/deck-switcher.js.
   Self-contained: does NOT touch css/styles.css. Colours mirror the app tokens
   (plum #3D1A5C, gold #d49a2c / #c08327) with hard fallbacks so it renders even
   before theme-tokens.css loads.
   ========================================================================== */

/* Mount: centre the inline plate no matter which board hosts it. min-width:0 lets
   the flex/grid column the plate lives in shrink so a wide plate never pushes the
   neighbouring streak chip off-screen. */
[data-deck-switch] {
  text-align: center;
  line-height: 1;
  min-width: 0;
}

/* ---- The plate button ---------------------------------------------------- */
.mt-ds-plate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 7px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(212, 154, 44, 0.5);
  border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 8px 20px -10px rgba(61, 26, 92, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.mt-ds-plate:active { transform: scale(0.97); }

.mt-ds-plate__preview {
  position: relative;
  width: 26px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 9px -3px rgba(61, 26, 92, 0.55),
              inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.mt-ds-plate__preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mt-ds-plate__preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.4), transparent 55%);
}

.mt-ds-plate__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  line-height: 1;
}
.mt-ds-plate__label {
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mt-gold-deep, #c08327);
}
.mt-ds-plate__name {
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--mt-plum, #3d1a5c);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mt-ds-plate__caret {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #f3d98c, #d49a2c);
  box-shadow: 0 3px 7px -2px rgba(192, 131, 39, 0.7);
}
.mt-ds-plate__caret svg { display: block; }

/* ---- Bottom sheet -------------------------------------------------------- */
.mt-ds-overlay {
  position: fixed;
  inset: 0;
  z-index: 1310;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mt-ds-scrim {
  position: absolute;
  inset: 0;
  background: rgba(28, 12, 52, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.mt-ds-overlay.in .mt-ds-scrim { opacity: 1; }

.mt-ds-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fbf6ff, #f3ecfc);
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(26px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(28, 12, 52, 0.3);
  transform: translateY(22px);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.26s ease;
}
.mt-ds-overlay.in .mt-ds-sheet { transform: none; opacity: 1; }

.mt-ds-grabber {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: rgba(61, 26, 92, 0.18);
  margin: 0 auto 14px;
  flex: 0 0 auto;
}

.mt-ds-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2px;
  flex: 0 0 auto;
}
.mt-ds-title {
  margin: 0;
  font-family: var(--mt-font-display, "Playfair Display", serif);
  font-style: italic;
  font-weight: 600;
  font-size: 21px;
  color: var(--mt-plum, #3d1a5c);
}
.mt-ds-close {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: rgba(61, 26, 92, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mt-ds-close svg { display: block; }

.mt-ds-hint {
  margin: 0 0 16px;
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 12px;
  font-weight: 500;
  color: #8b6db0;
  flex: 0 0 auto;
}

.mt-ds-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

/* ---- A deck cell --------------------------------------------------------- */
.mt-ds-cell {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

.mt-ds-cell__art {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 9px 18px -8px rgba(61, 26, 92, 0.5);
}
.mt-ds-cell__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mt-ds-cell__art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.35), transparent 50%);
}

/* Active = gold border + "Active" badge */
.mt-ds-cell.is-active .mt-ds-cell__art {
  box-shadow: 0 9px 18px -8px rgba(201, 147, 58, 0.6);
}
.mt-ds-cell.is-active .mt-ds-cell__art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2.5px solid #d49a2c;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}
.mt-ds-cell__badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  background: var(--mt-plum, #3d1a5c);
  color: #fff;
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Locked = dark overlay + lock icon + "Unlock · day N" note */
.mt-ds-cell.is-locked { cursor: default; }
.mt-ds-cell__lock {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(40, 20, 64, 0.5);
}
.mt-ds-cell__lock svg { display: block; }

.mt-ds-cell__name {
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  color: var(--mt-plum, #3d1a5c);
  text-align: center;
  line-height: 1.2;
}
.mt-ds-cell__note {
  font-family: var(--mt-font-body, "Inter", system-ui, sans-serif);
  font-size: 9.5px;
  font-weight: 600;
  color: #a487c4;
  text-align: center;
  line-height: 1.2;
  margin-top: -3px;
}

/* Locked-tap feedback: a subtle shake (no switch happens). */
.mt-ds-cell.is-shake { animation: mtDsShake 0.36s ease; }
@keyframes mtDsShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .mt-ds-scrim,
  .mt-ds-sheet { transition: none; }
  .mt-ds-cell.is-shake { animation: none; }
}
