/* ================================================================
   Eldersafe Design System v2.0
   Based on eldersafe.dk branding — red shield, clean minimalism
   ================================================================ */

:root {
  /* Primary palette */
  --es-red: #D32F2F;
  --es-red-dark: #B71C1C;
  --es-red-light: #EF5350;

  /* Neutrals */
  --es-black: #111827;
  --es-gray-900: #1F2937;
  --es-gray-700: #374151;
  --es-gray-500: #6B7280;
  --es-gray-400: #9CA3AF;
  --es-gray-200: #E5E7EB;
  --es-gray-100: #F3F4F6;
  --es-gray-50: #F9FAFB;
  --es-white: #FFFFFF;

  /* Semantic */
  --es-success: #059669;
  --es-warning: #D97706;
  --es-error: #DC2626;

  /* Typography */
  --es-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --es-font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --es-radius-sm: 6px;
  --es-radius: 8px;
  --es-radius-lg: 12px;
  --es-radius-xl: 16px;

  /* Shadows */
  --es-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --es-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --es-shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);

  /* Transitions */
  --es-transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--es-font);
  color: var(--es-black);
  background: var(--es-white);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ================================================================
   Brand — Logo + Wordmark
   ================================================================ */

.es-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.es-logo-img {
  width: 200px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Page header — consistent across all pages */
.es-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-top: 0.5rem;
}

.es-header .es-logo-img {
  width: 120px;
  max-width: 100%;
  height: auto;
  display: inline-block;
  margin: 0;
}

.es-logo-link {
  display: inline-block;
  text-decoration: none;
}

.es-logo-link:focus-visible {
  outline: 2px solid var(--es-red);
  outline-offset: 4px;
  border-radius: 4px;
}

.es-wordmark {
  font-family: var(--es-font);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--es-black);
  text-decoration: none;
}

/* ================================================================
   Layout — Page Shell
   ================================================================ */

.es-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.es-page-header {
  text-align: center;
  margin-bottom: 2rem;
}

.es-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--es-black);
  margin-bottom: 0.25rem;
}

.es-page-subtitle {
  font-size: 0.95rem;
  color: var(--es-gray-500);
}

/* ================================================================
   Card Container
   ================================================================ */

.es-card {
  background: var(--es-gray-100);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius-xl);
  padding: 1.5rem;
  width: 100%;
  max-width: var(--es-page-width);
  box-shadow: var(--es-shadow-sm);
}

.es-card--white {
  background: var(--es-white);
}

/* ================================================================
   Form Elements
   ================================================================ */

.es-form-group {
  margin-bottom: 1rem;
}

.es-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--es-gray-700);
  margin-bottom: 0.35rem;
}

.es-input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--es-font);
  color: var(--es-black);
  background: var(--es-white);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius);
  outline: none;
  transition: border-color var(--es-transition), box-shadow var(--es-transition);
  -webkit-appearance: none;
}

.es-input::placeholder {
  color: var(--es-gray-400);
}

.es-input:focus {
  border-color: var(--es-red);
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.12);
}

.es-input:focus-visible {
  outline: 2px solid var(--es-red);
  outline-offset: 1px;
}

.es-input--error {
  border-color: var(--es-error);
}

.es-input--error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* ================================================================
   Buttons
   ================================================================ */

.es-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--es-font);
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--es-radius);
  cursor: pointer;
  transition: background var(--es-transition), transform var(--es-transition), box-shadow var(--es-transition);
  -webkit-appearance: none;
}

.es-btn:active {
  transform: scale(0.98);
}

.es-btn--primary {
  background: var(--es-gray-900);
  color: var(--es-white);
}

.es-btn--primary:hover {
  background: var(--es-black);
}

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

.es-btn--danger {
  background: var(--es-red);
  color: var(--es-white);
}

.es-btn--danger:hover {
  background: var(--es-red-dark);
}

.es-btn--ghost {
  background: transparent;
  color: var(--es-gray-700);
  border: 1px solid var(--es-gray-200);
}

.es-btn--ghost:hover {
  background: var(--es-gray-50);
}

/* Focus-visible styles for all interactive elements (WCAG 2.1 AA) */
.es-btn:focus-visible {
  outline: 3px solid var(--es-red);
  outline-offset: 2px;
}

.es-btn--danger:focus-visible {
  outline: 3px solid var(--es-red);
  outline-offset: 2px;
}

.es-btn--ghost:focus-visible {
  outline: 3px solid var(--es-red);
  outline-offset: 2px;
}

.skip-link:focus-visible {
  outline: 3px solid var(--es-red);
  outline-offset: 2px;
}

/* ================================================================
   Status Cards (dashboard)
   ================================================================ */

.es-status {
  background: var(--es-white);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.es-status__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--es-black);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.es-status__icon {
  font-size: 1.25rem;
}

/* Status modifiers */
.es-status--pending {
  border-left: 3px solid var(--es-warning);
}

.es-status--verified {
  border-left: 3px solid var(--es-success);
}

.es-status--refused {
  border-left: 3px solid var(--es-error);
}

.es-status--timeout {
  border-left: 3px solid var(--es-gray-400);
}

.es-status--info {
  border-left: 3px solid var(--es-gray-700);
}

/* ================================================================
   Alert / Message Boxes
   ================================================================ */

