@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../assets/fonts/Inter-400.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --blue: #0b5cff;
  --blue-dark: #073ea8;
  --navy: #122033;
  --muted: #617087;
  --surface: #ffffff;
  --background: #f3f7fc;
  --line: #dbe5f1;
  --danger: #c52828;
  --danger-dark: #7f1d1d;
  --danger-soft: #fff0f0;
  --safe-soft: #edf7ff;
  --radius: 22px;
  --shadow: 0 18px 50px rgba(24, 56, 94, 0.1);
  font-family: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--navy);
  background:
    radial-gradient(circle at top left, rgba(11, 92, 255, 0.11), transparent 36rem),
    var(--background);
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; }

.emergency-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  width: min(100% - 32px, 960px);
  margin: 18px auto 0;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 30px rgba(24, 56, 94, 0.08);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; width: fit-content; }
.brand img { width: 104px; height: auto; display: block; }

.emergency-badge {
  padding: 7px 13px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-align: center;
}

.language-toggle {
  justify-self: end;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-dark);
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}

.language-toggle:hover, .language-toggle:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(11, 92, 255, 0.14);
}

.page-shell {
  width: min(100% - 32px, 960px);
  margin: 26px auto 52px;
}

.state-card, .identity-card, .clinical-card {
  border: 1px solid rgba(219, 229, 241, 0.88);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.state-card {
  display: grid;
  justify-items: center;
  padding: 72px 24px;
  text-align: center;
}

.state-card h1 { margin: 20px 0 8px; font-size: clamp(1.5rem, 5vw, 2.2rem); }
.state-card p { max-width: 570px; margin: 0; color: var(--muted); line-height: 1.65; }

.loader {
  width: 46px;
  height: 46px;
  border: 4px solid #dbe8ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.scan-card {
  position: relative;
  overflow: hidden;
  padding-top: 48px;
  background:
    radial-gradient(circle at 50% 24%, rgba(11, 92, 255, 0.11), transparent 15rem),
    var(--surface);
}

.scan-card::before,
.scan-card::after {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(11, 92, 255, 0.045);
  content: "";
  pointer-events: none;
  animation: ambient-drift 7s ease-in-out infinite;
}

.scan-card::before { top: -92px; left: -68px; }
.scan-card::after { right: -74px; bottom: -105px; animation-delay: -3.5s; }

.nfc-visual {
  position: relative;
  width: 220px;
  height: 168px;
  margin: -10px auto 4px;
  direction: ltr;
}

.nfc-card,
.nfc-phone {
  position: absolute;
  display: grid;
  place-items: center;
  box-shadow: 0 18px 35px rgba(7, 62, 168, 0.2);
}

.nfc-card {
  top: 34px;
  left: 24px;
  z-index: 2;
  width: 82px;
  height: 104px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #2c7bff, #0748c3);
  transform: rotate(-8deg);
  animation: card-float 3.8s ease-in-out infinite;
}

.nfc-card::before {
  position: absolute;
  top: 10px;
  left: 11px;
  width: 24px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  content: "";
}

.nfc-card svg { width: 46px; margin-left: 17px; }

.nfc-phone {
  top: 13px;
  right: 22px;
  z-index: 3;
  width: 83px;
  height: 142px;
  border: 5px solid #122f63;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(160deg, #eaf2ff 0 22%, #4a8cff 22% 100%);
  transform: rotate(6deg);
  animation: phone-float 4.1s ease-in-out -1.1s infinite;
}

.nfc-phone-speaker {
  position: absolute;
  top: 8px;
  width: 27px;
  height: 4px;
  border-radius: 99px;
  background: rgba(18, 47, 99, 0.35);
}

.nfc-phone-heart {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  font-size: 1.45rem;
  text-shadow: 0 3px 9px rgba(7, 62, 168, 0.22);
  animation: heart-beat 2.2s ease-in-out infinite;
}

.nfc-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 78px;
  height: 78px;
  border: 2px solid rgba(11, 92, 255, 0.3);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35);
  animation: nfc-pulse 3s ease-out infinite;
}

