/* ═══════════════════════════════════════════════════════════ */
/* SSIA VANGUARD CHRONICLES - CHARACTER PAGE V3              */
/* Full Updated CSS For New HTML Structure                   */
/* Responsive + Modal + Loader + Hero                        */
/* ═══════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────── */
/* PAGE FOUNDATION                                            */
/* ────────────────────────────────────────────────────────── */

body {
  overflow-x: hidden;
}

/* SECTION WRAPPER */

.section-wrapper {
  position: relative;
  z-index: 2;
}

.characters-section {
  max-width: 1500px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

/* ────────────────────────────────────────────────────────── */
/* HERO HEADER                                                 */
/* ────────────────────────────────────────────────────────── */

.characters-header {
  position: relative;
  z-index: 2;

  padding:
    8rem
    1.5rem
    4rem;

  overflow: hidden;

  border-bottom:
    1px solid
    rgba(255,255,255,0.06);
}

/* HERO BACKGROUND EFFECT */

.characters-header::before {
  content: "";

  position: absolute;
  inset: 0;

  background:
    radial-gradient(
      circle at top,
      rgba(0,255,153,0.14),
      transparent 55%
    );

  pointer-events: none;
}

.characters-header::after {
  content: "";

  position: absolute;

  width: 500px;
  height: 500px;

  top: -250px;
  right: -120px;

  background:
    radial-gradient(
      circle,
      rgba(0,255,153,0.12),
      transparent 70%
    );

  filter: blur(30px);

  pointer-events: none;
}

/* HEADER CONTENT */

.header-content {
  position: relative;
  z-index: 2;

  max-width: 1200px;
  margin: 0 auto;

  text-align: center;
}

/* BADGE */

.header-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding:
    0.55rem
    1rem;

  margin-bottom: 1.2rem;

  border-radius: 999px;

  background:
    rgba(0,255,153,0.08);

  border:
    1px solid
    rgba(0,255,153,0.18);

  color: var(--accent);

  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 700;

  letter-spacing: 0.16em;
  text-transform: uppercase;

  backdrop-filter: blur(12px);
}

/* TITLE */

.header-title {
  margin: 0;

  font-family: var(--f-head);

  font-size: clamp(2.8rem, 6vw, 5rem);

  font-weight: 900;

  letter-spacing: -0.04em;
  line-height: 0.95;

  text-transform: uppercase;

  color: var(--text);

  text-shadow:
    0 0 20px rgba(0,245,212,0.18);
}

/* SUBTITLE */

.header-subtitle {
  margin-top: 1.2rem;

  color: var(--text-dim);

  font-size: 1rem;
  font-weight: 400;

  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ────────────────────────────────────────────────────────── */
/* TOPBAR                                                      */
/* ────────────────────────────────────────────────────────── */

.characters-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 1rem;

  margin-bottom: 2rem;
}

/* COUNTER */

.character-counter {
  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 200px;

  padding:
    0.9rem
    1.2rem;

  border-radius: 14px;

  background:
    rgba(255,255,255,0.03);

  border:
    1px solid
    rgba(0,255,153,0.2);

  color: var(--accent);

  font-family: var(--f-mono);

  font-size: 0.82rem;
  font-weight: 700;

  letter-spacing: 0.12em;

  backdrop-filter: blur(12px);
}

/* ────────────────────────────────────────────────────────── */
/* SEARCH                                                      */
/* ────────────────────────────────────────────────────────── */

.search-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;

  top: 50%;
  left: 1.1rem;

  transform: translateY(-50%);

  color: var(--text-muted);

  font-size: 1rem;

  pointer-events: none;
}

#character-search {
  width: 100%;

  padding:
    1rem
    1.2rem
    1rem
    3rem;

  border-radius: 14px;

  background:
    rgba(0,255,153,0.03);

  border:
    1px solid
    rgba(0,255,153,0.15);

  color: var(--text);

  font-family: var(--f-ui);
  font-size: 0.9rem;

  outline: none;

  transition: 0.25s ease;

  backdrop-filter: blur(12px);
}

#character-search:focus {
  border-color: rgba(0,255,153,0.4);

  box-shadow:
    0 0 0 4px rgba(0,255,153,0.08);
}

#character-search::placeholder {
  color: var(--text-muted);

  letter-spacing: 0.08em;
}

