﻿/*--------------------------------------------------------------
# Interactive Periodic Table
# Builds on the shared primitives in style.css:
#   .calc-card / .calc-error / .option-rows / .option-row /
#   .option-row-label / .input-unit-wrap / .result-unit-toggle /
#   .unit-tab / .presets-panel / .presets-header / .presets-title /
#   .preset-load-btn / .file-count
# This file only contains periodic-specific styling: the 18-column
# grid, element tile styling, category color palette, view-mode
# heatmaps, detail panel layout, and mobile scroll affordance.
--------------------------------------------------------------*/
.periodic-section { padding: 60px 0; }

/* The card needs to grow well past 900px on wide screens so the table
   isn't jammed — bump the max-width specifically for this page. */
.pt-card {
  max-width: 1200px;
  padding: 30px 30px 40px;
}

.pt-options { margin-bottom: 14px; padding-bottom: 14px; }
.pt-search-wrap { flex: 1; }
.pt-view-toggle { flex: 1; }
.pt-view-toggle .unit-tab { flex: 1; padding: 7px 12px; text-align: center; }

/* ── Legend ──────────────────────────────────────────────────────────────── */
.pt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 12px 0 20px;
  font-size: 12px;
  color: #6c757d;
  align-items: center;
}
.pt-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pt-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.08);
}

/* ── Table grid ─────────────────────────────────────────────────────────── */
.pt-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pt-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(48px, 1fr));
  grid-template-rows: repeat(7, minmax(48px, 1fr));
  gap: 4px;
  min-width: 900px;
}
.pt-fblock {
  display: grid;
  grid-template-columns: repeat(18, minmax(48px, 1fr));
  gap: 4px;
  margin-top: 14px;
  min-width: 900px;
}

