/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --php-purple: #777BB4;
  --php-purple-dark: #4F5B93;
  --php-purple-deep: #3b3d5a;
  --php-purple-light: #a5a8d0;
  --php-purple-glow: rgba(119, 123, 180, 0.12);
  --warm-gold: #d4930d;
  --warm-amber: #b8860b;
  --warm-orange: #e8a735;
  --cream: #faf7f2;
  --cream-dark: #f0ebe3;
  --cream-deeper: #e6dfd4;
  --text: #2d2a26;
  --text-muted: #6b6560;
  --text-light: #9a938b;
  --code-bg: #f5f0e8;
  --code-border: #e0d8cc;
  --success-green: #4a8c5c;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Fira Code', monospace;
}

body {
  font-family: var(--font-body);
  background-color: var(--cream);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--warm-gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--warm-amber); text-decoration: underline; }

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--php-purple-dark) 0%, var(--php-purple) 50%, #8b8fd0 100%);
  padding: 2.5rem 2rem 2rem 4rem;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  border-radius: 50%;
}
.header::after {
  content: '<?= happiness ?>';
  position: absolute;
  right: 4rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.2);
  letter-spacing: 0.05em;
}
.header h1 {
  margin: 0;
  font-family: 'Nunito', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.header h1 a {
  color: #fff;
  text-decoration: none;
}
.header h1 a:hover { color: var(--warm-orange); text-decoration: none; }
.header h1 .php-highlight {
  color: var(--warm-orange);
  font-style: italic;
}
.header .tagline {
  font-family: var(--font-mono);
  color: rgba(255,255,255,0.65);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  letter-spacing: 0.02em;
}

/* ── Content Container ── */
.content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 2rem 8rem;
}

/* ── Index Page ── */
.intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.8;
}
.intro strong { color: var(--text); }

.category-heading {
  margin-top: 3rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--php-purple);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--php-purple-glow);
}

.entry-link {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}
.entry-link:hover {
  border-bottom-color: var(--cream-deeper);
}
.entry-link:hover .entry-title { color: var(--warm-gold); text-decoration: none; }

.entry-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-light);
  min-width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

.entry-title {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  color: var(--php-purple-deep);
  transition: color 0.2s;
}
.entry-title code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--php-purple-glow);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--php-purple-dark);
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--success-green);
  background: rgba(74, 140, 92, 0.08);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Detail Page ── */
.detail-view { display: block; }
.detail-view.active { display: block; }
.index-view.hidden { display: none; }

.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--cream-deeper);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.nav-buttons a {
  color: var(--php-purple);
  padding: 0.4rem 0;
}
.nav-buttons a:hover { color: var(--warm-gold); text-decoration: none; }
.nav-buttons .nav-index { font-weight: 600; }

.detail-view h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  line-height: 1.3;
}

.detail-view p {
  margin-bottom: 1.2rem;
  font-size: 1rem;
  line-height: 1.8;
}

.detail-view pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-left: 3px solid var(--php-purple);
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  border-radius: 0 4px 4px 0;
  font-size: 0.88rem;
  line-height: 1.65;
}
.detail-view code {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.detail-view p code, .detail-view li code {
  background: var(--php-purple-glow);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--php-purple-dark);
  font-size: 0.85em;
}
.detail-view pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Syntax Highlighting (Prism.js warm theme) ── */
code[class*="language-"],
pre[class*="language-"] {
  color: #4a453e;
  text-shadow: none;
  word-break: normal;
  word-wrap: normal;
  tab-size: 4;
  hyphens: none;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #a09585;
  font-style: italic;
}
.token.string,
.token.attr-value {
  color: #8b6c2a;
}
.token.number,
.token.boolean,
.token.constant {
  color: #b8680b;
}
.token.keyword {
  color: var(--php-purple-dark);
  font-weight: 500;
}
.token.class-name {
  color: var(--php-purple-deep);
}
.token.function {
  color: #6a5d8e;
}
.token.operator,
.token.entity,
.token.url {
  color: #7a7064;
}
.token.punctuation {
  color: #8a8078;
}
.token.variable {
  color: #5c6f44;
}
.token.delimiter.important,
.token.tag {
  color: var(--php-purple);
  font-weight: 600;
}
.token.attr-name {
  color: #8b6c5c;
}
.token.important,
.token.bold {
  font-weight: 600;
}
.token.italic {
  font-style: italic;
}
code[class*="language-"]::selection,
code[class*="language-"] *::selection,
pre[class*="language-"]::selection,
pre[class*="language-"] *::selection {
  background: rgba(119, 123, 180, 0.2);
}

