/* Modal overlay, dialog window, and premium Pokédex binder */

/* ── Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay--open {
  opacity: 1;
  pointer-events: all;
}

/* ── Dialog window ── */
.modal {
  width: 100%;
  max-width: min(1520px, calc(100vw - 16px));
  max-height: 96vh;
  overflow: visible;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  opacity: 0;
  transform: scale(0.95) translateY(24px);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.2, 1), opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay--open .modal {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal__content {
  width: 100%;
  overflow: visible;
}

/* ── Loading ── */
.modal-loading {
  max-width: 380px;
  margin: 36px auto;
  padding: 88px 22px;
  text-align: center;
  background: #fdfbf7;
  border: 3px solid #1a1a1a;
  box-shadow: none;
}
.spinner-lg {
  display: inline-block;
  width: 54px;
  height: 54px;
  border: 4px solid var(--muted);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.modal-loading__error {
  color: #dc2626;
  font-weight: 700;
  margin-bottom: 14px;
}
.modal-loading__btn--retry {
  padding: 10px 24px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font: 700 .9rem 'Outfit', sans-serif;
}
.modal-loading__btn--dismiss {
  padding: 8px 20px;
  background: none;
  color: var(--muted);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font: 600 .85rem 'Outfit', sans-serif;
}

/* ── Stage ── */
.pokedex-stage {
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: min(92vh, 880px);
  color: var(--text);
}

/* ── Navigation ── */
.pokedex-nav {
  display: grid;
  place-items: center;
  align-items: center;
  justify-items: center;
  gap: 4px;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f2efe6 100%);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
  font-size: 11px;
  transition: transform 0.2s ease, background 0.2s ease;
}
.pokedex-nav__icon svg {
  width: 20px;
  height: 20px;
}
.pokedex-nav:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff6cc 0%, #f0c020 100%);
  transform: translate(-1px, -1px);
}
.pokedex-nav:active:not(:disabled) {
  transform: translate(2px, 2px);
}
.pokedex-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Binder Shell ── */
.pokedex-shell {
  position: relative;
  transform-origin: center;
}

.pokedex-book {
  position: relative;
  height: 100%;
  overflow: visible;
  border-radius: 20px;
  border: 2px solid var(--border);
  box-shadow: none;
}
.pokedex-book::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 16px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.35), rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0 6px, rgba(0, 0, 0, 0.05) 6px 12px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 1;
}
.pokedex-book::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 18px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.pokedex-spread {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
  overflow: visible;
  perspective: 1800px;
  z-index: 2;
}

/* ── Pages ── */
.pokedex-page {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, #fdfbf7 100%);
  box-shadow:
    inset 0 0 0 2px rgba(18, 18, 18, 0.85),
    inset 0 18px 30px rgba(255, 255, 255, 0.6);
  backface-visibility: hidden;
}
.pokedex-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(14, 18, 26, 0.08) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
  opacity: 0.6;
  pointer-events: none;
}
.pokedex-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.7), rgba(0, 0, 0, 0.18));
  opacity: 0.25;
  pointer-events: none;
}
.pokedex-page--left {
  transform-origin: right center;
}
.pokedex-page--right {
  transform-origin: left center;
}

.pokedex-page-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 42px 28px 30px;
  z-index: 2;
}
.pokedex-page-inner--right {
  padding: 28px 30px 28px 42px;
}

/* ── Hero ── */
.pokedex-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  /* Reset global header styles */
  padding: 0;
  height: auto;
  position: static;
  top: auto;
  border-bottom: none;
  box-shadow: none;
  background: transparent;
}
.pokedex-title {
  min-width: 0;
}
.pokedex-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.55);
}
.pokedex-name {
  font-size: 36px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pokedex-genus {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0;
}
.pokedex-genus__label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.6);
}
.pokedex-genus__value {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.85);
}
.pokedex-id-card {
  min-width: 150px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background:
    linear-gradient(180deg, #fff4cc 0%, #f0c020 100%);
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  text-align: right;
  white-space: nowrap;
  flex-wrap: nowrap;
}
.pokedex-id-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 800;
  color: rgba(18, 18, 18, 0.65);
  white-space: nowrap;
}
.pokedex-id-value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ── Hero Grid ── */
.pokedex-hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  min-height: 0;
}
.pokedex-image-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pokedex-image-frame {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 2px solid var(--border);
  border-top-color: var(--border);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), rgba(0, 0, 0, 0.12)),
    linear-gradient(160deg, rgba(255, 255, 255, 0.8), rgba(0, 0, 0, 0.2));
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.18);
}
.pokedex-image-frame::before {
  content: none;
}
.pokedex-image {
  position: relative;
  z-index: 2;
  width: min(320px, 90%);
  height: min(320px, 90%);
  margin: 0 auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(12px 16px 0 rgba(0, 0, 0, 0.18));
}

.pokedex-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.type-badge {
  --type-bg: #64748b;
  --type-text: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--type-bg) 85%, white 15%), var(--type-bg));
  color: var(--type-text);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 0.12em;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.type-badge__label {
  font-size: 12px;
}
.type-badge--sm {
  padding: 6px 10px;
  gap: 6px;
}
.type-badge--sm .type-badge__label {
  font-size: 11px;
}
.type-badge--empty {
  background: #e8e6de;
  color: #333;
}
.type-badge:hover {
  filter: brightness(1.03);
}

/* ── Summary ── */
.pokedex-summary-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), #f8f4ea);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.1);
}
.pokedex-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.pokedex-section-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.6);
}
.pokedex-summary-tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.pokedex-summary-text {
  font-size: 15px;
  line-height: 1.7;
  color: rgba(18, 18, 18, 0.82);
}