/* ── Element tile ───────────────────────────────────────────────────────── */
.pt-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  position: relative;
  font-family: "Open Sans", sans-serif;
  user-select: none;
}
.pt-cell:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(15,25,40,0.18);
  z-index: 5;
}
.pt-cell.is-active {
  outline: 3px solid #0563bb;
  outline-offset: 2px;
  z-index: 6;
}
.pt-cell.is-dimmed {
  opacity: 0.18;
  filter: saturate(0.4);
}
.pt-cell .pt-num {
  font-size: 9px;
  line-height: 1;
  align-self: flex-start;
  padding-left: 4px;
  opacity: 0.75;
}
.pt-cell .pt-sym {
  font-family: "Poppins", sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  margin-top: 1px;
}
.pt-cell .pt-name {
  font-size: 8px;
  line-height: 1;
  margin-top: 3px;
  opacity: 0.85;
  text-align: center;
  padding: 0 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pt-cell .pt-mass {
  font-size: 8px;
  line-height: 1;
  margin-top: 2px;
  opacity: 0.7;
}

/* The placeholder tile in the f-block row that says "Lanthanides 57-71" */
.pt-cell.is-placeholder {
  background: #f8fafd;
  border-style: dashed;
  color: #6c757d;
  cursor: default;
}
.pt-cell.is-placeholder:hover { transform: none; box-shadow: none; }
.pt-cell.is-placeholder .pt-sym { font-size: 11px; font-weight: 600; }

/* The wrapper carries a view-mode class so we only apply the active palette;
   each cell still carries every category/state/en-bin/disc-bin data-attr at
   all times. Switching modes is just a class swap on .pt-table / .pt-fblock. */

/* ── Category palette (default view) ────────────────────────────────────── */
.pt-view-category .pt-cell[data-cat="alkali-metal"]        { background: #ffd2d2; color: #842029; }
.pt-view-category .pt-cell[data-cat="alkaline-earth"]      { background: #ffe4c0; color: #844c14; }
.pt-view-category .pt-cell[data-cat="transition-metal"]    { background: #ffe9a8; color: #685011; }
.pt-view-category .pt-cell[data-cat="post-transition"]     { background: #d8e6c2; color: #3a4f1c; }
.pt-view-category .pt-cell[data-cat="metalloid"]           { background: #c2e6d9; color: #1c4f3a; }
.pt-view-category .pt-cell[data-cat="nonmetal"]            { background: #c2dcf2; color: #0f3a63; }
.pt-view-category .pt-cell[data-cat="halogen"]             { background: #b9d4ff; color: #163a7a; }
.pt-view-category .pt-cell[data-cat="noble-gas"]           { background: #e0c8f2; color: #4a1f6e; }
.pt-view-category .pt-cell[data-cat="lanthanide"]          { background: #f6c6e0; color: #6e1f4e; }
.pt-view-category .pt-cell[data-cat="actinide"]            { background: #e8b8c4; color: #6e1f3a; }
.pt-view-category .pt-cell[data-cat="unknown"]             { background: #e9ecef; color: #45505b; }

/* ── State view ─────────────────────────────────────────────────────────── */
.pt-view-state .pt-cell[data-state="solid"]   { background: #d6e2ec; color: #2c3e50; }
.pt-view-state .pt-cell[data-state="liquid"]  { background: #b8d8ff; color: #0f3a63; }
.pt-view-state .pt-cell[data-state="gas"]     { background: #ffe1b6; color: #844c14; }
.pt-view-state .pt-cell[data-state="unknown"] { background: #e9ecef; color: #45505b; }

/* ── Electronegativity heatmap ──────────────────────────────────────────── */
.pt-view-en .pt-cell[data-en-bin="0"] { background: #f1f4f8; color: #45505b; }
.pt-view-en .pt-cell[data-en-bin="1"] { background: #d8e6f5; color: #1f3a63; }
.pt-view-en .pt-cell[data-en-bin="2"] { background: #b6cfeb; color: #1f3a63; }
.pt-view-en .pt-cell[data-en-bin="3"] { background: #8db5dd; color: #fff; }
.pt-view-en .pt-cell[data-en-bin="4"] { background: #5b94cc; color: #fff; }
.pt-view-en .pt-cell[data-en-bin="5"] { background: #2d6fb1; color: #fff; }
.pt-view-en .pt-cell[data-en-bin="6"] { background: #14467a; color: #fff; }

/* ── Discovery view (binned by century) ─────────────────────────────────── */
.pt-view-disc .pt-cell[data-disc-bin="ancient"] { background: #c9b691; color: #4a3a1a; }
.pt-view-disc .pt-cell[data-disc-bin="1700s"]   { background: #d8c3a3; color: #4a3a1a; }
.pt-view-disc .pt-cell[data-disc-bin="1800s"]   { background: #ffd8b3; color: #844c14; }
.pt-view-disc .pt-cell[data-disc-bin="1900s"]   { background: #b6e2c2; color: #1c4f3a; }
.pt-view-disc .pt-cell[data-disc-bin="2000s"]   { background: #b6c8e2; color: #1f3a63; }
.pt-view-disc .pt-cell[data-disc-bin="unknown"] { background: #e9ecef; color: #45505b; }

/* Placeholders always look the same regardless of view. */
.pt-cell.is-placeholder        { background: #f8fafd !important; color: #6c757d !important; }

/* ── Detail panel ───────────────────────────────────────────────────────── */
.pt-detail { margin-top: 26px; }
.pt-detail-header {
  flex-wrap: wrap;
  gap: 10px;
}
.pt-detail-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #0563bb;
  color: #fff;
  border-radius: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin-right: 10px;
}
.pt-detail-name {
  font-family: "Poppins", sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: #45505b;
}

.pt-detail-body {
  padding: 22px 28px 26px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 28px;
}
.pt-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pt-detail-label {
  font-size: 12px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pt-detail-value {
  font-size: 15px;
  color: #45505b;
  word-break: break-word;
}
.pt-detail-value strong { color: #0563bb; }

.pt-detail-summary {
  grid-column: 1 / -1;
  font-size: 14px;
  line-height: 1.65;
  color: #45505b;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 6px;
  padding: 14px 18px;
  margin-top: 4px;
}

/* Visual hint that the table scrolls horizontally on narrow viewports. */
.pt-scroll-hint {
  display: none;
  margin: 8px 0 0;
  font-size: 11px;
  color: #adb5bd;
  text-align: center;
  font-style: italic;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1199px) {
  .pt-cell .pt-name,
  .pt-cell .pt-mass { font-size: 7px; }
  .pt-cell .pt-sym  { font-size: 15px; }
}
@media (max-width: 992px) {
  .pt-scroll-hint { display: block; }
  /* Soft fade on the right edge so the user sees there's more table off-screen. */
  .pt-table-wrap {
    position: relative;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  }
  /* When the user has actually scrolled to the end, drop the fade so they
     don't miss the rightmost noble-gas column. */
  .pt-table-wrap.is-scrolled-end {
    -webkit-mask-image: none;
            mask-image: none;
  }
}
@media (max-width: 768px) {
  .pt-card { padding: 16px 14px 22px; }
  .periodic-section { padding: 36px 0; }

  .pt-table { gap: 3px; min-width: 720px; }
  .pt-fblock { gap: 3px; min-width: 720px; }
  .pt-table,
  .pt-fblock {
    grid-template-columns: repeat(18, minmax(38px, 1fr));
  }
  .pt-cell {
    padding: 3px 1px;
    border-radius: 4px;
  }
  .pt-cell .pt-name { display: none; }
  .pt-cell .pt-mass { display: none; }
  .pt-cell .pt-num  { font-size: 8px; padding-left: 2px; }
  .pt-cell .pt-sym  { font-size: 13px; }
  .pt-cell.is-placeholder .pt-sym { font-size: 9px; }

  .pt-legend {
    margin: 10px 0 14px;
    gap: 6px 10px;
    font-size: 11px;
  }
  .pt-legend-swatch { width: 12px; height: 12px; }

  .pt-detail { margin-top: 18px; }
  .pt-detail-header {
    padding: 14px 16px;
  }
  .pt-detail-symbol {
    width: 38px;
    height: 38px;
    font-size: 18px;
    margin-right: 6px;
  }
  .pt-detail-name { font-size: 16px; }
  .pt-detail-body {
    padding: 18px 18px 22px;
    gap: 12px 18px;
  }
  .pt-detail-value { font-size: 14px; }
  .pt-detail-summary {
    font-size: 13px;
    padding: 12px 14px;
  }
}

/* Below 480 px, drop the table cell minimum so even tiny phones show
   something useful (still scrollable, just denser). */
@media (max-width: 480px) {
  .pt-table { min-width: 600px; }
  .pt-fblock { min-width: 600px; }
  .pt-table,
  .pt-fblock {
    grid-template-columns: repeat(18, minmax(32px, 1fr));
  }
  .pt-cell .pt-sym { font-size: 12px; }
  .pt-cell .pt-num { font-size: 7px; }
}
