/* ============ DESIGN TOKENS ============ */
:root,
[data-theme='light'] {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Color - light mode */
  --color-bg: #fafbfc;
  --color-surface: #ffffff;
  --color-surface-2: #f1f5f9;
  --color-border: #e2e8f0;
  --color-divider: #ebeff5;
  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-faint: #94a3b8;

  /* Brand: cool cyan/teal */
  --color-primary: #0891b2;
  --color-primary-hover: #0e7490;
  --color-primary-active: #155e75;
  --color-primary-soft: #cffafe;

  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-error: #dc2626;
  --color-error-soft: #fee2e2;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-md: 0 4px 16px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 20px 48px rgb(15 23 42 / 0.1);
  --shadow-glow: 0 0 0 4px rgb(8 145 178 / 0.12);

  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-body: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --content-narrow: 720px;
  --content-default: 1080px;
}

[data-theme='dark'] {
  --color-bg: #0a0f1c;
  --color-surface: #11182a;
  --color-surface-2: #1a2238;
  --color-border: #1f2a44;
  --color-divider: #1c2540;
  --color-text: #e8eef9;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;
  --color-primary: #22d3ee;
  --color-primary-hover: #67e8f9;
  --color-primary-active: #a5f3fc;
  --color-primary-soft: #164e63;
  --color-success: #22c55e;
  --color-success-soft: #14532d;
  --color-error: #f87171;
  --color-error-soft: #4c1717;
  --color-warning: #fbbf24;
  --color-warning-soft: #422006;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 20px 48px rgb(0 0 0 / 0.5);
  --shadow-glow: 0 0 0 4px rgb(34 211 238 / 0.18);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition), color var(--transition);
}

img, svg { display: block; max-width: 100%; }

h1, h2, h3 { line-height: 1.15; text-wrap: balance; font-weight: 700; }
p { text-wrap: pretty; }

button {
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--color-primary-soft);
  color: var(--color-text);
}

/* ============ LAYOUT ============ */
.container {
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

/* ============ HEADER ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-divider);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--text-base);
}

.logo svg { color: var(--color-primary); }
.logo-text { letter-spacing: -0.01em; }

.theme-toggle {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* ============ HERO ============ */
.hero {
  padding-block: clamp(var(--space-12), 8vw, var(--space-24));
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, color-mix(in srgb, var(--color-primary) 12%, transparent), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.hero h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-3);
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 540px;
  margin: 0 auto var(--space-10);
}

/* ============ FORM ============ */
.check-form {
  display: flex;
  gap: var(--space-3);
  max-width: 560px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.input-wrap {
  flex: 1 1 280px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding-inline: var(--space-4);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}

.input-prefix {
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  user-select: none;
}

#url-input {
  flex: 1;
  padding-block: var(--space-3);
  padding-inline: var(--space-2);
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  min-width: 0;
}

#url-input::placeholder {
  color: var(--color-text-faint);
}

.check-btn {
  position: relative;
  padding: var(--space-3) var(--space-8);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
  letter-spacing: -0.01em;
  transition: background var(--transition), transform var(--transition);
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.check-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.check-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.check-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-spinner {
  display: none;
  animation: spin 0.8s linear infinite;
}

.check-btn.loading .btn-label { display: none; }
.check-btn.loading .btn-spinner { display: block; }

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

/* ============ EXAMPLES ============ */
.examples {
  margin-top: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
}

.examples-label {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

.example-chip {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  transition: all var(--transition);
}

.example-chip:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-surface);
}

/* ============ RESULT ============ */
.result {
  margin-top: var(--space-10);
  max-width: 560px;
  margin-inline: auto;
  text-align: left;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6);
  box-shadow: var(--shadow-md);
}

.result-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid currentColor;
  opacity: 0.25;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.4); opacity: 0; }
}

.status-up .status-dot { background: var(--color-success); color: var(--color-success); }
.status-down .status-dot { background: var(--color-error); color: var(--color-error); }
.status-degraded .status-dot { background: var(--color-warning); color: var(--color-warning); }

.status-label {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.status-up .status-label { color: var(--color-success); }
.status-down .status-label { color: var(--color-error); }
.status-degraded .status-label { color: var(--color-warning); }

.status-domain {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-left: auto;
  word-break: break-all;
  text-align: right;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
}

.detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.detail-value {
  font-size: var(--text-base);
  font-family: var(--font-mono);
  color: var(--color-text);
  font-weight: 500;
  word-break: break-word;
}

.result-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
}

.result-footer svg {
  flex-shrink: 0;
}

.result-error {
  background: var(--color-error-soft);
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
  color: var(--color-error);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

/* ============ FEATURES ============ */
.features {
  padding-block: clamp(var(--space-12), 8vw, var(--space-20));
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
}

.feature {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.feature-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}

.feature h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.feature p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============ FAQ ============ */
.faq {
  padding-block: clamp(var(--space-12), 8vw, var(--space-20));
}

.faq .container {
  max-width: var(--content-narrow);
}

.faq h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-8);
  letter-spacing: -0.02em;
}

.faq details {
  border-bottom: 1px solid var(--color-divider);
  padding-block: var(--space-5);
}

.faq summary {
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  color: var(--color-text);
}

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

.faq summary::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.faq details[open] summary::after {
  content: '–';
}

.faq details p {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.7;
}

/* ============ FOOTER ============ */
.footer {
  padding-block: var(--space-10);
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface);
}

.footer-inner {
  text-align: center;
}

.footer p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-sub {
  color: var(--color-text-faint);
  margin-top: var(--space-1);
  font-size: var(--text-xs);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 540px) {
  .check-form {
    flex-direction: column;
  }
  .check-btn {
    width: 100%;
  }
  .status-domain {
    margin-left: 0;
    margin-top: var(--space-2);
    text-align: left;
  }
  .result-status {
    flex-wrap: wrap;
  }
}

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