.nfc-ring-two { animation-delay: 1s; }
.nfc-ring-three { animation-delay: 2s; }

.scan-eyebrow {
  margin: 4px 0 -10px !important;
  color: var(--blue) !important;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scan-button {
  position: relative;
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
  padding: 12px 24px;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #2474ff, var(--blue));
  box-shadow: 0 14px 28px rgba(11, 92, 255, 0.24);
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.scan-button::after {
  position: absolute;
  inset: -100% -50%;
  background: linear-gradient(115deg, transparent 43%, rgba(255, 255, 255, 0.35) 50%, transparent 57%);
  content: "";
  transform: translateX(-55%);
  animation: button-shine 4.4s ease-in-out 1.4s infinite;
}

.scan-button svg { width: 23px; height: 23px; }
.scan-button svg, .scan-button span { position: relative; z-index: 1; }

.scan-button:hover:not(:disabled),
.scan-button:focus-visible {
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(11, 92, 255, 0.31);
}

.scan-button:focus-visible { box-shadow: 0 0 0 4px rgba(11, 92, 255, 0.17), 0 18px 34px rgba(11, 92, 255, 0.31); }
.scan-button:disabled { opacity: 0.68; cursor: wait; }

.scan-guidance {
  display: flex;
  max-width: 570px;
  align-items: center;
  gap: 13px;
  margin-top: 25px;
  padding: 14px 16px;
  border: 1px solid #cbdcff;
  border-radius: 16px;
  background: #f5f9ff;
  color: var(--muted);
  text-align: start;
}

.scan-guidance strong {
  display: block;
  margin-bottom: 3px;
  color: var(--navy);
  font-size: 0.9rem;
}

.scan-guidance span span { display: block; font-size: 0.8rem; line-height: 1.45; }

.guidance-icon {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 16px rgba(11, 92, 255, 0.18);
}

.guidance-icon svg { width: 24px; height: 24px; }

.scan-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px !important;
  color: var(--blue-dark) !important;
  font-size: 0.88rem;
  font-weight: 750;
}

.scan-status::before {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 0 rgba(11, 92, 255, 0.28);
  content: "";
  animation: status-pulse 1.8s ease-out infinite;
}

.scan-status.is-error { color: var(--danger) !important; }
.scan-status.is-error::before { background: var(--danger); animation: none; }

.scan-help {
  width: min(100%, 570px);
  margin-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  text-align: start;
}

.scan-help summary {
  width: fit-content;
  margin: 15px auto 0;
  color: var(--blue-dark);
  font-weight: 750;
  cursor: pointer;
}

.scan-help summary:focus-visible { outline: 3px solid rgba(11, 92, 255, 0.14); outline-offset: 4px; }
.scan-help ol { max-width: 470px; margin: 14px auto 0; padding-inline-start: 24px; line-height: 1.65; }
.scan-help li + li { margin-top: 6px; }

.scan-card.is-scanning .nfc-ring { animation-duration: 1.35s; }
.scan-card.is-scanning .nfc-phone { animation: phone-scan 1.35s ease-in-out infinite; }
.scan-card.is-scanning .nfc-card { animation: card-scan 1.35s ease-in-out infinite; }

@keyframes card-float {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-7px) rotate(-5deg); }
}

@keyframes phone-float {
  0%, 100% { transform: translateY(0) rotate(6deg); }
  50% { transform: translateY(6px) rotate(3deg); }
}

@keyframes card-scan {
  0%, 100% { transform: translateX(0) rotate(-8deg); }
  50% { transform: translateX(11px) rotate(-3deg); }
}

@keyframes phone-scan {
  0%, 100% { transform: translateX(0) rotate(6deg); }
  50% { transform: translateX(-8px) rotate(3deg); }
}

