/* ==========================================================================
   3MW Security Header Check — Styles
   Design tokens from 3MW brand guidelines (html_css_guidelines.md)
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  /* 3MW Brand Colors */
  --color-primary: #365072;
  --color-primary-light: #4a6a8f;
  --color-secondary: #F5BA36;
  --color-accent: #8b5cf6;

  /* Status Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Grade Colors */
  --grade-a: #059669;
  --grade-b: #F5BA36;
  --grade-c: #f59e0b;
  --grade-d: #ef4444;
  --grade-f: #991b1b;

  /* Neutrals */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;

  /* Typography */
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
  --font-size-body: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --font-size-h1: clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  --font-size-h2: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --font-size-small: 0.875rem;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Layout */
  --max-width: 56rem;
  --border-radius: 0.5rem;
  --border-radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --transition: 0.2s ease;
  --color-surface-muted: #f1f5f9;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Accessibility --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--color-primary);
  color: white;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--border-radius);
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: var(--space-md);
}

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

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Header --- */
.site-header {
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  height: 32px;
  width: auto;
}

.site-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* --- Hero --- */
.hero {
  max-width: var(--max-width);
  margin: var(--space-2xl) auto;
  padding: 0 var(--space-lg);
  text-align: center;
}

.hero-heading {
  font-size: var(--font-size-h1);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

.hero-text {
  color: var(--color-text-muted);
  max-width: 36rem;
  margin: 0 auto var(--space-xl);
}

/* --- Scan Form --- */
.scan-form {
  display: flex;
  gap: var(--space-xs);
  max-width: 32rem;
  margin: 0 auto;
}

.url-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: var(--font-size-body);
  font-family: var(--font-sans);
  transition: border-color var(--transition);
}

.url-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgb(54 80 114 / 0.15);
}

.scan-btn {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.scan-btn:hover {
  background: var(--color-primary-light);
}

.scan-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-md);
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Error / Expired --- */
.error-section,
.expired-section {
  max-width: var(--max-width);
  margin: var(--space-xl) auto;
  padding: 0 var(--space-lg);
}

.error-card,
.expired-card {
  background: var(--color-surface);
  border: 2px solid var(--color-danger);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  text-align: center;
}

.expired-card {
  border-color: var(--color-warning);
}

.error-message {
  color: var(--color-danger);
  margin-bottom: var(--space-md);
}

/* --- Results --- */
.results {
  max-width: var(--max-width);
  margin: 0 auto var(--space-2xl);
  padding: 0 var(--space-lg);
}

/* Grade Badge */
.grade-container {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
  padding: var(--space-xl);
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

.grade-badge {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
}

.grade-badge.grade-a { background: var(--grade-a); }
.grade-badge.grade-b { background: var(--grade-b); }
.grade-badge.grade-c { background: var(--grade-c); }
.grade-badge.grade-d { background: var(--grade-d); }
.grade-badge.grade-f { background: var(--grade-f); }

.grade-letter {
  font-size: 2.5rem;
  font-weight: 800;
  color: white;
  line-height: 1;
}

.grade-url {
  font-weight: 600;
  font-size: 1.125rem;
  word-break: break-all;
}

.grade-score {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

.grade-time {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* --- Tabs --- */
.report-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.tab {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: none;
  font-size: var(--font-size-body);
  font-family: var(--font-sans);
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

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

.tab.active,
.tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tab-panel {
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
}

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

/* --- Summary Table --- */
.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.summary-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-table tr:last-child td {
  border-bottom: none;
}

.header-cell {
  font-weight: 600;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: var(--font-size-small);
  font-weight: 600;
}

.status-pass {
  background: rgb(16 185 129 / 0.1);
  color: var(--color-success);
}

.status-warn {
  background: rgb(245 158 11 / 0.1);
  color: var(--color-warning);
}

.status-fail {
  background: rgb(239 68 68 / 0.1);
  color: var(--color-danger);
}

.status-icon::before {
  font-weight: 700;
}

.status-pass .status-icon::before { content: '\2713'; }
.status-warn .status-icon::before { content: '\26A0'; }
.status-fail .status-icon::before { content: '\2717'; }

/* Points column */
.points-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Found value */
.found-value {
  font-family: var(--font-mono);
  font-size: var(--font-size-small);
  color: var(--color-text-muted);
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Warnings List --- */
.warnings-list,
.recommendations-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.warnings-list li,
.recommendations-list li {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius);
  font-size: var(--font-size-small);
}

.warnings-list li {
  background: rgb(245 158 11 / 0.08);
  border-left: 3px solid var(--color-warning);
}

.warnings-list li.no-warnings {
  background: rgb(16 185 129 / 0.08);
  border-left-color: var(--color-success);
}

.recommendations-list li {
  background: rgb(139 92 246 / 0.06);
  border-left: 3px solid var(--color-accent);
}

.warning-header,
.recommendation-header {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* --- Raw Headers --- */
.raw-headers {
  font-family: var(--font-mono);
  font-size: var(--font-size-small);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--color-surface-muted);
  padding: var(--space-md);
  border-radius: var(--border-radius);
  overflow-x: auto;
}

/* --- Share Bar --- */
.share-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.btn-secondary {
  padding: var(--space-xs) var(--space-lg);
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: var(--border-radius);
  font-size: var(--font-size-small);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: white;
}

.copy-feedback {
  font-size: var(--font-size-small);
  color: var(--color-success);
  font-weight: 600;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  padding: var(--space-lg);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  border-top: 1px solid var(--color-border);
}

.site-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

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

/* --- Responsive --- */
@media (max-width: 640px) {
  .scan-form {
    flex-direction: column;
  }

  .grade-container {
    flex-direction: column;
    text-align: center;
  }

  .hide-mobile {
    display: none;
  }

  .report-tabs {
    gap: 0;
  }

  .tab {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-small);
  }
}