/* ── PHP link badges (matching phpsadness style) ── */
.link-php {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--php-purple);
  background: var(--cream);
  color: var(--php-purple-deep);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  margin: 0.15rem 0.1rem;
  transition: all 0.15s;
  text-decoration: none !important;
}
.link-php:hover {
  background: #fff;
  border-color: var(--php-purple-light);
  color: var(--php-purple);
  text-decoration: none;
}
.link-php-tag {
  background: var(--php-purple);
  color: #fff;
  padding: 0.15em 0.4em;
  font-weight: 600;
  font-size: 0.75em;
  letter-spacing: 0.03em;
}
.link-php:hover .link-php-tag {
  background: var(--php-purple-light);
}
.link-php-name {
  padding: 0.1em 0.5em;
}

/* ── Significance Box ── */
.significance {
  border: 2px solid var(--php-purple);
  border-radius: 6px;
  margin: 2.5rem 0;
  overflow: hidden;
}
.significance h3 {
  background: var(--php-purple);
  color: #fff;
  margin: 0;
  padding: 0.75rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.significance h3 .sig-label {
  color: rgba(255,255,255,0.6);
}
.significance .sig-body {
  padding: 1.2rem 1.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--php-purple-glow);
}

/* ── Bottom nav ── */
.nav-bottom {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--cream-deeper);
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 2rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header { padding: 1.5rem 1.25rem; }
  .header h1 { font-size: 2rem; }
  .header::after { display: none; }
  .content { padding: 1.25rem 1.25rem 6rem; }
  .detail-view h2 { font-size: 1.5rem; }
  .nav-buttons { font-size: 0.72rem; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
  .detail-view pre { padding: 0.8rem 1rem; font-size: 0.8rem; }
  .entry-link { gap: 0.5rem; }
}

/* ── Data Tables ── */
.stat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.stat-table th {
  background: var(--php-purple);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.65rem 1rem;
  text-align: left;
}
.stat-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--cream-deeper);
  vertical-align: top;
}
.stat-table tr:nth-child(even) td {
  background: var(--php-purple-glow);
}
.stat-table .num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--php-purple-dark);
}
.stat-table .highlight-row td {
  background: rgba(212, 147, 13, 0.08);
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--php-purple-glow);
  border: 1px solid var(--cream-deeper);
  border-radius: 6px;
  padding: 1.2rem;
  text-align: center;
}
.stat-card .stat-number {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--php-purple-dark);
  line-height: 1.2;
}
.stat-card .stat-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
}
.stat-card.gold {
  border-color: var(--warm-gold);
  background: rgba(212, 147, 13, 0.06);
}
.stat-card.gold .stat-number {
  color: var(--warm-amber);
}

.source-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

.bar-chart {
  margin: 1.5rem 0;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.bar-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 100px;
  text-align: right;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  background: var(--cream-dark);
  border-radius: 3px;
  height: 22px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--php-purple);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #fff;
  font-weight: 600;
  min-width: 2.5rem;
}
.bar-fill.gold {
  background: var(--warm-gold);
}

@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card .stat-number { font-size: 1.4rem; }
  .bar-label { min-width: 70px; font-size: 0.7rem; }
  .stat-table { font-size: 0.82rem; }
  .stat-table th, .stat-table td { padding: 0.45rem 0.6rem; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.detail-view.active {
  animation: fadeIn 0.25s ease-out;
}
.index-view {
  animation: fadeIn 0.2s ease-out;
}