.es-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--es-radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.es-alert--error {
  background: #FEF2F2;
  color: var(--es-error);
  border: 1px solid #FECACA;
}

.es-alert--success {
  background: #ECFDF5;
  color: var(--es-success);
  border: 1px solid #A7F3D0;
}

.es-alert--info {
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

.es-alert--magic-link {
  background: #ECFDF5;
  color: var(--es-success);
  border: 1px solid #A7F3D0;
  text-align: center;
  word-break: break-all;
  font-family: var(--es-font-mono);
  font-size: 0.85rem;
}

/* ================================================================
   Dashboard Layout
   ================================================================ */

.es-dashboard {
  max-width: var(--es-page-width);
  width: 100%;
  margin: 0 auto;
}

.es-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.es-dashboard-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.es-logout-btn {
  font-size: 0.85rem;
  color: var(--es-gray-500);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--es-radius-sm);
  transition: background var(--es-transition);
}

.es-logout-btn:hover {
  background: var(--es-gray-100);
  color: var(--es-gray-700);
}

.es-logout-btn:focus-visible {
  outline: 2px solid var(--es-red);
  outline-offset: 2px;
}

/* ================================================================
   Footer
   ================================================================ */

.es-footer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--es-gray-200);
  max-width: var(--es-page-width);
  width: 100%;
}

.es-footer-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--es-gray-500);
  text-decoration: none;
  transition: color var(--es-transition);
}

.es-footer-link:hover {
  color: var(--es-black);
}

.es-footer-link:focus-visible {
  outline: 2px solid var(--es-red);
  outline-offset: 2px;
}

.es-footer-icon {
  font-size: 1.25rem;
}

/* ================================================================
   Shield Logo (CSS-only)
   ================================================================ */

.es-shield {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.es-shield__top {
  width: 28px;
  height: 6px;
  background: var(--es-red);
  border-radius: 2px 2px 0 0;
}

.es-shield__frame {
  display: flex;
  gap: 3px;
}

.es-shield__side {
  width: 6px;
  height: 20px;
  background: var(--es-red);
  border-radius: 1px;
}

.es-shield__inner {
  width: 10px;
  height: 20px;
  border: 3px solid var(--es-red);
  border-radius: 2px;
  background: transparent;
}

.es-shield__bottom {
  display: flex;
  gap: 2px;
}

.es-shield__chevron {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--es-red);
}

/* ================================================================
   Language Switcher — 🇩🇰 / 🇪🇺 flags in top-right
   ================================================================ */

.lang-switcher {
  position: fixed;
  top: 0.5rem;
  right: max(0.75rem, calc((100vw - var(--es-page-width)) / 2 + 0.75rem));
  display: flex;
  gap: 0.4rem;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  font-size: 1.2rem;
  background: var(--es-white);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius-sm);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity var(--es-transition), border-color var(--es-transition);
  line-height: 1;
}

.lang-flag:hover,
.lang-flag:focus-visible {
  opacity: 1;
  border-color: var(--es-red);
  outline: none;
}

.lang-flag:focus-visible {
  outline: 2px solid var(--es-red);
  outline-offset: 2px;
}

.lang-flag--active {
  opacity: 1;
  border-color: var(--es-red);
  box-shadow: 0 0 0 2px rgba(211,47,47,0.15);
}

/* ================================================================
   Responsive
   ================================================================ */

/* Mobile-first default (smartphone) */
:root {
  --es-page-width: 420px;
}

/* Tablet (640px+) */
@media (min-width: 640px) {
  :root {
    --es-page-width: 600px;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  :root {
    --es-page-width: 900px;
  }
  
  /* Reading-optimized text blocks — cap at ~65 characters */
  .es-prose {
    max-width: 65ch;
    margin-left: auto;
    margin-right: auto;
  }
  
  /* Cards get wider but text stays readable */
  .es-card {
    padding: 2.5rem 3rem;
  }
  
  /* Dashboard: 2-column status grid */
  .es-dashboard .es-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  /* Larger type at desktop */
  .es-page-title {
    font-size: 1.75rem;
  }
  
  body {
    font-size: 17px;
  }
}

@media (max-width: 480px) {
  .es-page {
    padding: 1.5rem 1rem;
  }

  .es-card {
    padding: 1.25rem;
  }

  .es-footer {
    gap: 1rem;
  }
}

/* ================================================================
   Accessibility & Skip Links
   ================================================================ */

.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--es-red);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 var(--es-radius-sm) var(--es-radius-sm) 0;
}

.skip-link:focus {
  top: 0;
}

/* ================================================================
   Landing Page Styles
   ================================================================ */

.landing-brand {
  margin-bottom: 2rem;
}

.landing-shield {
  margin-bottom: 0.75rem;
}

.landing-tagline {
  font-size: 0.95rem;
  color: var(--es-gray-500);
  margin-top: 0.25rem;
}

/* ================================================================
   Utility
   ================================================================ */

.es-text-center { text-align: center; }
.es-text-dim { color: var(--es-gray-500); }
.es-text-sm { font-size: 0.85rem; }
.es-mt-1 { margin-top: 0.5rem; }
.es-mt-2 { margin-top: 1rem; }
.es-mb-1 { margin-bottom: 0.5rem; }
.es-mb-2 { margin-bottom: 1rem; }
.es-hidden { display: none; }
