/* ============================================
   CODEX AETERNA - Main Stylesheet
   ============================================ */

:root {
  --bg: #05060a;
  --bg-alt: #0c0f18;
  --accent: #f2c46b;
  --accent-soft: rgba(242, 196, 107, 0.12);
  --text: #f5f5f7;
  --text-soft: #b5b7c4;
  --border: #222637;
  --error: #ff6b6b;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
  --shadow-soft-small: 0 10px 25px rgba(0, 0, 0, 0.45);
  --max-width: 1040px;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1a1a2e 0, #05060a 40%, #020308 100%);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================
   LAYOUT
   ============================================ */

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text span:first-child {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--text);
}

.logo-text span:last-child {
  font-size: 0.78rem;
  color: var(--text-soft);
}

nav {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-soft);
}

nav a {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-soft);
}

nav a:hover {
  border-color: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

nav a.active,
nav a.highlight {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2.4fr);
  gap: 32px;
  margin-bottom: 48px;
}

.hero-main h1 {
  font-size: clamp(2.4rem, 3.2vw + 1rem, 3.3rem);
  line-height: 1.1;
  margin-bottom: 14px;
}

.hero-main h1 span {
  background: linear-gradient(120deg, var(--accent), #f9f0ff);
  -webkit-background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 1rem;
  color: var(--text-soft);
  margin-bottom: 18px;
}

.hero-tagline {
  font-style: italic;
  color: var(--accent);
  margin-bottom: 24px;
  font-size: 0.96rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.hero-meta {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
}

.hero-meta-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(242, 196, 107, 0.8);
}

/* ============================================
   HERO VISUAL
   ============================================ */

.hero-visual {
  background: radial-gradient(circle at top, #26263f, #05060a);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 28px;
  position: relative;
  overflow: visible;
}

.hero-visual-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.hero-visual-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
}

.hero-visual-meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero-visual-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.signature-preview {
  background: radial-gradient(circle at 15% 15%, rgba(242, 196, 107, 0.18), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(102, 126, 234, 0.28), transparent 55%),
    #020309;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  height: 260px;
  position: relative;      
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#visual-tooltip-wrapper {
  overflow: visible !important;
}

.signature-lines {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.8s ease-in-out;
  animation: pulse-soul 8s infinite ease-in-out;
}

.signature-lines.fade-out {
  opacity: 0;
}

.signature-fade {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0, transparent 48%, rgba(2, 3, 9, 0.85) 100%);
}

.hero-visual-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.hero-visual-footer > span:first-child {
  flex: 1 1 auto;
  min-width: 150px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, background 0.12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #ffecb0);
  color: #1a1307;
  box-shadow: var(--shadow-soft);
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ============================================
   PILLS & BADGES
   ============================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.72rem;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-soft);
  margin-bottom: 6px;
}

/* ============================================
   SECTIONS
   ============================================ */

section {
  margin-bottom: 40px;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.04), transparent 55%),
    radial-gradient(circle at bottom right, rgba(103, 65, 217, 0.16), transparent 60%), var(--bg-alt);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-soft);
  padding: 24px 20px 26px;
}

section h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

section > p.section-intro {
  font-size: 0.95rem;
  color: var(--text-soft);
  margin-bottom: 14px;
}

/* ============================================
   GRID SYSTEM
   ============================================ */

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ============================================
   CARDS
   ============================================ */

.card {
  border-radius: var(--radius-lg);
  background: rgba(2, 3, 10, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 14px 16px;
  font-size: 0.9rem;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.card p {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.products-grid .card {
  background: radial-gradient(circle at top, rgba(242, 196, 107, 0.08), rgba(2, 3, 10, 0.98));
}

.products-grid ul {
  list-style: none;
  margin-top: 6px;
  font-size: 0.84rem;
  color: var(--text-soft);
}

.products-grid ul li::before {
  content: "• ";
  color: var(--accent);
}

/* ============================================
   FORMS
   ============================================ */

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 22px;
}

form {
  display: grid;
  gap: 12px;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 3px;
  color: var(--text-soft);
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(2, 3, 10, 0.9);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(242, 196, 107, 0.4);
  background: #050714;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.form-row {
  display: grid;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.checkbox-row input {
  width: auto;
  margin-top: 2px;
}

.contact-note {
  font-size: 0.84rem;
  color: var(--text-soft);
  margin-top: 8px;
}

/* ============================================
   FOOTER
   ============================================ */

footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: var(--text-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes pulse-soul {
  0% { transform: scale(1.05); opacity: 0.9; }
  50% { transform: scale(1.02); opacity: 0.75; }
  100% { transform: scale(1.05); opacity: 0.9; }
}

/* ============================================
   TOOLTIPS
   ============================================ */

.signature-preview[data-tooltip] {
  position: relative;
  overflow: visible;
}

.signature-preview[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 110%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.3;
  max-width: 240px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.signature-preview[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 102%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
  opacity: 0;
  z-index: 9998;
  transition: opacity 0.2s ease;
}

.signature-preview[data-tooltip]:hover::after,
.signature-preview[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%);
}

/* ============================================
   HAMBURGER BUTTON
   ============================================ */

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-soft);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

header.nav-open .hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

header.nav-open .hamburger span:nth-child(2) {
  opacity: 0;
}

header.nav-open .hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 820px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  header {
    flex-wrap: wrap;
    align-items: center;
  }

  .hamburger {
    display: flex;
  }

  header nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 4px;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  header.nav-open nav {
    display: flex;
    background: #1a1a2e;
    border-radius: 12px;
    padding: 8px;
    margin-top: 10px;
  }

  header nav a {
    border-radius: 8px;
    padding: 10px 12px;
    border-color: transparent;
  }

  header nav a:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

@media (min-width: 720px) {
  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================
   DEMO PAGE SPECIFIC
   ============================================ */

.demo-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.demo-section .input-panel,
.demo-section .output-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 28px;
  border-radius: var(--radius-lg);
}

.demo-section h2 {
  font-size: 1.1rem;
  margin-bottom: 18px;
  font-weight: 500;
  color: var(--accent);
}

.demo-section textarea {
  height: 280px;
  background: rgba(0, 0, 0, 0.4);
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.demo-section .controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.demo-section .output-panel {
  text-align: center;
}

.demo-section .canvas-container {
  background: #000;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  position: relative;
}

.demo-section canvas {
  max-width: 100%;
  height: auto;
}

.demo-section .placeholder {
  color: #444;
  font-style: italic;
  position: absolute;
}

.demo-section .stats {
  margin-top: 18px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.demo-section .stats-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.demo-section .stats-row:last-child {
  border-bottom: none;
}

.demo-section .stats-label {
  color: #666;
}

.demo-section .stats-value {
  color: var(--accent);
}

.demo-section .loading {
  color: var(--accent);
  animation: pulse 1.5s infinite;
}

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

.footer-note {
  text-align: center;
  margin-top: 40px;
  color: #555;
  font-size: 0.85rem;
}

.footer-note a {
  color: var(--accent);
}

@media (max-width: 900px) {
  .demo-section {
    grid-template-columns: 1fr;
  }
}

/* Page title for demo */
.page-title {
  text-align: center;
  font-size: 2.2rem;
  margin-bottom: 10px;
  font-weight: 300;
  letter-spacing: 2px;
  color: var(--accent);
}

.page-subtitle {
  text-align: center;
  color: var(--text-soft);
  margin-bottom: 40px;
  font-style: italic;
}

/* Voice recording button */
.btn.recording {
  background: #7a1a1a;
  border-color: #c0392b;
  color: #ff9999;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

@media (max-width: 768px) {
  #micBtn { display: none; }
}
