/* Modern styling for PolicyHoster */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #3b82f6;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

/* Base resets & typography */
* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background-color: #f8fafc;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

img {
  max-width: 100%;
}

/* Modern Accessible Tabs implementation following guidelines */
.tablist-container {
  border-bottom: 2px solid var(--border);
  background-color: var(--surface);
  border-top-left-radius: 0.75rem;
  border-top-right-radius: 0.75rem;
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  position: relative;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.85rem 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: color 0.15s ease;
}

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

.tab-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* Selected tab indicator: non-color-alone underline pseudo-element */
.tab-btn[aria-selected="true"] {
  color: var(--primary);
  font-weight: 600;
}

.tab-btn[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 -2px 0;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* Panels */
.tab-panel {
  display: block;
}

.tab-panel[hidden] {
  display: none !important;
}

/* Markdown preview typography */
.markdown-body {
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: break-word;
}

.markdown-body table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.25rem 0;
  -webkit-overflow-scrolling: touch;
}

.markdown-body th {
  background-color: #f1f5f9;
  font-weight: 600;
  color: #1e293b;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  font-size: 0.85rem;
}

.markdown-body td {
  padding: 0.65rem 0.85rem;
  border: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #334155;
}

.markdown-body tr:nth-child(even) {
  background-color: #f8fafc;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  background-color: #f1f5f9;
  color: #0f172a;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  border: 1px solid #e2e8f0;
  word-break: break-all;
}

.markdown-body pre {
  max-width: 100%;
  overflow-x: auto;
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1rem 0;
}

.markdown-body pre code {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  word-break: normal;
}

.markdown-body h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.markdown-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.35rem;
}

.markdown-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #334155;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown-body p {
  margin-bottom: 1rem;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-body li {
  margin-bottom: 0.35rem;
}

.markdown-body a {
  color: var(--primary);
  text-decoration: underline;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background-color: #f8fafc;
  color: #64748b;
  border-radius: 0 0.375rem 0.375rem 0;
}

/* Vertical Ads / Skyscraper Styling */
.vertical-ad-slot {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  overflow: hidden;
  position: sticky;
  top: 5rem;
  width: 160px;
  min-height: 600px;
  padding: 1rem 0.5rem;
  flex-shrink: 0;
}

@media (max-width: 1535px) {
  .vertical-ad-slot {
    display: none !important;
  }
}

.ad-slot-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  margin-bottom: 1rem;
}

.ad-slot-card {
  background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  position: relative;
}

/* Custom scrollbars for editors */
textarea.code-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  tab-size: 2;
  resize: vertical;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modern Web Guidance: Native Dialog Scroll Containment & Backdrop */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

/* ========================================================
   Swipe-Inspired Pure CSS Micro-Animations & "Life" Layer
   Zero external libraries • 60 FPS GPU-accelerated • Fully Mobile Responsive
   ======================================================== */

/* 1. Ambient Background Mesh Glow */
.hero-glow-bg {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  height: 280px;
  background: radial-gradient(circle at 50% 30%, rgba(59, 130, 246, 0.16) 0%, rgba(99, 102, 241, 0.08) 45%, transparent 70%);
  filter: blur(45px);
  pointer-events: none;
  z-index: 0;
  animation: pulseGlow 6s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: translateX(-50%) scale(0.96); opacity: 0.7; }
  100% { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

/* 2. Floating Badges (Swipe-style subtle vertical drift) */
@keyframes floatSlow1 {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

@keyframes floatSlow2 {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-7px); }
}

.float-badge-1 {
  animation: floatSlow1 4.2s ease-in-out infinite;
}

.float-badge-2 {
  animation: floatSlow2 5.1s ease-in-out infinite;
}

/* 3. Primary CTA Button Shimmer Beam */
.btn-shimmer {
  position: relative;
  overflow: hidden;
}

.btn-shimmer::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -120%;
  width: 60%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  transform: rotate(25deg);
  pointer-events: none;
  animation: shimmerSweep 4.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes shimmerSweep {
  0%, 65% { left: -120%; }
  100% { left: 160%; }
}

/* 4. Active Radar Pulse Beacon */
.pulse-beacon {
  position: relative;
  display: inline-block;
}

.pulse-beacon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background-color: inherit;
  opacity: 0.75;
  animation: radarPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
  75%, 100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* 5. Interactive Cards: 3D Lift & Icon Pop */
.interactive-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .interactive-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px -6px rgba(37, 99, 235, 0.12),
                0 6px 12px -4px rgba(15, 23, 42, 0.04);
    border-color: #93c5fd;
  }
  .interactive-card:hover .card-icon {
    transform: scale(1.1) rotate(2deg);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

.card-icon {
  transition: transform 0.2s ease;
}

/* 6. Success Modal Pop & Ring */
@keyframes successPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.success-pulse-icon {
  animation: successPop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 7. Tactile Micro-Interactions */
input[type="checkbox"]:active {
  transform: scale(0.9);
  transition: transform 0.08s ease;
}

/* 8. Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .hero-glow-bg,
  .float-badge-1,
  .float-badge-2,
  .btn-shimmer::after,
  .pulse-beacon::before,
  .success-pulse-icon {
    animation: none !important;
  }
  .interactive-card:hover {
    transform: none !important;
  }
}
