/* ==========================================================================
   FNN SEO Analyzer — Branded Styles
   Navy/Gold Glassmorphism with Orb Background
   ========================================================================== */

/* ---------- Brand Tokens ---------- */
:root {
  --gold: #E8B84B;
  --gold-dark: #C9962D;
  --gold-glow: rgba(232, 184, 75, 0.22);
  --gold-glow-strong: rgba(232, 184, 75, 0.45);
  --navy-deep: #0D1B3E;
  --navy-mid: #1B3869;
  --navy-dark: #0A2344;
  --navy-darker: #111827;

  /* Glass — Light mode (on dark bg, "light" = more white) */
  --glass-card-bg: rgba(255, 255, 255, 0.13);
  --glass-card-border: rgba(255, 255, 255, 0.25);
  --glass-form-bg: rgba(255, 255, 255, 0.30);
  --glass-form-border: rgba(255, 255, 255, 0.44);
  --glass-form-inset: rgba(255, 255, 255, 0.55);
  --glass-input-bg: rgba(255, 255, 255, 0.55);
  --glass-input-border: rgba(255, 255, 255, 0.65);
  --input-text: rgba(0, 0, 0, 0.85);
  --card-text: rgba(255, 255, 255, 0.95);
  --card-text-muted: rgba(255, 255, 255, 0.82);
  --card-title-color: rgba(0, 0, 0, 0.92);

  /* Typography — aligned to shared design system */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
}

/* ---------- Dark Mode Overrides ---------- */
html.dark {
  --glass-card-bg: rgba(255, 255, 255, 0.10);
  --glass-card-border: rgba(255, 255, 255, 0.18);
  --glass-form-bg: rgba(18, 18, 18, 0.60);
  --glass-form-border: rgba(255, 255, 255, 0.18);
  --glass-form-inset: rgba(255, 255, 255, 0.12);
  --glass-input-bg: rgba(255, 255, 255, 0.08);
  --glass-input-border: rgba(255, 255, 255, 0.18);
  --input-text: rgba(255, 255, 255, 0.88);
  --card-text-muted: rgba(255, 255, 255, 0.70);
  --card-title-color: rgba(255, 255, 255, 0.95);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--card-text);
  background: var(--navy-deep);
}

/* ---------- Background Layer (3001 reference) ---------- */
.bg-layer { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-gradient { position: absolute; inset: 0; background: linear-gradient(140deg, #0D1B3E, #1B3869, #0A2344, #111827); background-size: 300% 300%; animation: gradientShift 18s ease infinite; }
html.dark .bg-gradient { background: linear-gradient(140deg, #050a18, #0a1530, #060f22, #080c15); background-size: 300% 300%; }
.bg-orbs { position: absolute; inset: 0; pointer-events: none; }
.bg-orbs img { position: absolute; filter: hue-rotate(195deg) saturate(1.4) brightness(1.1); object-fit: contain; pointer-events: none; }

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes floatSlow {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(20px, -25px) rotate(3deg); }
  50% { transform: translate(-15px, 20px) rotate(-4deg); }
  75% { transform: translate(25px, 15px) rotate(5deg); }
}

@keyframes floatSlow2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-18px, 30px) rotate(-3deg); }
  50% { transform: translate(22px, -18px) rotate(5deg); }
  75% { transform: translate(-12px, -20px) rotate(-6deg); }
}

@keyframes floatMedium {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-25px, 20px) rotate(5deg); }
  66% { transform: translate(20px, -30px) rotate(-6deg); }
}

@keyframes floatMedium2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(30px, -15px) rotate(-5deg); }
  66% { transform: translate(-20px, 28px) rotate(7deg); }
}

@keyframes floatFast {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(18px, -15px) rotate(6deg); }
  50% { transform: translate(-22px, 25px) rotate(-10deg); }
  75% { transform: translate(28px, -18px) rotate(12deg); }
}

@keyframes floatFast2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-20px, 18px) rotate(-8deg); }
  50% { transform: translate(25px, -22px) rotate(10deg); }
  75% { transform: translate(-15px, 12px) rotate(-6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-gradient {
    animation: none !important;
  }
  .bg-orbs img {
    animation: none !important;
  }
}

/* ---------- Theme Toggle ---------- */
.theme-toggle-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  color: var(--gold);
}

.theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.08);
}

