/* ============================================================
   Theme Chooser — Self-contained, theme-independent styles
   All values hardcoded (no CSS variable dependencies)
   ============================================================ */

/* ── Toggle Button ── */
.tc-toggle {
  position: fixed;
  bottom: 88px;
  right: 32px;
  z-index: 100;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a2a3e 0%, #1e1e30 100%);
  color: #f5f5f5;
  border: 2px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(255, 255, 255, 0);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
  opacity: 0;
  animation: tc-fade-in 400ms ease 1s forwards;
  -webkit-tap-highlight-color: transparent;
}

.tc-toggle svg {
  width: 22px;
  height: 22px;
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tc-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.25);
}

.tc-toggle:hover svg {
  transform: rotate(-15deg) scale(1.05);
}

.tc-toggle:focus-visible {
  outline: 2px solid #5DADE2;
  outline-offset: 3px;
}

.tc-toggle.is-active {
  border-color: rgba(255, 255, 255, 0.3);
  background: linear-gradient(135deg, #3a3a52 0%, #2a2a42 100%);
}

@keyframes tc-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panel ── */
.tc-panel {
  position: fixed;
  bottom: 144px;
  right: 32px;
  z-index: 100;
  width: 340px;
  background: linear-gradient(180deg, #222236 0%, #1a1a2c 100%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.tc-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: opacity 250ms ease, transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Panel Header ── */
.tc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tc-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0;
  line-height: 1;
}

.tc-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, color 150ms ease;
  padding: 0;
}

.tc-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
}

.tc-close:focus-visible {
  outline: 2px solid #5DADE2;
  outline-offset: 2px;
}

.tc-close svg {
  width: 14px;
  height: 14px;
}

/* ── Theme Grid ── */
.tc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 8px 12px 12px;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.tc-grid::-webkit-scrollbar { width: 4px; }
.tc-grid::-webkit-scrollbar-track { background: transparent; }
.tc-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ── Theme Item ── */
.tc-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
  text-align: left;
  width: 100%;
  font-size: inherit;
  line-height: inherit;
  -webkit-tap-highlight-color: transparent;
}

.tc-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.tc-item:active {
  transform: scale(0.98);
}

.tc-item:focus-visible {
  outline: 2px solid #5DADE2;
  outline-offset: -2px;
  border-radius: 10px;
}

.tc-item[aria-checked="true"] {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

/* ── Swatch ── */
.tc-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tc-swatch-dark,
.tc-swatch-accent {
  width: 50%;
  height: 100%;
}

/* ── Name & Font Preview ── */
.tc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tc-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.tc-font-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.tc-font-preview {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
  line-height: 1;
  width: 32px;
  text-align: center;
}

/* ── Active Checkmark ── */
.tc-check {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4CAF50;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.tc-check svg {
  width: 10px;
  height: 10px;
  color: white;
}

.tc-item[aria-checked="true"] .tc-check {
  display: flex;
}

/* ── Responsive ── */
@media (max-width: 639px) {
  .tc-toggle {
    right: 2rem;
    bottom: 88px;
  }

  .tc-panel {
    right: 12px;
    left: 12px;
    bottom: 144px;
    width: auto;
    max-height: 60vh;
  }

  .tc-grid {
    max-height: calc(60vh - 60px);
  }
}

/* ── Print: hide everything ── */
@media print {
  .tc-toggle,
  .tc-panel {
    display: none !important;
  }
}