/* ────────────────────────────────────────────────────────── */
/* GRID                                                        */
/* ────────────────────────────────────────────────────────── */

.characters-grid {
  display: grid;

  grid-template-columns:
    repeat(auto-fit, minmax(320px, 1fr));

  gap: 1.5rem;

  width: 100%;
}

/* ────────────────────────────────────────────────────────── */
/* CHARACTER CARD                                               */
/* ────────────────────────────────────────────────────────── */

.character-card {
  position: relative;

  display: flex;
  flex-direction: column;

  min-height: 100%;

  overflow: hidden;

  border-radius: 24px;

  background:
    linear-gradient(
      180deg,
      rgba(0,255,153,0.04),
      rgba(255,221,0,0.02)
    );

  border:
    1px solid
    rgba(0,255,153,0.15);

  backdrop-filter: blur(14px);

  transition:
    transform 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.character-card:hover {
  transform: translateY(-10px);

  border-color:
    rgba(0,255,153,0.4);

  box-shadow:
    0 20px 50px rgba(0,255,153,0.12);
}

/* RARITY BAR */

.rarity-bar {
  width: 100%;
  height: 4px;
}

.rarity-5 {
  background:
    linear-gradient(
      90deg,
      #ffd166,
      #ff9f1c
    );
}

.rarity-4 {
  background:
    linear-gradient(
      90deg,
      #9b5cff,
      #6c2cff
    );
}

/* CLICKABLE */

.card-clickable {
  cursor: pointer;
}

/* PORTRAIT */

.portrait {
  position: relative;

  height: 340px;

  overflow: hidden;

  background:
    linear-gradient(
      135deg,
      rgba(0,255,153,0.08),
      rgba(255,221,0,0.03)
    );
}

.portrait::after {
  content: "";

  position: absolute;
  inset: 0;

  background:
    linear-gradient(
      to top,
      rgba(0,0,0,0.45),
      transparent
    );

  pointer-events: none;
}

.portrait img {
  width: 100%;
  height: 100%;

  object-fit: cover;

  transition:
    transform 0.45s ease,
    filter 0.45s ease;

  filter:
    saturate(0.95)
    brightness(0.95);
}

.character-card:hover .portrait img {
  transform: scale(1.08);

  filter:
    saturate(1.08)
    brightness(1);
}

/* OVERLAY */

.character-overlay {
  position: absolute;
  inset: 0;

  z-index: 2;

  display: flex;
  align-items: flex-end;
  justify-content: center;

  padding-bottom: 1.5rem;

  opacity: 0;

  transition: 0.3s ease;

  background:
    linear-gradient(
      to top,
      rgba(0,0,0,0.75),
      rgba(0,0,0,0.1)
    );
}

.character-card:hover .character-overlay {
  opacity: 1;
}

.character-overlay span {
  padding:
    0.7rem
    1rem;

  border-radius: 999px;

  background:
    rgba(255,255,255,0.08);

  border:
    1px solid
    rgba(255,255,255,0.12);

  color: white;

  font-size: 0.72rem;
  font-weight: 700;

  letter-spacing: 0.14em;

  backdrop-filter: blur(12px);
}

/* INFO */

.info {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;

  padding: 1.4rem;
}

/* HEADER */

.character-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 1rem;
}

.character-header h2 {
  margin: 0;

  font-size: 1.2rem;
  line-height: 1.15;

  color: var(--text);

  font-family: var(--f-head);
}

.rarity {
  flex-shrink: 0;

  font-size: 0.8rem;
}

/* META */

.character-meta {
  display: flex;
  flex-wrap: wrap;

  gap: 0.5rem;
}

.character-meta span {
  padding:
    0.45rem
    0.75rem;

  border-radius: 999px;

  background:
    rgba(255,255,255,0.04);

  border:
    1px solid
    rgba(255,255,255,0.08);

  font-size: 0.72rem;

  color: var(--text-dim);
}

/* TAGS */

.tag-group {
  display: flex;
  flex-wrap: wrap;

  gap: 0.5rem;
}

.tag {
  padding:
    0.4rem
    0.7rem;

  border-radius: 999px;

  background:
    rgba(0,255,153,0.08);

  border:
    1px solid
    rgba(0,255,153,0.18);

  color: var(--accent);

  font-size: 0.72rem;
  font-weight: 600;
}

/* BIO */

