/* ============================================
   Now is Youngest — Home Page Styles
   Variables are defined in variables.css
   ============================================ */

/* --- Site Header --- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-4xl);
  height: var(--header-height);
  background: var(--color-bg-base);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--color-text-primary);
  font-size: var(--text-lg);
  font-weight: 700;
}

.logo-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 0.25rem;
  background: var(--color-accent);
  display: inline-block;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-nav a {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: var(--text-md);
  font-weight: 500;
  transition: color 0.2s ease;
}

.site-nav a:hover {
  color: var(--color-text-primary);
}

.btn-start {
  background: var(--color-text-primary);
  color: var(--color-bg-base) !important;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: var(--text-base);
  transition: opacity 0.2s ease;
}

.btn-start:hover {
  opacity: 0.85;
}

/* --- Scallop Line --- */
.scallop-line {
  display: block;
  width: 100%;
  height: 1rem;
  overflow: visible;
}

/* --- Tools Section (2-col Grid) --- */
.tools-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3xl) var(--space-2xl);
  padding: var(--space-3xl) var(--space-4xl);
  max-width: 1280px;
  margin: 0 auto;
}

/* --- Tool Group --- */
.tool-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  opacity: 0;
  transform: translateY(1.5rem);
  animation: toolGroupReveal 0.6s ease forwards;
}

@keyframes toolGroupReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-group--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Title row */
.tool-group-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.tool-group-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.tool-group-sep {
  font-size: var(--text-base);
  color: var(--color-text-muted);
}

.tool-group-catch {
  font-size: var(--text-md);
  color: var(--color-text-secondary);
}

/* Preview area */
.tool-group-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--color-card-bg);
  border: 2px solid var(--color-border);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.tool-group-preview:hover {
  border-color: var(--color-accent);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
  animation: previewRipple 0.6s ease;
}

