/* ===== Theme Button ===== */
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  transition: transform var(--anim-fast) var(--ease), background var(--anim-fast) var(--ease), border-color var(--anim-fast) var(--ease);
}

.theme-btn:hover {
  transform: translateY(-1px);
  background: var(--hover-bg);
  border-color: var(--muted);
}

.theme-btn:active {
  transform: translateY(0);
}

.theme-btn-icon {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background-image: linear-gradient(135deg, var(--primary) 50%, var(--accent) 50%);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

[data-theme="avenged-sevenfold"] .theme-btn-icon {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  background-image: url("../assets/images/avenged-sevenfold-logo.jpeg");
  background-size: 400%;
  background-position: center;
}

/* ===== Theme Overlay ===== */
.theme-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.theme-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* ===== Theme Modal ===== */
.theme-modal {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow), 0 0 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.theme-overlay.open .theme-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.theme-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.theme-modal-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text);
}

.theme-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--anim-fast) var(--ease), color var(--anim-fast) var(--ease), border-color var(--anim-fast) var(--ease);
}

.theme-modal-close:hover {
  background: var(--hover-bg);
  color: var(--text);
  border-color: var(--hover-border);
}

.theme-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  color: var(--text);
  transition: background var(--anim-fast) var(--ease), border-color var(--anim-fast) var(--ease), transform var(--anim-fast) var(--ease), box-shadow var(--anim-fast) var(--ease);
  border-radius: var(--radius2);
}

.theme-option:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.theme-option.is-active {
  border-color: var(--primary);
  background: var(--hover-bg);
  box-shadow: 0 0 16px var(--glow-color);
}

/* Theme Preview Swatch */
.theme-preview {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius2) - 4px);
  position: relative;
  overflow: hidden;
}

.theme-preview-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 75%;
  height: 34px;
  border: 1px solid;
  border-radius: calc(var(--radius2) - 6px);
  background: var(--card);
}

.theme-preview-dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.theme-preview-bar {
  display: block;
  width: 36px;
  height: 5px;
  border-radius: 3px;
  opacity: 0.6;
}

.theme-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.theme-info-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.theme-icon {
  font-size: 14px;
  line-height: 1;
}

.theme-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

.theme-desc {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}


/* ===== Theme Personality Effects ===== */

/* Glassmorphism cards */
.card, .article, .panel-soft, .modal-card, .linkbtn {
  background: var(--glass-bg, var(--white-002));
  backdrop-filter: blur(var(--glass-blur, 0px));
  -webkit-backdrop-filter: blur(var(--glass-blur, 0px));
}

/* Glow effects */
.card:hover, .article:hover {
  box-shadow: var(--card-shadow);
}

/* Hover lift */
.card, .article, .btn, .linkbtn, .theme-btn, .langBtn, .menuBtn {
  transition: transform var(--anim-fast) var(--ease-spring), background var(--anim-fast) var(--ease), border-color var(--anim-fast) var(--ease), box-shadow var(--anim-fast) var(--ease);
}

.card:hover, .article:hover {
  transform: translateY(var(--hover-lift));
}

/* ===== Terminal Theme Specific ===== */
[data-theme="terminal"] .card,
[data-theme="terminal"] .article,
[data-theme="terminal"] .panel-soft {
  border: 1px solid var(--line);
  box-shadow: none !important;
  backdrop-filter: none !important;
}

[data-theme="terminal"] .card:hover,
[data-theme="terminal"] .article:hover {
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(0,255,65,0.15) !important;
}

[data-theme="terminal"] .topbar {
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

[data-theme="terminal"] .nav a[aria-current="page"] {
  text-shadow: 0 0 8px rgba(0,255,65,0.4);
}

/* ===== Cloud Theme Specific ===== */
[data-theme="cloud"] .card,
[data-theme="cloud"] .article {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
}

[data-theme="cloud"] .panel-soft {
  background: var(--card);
}

[data-theme="cloud"] .topbar {
  border-bottom: 1px solid var(--line);
}

/* ===== Avenged Sevenfold Theme Specific ===== */
[data-theme="avenged-sevenfold"] {
  /* Cinematic atmosphere via subtle overlay on bg-layer */
}

/* Dark vignette overlay for readability — sits behind content */
[data-theme="avenged-sevenfold"] .bg-layer::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(5,5,5,0.4) 100%);
  pointer-events: none;
}

