/**
 * Legal Pages Styles
 * Apple-inspired design for Privacy Policy and Terms of Use pages
 */

/* ========================================================================
   LEGAL HERO
   Elevated dark hero with glassmorphism matching about page
   ======================================================================== */

.legal-hero {
  position: relative;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-20) var(--space-6) var(--space-12);
  text-align: center;
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
  overflow: hidden;
}

/* Hero background effects */
.legal-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle at 30% 50%,
    rgba(99, 102, 241, 0.12) 0%,
    rgba(168, 85, 247, 0.08) 25%,
    transparent 50%
  );
  animation: pulse 8s ease-in-out infinite;
  z-index: 0;
}

.legal-hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.5;
  z-index: 0;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.legal-badge {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  color: var(--color-white);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
  animation: fadeInUp 0.6s ease-out;
}

.legal-title {
  position: relative;
  z-index: 1;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.1;
  margin-bottom: var(--space-4);
  letter-spacing: -0.03em;
  animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s backwards;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.legal-subtitle {
  position: relative;
  z-index: 1;
  font-size: clamp(18px, 2.5vw, 21px);
  font-weight: var(--font-weight-regular);
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  max-width: 700px;
  margin: 0 auto var(--space-4);
  animation: fadeInUp 0.6s ease-out 0.2s backwards;
}

.legal-last-updated {
  position: relative;
  z-index: 1;
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.6);
  font-weight: var(--font-weight-medium);
  animation: fadeInUp 0.6s ease-out 0.3s backwards;
}

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

@media (max-width: 768px) {
  .legal-hero {
    min-height: 50vh;
    padding: var(--space-16) var(--space-4) var(--space-10);
  }

  .legal-title {
    font-size: clamp(32px, 8vw, 40px);
  }

  .legal-subtitle {
    font-size: var(--font-size-base);
  }
}

/* ========================================================================
   LEGAL LAYOUT
   Two-column layout with sticky TOC
   ======================================================================== */

.legal-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
}

.legal-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-12);
  align-items: start;
}

@media (max-width: 1024px) {
  .legal-layout {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* ========================================================================
   TABLE OF CONTENTS
   Sticky sidebar navigation
   ======================================================================== */

.legal-toc {
  position: sticky;
  top: var(--space-20);
  padding: var(--space-6);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.legal-toc-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-grey-900);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
}

.legal-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.legal-toc-list li {
  margin-bottom: var(--space-2);
}

.toc-link {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--color-grey-700);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-standard);
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--color-grey-900);
  background: rgba(0, 0, 0, 0.04);
}

.toc-link.active {
  color: var(--color-grey-900);
  background: rgba(0, 0, 0, 0.06);
  font-weight: var(--font-weight-semibold);
}

@media (max-width: 1024px) {
  .legal-toc {
    position: static;
    max-width: 100%;
  }
}

/* ========================================================================
   LEGAL CONTENT
   Main content area with sections
   ======================================================================== */

.legal-content {
  max-width: 800px;
  margin: 0 auto;
}

.legal-section {
  margin-bottom: var(--space-16);
  scroll-margin-top: 100px;
}

.legal-section:last-child {
  margin-bottom: 0;
}

.legal-section-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-grey-900);
  margin-bottom: var(--space-6);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.legal-section-content {
  color: var(--color-grey-700);
  font-size: var(--font-size-base);
  line-height: 1.7;
}

/* ========================================================================
   TYPOGRAPHY
   Paragraphs, lists, and subsections
   ======================================================================== */

.legal-paragraph {
  margin-bottom: var(--space-4);
  color: var(--color-grey-700);
  line-height: 1.7;
}

.legal-paragraph:last-child {
  margin-bottom: 0;
}

.legal-list {
  margin: var(--space-4) 0;
  padding-left: var(--space-6);
  list-style-type: disc;
}

.legal-list li {
  margin-bottom: var(--space-3);
  color: var(--color-grey-700);
  line-height: 1.7;
  padding-left: var(--space-2);
}

.legal-list li::marker {
  color: var(--color-grey-500);
}

.legal-subsection {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  padding-left: var(--space-6);
  background: linear-gradient(
    to right,
    rgba(99, 102, 241, 0.03) 0%,
    transparent 100%
  );
  border-left: 3px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
}

.legal-subsection-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-grey-900);
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

/* ========================================================================
   CONTACT INFO
   Special styling for contact sections
   ======================================================================== */