/* ---------- Page Wrapper ---------- */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.seo-header {
  position: relative;
  z-index: 10;
  padding: 0 24px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.brand-sep {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 300;
  font-size: 18px;
}

.brand-page {
  font-weight: 600;
  font-size: 15px;
  color: var(--gold);
}

/* ---------- Footer ---------- */
.seo-footer {
  text-align: center;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.footer-text {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

.footer-link {
  color: var(--gold);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* ---------- Hero Section ---------- */
.seo-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
  flex: 1;
}

.hero-section {
  text-align: center;
  padding: 48px 0 24px;
}

.hero-title {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 8px;
}

.hero-white {
  color: rgba(255, 255, 255, 0.95);
}

.hero-gold {
  color: var(--gold);
}

.hero-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 32px;
}

/* ---------- Glass Form Card (Analyze) ---------- */
.glass-form-card {
  background: var(--glass-form-bg);
  backdrop-filter: blur(60px);
  -webkit-backdrop-filter: blur(60px);
  border-radius: 24px;
  border: 2px solid var(--glass-form-border);
  box-shadow:
    0 0 40px var(--gold-glow),
    0 24px 72px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 var(--glass-form-inset);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.analyze-card {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 24px;
}

.input-row {
  display: flex;
  gap: 12px;
}

.url-input {
  flex: 1;
  background: var(--glass-input-bg);
  border: 1.5px solid var(--glass-input-border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--input-text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input::placeholder {
  color: rgba(100, 116, 139, 0.7);
}

html.dark .url-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.url-input:focus {
  border-color: var(--color-primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.analyze-btn {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--navy-deep);
  border: none;
  border-radius: var(--radius-md, 8px);
  padding: 12px 24px;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  min-width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(232, 184, 75, 0.40);
}

.analyze-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(232, 184, 75, 0.55);
}

.analyze-btn:active {
  transform: translateY(0);
}

.analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(13, 27, 62, 0.3);
  border-top-color: var(--navy-deep);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #f87171;
  font-size: 13px;
  text-align: left;
}

/* ---------- Glass Cards (Results) — aligned to shared design system ---------- */
.glass-card {
  background: var(--glass-card-bg);
  backdrop-filter: blur(60px) saturate(1.4);
  -webkit-backdrop-filter: blur(60px) saturate(1.4);
  border-radius: var(--radius-3xl, 24px);
  border: 1px solid var(--glass-card-border);
  box-shadow:
    0 0 22px var(--gold-glow),
    0 6px 24px rgba(0, 0, 0, 0.30);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* SVG noise texture overlay for tactile depth */
.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
}

.glass-card > * {
  position: relative;
  z-index: 1;
}

.glass-card:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 36px var(--gold-glow-strong),
    0 16px 40px rgba(0, 0, 0, 0.35);
}

/* ---------- Score Overview ---------- */
.results-section {
  margin-top: 24px;
}

.score-overview {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 28px;
  margin-bottom: 20px;
}

.score-ring-container {
  flex-shrink: 0;
}

.score-details {
  flex: 1;
  min-width: 0;
}

.result-url {
  font-size: 16px;
  font-weight: 700;
  word-break: break-all;
  margin-bottom: 4px;
  color: var(--card-text);
}

.result-time {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

/* ---------- Score Ring SVG ---------- */
.score-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.score-ring svg {
  transform: rotate(-90deg);
}

.score-ring__bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 8;
}

.score-ring__fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease-out, stroke 0.5s;
}

.score-ring__label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-ring__value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.score-ring__grade {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

/* ---------- Category Grid ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.cat-card {
  padding: 16px 20px;
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cat-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(232, 184, 75, 0.55);
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(232, 184, 75, 0.45);
}

.cat-score-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
}

.cat-score-badge.score-high {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.cat-score-badge.score-mid {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.cat-score-badge.score-low {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Score bar */
.cat-score-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 12px;
  overflow: hidden;
}

.cat-score-bar__fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s ease-out;
}

/* Findings list */
.findings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.finding {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  padding: 4px 0;
  color: var(--card-text-muted);
}

.finding-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-top: 2px;
}

.finding-icon.type-pass {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.finding-icon.type-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.finding-icon.type-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.finding-icon.type-info {
  background: rgba(232, 184, 75, 0.15);
  color: var(--gold);
}

/* Expandable details */
.cat-details-toggle {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
}

.cat-details-toggle:hover {
  text-decoration: underline;
}

.cat-details {
  margin-top: 8px;
  font-size: 12px;
  overflow: hidden;
}

.cat-details[hidden] {
  display: none;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.detail-table th,
.detail-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--card-text-muted);
}

.detail-table th {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}

/* ---------- Skeleton Loading ---------- */
.skeleton-card { pointer-events: none; }

.skeleton {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(-90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

@keyframes skeletonShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton--ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton--title {
  height: 14px;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton--bar {
  height: 8px;
  width: 100%;
  margin-bottom: 8px;
}

.cat-skeleton {
  padding: 16px 20px;
  min-height: 160px;
}

/* ---------- History ---------- */
.history-section {
  margin-top: 48px;
  padding-bottom: 48px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--card-text);
  margin-bottom: 16px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 8px;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.history-url {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  flex: 1;
  margin-right: 16px;
  color: var(--card-text-muted);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.history-grade {
  font-weight: 700;
  font-size: 14px;
}

.history-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .seo-main {
    padding: 0 16px;
  }

  .hero-section {
    padding: 24px 0 16px;
  }

  .hero-title {
    font-size: 28px;
  }

  .input-row {
    flex-direction: column;
  }

  .analyze-btn {
    width: 100%;
  }

  .score-overview {
    flex-direction: column;
    text-align: center;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .theme-toggle-btn {
    top: 10px;
    right: 10px;
  }
}

@media (max-width: 480px) {
  .analyze-card {
    padding: 16px;
  }
}
