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

[hidden] {
  display: none !important;
}

:root {
  --bg: #faf6f1;
  --bg-card: #ffffff;
  --text: #3a3028;
  --text-secondary: #9a8a7a;
  --text-heading: #5c4a3a;
  --border: #e8ddd0;
  --shadow: rgba(0, 0, 0, 0.06);
  --gi-low: #7a9a5a;
  --gi-medium: #c4a23a;
  --gi-high: #c26a4a;
}

html {
  font-size: 16px;
}

body {
  font-family: Georgia, 'Times New Roman', Times, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

header {
  text-align: center;
  padding: 2rem 1rem 0.5rem;
}

header h1 {
  font-size: 1.75rem;
  color: var(--text-heading);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 0.25rem;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

/* Search */
.search-container {
  margin-bottom: 1.25rem;
  position: relative;
}

#search {
  width: 100%;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px var(--shadow);
  outline: none;
  transition: border-color 0.2s;
}

#search:focus {
  border-color: var(--text-secondary);
}

#search::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Hide native search clear button */
#search::-webkit-search-cancel-button,
#search::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}

.clear-btn:hover {
  color: var(--text);
}

/* Welcome state */
.welcome {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.welcome strong {
  color: var(--text-heading);
}

/* GI Legend */
.gi-legend {
  margin-top: 1.75rem;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
}

.gi-legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.gi-legend-value {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.gi-legend-range {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.gi-legend-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* No results */
.no-results {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Result cards */
.results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Card entrance animation */
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: 0 1px 3px var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  animation: cardIn 0.25s ease-out both;
}

.result-card:active {
  transform: scale(0.985);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}

.result-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  gap: 0.75rem;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.result-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.result-gi {
  text-align: right;
  flex-shrink: 0;
}

.gi-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.gi-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.2rem;
}

/* Expanded detail */
.result-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease-out;
}

.result-card.expanded .result-detail {
  grid-template-rows: 1fr;
}

.detail-inner {
  overflow: hidden;
}

.detail-content {
  padding: 0 1rem 0.875rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 0.1rem;
}

/* Results count */
.results-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* History */
.history {
  margin-top: 1.5rem;
  text-align: left;
}

.history-heading {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

.history .result-card {
  margin-bottom: 0.5rem;
}

.clear-history {
  display: inline-block;
  margin-top: 0.5rem;
  padding-left: 0.25rem;
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
}

.clear-history:hover {
  color: var(--text);
  text-decoration: underline;
}

/* About link */
.about-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.15s;
}

.about-link:hover {
  color: var(--text-heading);
  text-decoration: underline;
}

/* About page */
.about {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

.about-content h2 {
  font-size: 1.25rem;
  color: var(--text-heading);
  margin-bottom: 1rem;
}

.about-content h3 {
  font-size: 0.95rem;
  color: var(--text-heading);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.about-content p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.about-content a {
  color: var(--text-heading);
  transition: color 0.15s;
}

.about-content a:hover {
  color: var(--text);
}

.citation {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
  font-style: italic;
}

.about-back {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.about-back:hover {
  color: var(--text);
}

/* Loading state */
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loading-dot {
  display: inline-block;
  animation: pulse 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .result-card {
    animation: none;
  }
  .result-detail {
    transition: none;
  }
  .result-card.expanded .result-detail {
    transition: none;
  }
}