@keyframes previewRipple {
  0%   { filter: url(#svg-ripple-0); }
  30%  { filter: url(#svg-ripple-1); }
  60%  { filter: url(#svg-ripple-2); }
  100% { filter: none; }
}

@media (prefers-color-scheme: dark) {
  .tool-group-preview:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  }
}

/* Placeholder (shown until real screenshots) */
.tool-group-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
}

/* CTA button */
.tool-group-cta {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.375rem;
  padding: var(--space-xs) var(--space-lg);
  background: var(--color-text-primary);
  color: var(--color-bg-base);
  border-radius: var(--radius-btn);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.tool-group-cta:hover {
  opacity: 0.85;
}

.tool-group-cta svg {
  flex-shrink: 0;
}

/* ===========================================
   Preview Demo Animations
   =========================================== */

.demo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-2xl);
  font-family: var(--font-base);
  pointer-events: none;
}

.demo-label {
  font-size: var(--demo-text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.demo-arrow {
  font-size: var(--demo-text-2xl);
  color: var(--color-accent);
  font-weight: 700;
  animation: demoArrowPulse 4s ease-in-out infinite;
}

@keyframes demoArrowPulse {
  0%, 30% { opacity: 0; }
  40%, 80% { opacity: 1; }
  90%, 100% { opacity: 0; }
}

/* Typing effect */
.demo-typing {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: 0;
  font-size: var(--demo-text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  font-family: 'SF Mono', 'Menlo', monospace;
  animation: demoType 4s steps(var(--chars, 4)) infinite;
}

@keyframes demoType {
  0%, 5%   { width: 0; }
  25%, 80% { width: calc(var(--chars, 4) * 0.7em); }
  95%, 100% { width: 0; }
}

.demo-cursor {
  display: inline-block;
  color: var(--color-accent);
  font-weight: 300;
  animation: demoBlink 0.8s step-end infinite;
}

@keyframes demoBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Fade-in result */
.demo-fadein {
  animation: demoFadeIn 4s ease infinite;
}

@keyframes demoFadeIn {
  0%, 30%  { opacity: 0; transform: translateY(4px); }
  45%, 80% { opacity: 1; transform: translateY(0); }
  95%, 100% { opacity: 0; transform: translateY(4px); }
}

/* --- Year Calculation Demo --- */
.demo--year {
  gap: var(--space-md);
}

.demo-input-row,
.demo-result-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
}

.demo-field {
  display: flex;
  align-items: center;
  background: var(--color-bg-base);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: var(--space-2xs) var(--space-sm);
  min-width: 5em;
  justify-content: center;
}

.demo-value {
  font-size: var(--demo-text-xl);
  font-weight: 700;
  color: var(--color-accent);
  font-family: 'SF Mono', 'Menlo', monospace;
}

/* --- Budget Demo --- */
.demo--budget {
  flex-direction: column;
  gap: var(--space-sm);
}

.demo-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-md);
  height: 60%;
  width: 60%;
}

.demo-bar {
  width: 3rem;
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--space-2xs);
  height: 0;
  animation: demoBarGrow 4s ease infinite;
}

.demo-bar span {
  font-size: var(--demo-text-2xs);
  font-weight: 600;
  color: #fff;
  opacity: 0;
  animation: demoFadeIn 4s ease infinite;
}

@keyframes demoBarGrow {
  0%, 10%  { height: 0; }
  35%, 80% { height: var(--bar-h, 50%); }
  95%, 100% { height: 0; }
}

.demo-bar--income  { background: var(--color-accent); animation-delay: 0s; }
.demo-bar--income span { animation-delay: 0s; }
.demo-bar--expense { background: #ef4444; animation-delay: 0.15s; }
.demo-bar--expense span { animation-delay: 0.15s; }
.demo-bar--saving  { background: #22c55e; animation-delay: 0.3s; }
.demo-bar--saving span { animation-delay: 0.3s; }

.demo-chart-label {
  font-size: var(--demo-text-lg);
  font-weight: 700;
  color: #22c55e;
}

/* --- Decode Demo --- */
.demo--decode {
  flex-direction: column;
  gap: var(--space-xs);
}

.demo-before {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: var(--demo-text-xs);
  color: var(--color-text-muted);
  background: var(--color-bg-base);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: var(--space-2xs) var(--space-sm);
  word-break: break-all;
  text-align: center;
  max-width: 90%;
  animation: demoBeforeFade 4s ease infinite;
}

@keyframes demoBeforeFade {
  0%, 5%   { opacity: 0; }
  15%, 80% { opacity: 1; }
  95%, 100% { opacity: 0; }
}

.demo-after {
  font-size: var(--demo-text-2xl);
  font-weight: 700;
  color: var(--color-accent);
}

/* --- Encode Demo --- */
.demo--encode {
  flex-direction: column;
  gap: var(--space-xs);
}

.demo--encode .demo-before {
  font-size: var(--demo-text-lg);
  font-weight: 700;
  color: var(--color-text-primary);
  background: var(--color-bg-base);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: var(--space-2xs) var(--space-sm);
  text-align: center;
}

.demo--encode .demo-after {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: var(--demo-text-xs);
  color: var(--color-accent);
  background: var(--color-accent-light);
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-btn);
  padding: var(--space-2xs) var(--space-sm);
  word-break: break-all;
  text-align: center;
  max-width: 90%;
}

/* --- Datetime Demo --- */
.demo--datetime {
  flex-direction: column;
  gap: var(--space-xs);
}

.demo-lines {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: var(--demo-text-xs);
  white-space: nowrap;
}

.demo-lines--before {
  color: var(--color-text-muted);
  animation: demoBeforeFade 4s ease infinite;
}

.demo-lines--before span {
  background: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 1px var(--space-2xs);
}

.demo-lines--after span {
  background: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  border-radius: 3px;
  padding: 1px var(--space-2xs);
  color: var(--color-accent);
  font-weight: 600;
}

/* --- Format Demo --- */
.demo--format {
  flex-direction: column;
  gap: var(--space-xs);
}

.demo--format .demo-lines {
  font-size: var(--demo-text-xs);
}

.demo--format .demo-lines--before span {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  color: var(--color-error-text);
  border-radius: 3px;
  padding: 1px var(--space-2xs);
  white-space: pre;
}

.demo--format .demo-lines--after span {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: var(--color-success-text);
  border-radius: 3px;
  padding: 1px var(--space-2xs);
}

/* --- Wave Divider (smooth wave before footer) --- */
.wave-divider {
  display: block;
  width: 100%;
  line-height: 0;
  margin-bottom: -1px;
}

.wave-divider svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Footer --- */
.site-footer {
  background: var(--color-footer-bg);
  padding: var(--space-2xl) var(--space-4xl);
  position: relative;
  overflow: hidden;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  position: relative;
  z-index: 1;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
}

.footer-logo .logo-dot {
  background: var(--color-gold);
}

.footer-logo-text {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-footer-text);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
}

.footer-links a {
  color: var(--color-footer-link);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--color-footer-text);
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
}

.footer-tagline {
  font-size: var(--text-2xs);
  color: var(--color-footer-muted);
}

.footer-copy {
  font-size: var(--text-2xs);
  color: var(--color-footer-muted);
}

/* Gold vein lines in footer */
.gold-veins {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* --- Ad slots --- */
.ad-slot {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem var(--space-4xl);
}

/* --- Responsive (layout-only, font scaling handled by root clamp) --- */
@media (max-width: 1024px) {
  .site-header {
    padding: 0 var(--space-md);
  }

  .tools-section {
    padding: var(--space-2xl) var(--space-md);
    gap: var(--space-2xl) var(--space-lg);
  }

  .site-footer {
    padding: var(--space-md) var(--space-md);
  }

  .ad-slot {
    padding: 1rem var(--space-md);
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0 var(--space-md);
  }

  .tools-section {
    grid-template-columns: 1fr;
    padding: var(--space-lg) var(--space-md);
    gap: var(--space-xl);
  }

  .tool-group-preview {
    aspect-ratio: 16 / 9;
  }

  .tool-group-title {
    flex-direction: column;
    gap: var(--space-2xs);
  }

  .tool-group-sep {
    display: none;
  }

  .site-footer {
    padding: var(--space-md) var(--space-md);
  }

  .ad-slot {
    padding: var(--space-sm) var(--space-md);
  }
}

@media (max-width: 480px) {
  .tool-group-cta {
    width: 100%;
    justify-content: center;
  }

  .footer-links {
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
  }
}