.char-bio {
  color: var(--text-dim);

  font-size: 0.85rem;
  line-height: 1.6;
}

/* ────────────────────────────────────────────────────────── */
/* ACTION BUTTONS                                              */
/* ────────────────────────────────────────────────────────── */

.char-actions {
  display: grid;

  grid-template-columns:
    repeat(3, 1fr);

  gap: 0.7rem;

  padding:
    0
    1.4rem
    1.4rem;
}

.btn-char-action {
  padding:
    0.8rem
    0.5rem;

  border-radius: 12px;

  border:
    1px solid
    rgba(0,255,153,0.2);

  background:
    rgba(0,255,153,0.05);

  color: var(--text);

  font-size: 0.78rem;
  font-weight: 700;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.btn-char-action:hover {
  transform: translateY(-2px);
}

.fav-btn:hover {
  border-color: #ff5f93;
  background: rgba(255,95,147,0.08);
}

.like-btn:hover {
  border-color: #00ff99;
  background: rgba(0,255,153,0.12);
}

.own-btn:hover {
  border-color: #ffdd00;
  background: rgba(255,221,0,0.12);
}

/* ────────────────────────────────────────────────────────── */
/* MODAL                                                       */
/* ────────────────────────────────────────────────────────── */

#character-modal {
  position: fixed;
  inset: 0;

  z-index: 9999;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.3s ease;
}

#character-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;

  background:
    rgba(0,0,0,0.75);

  backdrop-filter: blur(10px);
}

.character-modal-content {
  position: absolute;

  top: 50%;
  left: 50%;

  transform:
    translate(-50%, -50%)
    scale(0.95);

  width: min(1000px, 92vw);

  max-height: 85vh;
  height: auto;

  border-radius: 28px;

  background:
    linear-gradient(
      180deg,
      rgba(15,22,10,0.98),
      rgba(10,15,8,0.98)
    );

  border:
    1px solid
    rgba(0,255,153,0.2);

  transition:
    transform 0.3s ease;

  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(0, 255, 153, 0.15);
}

#character-modal.active .character-modal-content {
  transform:
    translate(-50%, -50%)
    scale(1);
}

/* CLOSE */

.modal-close-btn {
  position: absolute;

  top: 1rem;
  right: 1rem;

  width: 44px;
  height: 44px;

  border: none;
  border-radius: 50%;

  z-index: 10;

  cursor: pointer;

  background:
    rgba(255,221,0,0.15);

  color: #ffdd00;

  font-size: 1rem;

  backdrop-filter: blur(10px);

  transition: 0.2s ease;
}

.modal-close-btn:hover {
  background:
    rgba(255,221,0,0.25);
}

/* BANNER */

.modal-banner {
  height: 280px;

  overflow: hidden;
  flex-shrink: 0;
}

.modal-banner img {
  width: 100%;
  height: 100%;

  object-fit: cover;
}

/* MODAL INFO */

.modal-info {
  padding: 2rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  scroll-behavior: smooth;
}

/* Custom scrollbar styling */
.modal-info::-webkit-scrollbar {
  width: 8px;
}

.modal-info::-webkit-scrollbar-track {
  background: rgba(0, 255, 153, 0.05);
  border-radius: 10px;
}

.modal-info::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 153, 0.3);
  border-radius: 10px;
  transition: background 0.2s;
}

.modal-info::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 153, 0.5);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 1rem;

  margin-bottom: 2rem;
}

.modal-top h2 {
  margin: 0;

  font-size: 2rem;

  color: white;
}

.modal-rarity {
  margin-top: 0.5rem;

  color: #ffdd00;
}

.modal-role {
  padding:
    0.7rem
    1rem;

  border-radius: 999px;

  margin-bottom: 1rem;
  flex-shrink: 0;

  background:
    rgba(0,255,153,0.08);

  border:
    1px solid
    rgba(0,255,153,0.18);

  color: var(--accent);

  font-size: 0.82rem;
  font-weight: 700;
}

/* META GRID */

.modal-meta-grid {
  display: grid;

  grid-template-columns:
    repeat(2, 1fr);

  gap: 1rem;
}

.meta-box {
  padding: 1rem;

  border-radius: 16px;

  background:
    rgba(0,255,153,0.05);

  border:
    1px solid
    rgba(0,255,153,0.15);
}

