:root {
  color-scheme: dark;
  --page: #101b28;
  --text: #edf3f7;
  --soft: #aebdca;
  --gap: clamp(2px, .32vw, 5px);
  --cell-height: clamp(38px, 6.5dvh, 67px);
  --series-gap: clamp(5px, 1.2dvh, 13px);
  --info-space: clamp(125px, 20dvh, 168px);
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  background: var(--page);
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: radial-gradient(ellipse at 45% 35%, #192a3b, var(--page) 78%); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #fff5d6; outline-offset: 2px; z-index: 1; }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; pointer-events: none; }

[data-family="alkali-metal"]          { --tone: #eba8a9; }
[data-family="alkaline-earth-metal"]  { --tone: #e4be83; }
[data-family="transition-metal"]     { --tone: #92bde5; }
[data-family="post-transition-metal"] { --tone: #b4c6cc; }
[data-family="metalloid"]            { --tone: #bfd889; }
[data-family="nonmetal"]             { --tone: #8bd5b6; }
[data-family="halogen"]              { --tone: #79d5de; }
[data-family="noble-gas"]            { --tone: #b9adf0; }
[data-family="lanthanide"]           { --tone: #d4a8da; }
[data-family="actinide"]             { --tone: #e7a2bb; }

.periodic-page {
  position: fixed;
  inset: 0;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(var(--info-space), max-content);
  justify-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.board {
  width: min(100%, 1152px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.group-axis, #periodic-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  column-gap: var(--gap);
}
.group-axis {
  flex: none;
  text-align: center;
  margin-bottom: 5px;
  font: 11px/1.2 Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  color: #94a7b7;
}
#periodic-table {
  height: calc(9 * var(--cell-height) + 9 * var(--gap) + var(--series-gap));
  min-height: 0;
  flex: 0 1 auto;
  grid-template-rows: repeat(7, minmax(0, 1fr)) var(--series-gap) repeat(2, minmax(0, 1fr));
  row-gap: var(--gap);
}
.element {
  min-width: 0;
  min-height: 0;
  padding: 1px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  color: var(--tone);
  border: 1px solid color-mix(in srgb, var(--tone) 48%, #1c2b37);
  border-radius: clamp(2px, .3vw, 5px);
  background: color-mix(in srgb, var(--tone) 13%, #12202d);
}
.element small { font: 500 clamp(9px, .94vw, 13px)/1 Arial, sans-serif; font-variant-numeric: tabular-nums; }
.element strong { font: 600 clamp(14px, 1.95vw, 28px)/1.04 Georgia, "Times New Roman", serif; }
.series-reference { align-self: center; text-align: center; font-size: clamp(8px, .9vw, 12px); color: var(--tone); opacity: .75; }
.element.is-muted { opacity: .32; }
.element.is-member { background: color-mix(in srgb, var(--tone) 33%, #14212f); border-color: var(--tone); }
.element[aria-pressed="true"] { background: var(--tone); color: #0e1a24; border-color: #f3f7f9; box-shadow: 0 0 0 1px #f3f7f9; }
#periodic-legend {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 10px;
  margin: clamp(8px, 1.8dvh, 20px) auto 0;
}
.family {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 2px 3px;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: #ccd6df;
  font-size: clamp(12px, 1vw, 14px);
  white-space: nowrap;
}
.family::before, #family-name::before {
  content: '';
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 2px;
  background: var(--tone);
}
.family[aria-pressed="true"] { color: var(--tone); text-decoration: underline; text-underline-offset: 4px; }

#information {
  align-self: end;
  width: min(100%, 500px);
  padding: 13px 17px;
  border: 1px solid #405160;
  border-inline-start: 3px solid var(--tone);
  border-radius: 12px;
  background: #1a2a39;
  box-shadow: 0 5px 24px #030b1538;
}
.identity { display: flex; align-items: center; gap: 12px; }
.detail-symbol {
  min-width: 48px;
  text-align: center;
  color: var(--tone);
  font: 600 36px/1 Georgia, "Times New Roman", serif;
}
.names { display: flex; align-items: baseline; gap: 4px 15px; flex-wrap: wrap; }
.pronunciation {
  border: 0;
  background: transparent;
  padding: 3px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text);
}
.pronunciation[lang="en"] { color: #cbd6df; font: 19px/1.1 Georgia, "Times New Roman", serif; }
.pronunciation svg { width: 15px; height: 15px; opacity: .68; }
.pronunciation.is-speaking { color: var(--tone); }
.facts { margin: 3px 0 0; font-size: 13px; color: #bbcad6; line-height: 1.4; }
.occurrence { margin-top: 9px; border-top: 1px solid #394958; padding-top: 7px; }
.examples-title { margin: 0 0 3px; font-size: 13px; color: var(--soft); }
#examples { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; gap: 2px 15px; }
#examples li { display: flex; align-items: baseline; gap: 6px; font-size: 14px; line-height: 1.45; }
#examples li::before { content: ''; width: 4px; height: 4px; align-self: center; flex: none; border-radius: 50%; background: var(--tone); }
.occurrence-note, #family-explanation { margin: 4px 0 0; line-height: 1.5; font-size: 15px; }
#family-name { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--tone); font-size: 20px; }
#voice-status { margin: 6px 0 0; color: #f3d6aa; font-size: 13px; }

@media (hover: hover) {
  .element:hover { border-color: var(--tone); opacity: 1; }
  .family:hover, .pronunciation:hover { color: var(--tone); }
}
@media (max-width: 650px) {
  :root { --gap: clamp(1px, .35vw, 2.3px); --cell-height: clamp(34px, 5.6dvh, 49px); --info-space: clamp(154px, 23dvh, 188px); }
  .periodic-page { padding-inline: max(5px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-left)); }
  .group-axis { font-size: clamp(7px, 2vw, 10px); margin-bottom: 4px; }
  .element { padding: 1px 0; gap: 3px; border-radius: 2px; }
  .element small { font-size: clamp(7px, 1.95vw, 10px); }
  .element strong { font-size: clamp(9px, 3.05vw, 18px); }
  .series-reference { display: flex; flex-direction: column; font-size: clamp(7px, 1.9vw, 10px); }
  #periodic-legend { gap: 0 8px; padding-inline: 2px; }
  .family { min-height: 27px; gap: 4px; font-size: clamp(11px, 3vw, 14px); }
  .family::before { width: 6px; height: 6px; }
  #information { width: min(100% - 6px, 570px); padding: 10px 12px; }
  .detail-symbol { min-width: 37px; font-size: 29px; }
  .identity { gap: 8px; }
  .names { gap: 2px 12px; }
  .pronunciation { font-size: 19px; }
  .pronunciation[lang="en"] { font-size: 17px; }
  .facts { margin-top: 2px; }
}
@media (max-height: 540px) and (min-aspect-ratio: 6/5) {
  :root { --info-space: 82px; --series-gap: 2px; --gap: 2px; }
  .periodic-page { padding-block-start: max(3px, env(safe-area-inset-top)); padding-block-end: max(4px, env(safe-area-inset-bottom)); }
  .group-axis { font-size: 8px; margin-bottom: 2px; }
  .element { gap: 0; flex-direction: row; align-items: baseline; justify-content: center; column-gap: 2px; align-content: center; flex-wrap: wrap; padding: 0; }
  .element small { font-size: 8px; }
  .element strong { font-size: clamp(11px, 3.7dvh, 19px); }
  #periodic-legend { gap: 0 9px; margin-top: 3px; }
  .family { font-size: 11px; min-height: 19px; }
  #information { width: min(100%, 850px); padding: 6px 12px; }
  #element-detail { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 13px; }
  .occurrence { border-top: 0; border-inline-start: 1px solid #394958; padding: 0; padding-inline-start: 12px; margin: 0; }
  .detail-symbol { min-width: 33px; font-size: 28px; }
  .names { gap: 3px 9px; }
  .pronunciation, #family-name { font-size: 17px; }
  .pronunciation[lang="en"] { font-size: 16px; }
  .facts, .examples-title { font-size: 12px; }
  #examples li, .occurrence-note, #family-explanation { font-size: 13px; line-height: 1.3; }
}