.legal-contact {
  margin: var(--space-6) 0;
  padding: var(--space-8);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(249, 250, 251, 0.9) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.legal-contact-item {
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

.legal-contact-item:last-child {
  margin-bottom: 0;
}

.legal-contact-item strong {
  color: var(--color-grey-900);
  font-weight: var(--font-weight-semibold);
}

.legal-link {
  color: var(--color-grey-700);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--duration-fast) var(--ease-standard);
}

.legal-link:hover {
  color: var(--color-grey-900);
}

.legal-address {
  margin-top: var(--space-2);
  color: var(--color-grey-700);
  line-height: 1.6;
}

/* ========================================================================
   BACK TO TOP BUTTON
   Floating button to scroll back to top
   ======================================================================== */

.back-to-top {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--color-white);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-standard);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.back-to-top:active {
  transform: translateY(-1px);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.back-to-top svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

@media (max-width: 768px) {
  .back-to-top {
    bottom: var(--space-6);
    right: var(--space-6);
    width: 48px;
    height: 48px;
  }

  .back-to-top svg {
    width: 20px;
    height: 20px;
  }
}

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

@media (max-width: 768px) {
  .legal-container {
    padding: var(--space-8) var(--space-4);
  }

  .legal-section {
    margin-bottom: var(--space-12);
  }

  .legal-section-title {
    font-size: var(--font-size-xl);
  }

  .legal-subsection-title {
    font-size: var(--font-size-base);
  }

  .legal-paragraph,
  .legal-list li {
    font-size: var(--font-size-sm);
  }

  .legal-subsection {
    padding-left: var(--space-3);
    border-left-width: 2px;
  }
}

/* ========================================================================
   PRINT STYLES
   ======================================================================== */

@media print {
  .legal-toc,
  .back-to-top,
  .site-header,
  .site-footer {
    display: none;
  }

  .legal-layout {
    grid-template-columns: 1fr;
  }

  .legal-hero {
    background: none;
    border: none;
    padding: var(--space-8) 0 var(--space-6);
  }

  .legal-section {
    page-break-inside: avoid;
  }

  .legal-section-title {
    page-break-after: avoid;
  }

.legal-link {
  text-decoration: underline;
  color: inherit;
}
}

/* ========================================================================
   FOOTER OVERRIDES (Match Playground / Learn)
   ======================================================================== */

.app-shell .site-footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  transition: all 0.3s ease;
  padding: 0;
}

.app-shell .footer-toggle {
  width: 100%;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
  z-index: 10;
}

.app-shell .footer-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.app-shell .footer-toggle-icon {
  font-size: 12px;
  transition: transform 0.3s ease;
  display: inline-block;
}

.app-shell #siteFooter.expanded .footer-toggle-icon {
  transform: rotate(180deg);
}

.app-shell #siteFooter.expanded .footer-copyright-minimized {
  opacity: 0;
  pointer-events: none;
}

.app-shell .footer-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
  padding: 0 20px;
}

.app-shell #siteFooter.expanded .footer-content {
  max-height: 1000px;
  opacity: 1;
  padding: 24px 20px 16px;
}

.app-shell .site-footer .footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.app-shell .site-footer .footer-column h4 {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.app-shell .site-footer .footer-column a {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s ease;
  display: block;
  margin-bottom: 6px;
}

.app-shell .site-footer .footer-column a:hover {
  color: rgba(255, 255, 255, 0.95);
}

.app-shell .site-footer .footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  text-align: center;
}

.app-shell .site-footer .footer-copyright {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  margin: 0;
}

.app-shell .site-footer .footer-legal {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.app-shell .site-footer .footer-legal a {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s ease;
}

.app-shell .site-footer .footer-legal a:hover {
  color: rgba(255, 255, 255, 0.95);
}

.app-shell .site-footer .footer-legal a:not(:last-child)::after {
  content: '|';
  margin-left: 16px;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

@media (max-width: 1024px) {
  .app-shell .site-footer .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .app-shell .site-footer .footer-grid {
    grid-template-columns: 1fr;
  }

  .app-shell #siteFooter.expanded .footer-content {
    padding: 20px 16px 16px;
  }
}

/* Focus styles */
.toc-link:focus-visible,
.legal-link:focus-visible {
  outline: 2px solid var(--color-grey-900);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .legal-badge {
    border: 2px solid currentColor;
  }

  .toc-link,
  .legal-link {
    text-decoration: underline;
  }

  .legal-toc {
    border: 2px solid currentColor;
  }
}