.meta-box span {
  display: block;

  margin-bottom: 0.45rem;

  color: var(--text-muted);

  font-size: 0.75rem;
}

.meta-box strong {
  color: white;

  font-size: 0.95rem;
}

/* BIO */

.modal-bio {
  margin-top: 2rem;
  flex-shrink: 0;
}

.modal-bio h3 {
  margin: 0 0 0.8rem 0;

  color: white;
  font-size: 1rem;
}

.modal-bio p {
  color: var(--text-dim);
  line-height: 1.7;
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* RESPONSIVE MODAL */

@media (max-width: 768px) {
  .character-modal-content {
    max-height: 90vh;
    width: min(100vw, 96vw);
    border-radius: 20px;
  }

  .modal-banner {
    height: 200px;
  }

  .modal-info {
    padding: 1.5rem;
  }

  .modal-top {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 1.5rem;
  }

  .modal-role {
    width: 100%;
    text-align: center;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .modal-bio {
    margin-top: 0.8rem;
  }
}

@media (max-width: 480px) {
  .character-modal-content {
    max-height: 95vh;
    width: 100vw;
    border-radius: 16px;
  }

  .modal-close-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .modal-banner {
    height: 150px;
  }

  .modal-info {
    padding: 1.2rem;
  }

  .modal-top h2 {
    font-size: 1.5rem;
  }

  .meta-box {
    padding: 0.8rem;
  }

  .meta-box span {
    font-size: 0.7rem;
  }

  .meta-box strong {
    font-size: 0.9rem;
  }
}

/* ────────────────────────────────────────────────────────── */
/* LOADER                                                      */
/* ────────────────────────────────────────────────────────── */

#page-loader {
  position: fixed;
  inset: 0;

  z-index: 99999;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    linear-gradient(
      180deg,
      #0a0f05,
      #0d1608
    );

  transition:
    opacity 0.5s ease,
    visibility 0.5s ease;
}

#page-loader.hide {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
}

.loader-content p {
  margin-top: 1rem;

  color: var(--accent);

  font-family: var(--f-mono);

  letter-spacing: 0.12em;
}

/* SPINNER */

