* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --accent: #f59e0b;
  --bg-dark: #0f0a1a;
  --bg-card: #1a1033;
  --bg-card-hover: #231545;
  --text: #e2e0e7;
  --text-muted: #b0adb8;
  --error: #ef4444;
  --success: #22c55e;
  --border: #2d2548;
  --glow: rgba(124, 58, 237, 0.3);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SKIP NAVIGATION (a11y) ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 9999;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  color: #fff;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: var(--accent);
}

.stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 45% 45%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 60% 70%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 55% 90%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 85% 55%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 95% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 40% 75%, rgba(255,255,255,0.4), transparent);
}

/* ===== NAVBAR ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 10, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.navbar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
}

.navbar-logo {
  font-weight: 700;
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  margin-right: auto;
}

.navbar-links {
  display: flex;
  gap: 6px;
  list-style: none;
  flex-wrap: wrap;
}

.navbar-links a {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: background 0.3s, color 0.3s;
}

.navbar-links a:hover,
.navbar-links a.active {
  background: var(--bg-card);
  color: var(--text);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 640px) {
  .menu-toggle {
    display: block;
  }
  .navbar-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(15, 10, 26, 0.97);
    backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .navbar-links.open {
    display: flex;
  }
  .navbar-links a {
    padding: 10px 14px;
  }
}

/* ===== CONTAINER ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* ===== PAGE HEADER ===== */
header {
  text-align: center;
  margin-bottom: 48px;
}

.symbol {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 12px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ===== FORM ===== */
form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--primary-light);
  font-size: 0.95rem;
}

input[type="text"],
input[type="date"],
input[type="email"],
textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s, box-shadow 0.3s;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}

/* Inline error messages (a11y) */
.error-message {
  display: none;
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 6px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  animation: fadeIn 0.3s ease;
}

.error-message.visible {
  display: block;
}

.form-group.has-error input {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

button[type="submit"] {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--glow);
}

button[type="submit"]:active {
  transform: translateY(0);
}

button[type="submit"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Loading state */
button[type="submit"].btn-loading {
  pointer-events: none;
  opacity: 0.85;
}

button[type="submit"].btn-loading .btn-text {
  visibility: hidden;
}

button[type="submit"].btn-loading .btn-icon {
  visibility: hidden;
}

button[type="submit"].btn-loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

button[type="submit"] {
  position: relative;
}

.btn-icon {
  font-size: 1.3rem;
}

/* ===== RESULTS ===== */
.results {
  animation: fadeIn 0.6s ease;
}

.results.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Staggered card animation */
.result-card {
  animation: fadeIn 0.5s ease both;
}
.results-grid .result-card:nth-child(1) { animation-delay: 0s; }
.results-grid .result-card:nth-child(2) { animation-delay: 0.1s; }
.results-grid .result-card:nth-child(3) { animation-delay: 0.2s; }
.results-grid .result-card:nth-child(4) { animation-delay: 0.3s; }
.results-grid .result-card:nth-child(5) { animation-delay: 0.4s; }

.results h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 28px;
  color: var(--accent);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

.results-grid > .result-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: 50%;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
  .results-grid > .result-card:last-child:nth-child(odd) {
    max-width: 100%;
  }
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.result-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--glow);
}

.result-header {
  margin-bottom: 16px;
}

.result-label {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-light);
}

.result-sublabel {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.result-number {
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  line-height: 1.1;
}

.result-keyword {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.result-description {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: left;
}

.result-calc {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Consolas', 'Courier New', monospace;
  word-break: break-all;
  text-align: left;
}

/* ===== PYTHAGOREAN TABLE ===== */
.pythagorean-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 28px;
  text-align: center;
}

.pythagorean-table h3 {
  margin-bottom: 16px;
  color: var(--primary-light);
  font-size: 1rem;
}

.pythagorean-table table {
  width: 100%;
  border-collapse: collapse;
}

.pythagorean-table th,
.pythagorean-table td {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.pythagorean-table th {
  background: var(--primary-dark);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.pythagorean-table td {
  color: var(--text);
  background: var(--bg-dark);
}

/* ===== RESET BUTTON ===== */
.btn-secondary {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--text);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== SHARE RESULTS BUTTON ===== */
.btn-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--accent), #d97706);
  border: none;
  border-radius: 10px;
  color: #0f0a1a;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin: 20px auto 0;
}

.btn-share:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

.btn-share:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.share-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--success);
  color: #0f0a1a;
  padding: 12px 28px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 1001;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s;
  pointer-events: none;
}