@keyframes nfc-pulse {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  18% { opacity: 0.65; }
  75%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.15); }
}

@keyframes heart-beat {
  0%, 44%, 100% { transform: scale(1); }
  12%, 28% { transform: scale(1.1); }
  20% { transform: scale(0.98); }
}

@keyframes button-shine {
  0%, 66% { transform: translateX(-55%); }
  86%, 100% { transform: translateX(55%); }
}

@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(11, 92, 255, 0.3); }
  75%, 100% { box-shadow: 0 0 0 9px rgba(11, 92, 255, 0); }
}

@keyframes ambient-drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(10px, 7px, 0) scale(1.08); }
}

.state-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #fff;
  background: var(--danger);
  font-size: 1.7rem;
  font-weight: 800;
}

.retry-button {
  min-height: 46px;
  margin-top: 24px;
  padding: 10px 22px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 750;
  cursor: pointer;
}

.identity-card {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(24px, 5vw, 40px);
  background: linear-gradient(135deg, #fff 55%, #eaf2ff);
}

.identity-copy { align-self: center; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.eyebrow.danger { color: var(--danger); }

.identity-card h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.patient-meta { margin: 12px 0 0; color: var(--muted); font-size: 1rem; }

.blood-card {
  display: grid;
  place-items: center;
  align-content: center;
  min-width: 155px;
  padding: 22px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #de3030, #a41521);
  text-align: center;
  box-shadow: 0 14px 28px rgba(164, 21, 33, 0.2);
}

.blood-card span { font-size: 0.76rem; font-weight: 700; opacity: 0.86; text-transform: uppercase; }
.blood-card strong {
  margin-top: 3px;
  font-size: 2.6rem;
  line-height: 1;
  direction: ltr;
  unicode-bidi: isolate;
}

.clinical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.clinical-card { padding: 24px; box-shadow: 0 10px 34px rgba(24, 56, 94, 0.07); }
.allergy-card { border: 2px solid #efb3b3; background: linear-gradient(145deg, #fff, var(--danger-soft)); }
.medication-card { grid-column: 1 / -1; }

.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.02em; }
.section-heading .eyebrow { margin-bottom: 1px; font-size: 0.65rem; }

.section-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--blue-dark);
  background: #e8f0ff;
  font-weight: 850;
}
.allergy-icon { color: #fff; background: var(--danger); }

.item-list { display: flex; flex-wrap: wrap; gap: 9px; }
.item-chip {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafc;
  font-weight: 700;
}
.allergy-card .item-chip { border-color: #efb3b3; color: var(--danger-dark); background: #fff; }

.empty-value { margin: 0; color: var(--muted); font-style: italic; }

.medication-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.medication-item { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.medication-item strong { display: block; font-size: 1rem; }
.medication-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }

.contact-name { margin: 0; font-size: 1.05rem; font-weight: 800; }
.contact-relation { margin: 4px 0 16px; color: var(--muted); }
.phone-link {
  display: flex;
  justify-content: center;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.profile-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding: 0 5px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}
.profile-footer p { margin: 0; }

html[dir="rtl"] body { font-family: Arial, Tahoma, sans-serif; }
html[dir="rtl"] .eyebrow { letter-spacing: 0; }

@media (max-width: 680px) {
  .emergency-header { grid-template-columns: 1fr auto; border-radius: 18px; }
  .emergency-badge { grid-column: 1 / -1; grid-row: 2; }
  .identity-card { flex-direction: column; }
  .blood-card { min-height: 112px; }
  .clinical-grid, .medication-list { grid-template-columns: 1fr; }
  .medication-card { grid-column: auto; }
  .profile-footer { flex-direction: column; }
  .state-card { padding: 48px 20px; }
  .scan-card { padding-top: 38px; }
  .nfc-visual { transform: scale(0.9); margin-block: -18px -6px; }
  .scan-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
