/* ============================================
   MatrixDestiny — Stylesheet
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Color system — Dark theme (default) */
  --primary: #c9a84a;
  --primary-light: #e0c870;
  --primary-dark: #9d8232;
  --primary-50: rgba(201, 168, 74, 0.06);
  --primary-100: rgba(201, 168, 74, 0.12);
  --primary-200: rgba(201, 168, 74, 0.25);

  --secondary: #4a7c8f;
  --secondary-light: #6ba3b8;
  --secondary-dark: #345968;

  --accent: #d4af6a;
  --accent-light: #e8c98a;

  --success: #5b9a6e;
  --success-light: #7bc490;
  --warning: #d4a554;
  --warning-light: #e8c27a;
  --error: #c95c5c;
  --error-light: #e07878;

  --bg: #0d0f14;
  --bg-elevated: #161922;
  --bg-card: #1a1e2a;
  --bg-input: #222735;
  --bg-hover: #283040;

  --text: #e8e6e0;
  --text-secondary: #a4a2a0;
  --text-muted: #6c6a68;
  --text-on-primary: #1a1e2a;

  --border: #2a3040;
  --border-light: #353d50;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 30px rgba(201, 168, 74, 0.15);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms ease;
}

[data-theme="light"] {
  --primary: #8a6d1b;
  --primary-light: #b39239;
  --primary-dark: #6a5414;
  --primary-50: rgba(138, 109, 27, 0.05);
  --primary-100: rgba(138, 109, 27, 0.10);
  --primary-200: rgba(138, 109, 27, 0.22);

  --secondary: #3a6b7e;
  --secondary-light: #5a8ba0;
  --secondary-dark: #2a4f5e;

  --accent: #9a7b3a;
  --accent-light: #c0a05a;

  --bg: #f5f3ee;
  --bg-elevated: #fffef9;
  --bg-card: #fffdf7;
  --bg-input: #f0ede5;
  --bg-hover: #eae6db;

  --text: #2a2825;
  --text-secondary: #6a665f;
  --text-muted: #9a958c;
  --text-on-primary: #fffdf7;

  --border: #ddd8cc;
  --border-light: #c9c3b5;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 0 30px rgba(138, 109, 27, 0.08);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  line-height: 1.2;
  font-weight: 600;
}

/* ---------- Starfield ---------- */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.starfield .star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0;
  animation: twinkle 4s infinite ease-in-out;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 0.6; transform: scale(1); }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

[data-theme="light"] .site-header {
  background: rgba(245, 243, 238, 0.85);
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.logo-text span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
}

