/* ============================================================
   U3 — Periodic element card
   Styles specific to the U3 build, scoped under #u3-periodic.
   Uses the original periodic green gradient background; the tile and
   detail panel reuse the site's design tokens (var(--copper) etc.).
   ============================================================ */

#u3-periodic {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Original periodic background: dark base with an upward green gradient. */
  background: #141414;
  background-image:
    linear-gradient(
      to top,
      rgba(56, 158, 61, 0.5) 10%,
      rgba(56, 58, 61, 0.5) 40%,
      rgba(56, 58, 61, 1) 80%
    );
}

/* The whole socket is the interactive area; the tile sits centered.
   The stage fills the socket and never overflows its bounds. */
#u3-periodic .element-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;            /* allow the flex child to shrink, not overflow */
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 4px;
  overflow: hidden;
}
/* When open, pack contents from the top so the detail panel has room. */
#u3-periodic.is-open .element-stage {
  justify-content: flex-start;
}

/* The clickable element tile. */
#u3-periodic .element-tile {
  width: 120px;
  height: 120px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: #000;
  box-shadow: 0 0 0 1px rgba(81, 228, 255, 0.08), 0 10px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--silk);
  transition: border-color var(--motion) ease, box-shadow var(--motion) ease,
              transform var(--motion) ease;
}
#u3-periodic .element-tile:hover,
#u3-periodic .element-tile:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(81, 228, 255, 0.3), 0 10px 28px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
  outline: none;
}
/* Shrink the tile when the detail panel is showing so both fit the socket. */
#u3-periodic.is-open .element-tile {
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}
#u3-periodic.is-open .el-symbol { font-size: 2rem; }

#u3-periodic .el-num {
  font-family: 'Inconsolata', monospace;
  font-size: 0.8rem;
  color: var(--led-green);
  align-self: flex-start;
  margin: 6px 0 0 10px;
  line-height: 1;
}
#u3-periodic .el-symbol {
  font-family: 'Space Mono', monospace;
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  margin-top: -4px;
}
#u3-periodic .el-name {
  font-family: 'Inconsolata', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--silk-dim);
  margin-bottom: 8px;
}

#u3-periodic .element-hint {
  font-family: 'Inconsolata', monospace;
  font-size: 0.78rem;
  color: var(--silk-dim);
  margin: 0;
}

/* Detail panel — hidden until the tile is clicked. */
/* Detail panel. It carries the [hidden] attribute by default, so it stays
   hidden even if this stylesheet hasn't loaded yet. When open it stacks
   the facts above a full-width atom canvas. */
#u3-periodic .element-detail {
  flex-direction: column;
  width: 100%;
  min-height: 0;
  margin-top: 4px;
  border-top: 1px solid var(--grid-line);
  padding-top: 14px;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
}
/* [hidden] must always win over the display below. */
#u3-periodic .element-detail[hidden] { display: none; }
#u3-periodic.is-open .element-detail:not([hidden]) { display: flex; }
#u3-periodic.is-open .element-hint { display: none; }

#u3-periodic .element-facts {
  font-family: 'Inconsolata', monospace;
  font-size: 0.82rem;
  color: var(--silk-dim);
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
  /* Two columns, filling top-to-bottom then across:
     col 1 = Group, Period   col 2 = Block, Mass */
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  column-gap: 24px;
  row-gap: 2px;
}
#u3-periodic .element-facts li { padding: 0; white-space: nowrap; }
#u3-periodic .element-facts b { color: var(--copper); font-weight: 700; }

/* The atom canvas spans the full width of the detail area and is tall
   enough to show every shell. JS sets its pixel buffer from this box. */
#u3-periodic .atom-canvas {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  background: rgba(0, 12, 4, 0.6);
}

/* Prev / next navigation flanking the tile. */
#u3-periodic .element-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
#u3-periodic .el-prev,
#u3-periodic .el-next {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.5);
  color: var(--silk);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--motion) ease, background var(--motion) ease,
              color var(--motion) ease;
}
#u3-periodic .el-prev:hover,
#u3-periodic .el-next:hover,
#u3-periodic .el-prev:focus-visible,
#u3-periodic .el-next:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(81, 228, 255, 0.08);
  outline: none;
}

/* An open socket sizes to its content (the tall canvas needs the room)
   rather than the fixed 400px grid track; nothing is clipped. Spanning
   more rows makes the grid reserve the height instead of capping it. */
#u3-periodic.is-open {
  height: auto;
  min-height: 400px;
  overflow: visible;
  grid-row: span 3;
  align-self: start;
}
#u3-periodic.is-open .element-stage { overflow: visible; }

/* On very narrow screens, give the canvas more height so the atom and all
   its shells sit comfortably at full width below the data. */
@media (max-width: 520px) {
  #u3-periodic .atom-canvas { height: 300px; }
  #u3-periodic.is-open { grid-row: span 4; }
  #u3-periodic.is-open .element-tile { width: 104px; height: 104px; }
  #u3-periodic.is-open .el-symbol { font-size: 2.3rem; }
}