.pokedex-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.pokedex-metric {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 70px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: #ffffff;
  box-shadow: none;
}
.pokedex-metric__label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.55);
}
.pokedex-metric__value {
  font-size: 18px;
  font-weight: 900;
  color: var(--metric-accent, var(--text));
}

/* ── Notes ── */
.pokedex-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pokedex-notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.pokedex-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: #ffffff;
  box-shadow: none;
}
.pokedex-note__label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.6);
}
.pokedex-note__value {
  font-size: 14px;
  font-weight: 900;
}

/* ── Cards Right Page ── */
.pokedex-card {
  padding: 14px;
  border: 2px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), #f5f1e6);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.08);
}
.pokedex-abilities {
  border: none;
  background: transparent;
  box-shadow: none;
}
.pokedex-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pokedex-card-head--split {
  margin-bottom: 12px;
}
.pokedex-meta {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.55);
}
.pokedex-right-top {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 12px;
}
.pokedex-progress {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(240, 192, 32, 0.25));
}
.pokedex-moves,
.pokedex-weakness {
  border: none;
  background: transparent;
  box-shadow: none;
}
.pokedex-progress-value {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.pokedex-progress-sub {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.55);
}

.ability-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ability-chip {
  padding: 7px 12px;
  border: 2px solid var(--border);
  background: var(--ability-bg, #ffffff);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 900;
  transition: transform 0.2s ease;
}
.ability-chip--hidden {
  background: #f0c020;
}
.ability-chip--more {
  background: #e6e4db;
  color: rgba(18, 18, 18, 0.7);
}
.ability-chip:hover {
  transform: translate(-1px, -1px);
}

/* ── Stats ── */
.pokedex-stats {
  min-height: 0;
  padding: 18px;
}
.pokedex-stats-list {
  display: grid;
  gap: 14px;
}
.pokedex-stat-row {
  display: grid;
  grid-template-columns: 110px 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.pokedex-stat-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.6);
}
.pokedex-stat-value {
  font-size: 16px;
  font-weight: 900;
  text-align: right;
}
.pokedex-stat-track {
  position: relative;
  height: 16px;
  border: 2px solid var(--border);
  background: #e7e4dc;
  overflow: hidden;
}
.pokedex-stat-fill {
  height: 100%;
  width: 0;
  background: var(--stat-color, #64748b);
  box-shadow: 0 0 16px var(--stat-glow, transparent);
  transition: width 0.8s ease-out;
}

/* ── Moves / Weakness ── */
.pokedex-bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.moves-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.move-chip {
  padding: 8px 10px;
  border: 2px solid var(--border);
  background: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 900;
  box-shadow: none;
}
.move-chip--more {
  grid-column: span 2;
  text-align: center;
  background: #e6e4db;
}
.moves-empty {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(18, 18, 18, 0.6);
}

.pokedex-weakness {
  background: transparent;
}
.pokedex-weakness-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Close Button ── */
.pokedex-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: 2px solid var(--border);
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  z-index: 3;
}
.pokedex-close:hover {
  background: #fff4cc;
  transform: translate(-1px, -1px);
  box-shadow: none;
}
.pokedex-close:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.pokedex-close svg {
  width: 18px;
  height: 18px;
}

/* ── Rings / Spine ── */
.book-rings {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 18px 0;
  pointer-events: none;
  z-index: 3;
}
.book-rings--left {
  left: -6px;
  align-items: flex-start;
}
.book-rings--right {
  right: -6px;
  align-items: flex-end;
}
.book-ring {
  position: relative;
  width: 26px;
  height: 14px;
}
.book-ring__outer,
.book-ring__inner,
.book-ring__bar {
  position: absolute;
}
.book-ring__outer {
  width: 26px;
  height: 14px;
  border-radius: 8px;
  border: 2px solid #2b2b2b;
  background: #d9d9d9;
  top: 0;
}
.book-rings--left .book-ring__outer {
  left: 0;
}
.book-rings--right .book-ring__outer {
  right: 0;
}
.book-ring__inner {
  display: none;
}
.book-rings--left .book-ring__inner {
  left: 13px;
}
.book-rings--right .book-ring__inner {
  right: 13px;
}
.book-ring__bar {
  display: none;
}
.book-rings--left .book-ring__bar {
  left: 0;
  border-radius: 0 6px 6px 0;
}
.book-rings--right .book-ring__bar {
  right: 0;
  border-radius: 6px 0 0 6px;
}
.book-spine {
  position: absolute;
  inset: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 18px 0;
  pointer-events: none;
  z-index: 4;
}
.book-spine__row {
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-spine__connector {
  width: 100%;
  height: 14px;
  border-radius: 0;
  border-top: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  border-left: none;
  border-right: none;
  background: #d9d9d9;
  box-shadow: none;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .pokedex-nav {
    width: 54px;
    height: 54px;
  }
  .pokedex-name {
    font-size: 38px;
  }
}

@media (max-width: 820px) {
  .pokedex-hero-grid {
    grid-template-columns: 1fr;
  }
  .pokedex-right-top {
    grid-template-columns: 1fr;
  }
  .pokedex-bottom-grid {
    grid-template-columns: 1fr;
  }
  .pokedex-metrics {
    grid-template-columns: 1fr;
  }
  .pokedex-notes-grid {
    grid-template-columns: 1fr;
  }
  .pokedex-image {
    width: min(280px, 80%);
    height: min(280px, 80%);
  }
}

@media (max-width: 540px) {
  .pokedex-stage {
    gap: 8px;
  }
  .pokedex-name {
    font-size: 32px;
  }
  .pokedex-id-card {
    min-width: 120px;
  }
}