/* Theme toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: scale(1.05);
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
  color: var(--text);
  transition: opacity var(--transition), transform 400ms ease;
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

.theme-toggle:hover svg { color: var(--primary); }

/* ---------- Main ---------- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  position: relative;
  z-index: 1;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.hero-title em {
  color: var(--primary);
  font-style: italic;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}

.card-title {
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- Form ---------- */
.input-section {
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

.birth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.date-row {
  gap: 0.75rem;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.optional {
  text-transform: none;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-error {
  color: var(--error);
  font-size: 0.85rem;
  min-height: 1.2rem;
  transition: opacity var(--transition-fast);
}

.form-error:empty { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--text-on-primary);
  padding: 0.85rem 2rem;
  box-shadow: 0 4px 16px var(--primary-200);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 6px 24px var(--primary-200), var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border-light);
  padding: 0.6rem 1.25rem;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
}

.btn-ghost:hover {
  color: var(--error);
  background: rgba(201, 92, 92, 0.08);
}

.btn-sm { font-size: 0.82rem; padding: 0.5rem 1rem; }
.btn-lg { font-size: 1.05rem; padding: 1rem 2.5rem; }

.btn-large {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.btn-icon { width: 20px; height: 20px; }
.btn-icon-sm { width: 16px; height: 16px; }

/* ---------- Results ---------- */
.results-section {
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.profile-info h3 {
  font-size: 1.5rem;
  color: var(--text);
}

.profile-info p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- Matrix SVG ---------- */
.matrix-card {
  text-align: center;
}

.matrix-wrapper {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

#matrixSvg {
  width: 100%;
  max-width: 560px;
  height: auto;
}

/* SVG element styles */
.matrix-line {
  stroke: var(--border-light);
  stroke-width: 1;
  fill: none;
  transition: stroke var(--transition);
}

.matrix-line-accent {
  stroke: var(--primary-200);
  stroke-width: 1.5;
  fill: none;
}

.matrix-star-line {
  stroke: var(--primary-200);
  stroke-width: 1;
  fill: none;
  opacity: 0.5;
}

.matrix-node-bg {
  fill: var(--bg-elevated);
  stroke: var(--primary);
  stroke-width: 2;
  transition: all var(--transition);
}

.matrix-node-bg.center {
  fill: var(--primary-50);
  stroke: var(--primary);
  stroke-width: 2.5;
}

.matrix-node-bg.k-arm,
.matrix-node-bg.k-head {
  stroke: var(--secondary);
}

.matrix-node-text {
  fill: var(--text);
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 22px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

.matrix-node-label {
  fill: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 9px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.5px;
}

.matrix-node-group {
  cursor: pointer;
}

.matrix-node-group:hover .matrix-node-bg {
  fill: var(--primary);
  stroke: var(--primary-light);
  transform: scale(1.1);
  transform-origin: center;
}

.matrix-node-group:hover .matrix-node-text {
  fill: var(--text-on-primary);
}

.matrix-node-group.active .matrix-node-bg {
  fill: var(--primary);
  stroke: var(--primary-light);
}

.matrix-node-group.active .matrix-node-text {
  fill: var(--text-on-primary);
}

.matrix-title-text {
  fill: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  text-anchor: middle;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.matrix-legend {
  margin-top: 1rem;
}

.matrix-legend p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Interpretations ---------- */
.interpretation-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.interpretation-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  transition: all var(--transition);
  animation: slideIn 0.4s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.interpretation-item:hover {
  border-color: var(--primary-200);
}

.interpretation-item.highlighted {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.interpretation-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.arcana-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.arcana-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 600;
}

.arcana-position {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}

.arcana-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}

.keyword-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  background: var(--primary-50);
  color: var(--primary);
  border: 1px solid var(--primary-100);
  font-weight: 500;
}

.arcana-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.arcana-shadow {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.arcana-shadow strong {
  color: var(--error);
  font-weight: 600;
}

/* ---------- History ---------- */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.history-header .card-title {
  margin: 0;
  padding: 0;
  border: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--border-light);
  margin-bottom: 0.75rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  animation: slideIn 0.4s ease;
}

.history-item:hover {
  border-color: var(--primary-200);
  transform: translateX(4px);
}

.history-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.history-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

.history-item-text {
  min-width: 0;
}

.history-item-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-item-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.edit:hover { color: var(--primary); }
.icon-btn.delete:hover { color: var(--error); background: rgba(201, 92, 92, 0.1); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error { border-color: var(--error); }
.toast.success { border-color: var(--success); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .header-content { padding: 0.75rem 1rem; }
  .logo-text span { display: none; }
  .logo-text h1 { font-size: 1.25rem; }
  main { padding: 1.5rem 1rem 3rem; }
  .hero { padding: 1rem 0.5rem 1.5rem; }
  .card { padding: 1.25rem; }
  .form-row { flex-direction: column; }
  .date-row { flex-direction: row; }
  .date-row .form-group { min-width: 0; }
  .profile-card { flex-direction: column; align-items: flex-start; }
  #matrixSvg { max-width: 100%; }
  .matrix-node-text { font-size: 18px; }
  .matrix-node-label { font-size: 7px; }
}

@media (max-width: 380px) {
  .matrix-node-text { font-size: 15px; }
  .matrix-node-label { font-size: 6px; }
}
