/* ==========================================================================
   Anomaly Detection Demo — Additional Styles
   Inherits design system from style.css
   ========================================================================== */

/* ---------- Anomaly Page Layout ---------- */
.anomaly-page {
  /* Inherits .wrap from style.css */
  font-size: 1rem;
  max-width: min(var(--max-w), 100vw);
}

.anomaly-page [hidden] {
  display: none !important;
}

/* ---------- Hero Section ---------- */
.anomaly-hero {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.anomaly-hero__eyebrow {
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.anomaly-hero__title {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 600;
  font-size: clamp(1.85rem, 4.2vw, 2.55rem);
  line-height: 1.25;
  margin: 0 0 1rem;
}

.anomaly-hero__lead {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.9;
  margin: 0;
  color: var(--text);
}

/* ---------- Section Structure ---------- */
.anomaly-section {
  margin-bottom: 3rem;
}

.anomaly-section__head {
  margin-bottom: 1.5rem;
}

.anomaly-section__title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.anomaly-section__desc {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.75;
}

/* ---------- Sample Image Grid ---------- */
.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.sample-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  /* Minimum tap target: 48x48px ensured by min-height + padding */
}

.sample-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.sample-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
}

.sample-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sample-card__image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-subtle);
}

.sample-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 1rem 1.15rem;
}

.sample-card__name {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.3rem;
  color: var(--text);
}

.sample-card__meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ---------- Upload Area ---------- */
.upload-area {
  background: var(--bg-elevated);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.upload-area.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-area__prompt {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
  color: var(--text);
}

.upload-area__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.upload-area__btn {
  /* Inherits .btn-primary from style.css */
  min-height: 48px;
  min-width: 48px;
}

.upload-area__status {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
}

/* ---------- Result Area ---------- */
.result-area {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-placeholder {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.75;
}

/* ---------- Loading State ---------- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-state__message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0;
}

.loading-state__progress {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
}

.loading-state__hint {
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0.5rem 0 0;
}

/* ---------- Error State ---------- */
.anomaly-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: rgba(220, 38, 38, 0.05);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 1rem;
  line-height: 1.65;
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.upload-area .anomaly-error {
  margin-top: 1.25rem;
}

.anomaly-error__category {
  display: inline-block;
  margin: 0;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  background: rgba(153, 27, 27, 0.1);
  color: #7f1d1d;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.anomaly-error__message {
  font-size: 1rem;
  color: #991b1b;
  margin: 0;
  text-align: center;
  line-height: 1.65;
}

.anomaly-error__retry {
  /* Inherits .btn-primary from style.css */
  min-height: 48px;
  min-width: 48px;
}

.anomaly-error__retry:focus-visible,
.upload-area__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.anomaly-error__retry:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

/* ---------- Result Content ---------- */
.result-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.result-header__name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.result-header__score {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Heatmap Stage ---------- */
.heatmap-stage {
  position: relative;
  align-self: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.heatmap-stage__source,
.heatmap-stage__overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.heatmap-stage__overlay {
  pointer-events: none;
}

/* ---------- Heatmap Legend ---------- */
.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.heatmap-legend__bar {
  width: 100px;
  height: 8px;
  background: linear-gradient(
    to right,
    #30123b,
    #466be3,
    #28bbec,
    #a2fc3c,
    #fb8022,
    #d23105,
    #7a0403
  );
  border-radius: 999px;
}

/* ---------- Opacity Control ---------- */
.opacity-control {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.opacity-control__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.opacity-control__slider {
  width: 100%;
  height: 6px;
  margin: 0.65rem 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-subtle);
  border-radius: 999px;
  outline: none;
}

.opacity-control__slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.opacity-control__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.opacity-control__slider::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

.opacity-control__slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.opacity-control__slider::-moz-range-thumb:hover {
  background: var(--accent-hover);
}

.result-caption {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.65;
  text-align: center;
}

/* ---------- FAQ / Technical Details ---------- */
.faq-details {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
}

.faq-details__summary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  user-select: none;
}

.faq-details__summary::-webkit-details-marker {
  display: none;
}

.faq-details__summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.faq-details__summary::after {
  content: "▼";
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.faq-details[open] .faq-details__summary::after {
  transform: rotate(-180deg);
}

.faq-details__body {
  padding: 0.75rem 0 0.5rem;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.faq-details__body h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.faq-details__body h3:first-child {
  margin-top: 0;
}

.faq-details__body p {
  margin: 0 0 0.85rem;
}

.faq-details__body p:last-child {
  margin-bottom: 0;
}

.faq-details__body a {
  font-weight: 600;
  border-bottom: 1px solid currentColor;
}

.faq-details__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-subtle);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--accent);
}

/* ---------- Screen Reader Only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .anomaly-hero {
    padding-bottom: 1.5rem;
  }

  .anomaly-hero__title {
    font-size: 1.75rem;
  }

  .anomaly-hero__lead {
    font-size: 1rem;
  }

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

  .upload-area {
    padding: 2rem 1rem;
  }

  .result-area {
    padding: 1.5rem 1rem;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .heatmap-legend {
    flex-wrap: wrap;
  }

  .heatmap-legend__bar {
    width: 80px;
  }
}

@media (min-width: 721px) {
  .sample-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 1024px) {
  .sample-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- Footer Link Styling ---------- */
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.site-footer a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

.site-footer a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}


/* ========================================
   EAD-D Hero Metrics, Category Tabs & Badges
   ======================================== */
.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
}

.hero-metrics__item {
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hero-metrics__item strong {
  color: var(--accent);
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.category-tab:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.category-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.category-tab__badge {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.82;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.model-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.model-status-pill.is-ready {
  color: #166534;
  background: rgba(22, 163, 74, 0.1);
  border-color: rgba(22, 163, 74, 0.25);
}

.model-status-pill.is-loading {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--border);
}

.sample-card__tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.25rem;
}

.sample-card__tag--normal {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.sample-card__tag--anomaly {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

.result-header__title-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.result-header__latency {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.result-header__score.is-normal {
  color: #166534;
}

.result-header__score.is-anomaly {
  color: #b91c1c;
}