/* Cards — monochrome dark glass */
[data-theme="avenged-sevenfold"] .card,
[data-theme="avenged-sevenfold"] .article {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(12,12,12,0.88);
  backdrop-filter: blur(4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: transform 0.45s var(--ease-spring), background 0.45s var(--ease), border-color 0.45s var(--ease), box-shadow 0.45s var(--ease);
}

[data-theme="avenged-sevenfold"] .card:hover,
[data-theme="avenged-sevenfold"] .article:hover {
  transform: translateY(var(--hover-lift));
  border-color: rgba(255,255,255,0.18);
  background: rgba(10,10,10,0.94);
  box-shadow: 0 15px 50px rgba(0,0,0,0.55);
}

/* Topbar */
[data-theme="avenged-sevenfold"] .topbar {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 30px rgba(0,0,0,0.5);
}

/* Navigation active */
[data-theme="avenged-sevenfold"] .nav a[aria-current="page"] {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(255,255,255,0.15);
}

/* Section headings */
[data-theme="avenged-sevenfold"] .section.active .panelHead h3 {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(255,255,255,0.08);
}

/* Buttons */
[data-theme="avenged-sevenfold"] .btn {
  border-color: rgba(255,255,255,0.12);
  background: rgba(10,10,10,0.7);
  color: var(--text);
}

[data-theme="avenged-sevenfold"] .btn:hover {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

/* Links */
[data-theme="avenged-sevenfold"] .linkbtn {
  border-color: rgba(255,255,255,0.10);
}

[data-theme="avenged-sevenfold"] .linkbtn:hover {
  border-color: rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.04);
}

/* Modal */
[data-theme="avenged-sevenfold"] .modal {
  border-color: rgba(255,255,255,0.10);
  background: #0A0A0A;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7);
}

/* Tags */
[data-theme="avenged-sevenfold"] .tag {
  border-color: rgba(255,255,255,0.10);
  background: rgba(10,10,10,0.6);
}

/* Search input */
[data-theme="avenged-sevenfold"] .search input {
  border-color: rgba(255,255,255,0.10);
  background: rgba(10,10,10,0.7);
  color: var(--text);
}

[data-theme="avenged-sevenfold"] .search input::placeholder {
  color: var(--muted);
}

[data-theme="avenged-sevenfold"] .search input:focus {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.10);
}

/* Panel soft background */
[data-theme="avenged-sevenfold"] .panel-soft {
  background: rgba(10,10,10,0.5);
}

/* ===== Aurora Theme Specific ===== */
[data-theme="aurora"] .card:hover,
[data-theme="aurora"] .article:hover {
  box-shadow: var(--card-shadow), 0 0 20px rgba(167,139,250,0.1);
}

[data-theme="aurora"] .card,
[data-theme="aurora"] .article {
  border: 1px solid var(--line);
}

/* ===== Ember Theme Specific ===== */
[data-theme="ember"] .card:hover,
[data-theme="ember"] .article:hover {
  transform: translateY(calc(var(--hover-lift) * 1.2));
  box-shadow: var(--card-shadow), 0 0 15px rgba(251,146,60,0.08);
}

/* ===== Cosmos Theme Specific ===== */
[data-theme="cosmos"] .card,
[data-theme="cosmos"] .article {
  background: var(--glass-bg, var(--white-002));
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .theme-modal {
    max-width: 500px;
  }

  .theme-modal-body {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .theme-preview {
    height: 64px;
  }

  .theme-modal-head {
    padding: 16px 20px;
  }

  .theme-modal-body {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .theme-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .theme-modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius2) var(--radius2) 0 0;
  }

  .theme-modal-body {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px;
  }

  .theme-option {
    padding: 8px 6px;
  }

  .theme-preview {
    height: 56px;
  }

  .theme-modal-head {
    padding: 14px 16px;
  }
}

@media (max-width: 360px) {
  .theme-modal-body {
    grid-template-columns: 1fr;
  }

  .theme-preview {
    height: 72px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .bg-layer, .bg-glow, .bg-orb {
    opacity: 0 !important;
    display: none !important;
  }

  [data-theme="avenged-sevenfold"] .bg-layer::after,
  #bgWatermark {
    opacity: 0 !important;
    display: none !important;
  }

  .theme-overlay,
  .theme-modal {
    transition: none !important;
  }

  .card, .article, .btn, .linkbtn, .theme-btn, .langBtn, .menuBtn {
    transition: none !important;
  }

  .card:hover, .article:hover {
    transform: none !important;
  }

  #terminalRefresh {
    display: none !important;
  }
}
