/* ================================================================
   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: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

.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: 16px;
  font-size: 16px;
  font-family: var(--es-font);
  color: var(--es-black);
  background: var(--es-white);
  border: 2px solid #d1d5db;
  border-radius: 12px;
  outline: none;
  transition: border-color var(--es-transition), box-shadow var(--es-transition), transform var(--es-transition);
  -webkit-appearance: none;
}

.es-input::placeholder {
  color: #9ca3af;
}

.es-input:focus {
  border-color: var(--es-red);
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.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: 18px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--es-font);
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--es-transition), transform var(--es-transition), box-shadow var(--es-transition);
  -webkit-appearance: none;
}

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

.es-btn--primary {
  background: #1e293b;
  color: var(--es-white);
}

.es-btn--primary:hover {
  background: #334155;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 41, 59, 0.3);
}

.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;
  margin-top: 2rem;
  padding: 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
  max-width: 480px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.es-footer-links {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.es-footer-link {
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.3s ease;
}

.es-footer-link:hover {
  color: #dc2626;
}

.es-footer-link svg {
  width: 18px;
  height: 18px;
}

/* ================================================================
   Entrance Animations
   ================================================================ */

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-up-1 {
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.animate-fade-in-up-2 {
  animation: fadeInUp 0.6s ease-out 0.4s both;
}

.animate-fade-in-up-3 {
  animation: fadeInUp 0.6s ease-out 0.6s both;
}

/* ================================================================
   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;
  }
  
  .es-card {
    padding: 2rem 2.5rem;
  }
  
  .es-page-title {
    font-size: 1.6rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  :root {
    --es-page-width: 900px;
  }
  
  /* Reading-optimized text — cap line length but let container span full width */
  .es-prose p,
  .es-prose li,
  .es-prose h2,
  .es-prose h3,
  .es-prose .concept-box {
    max-width: 65ch;
  }
  
  .es-prose h1 {
    max-width: none;
  }
  
  /* 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: 40px;
}

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

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

.es-page h1 {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
  line-height: 1.3;
  color: #1e293b;
}

@media (max-width: 480px) {
  .es-page h1 {
    font-size: 24px;
  }
}

/* ================================================================
   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; }

/* ================================================================
   3-Step Login Progress Indicator
   ================================================================ */

.es-progress {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  padding: 0.5rem 0;
}

.es-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.es-progress-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--es-gray-200);
  color: var(--es-gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.es-progress-step--active .es-progress-dot {
  background: var(--es-red);
  color: var(--es-white);
}

.es-progress-line {
  flex: 1;
  height: 3px;
  background: var(--es-gray-200);
  margin-top: 1rem;
  min-width: 2rem;
}

.es-progress-line--active {
  background: var(--es-red);
}

/* ================================================================
   Button Variants for Login Flow
   ================================================================ */

.es-btn--large {
  padding: 0.9rem 2rem;
  font-size: 1.15rem;
}

.es-btn--block {
  display: block;
  width: 100%;
}

.es-btn--outline {
  background: transparent;
  color: var(--es-gray-700);
  border: 2px solid var(--es-gray-400);
}

.es-btn--outline:hover {
  border-color: var(--es-red);
  color: var(--es-red);
}

.es-btn-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ================================================================
   Card Variants
   ================================================================ */

.es-card--inset {
  background: var(--es-gray-50);
  border: 1px dashed var(--es-gray-400);
  padding: 1rem 1.5rem;
}

/* ================================================================
   Large Input
   ================================================================ */

.es-input--large {
  font-size: 1.3rem;
  padding: 0.9rem 1rem;
  text-align: center;
  letter-spacing: 0.1em;
}

/* ================================================================
   4-Channel Identity Binding Status
   ================================================================ */

.es-channel-status {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.es-channel-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--es-gray-100);
  border: 1px solid var(--es-gray-200);
  transition: all 0.3s ease;
}

.es-channel--ok {
  background: #f0fdf4;
  border-color: var(--es-success);
}

.es-channel-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--es-gray-200);
  color: var(--es-gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.es-channel--ok .es-channel-icon {
  background: var(--es-success);
  color: white;
}

.es-channel-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--es-gray-500);
}

.es-channel--ok .es-channel-label {
  color: var(--es-gray-900);
  font-weight: 600;
}

.es-channel-check {
  font-size: 1.1rem;
  font-weight: 700;
  width: 1.5rem;
  text-align: center;
  color: var(--es-gray-400);
}

.es-channel--ok .es-channel-check {
  color: var(--es-success);
}

/* ================================================================
   Wallet Section
   ================================================================ */

.es-wallet {
  margin-top: 1.5rem;
}

.es-wallet__title,
.es-activity__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--es-black);
  margin-bottom: 1rem;
}

.es-wallet__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.es-wallet__card {
  background: var(--es-white);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius-lg);
  padding: 1rem;
  text-align: center;
}

.es-wallet__card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--es-gray-700);
  margin-bottom: 0.5rem;
}

.es-wallet__icon {
  font-size: 1rem;
}

.es-wallet__balance {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--es-font-mono);
  color: var(--es-black);
  margin-bottom: 0.5rem;
}

.es-wallet__card--satoshi .es-wallet__balance {
  color: #F59E0B;
}

.es-wallet__card--events .es-wallet__balance {
  color: var(--es-red);
}

.es-wallet__card--streak .es-wallet__balance {
  color: var(--es-warning);
}

.es-wallet__breakdown {
  text-align: left;
}

.es-wallet__breakdown p {
  margin-bottom: 0.35rem;
}

.es-wallet__sources {
  list-style: none;
  font-size: 0.8rem;
  color: var(--es-gray-600);
}

.es-wallet__sources li {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--es-gray-100);
}

.es-wallet__sources li:last-child {
  border-bottom: none;
}

.es-wallet__sources .es-text-bold {
  color: var(--es-black);
  font-weight: 600;
}

/* ================================================================
   Activity History
   ================================================================ */

.es-activity {
  margin-top: 1.5rem;
}

.es-activity__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.es-activity__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--es-white);
  border: 1px solid var(--es-gray-200);
  border-radius: var(--es-radius);
  padding: 0.75rem 1rem;
  transition: border-color var(--es-transition);
}

.es-activity__item:hover {
  border-color: var(--es-gray-300);
}

.es-activity__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--es-gray-100);
  color: var(--es-gray-500);
}

.es-activity__item--satoshi .es-activity__icon {
  background: #FEF3C7;
  color: #F59E0B;
}

.es-activity__item--event .es-activity__icon {
  background: #FEE2E2;
  color: var(--es-red);
}

.es-activity__details {
  flex: 1;
  min-width: 0;
}

.es-activity__memo {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--es-black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-activity__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.es-activity__amount {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--es-font-mono);
  white-space: nowrap;
}

.es-activity__amount--in {
  color: var(--es-success);
}

.es-activity__amount--out {
  color: var(--es-error);
}

.es-text-dim {
  color: var(--es-gray-500);
}

.es-text-bold {
  font-weight: 700;
}

.es-text-sm {
  font-size: 0.85rem;
}

.es-mt-1 {
  margin-top: 0.5rem;
}

.es-center {
  text-align: center;
}

.es-status-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .es-status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