.loader-spinner {
  width: 72px;
  height: 72px;

  margin: 0 auto;

  border-radius: 50%;

  border:
    3px solid
    rgba(0,255,153,0.15);

  border-top-color:
    var(--accent);

  animation:
    spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ────────────────────────────────────────────────────────── */
/* REVEAL                                                      */
/* ────────────────────────────────────────────────────────── */

.reveal {
  opacity: 0;

  transform: translateY(30px);

  transition:
    opacity 0.7s ease,
    transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;

  transform: translateY(0);
}

/* ────────────────────────────────────────────────────────── */
/* TABLETS                                                     */
/* ────────────────────────────────────────────────────────── */

@media (max-width: 992px) {

  .characters-header {
    padding-top: 7rem;
  }

  .portrait {
    height: 300px;
  }

  .modal-banner {
    height: 260px;
  }

  .modal-info {
    padding: 1.6rem;
  }

}

/* ────────────────────────────────────────────────────────── */
/* MOBILE LANDSCAPE & TABLETS                                  */
/* ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {

  .characters-header {
    padding: 6rem 1rem 2.5rem;
  }

  .header-badge {
    font-size: 0.65rem;
    padding: 0.5rem 0.9rem;
    margin-bottom: 1rem;
  }

  .header-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
  }

  .header-subtitle {
    font-size: 0.9rem;
    margin-top: 0.8rem;
  }

  .characters-section {
    padding: 2rem 1rem 3rem;
  }

  .characters-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .sort-wrap {
    order: -1;
    width: 100%;
    flex-direction: column;
  }

  .sort-select {
    width: 100%;
  }

  .search-wrap {
    width: 100%;
  }

  #character-search {
    width: 100%;
  }

  .character-counter {
    width: 100%;
    min-width: unset;
  }

  .characters-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
  }

  .portrait {
    height: 280px;
  }

  .character-card {
    min-height: auto;
  }

  .char-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .btn-char-action {
    font-size: 0.75rem;
    padding: 0.6rem 0.8rem;
  }

  .modal-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .modal-top h2 {
    font-size: 1.8rem;
  }

  .modal-meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
  }

  .modal-meta-item {
    grid-column: span 1;
  }

  .modal-banner {
    height: 240px;
  }

  .modal-info {
    padding: 1.4rem;
  }

  .character-modal-content {
    width: 90vw;
    max-width: 600px;
  }

}

/* ────────────────────────────────────────────────────────── */
/* SMALL MOBILE                                                */
/* ────────────────────────────────────────────────────────── */

@media (max-width: 640px) {

  .characters-header {
    padding: 5rem 0.75rem 2rem;
  }

  .header-badge {
    font-size: 0.6rem;
    padding: 0.45rem 0.8rem;
    margin-bottom: 0.8rem;
  }

  .header-title {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    line-height: 1.1;
  }

  .header-subtitle {
    font-size: 0.85rem;
    margin-top: 0.6rem;
  }

  .characters-section {
    padding: 1.5rem 0.75rem 2.5rem;
  }

  .characters-topbar {
    gap: 0.8rem;
  }

  .search-wrap {
    order: -1;
  }

  #character-search {
    font-size: 0.8rem;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
  }

  .search-icon {
    font-size: 0.9rem;
    left: 0.9rem;
  }

  .character-counter {
    font-size: 0.75rem;
    padding: 0.8rem 1rem;
  }

  .characters-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .portrait {
    height: 260px;
  }

  .character-card {
    border-radius: 16px;
  }

  .character-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .character-header h2 {
    font-size: 1.2rem;
  }

  .rarity {
    font-size: 0.85rem;
  }

  .character-meta {
    font-size: 0.8rem;
    gap: 0.4rem;
  }

  .tag-group {
    gap: 0.5rem;
  }

  .tag {
    font-size: 0.7rem;
    padding: 0.4rem 0.7rem;
  }

  .char-bio {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .char-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .btn-char-action {
    font-size: 0.7rem;
    padding: 0.5rem 0.6rem;
  }

  .btn-char-action span {
    display: none;
  }

  .info {
    padding: 1rem;
    gap: 0.7rem;
  }

  .modal-banner {
    height: 220px;
  }

  .modal-top h2 {
    font-size: 1.5rem;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .modal-info {
    padding: 1.2rem;
  }

  .character-modal-content {
    width: 95vw;
    max-width: 95vw;
    max-height: 85vh;
  }

}

/* ────────────────────────────────────────────────────────── */
/* EXTRA SMALL DEVICES                                          */
/* ────────────────────────────────────────────────────────── */

@media (max-width: 480px) {

  .characters-header {
    padding: 4.5rem 0.5rem 1.5rem;
  }

  .header-badge {
    font-size: 0.55rem;
    padding: 0.4rem 0.7rem;
    margin-bottom: 0.6rem;
  }

  .header-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1;
  }

  .header-subtitle {
    font-size: 0.8rem;
    margin-top: 0.5rem;
  }

  .characters-section {
    padding: 1rem 0.5rem 2rem;
  }

  .sort-wrap {
    flex-direction: column;
    width: 100%;
  }

  .sort-select {
    width: 100%;
    font-size: 0.8rem;
  }

  #character-search {
    font-size: 0.75rem;
    padding: 0.75rem 0.9rem 0.75rem 2.4rem;
  }

  .search-icon {
    font-size: 0.85rem;
    left: 0.8rem;
  }

  .character-counter {
    font-size: 0.7rem;
    padding: 0.7rem 0.9rem;
  }

  .characters-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .portrait {
    height: 240px;
  }

  .character-card {
    border-radius: 12px;
  }

  .character-header {
    gap: 0.3rem;
  }

  .character-header h2 {
    font-size: 1.1rem;
  }

  .rarity {
    font-size: 0.75rem;
  }

  .character-meta {
    font-size: 0.75rem;
    gap: 0.3rem;
  }

  .tag {
    font-size: 0.65rem;
    padding: 0.3rem 0.6rem;
  }

  .char-bio {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .char-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
  }

  .btn-char-action {
    font-size: 0.65rem;
    padding: 0.4rem 0.5rem;
  }

  .info {
    padding: 0.9rem;
    gap: 0.6rem;
  }

  .modal-banner {
    height: 200px;
  }

  .modal-top h2 {
    font-size: 1.3rem;
  }

  .modal-info {
    padding: 1rem;
  }

  .character-modal-content {
    width: 95vw;
    max-height: 80vh;
  }

}