.share-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== RESULT TOOLTIP ===== */
.result-header {
  position: relative;
}

.result-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  width: max-content;
  max-width: 260px;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  text-align: center;
}

.result-tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--primary);
}

.result-header:hover .result-tooltip,
.result-header:focus-within .result-tooltip {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ===== ARTICLE / CONTENT PAGES ===== */
.article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  margin-bottom: 32px;
  line-height: 1.8;
}

.article h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin: 32px 0 14px;
}

.article h2:first-child {
  margin-top: 0;
}

.article h3 {
  font-size: 1.15rem;
  color: var(--primary-light);
  margin: 24px 0 10px;
}

.article p {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.article ul,
.article ol {
  color: var(--text-muted);
  margin: 0 0 16px 24px;
  font-size: 0.95rem;
}

.article li {
  margin-bottom: 6px;
}

.article strong {
  color: var(--text);
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
}

.article th,
.article td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  text-align: left;
}

.article th {
  background: var(--primary-dark);
  color: var(--accent);
  font-weight: 600;
}

.article td {
  background: var(--bg-dark);
  color: var(--text-muted);
}

.article blockquote {
  border-left: 3px solid var(--primary);
  padding: 12px 20px;
  margin: 16px 0;
  background: rgba(124, 58, 237, 0.08);
  border-radius: 0 10px 10px 0;
}

.article blockquote p {
  margin-bottom: 0;
  font-style: italic;
  color: var(--text);
}

.article .number-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
  margin-right: 12px;
  vertical-align: middle;
}

.article-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0;
}

@media (max-width: 640px) {
  .article-cards {
    grid-template-columns: 1fr;
  }
  .article {
    padding: 28px 20px;
  }
}

.article-card-link {
  display: block;
  text-decoration: none;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}

.article-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 0 16px var(--glow);
  transform: translateY(-2px);
}

.article-card-link h3 {
  margin: 0 0 6px;
  color: var(--primary-light);
  font-size: 1rem;
}

.article-card-link p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== CTA SECTION ===== */
.cta-section {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  margin-bottom: 32px;
}

.cta-section p {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.cta-button {
  display: inline-block;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--glow);
  color: white;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 32px 20px;
}

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
}

@media (max-width: 640px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }
}

.footer-col h4 {
  color: var(--primary-light);
  font-size: 0.9rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 8px;
}

.footer-col a {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-col p {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.footer-bottom {
  max-width: 800px;
  margin: 24px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== LANGUAGE SELECTOR ===== */
#lang-selector {
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  min-width: 42px;
}

#lang-selector:focus {
  outline: none;
  border-color: var(--primary);
}

@media (max-width: 640px) {
  #lang-selector {
    margin-left: auto;
    margin-right: 8px;
  }
}

/* ===== LANGUAGE NOTICE ===== */
.lang-notice {
  display: none;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 12px 20px;
  margin-bottom: 20px;
  color: var(--accent);
  font-size: 0.9rem;
  text-align: center;
}
/* ===== COOKIE BANNER ===== */
.cookie-banner {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  background: rgba(26, 16, 51, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.4s, transform 0.4s;
}

.cookie-banner.hidden {
  opacity: 0;
  transform: translateY(20px);
}

.cookie-banner-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.cookie-banner p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  margin: 0;
}

.cookie-banner-btns {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.cookie-banner-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: underline;
}

.cookie-banner-btn {
  padding: 10px 24px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

.cookie-banner-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  .cookie-banner-inner {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  .cookie-banner-btns {
    width: 100%;
    justify-content: center;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .stars,
  .navbar,
  .cookie-banner,
  .site-footer,
  .btn-secondary,
  .btn-share,
  .skip-link,
  #lang-selector,
  .menu-toggle,
  form {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .results {
    display: block !important;
  }

  .results.hidden {
    display: block !important;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .result-card {
    border: 1px solid #ccc;
    break-inside: avoid;
    animation: none !important;
  }

  .result-number {
    background: none;
    -webkit-text-fill-color: #000;
    color: #000;
  }

  h1 {
    background: none;
    -webkit-text-fill-color: #000;
    color: #000;
  }

  a {
    color: #000;
  }
}

/* ===== GLOBAL FOCUS VISIBLE ===== */
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
