/* styles.css */
:root {
  /* ASD Role Colors */
  --growth-surface-color: #4CAF50;
  --non-growth-surface-color: #F44336;
  --grown-material-color: #2196F3;
  
  /* Element Category Colors - now with 50% transparency */
  --alkali-metal-color: rgba(255, 138, 101, 0.5);
  --alkaline-earth-metal-color: rgba(255, 183, 77, 0.5);
  --transition-metal-color: rgba(144, 164, 174, 0.5);
  --post-transition-metal-color: rgba(161, 136, 127, 0.5);
  --metalloid-color: rgba(129, 199, 132, 0.5);
  --nonmetal-color: rgba(128, 203, 196, 0.5);
  --halogen-color: rgba(159, 168, 218, 0.5);
  --noble-gas-color: rgba(206, 147, 216, 0.5);
  --lanthanide-color: rgba(255, 204, 128, 0.5);
  --actinide-color: rgba(255, 171, 145, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  overflow-x: hidden;
}

.main-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header-bar {
  background-color: #1a237e;
  color: white;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.header-bar h1 {
  font-size: 1.5rem;
  margin-right: 20px;
}

.search-container {
  flex: 1;
  max-width: 400px;
  margin: 0 20px;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-left: 15px;
  font-size: 0.9rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border-radius: 3px;
}

.growth-indicator { background-color: var(--growth-surface-color); }
.non-growth-indicator { background-color: var(--non-growth-surface-color); }
.grown-indicator { background-color: var(--grown-material-color); }

.periodic-table-container {
  flex: 1;
  padding: 10px;
  overflow: auto;
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
}

.group-labels {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  margin-bottom: 5px;
  padding-left: 25px;
  font-size: 1rem;
  font-weight: bold;
  color: #555;
}

.group-labels div {
  text-align: center;
}

.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  gap: 3px;
  padding-bottom: 20px;
  max-width: 100%;
}

.element {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  user-select: none;
  min-width: 50px;
  min-height: 50px;
  /* Ensure crisp text rendering */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Make text dark for better readability against transparent backgrounds */
.symbol, .name, .atomic-number {
  color: #000;
  font-weight: bold;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.element:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  z-index: 10;
}

/* Category-based background colors */
.alkali-metal { background-color: var(--alkali-metal-color); }
.alkaline-earth-metal { background-color: var(--alkaline-earth-metal-color); }
.transition-metal { background-color: var(--transition-metal-color); }
.post-transition-metal { background-color: var(--post-transition-metal-color); }
.metalloid { background-color: var(--metalloid-color); }
.nonmetal { background-color: var(--nonmetal-color); }
.halogen { background-color: var(--halogen-color); }
.noble-gas { background-color: var(--noble-gas-color); }
.lanthanide { background-color: var(--lanthanide-color); }
.actinide { background-color: var(--actinide-color); }

/* Empty element placeholders */
.element.empty {
  background-color: transparent;
  box-shadow: none;
  cursor: default;
}

.element.empty:hover {
  transform: none;
}

.role-indicators {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: calc(100% - 6px);
}

.role-indicator {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid #000;
  box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Ensure consistent spacing even when indicators are hidden */
.role-indicator[style*="hidden"] {
  display: block;
  visibility: hidden;
}

.atomic-number {
  position: absolute;
  top: 3px;
  left: 3px;
  font-size: 0.8rem;
  color: #555;
  text-align: left;
}

.symbol {
  margin-top: 18px;
  font-size: 1.4rem;
  font-weight: bold;
  text-align: left;
  padding-left: 5px;
}

.name {
  font-size: 0.7rem;
  text-align: left;
  padding-left: 5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lanthanide and actinide rows */
.periodic-table-container .f-block-spacer {
  grid-column: span 18;
  height: 15px;
}

.periodic-table-container .f-block-label {
  padding: 5px;
  font-size: 0.7rem;
  color: #666;
  text-align: right;
}

/* Element details panel */
.element-details {
  width: 100%;
  max-width: 1400px;
  margin: 20px auto;
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.2);
  display: none;
  overflow-y: auto;
}

.element-details.active {
  display: block;
}

.close-button {
  display: none; /* Hide close button since it's not a modal anymore */
}

.element-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.element-symbol {
  font-size: 2.5em;
  font-weight: bold;
  margin-right: 15px;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  color: black;
}

.element-info h2 {
  margin: 0;
  font-size: 1.8em;
}

.element-info p {
  margin: 5px 0;
  font-size: 1em;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  margin-right: 5px;
  background-color: #f5f5f5;
  font-size: 0.9rem;
}

.tab.active {
  background-color: white;
  border-color: #ddd;
  border-bottom-color: white;
  margin-bottom: -1px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.paper-list {
  list-style-type: none;
  padding: 0;
}

.paper-item {
  margin-bottom: 15px;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 4px;
  border-left: 4px solid #1a237e;
}

.paper-title {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 5px;
}

.paper-authors {
  font-style: italic;
  margin-bottom: 5px;
}

.paper-doi {
  font-family: monospace;
  margin-bottom: 5px;
}

.paper-doi a {
  color: #1a237e;
  text-decoration: none;
}

.paper-doi a:hover {
  text-decoration: underline;
}

.compound-group {
  margin-bottom: 20px;
}

.compound-group h3 {
  background-color: #e0e0e0;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 1rem;
}

.footer-attribution {
  background-color: #1a237e;
  color: white;
  text-align: center;
  padding: 5px 0;
  font-size: 0.8rem;
  position: fixed;
  bottom: 0;
  width: 100%;
  opacity: 0.8;
}

/* Responsive design */
@media (max-width: 768px) {
  .header-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header-bar h1 {
    margin-bottom: 10px;
    text-align: center;
  }
  
  .search-container {
    margin: 10px 0;
    max-width: none;
  }
  
  .legend {
    justify-content: center;
    margin-top: 10px;
  }
  
  .element-details {
    width: 95%;
  }
}

@media (max-width: 480px) {
  .element-header {
    flex-direction: column;
    text-align: center;
  }
  
  .element-symbol {
    margin-right: 0;
    margin-bottom: 10px;
  }
}