/* Vista "Tavola periodica": griglia, legenda, modalita gioco e popup */

.pt-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 32px;
  background: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.pt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin: 20px 0 8px;
}

.pt-modes {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 24px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.pt-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--color-text-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.pt-mode-btn.is-active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(13, 127, 242, 0.3);
}

.pt-mode-btn .material-symbols-outlined { font-size: 19px; }

.pt-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

/* Legenda / filtri per gruppo */
.pt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.pt-cat {
  --cat: var(--color-border);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 8px;
  border: 2px solid var(--color-border);
  border-radius: 22px;
  background-color: var(--color-white);
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .18s, transform .12s;
}

.pt-cat:hover { transform: translateY(-1px); border-color: var(--cat); }

.pt-cat__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cat);
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.pt-cat.is-active {
  border-color: var(--cat);
  background-color: var(--cat);
  color: #14161d;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.pt-cat.is-active .pt-cat__dot {
  background: rgba(255, 255, 255, 0.85);
}

.pt-cat__count {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.65;
}

/* Griglia */
.pt-scroller {
  overflow-x: auto;
  padding: 26px 4px 12px;
}

.pt-grid {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  grid-auto-rows: 1fr;
  gap: 3px;
  min-width: 1000px;
}

.pt-el {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 5px;
  background: #eee;
  color: #14161d;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform .12s ease-out, box-shadow .12s, opacity .25s;
}

.pt-el__num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.7;
}

.pt-el__mass {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 8px;
  opacity: 0.55;
}

.pt-el__sym {
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.pt-el__name {
  font-size: 8px;
  line-height: 1.15;
  text-align: center;
  margin-top: 2px;
  padding: 0 1px;
  max-width: 100%;
}

.pt-el:hover {
  transform: scale(1.22);
  z-index: 6;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.pt-el.is-dimmed {
  opacity: 0.15;
  pointer-events: none;
}

.pt-el.is-blank {
  background: var(--color-bg);
  border: 2px dashed var(--color-text-muted);
  color: var(--color-text-muted);
}

.pt-el.is-blank .pt-el__sym { font-size: 20px; opacity: 0.5; }

.pt-el.is-solved { animation: pt-pop .45s ease-out; }
.pt-el.is-revealed { box-shadow: inset 0 0 0 2px #f59e0b; }
.pt-el.is-wrong { animation: pt-shake .4s; }

@keyframes pt-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes pt-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* Segnaposto per lantanidi e attinidi nella tabella principale */
.pt-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 1px dashed var(--color-border);
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.pt-row-label {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .pt-el, .pt-el:hover { transition: none; transform: none; animation: none; }
}

/* Barra della modalita "completa la tabella" */
.pt-game-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0 4px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
}

.pt-game-bar.is-visible { display: flex; }

.pt-progress {
  font-weight: 700;
  font-size: 14px;
}

.pt-progress__bar {
  flex: 1 1 160px;
  height: 8px;
  min-width: 120px;
  border-radius: 99px;
  background: var(--color-border);
  overflow: hidden;
}

.pt-progress__fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: #22c55e;
  transition: width .3s ease;
}

.pt-btn {
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.pt-btn:hover { border-color: var(--color-primary); background: var(--color-bg); }
.pt-btn--primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.pt-btn--primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.pt-btn:disabled { opacity: .55; cursor: default; }

/* Popup */
.pt-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.pt-modal__card {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: 20px;
  background: var(--color-white);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: pt-modal-in .22s ease-out;
}

@keyframes pt-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.pt-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pt-modal__close:hover { background: var(--color-bg); }

.pt-el-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 40px;
}

.pt-el-badge {
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #14161d;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.pt-el-badge__sym { font-size: 30px; font-weight: 800; line-height: 1; }
.pt-el-badge__num { font-size: 12px; font-weight: 700; opacity: .7; }

.pt-el-title { margin: 0; font-size: 24px; font-weight: 800; }
.pt-el-sub { margin: 4px 0 0; font-size: 13px; color: var(--color-text-muted); }

.pt-cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: #14161d;
}

.pt-props {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.pt-prop {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.pt-prop__label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.pt-prop__value { font-size: 14px; font-weight: 600; margin-top: 2px; }

.pt-summary {
  margin-top: 18px;
  line-height: 1.6;
  font-size: 14.5px;
  color: var(--color-text-muted);
}

.pt-source {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
}

/* Form di risposta nel popup */
.pt-quiz-form { margin-top: 20px; }

.pt-field { margin-bottom: 14px; }

.pt-field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.pt-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-white);
  color: var(--color-text);
  font-family: inherit;
  font-size: 15px;
}

.pt-field input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.pt-field input.is-ko { border-color: #ef4444; background: #fee2e2; }
.pt-field input.is-ok { border-color: #22c55e; background: #dcfce7; }

.pt-quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

.pt-feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  display: none;
  align-items: center;
  gap: 8px;
}

.pt-feedback.is-visible { display: flex; }
.pt-feedback.is-ok { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.pt-feedback.is-ko { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.pt-feedback.is-info { background: #fffbeb; color: #b45309; border: 1px solid #fcd34d; }

.pt-card-shake { animation: pt-shake .4s; }

.pt-done {
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #15803d;
  font-weight: 700;
  display: none;
}

.pt-done.is-visible { display: block; }

body.dark-mode .pt-el.is-blank { background: #232333; }
body.dark-mode .pt-placeholder { background: #232333; }
body.dark-mode .pt-feedback.is-ok { background: #14321f; color: #86efac; }
body.dark-mode .pt-feedback.is-ko { background: #3a1717; color: #fca5a5; }
body.dark-mode .pt-feedback.is-info { background: #382a10; color: #fcd34d; }
body.dark-mode .pt-done { background: #14321f; color: #86efac; }
body.dark-mode .pt-field input.is-ko { background: #3a1717; }
body.dark-mode .pt-field input.is-ok { background: #14321f; }

@media (max-width: 640px) {
  .pt-container { margin: 16px auto; padding: 18px; border-radius: 0; }
  .pt-toolbar { gap: 10px; }
  .pt-el__mass { display: none; }
}
