/* ============================================================
   TABEL PERIODIK — Ruang Belajar
   Prefix: .tp-
   Style reference: kalkulator (dark surface, rounded, shadow)
   ============================================================ */

.tp-page {
  padding: 56px 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------------- INTRO ---------------- */
.tp-intro {
  text-align: center;
  max-width: 44ch;
  margin-bottom: 28px;
}

.tp-intro .hero__eyebrow {
  margin-bottom: 18px;
}

.tp-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.tp-intro p {
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.6;
}

/* ---------------- LEGEND ---------------- */
.tp-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-bottom: 32px;
}

.tp-legend__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-right: 4px;
}

.tp-legend__chip {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.tp-legend__chip--alkali          { background: #e74c3c; }
.tp-legend__chip--alkaline        { background: #e67e22; }
.tp-legend__chip--transition      { background: #c0392b; }
.tp-legend__chip--post-transition { background: #2ecc71; }
.tp-legend__chip--metalloid       { background: #1abc9c; }
.tp-legend__chip--nonmetal        { background: #27ae60; }
.tp-legend__chip--halogen         { background: #3498db; }
.tp-legend__chip--noble-gas       { background: #9b59b6; }
.tp-legend__chip--lanthanide      { background: #e91e63; }
.tp-legend__chip--actinide        { background: #ad1457; }

/* ---------------- TABLE WRAPPER ---------------- */
.tp-table-wrap {
  width: 100%;
  max-width: 1060px;
  overflow-x: auto;
  padding-bottom: 8px;
}

/* ---------------- GRID (periodic table layout) ---------------- */
.tp-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(48px, 1fr));
  gap: 3px;
  min-width: 900px;
}

.tp-grid--series {
  grid-template-columns: repeat(15, minmax(48px, 1fr));
}

.tp-series-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
  padding: 6px 8px 4px;
  min-width: 900px;
}

/* ---------------- ELEMENT CELL ---------------- */
.tp-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 140ms var(--ease), box-shadow var(--dur-fast) var(--ease);
  color: #fff;
  font-family: var(--font-mono);
  user-select: none;
  padding: 2px;
  min-width: 44px;
  border: 2px solid transparent;
}

.tp-cell:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(27, 31, 59, 0.25);
  z-index: 5;
}

.tp-cell:active {
  transform: scale(0.94);
}

.tp-cell--spacer {
  visibility: hidden;
}

.tp-cell__number {
  font-size: 0.56rem;
  font-weight: 600;
  opacity: 0.78;
  line-height: 1;
}

.tp-cell__symbol {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.tp-cell__name {
  font-size: 0.46rem;
  font-weight: 500;
  opacity: 0.78;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Category colors */
.tp-cell--alkali          { background: #e74c3c; }
.tp-cell--alkaline        { background: #e67e22; }
.tp-cell--transition      { background: #c0392b; }
.tp-cell--post-transition { background: #2ecc71; }
.tp-cell--metalloid       { background: #1abc9c; }
.tp-cell--nonmetal        { background: #27ae60; }
.tp-cell--halogen         { background: #3498db; }
.tp-cell--noble-gas       { background: #9b59b6; }
.tp-cell--lanthanide      { background: #e91e63; }
.tp-cell--actinide        { background: #ad1457; }
.tp-cell--unknown         { background: #95a5a6; }

/* ---------------- MODAL OVERLAY ---------------- */
.tp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 31, 59, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease);
}

.tp-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------- MODAL CARD (dark style seperti kalkulator) ---------------- */
.tp-modal {
  background: var(--ink);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(27, 31, 59, 0.55);
  transform: translateY(18px) scale(0.96);
  transition: transform var(--dur-med) var(--ease), opacity var(--dur-med) var(--ease);
  opacity: 0;
}

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

.tp-modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.tp-modal__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.tp-modal__close .icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tp-modal__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 20px;
  padding-right: 28px;
}

.tp-modal__atomic {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
}

.tp-modal__symbol {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.02em;
}

.tp-modal__name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  letter-spacing: -0.01em;
}

.tp-modal__category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  margin-top: 6px;
  width: fit-content;
  color: #fff;
}

/* Category badge colors in modal */
.tp-cat--alkali          { background: #e74c3c; }
.tp-cat--alkaline        { background: #e67e22; }
.tp-cat--transition      { background: #c0392b; }
.tp-cat--post-transition { background: #2ecc71; }
.tp-cat--metalloid       { background: #1abc9c; }
.tp-cat--nonmetal        { background: #27ae60; }
.tp-cat--halogen         { background: #3498db; }
.tp-cat--noble-gas       { background: #9b59b6; }
.tp-cat--lanthanide      { background: #e91e63; }
.tp-cat--actinide        { background: #ad1457; }
.tp-cat--unknown         { background: #95a5a6; }

.tp-modal__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tp-modal__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tp-modal__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.tp-modal__value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-align: right;
}

.tp-modal__value--mono {
  font-size: 0.74rem;
}

.tp-modal__fact {
  margin: 16px 0 0;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
  border-left: 3px solid var(--highlight);
}

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1040px) {
  .tp-grid {
    grid-template-columns: repeat(18, minmax(40px, 1fr));
    min-width: 760px;
  }

  .tp-grid--series {
    grid-template-columns: repeat(15, minmax(40px, 1fr));
    min-width: 640px;
  }

  .tp-series-label {
    min-width: 760px;
  }

  .tp-cell__symbol {
    font-size: 0.9rem;
  }

  .tp-cell__number {
    font-size: 0.5rem;
  }

  .tp-cell__name {
    font-size: 0.4rem;
  }
}

@media (max-width: 500px) {
  .tp-modal {
    padding: 28px 20px 20px;
    max-width: 100%;
  }

  .tp-modal__symbol {
    font-size: 2.4rem;
  }
}
