/* Skymed · SkAuth — generic auth MPA (spec 04). Refined clinical-trust system.
   Brand tokens are the single source of truth; everything derives from them. */

:root {
  --c-primary: #00B894;
  --c-primary-hover: #00D4A1;
  --c-primary-muted: rgba(0, 184, 148, .08);
  --c-text: #0F172A;
  --c-text-2: #475569;
  --c-text-3: #64748B;
  --c-bg: #FFFFFF;
  --c-surface: #F8FAFC;
  --c-surface-2: #F1F5F9;
  --c-border: #E2E8F0;
  --c-error: #EF4444;
  --c-success: #10B981;
  --c-clinical-bg: #FEF3C7;
  --c-clinical-fg: #92400E;
  --c-clinical-bd: #FCD34D;
  --shadow-card: 0 4px 24px rgba(15, 23, 42, .06);
  --shadow-glow: 0 4px 20px rgba(0, 184, 148, .08);
  --r-card: 20px;
  --r-control: 12px;
  /* #1666-D: pilha de fontes de sistema — IdP autocontido, sem Google Fonts externas
     (nada sai para fonts.googleapis/gstatic). Degrada de forma nativa em qualquer SO. */
  --ff-head: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ff-body: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--ff-body);
  color: var(--c-text);
  background: var(--c-surface);
  /* layered mint atmosphere over the surface, plus a faint grain */
  background-image:
    radial-gradient(900px 600px at 12% -8%, rgba(0, 184, 148, .10), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(0, 212, 161, .08), transparent 55%),
    radial-gradient(600px 600px at 50% 120%, rgba(15, 23, 42, .035), transparent 60%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  /* flex-start + margin:auto on .shell centers when there's room but lets a tall
     card (many scopes / short viewport / zoom) scroll fully to the top — avoids
     the classic align-items:center clipping that hides the header and actions. */
  align-items: flex-start;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

/* ── language switch ─────────────────────────────────────────────────────── */
.lang {
  position: fixed;
  top: 20px;
  right: 22px;
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 3px;
  font-family: var(--ff-head);
}
.lang a {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--c-text-3);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
  transition: color .15s, background .15s;
}
.lang a[aria-current="true"] { color: #fff; background: var(--c-primary); }
.lang a:hover:not([aria-current="true"]) { color: var(--c-text); }
.lang a:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ── card ────────────────────────────────────────────────────────────────── */
.shell { width: 100%; max-width: 432px; margin: auto; }

.card {
  position: relative;
  background: var(--c-bg);
  border: 1px solid rgba(226, 232, 240, .8);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  padding: 40px 36px 34px;
  overflow: hidden;
  animation: rise .5s cubic-bezier(.16, 1, .3, 1) both;
}
.card::before { /* thin brand accent on top edge */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-hover));
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.stagger > * { animation: fade .45s ease both; }
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .10s; }
.stagger > *:nth-child(3) { animation-delay: .16s; }
.stagger > *:nth-child(4) { animation-delay: .22s; }
.stagger > *:nth-child(5) { animation-delay: .28s; }
@media (prefers-reduced-motion: reduce) {
  .card, .stagger > * { animation: none !important; }
}

/* ── logo ────────────────────────────────────────────────────────────────── */
.logo { display: inline-flex; flex-direction: column; line-height: 1; margin-bottom: 28px; }
.logo b {
  font-family: var(--ff-head);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -.02em;
  color: var(--c-text);
}
.logo b i { color: var(--c-primary); font-style: normal; }
.logo span {
  font-family: var(--ff-head);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--c-text-3);
  margin-top: 6px;
}

/* ── headings ────────────────────────────────────────────────────────────── */
h1 {
  font-family: var(--ff-head);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.sub { color: var(--c-text-2); font-size: 14.5px; margin-bottom: 26px; }
.sub strong { color: var(--c-text); font-weight: 700; }

/* ── form ────────────────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-2);
  font-family: var(--ff-head);
  letter-spacing: .01em;
}
input[type=text], input[type=password] {
  font-family: var(--ff-body);
  font-size: 15px;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-control);
  padding: 13px 14px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: var(--c-text-3); }
input:hover { border-color: #CBD5E1; }
input:focus {
  outline: none;
  background: var(--c-bg);
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px var(--c-primary-muted);
}

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btns { display: flex; gap: 12px; margin-top: 6px; }
button {
  font-family: var(--ff-head);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  border: 0;
  border-radius: var(--r-control);
  padding: 14px 18px;
  cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s, color .15s;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 3px; }
.btn-primary {
  flex: 1;
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 184, 148, .22);
}
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-primary:disabled { background: #94D7C7; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  flex: 1;
  background: transparent;
  color: var(--c-text-2);
  border: 1.5px solid var(--c-border);
}
.btn-ghost:hover { color: var(--c-text); border-color: #CBD5E1; background: var(--c-surface-2); }
.full { width: 100%; }

/* ── links ───────────────────────────────────────────────────────────────── */
.linkrow { margin-top: 18px; text-align: center; }
a.link {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-primary);
  text-decoration: none;
  font-family: var(--ff-head);
}
a.link:hover { color: var(--c-primary-hover); text-decoration: underline; }
a.link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }

/* ── alert ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(239, 68, 68, .07);
  border: 1px solid rgba(239, 68, 68, .28);
  color: #B91C1C;
  font-size: 13.5px;
  line-height: 1.45;
  border-radius: var(--r-control);
  padding: 12px 14px;
}
.alert svg { flex: none; margin-top: 1px; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(16, 185, 129, .08);
  border: 1px solid rgba(16, 185, 129, .30);
  color: #047857;
  font-size: 13.5px;
  line-height: 1.45;
  border-radius: var(--r-control);
  padding: 12px 14px;
}
.notice svg { flex: none; margin-top: 1px; }

/* ── consent: identity chip ──────────────────────────────────────────────── */
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 7px 8px 7px 14px;
  font-size: 13px;
  color: var(--c-text-2);
  margin-bottom: 22px;
}
.who .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: grid; place-items: center;
  font-family: var(--ff-head); font-weight: 700; font-size: 12px;
}
.who strong { color: var(--c-text); font-weight: 700; }
.who a { margin-left: auto; }

/* ── consent: scopes ─────────────────────────────────────────────────────── */
/* Header above the list — label + count so the magnitude is obvious at a glance. */
.scopes-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 2px;
}
.scopes-head .label {
  font-family: var(--ff-head);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--c-text-3);
}
.scopes-head .count {
  font-family: var(--ff-head);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-primary);
  background: var(--c-primary-muted);
  border-radius: 999px;
  padding: 2px 9px;
}

.scopes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 20px;
  /* Scroll the list INSIDE the card so the header above and the Allow/Deny
     buttons below stay visible regardless of how many scopes are requested. */
  max-height: clamp(184px, 42vh, 384px);
  overflow-y: auto;
  /* room for the scrollbar so text never sits under it */
  padding-right: 6px;
  /* edge fade hints there's more above/below when scrollable */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  /* thin, on-brand scrollbar (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
  overscroll-behavior: contain;
}
/* thin, on-brand scrollbar (WebKit/Blink) */
.scopes::-webkit-scrollbar { width: 8px; }
.scopes::-webkit-scrollbar-track { background: transparent; }
.scopes::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 999px;
  border: 2px solid var(--c-bg);
}
.scopes::-webkit-scrollbar-thumb:hover { background: #CBD5E1; }

.scope {
  display: flex;
  gap: 13px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--c-surface-2);
}
.scope:last-child { border-bottom: 0; }
.scope .tick {
  flex: none; width: 22px; height: 22px; margin-top: 1px;
  border-radius: 7px; background: var(--c-primary-muted);
  display: grid; place-items: center; color: var(--c-primary);
}
.scope .body { flex: 1; min-width: 0; }
.scope .name {
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 14.5px;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.scope .desc { color: var(--c-text-3); font-size: 13px; margin-top: 3px; line-height: 1.45; }
.badge-clin {
  font-family: var(--ff-head);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--c-clinical-bg);
  color: var(--c-clinical-fg);
  border: 1px solid var(--c-clinical-bd);
  border-radius: 6px;
  padding: 2px 7px;
}

/* ── consent: egress notice ──────────────────────────────────────────────── */
.egress {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #92400E;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: var(--r-control);
  padding: 12px 14px;
  margin-bottom: 22px;
}
.egress svg { flex: none; margin-top: 1px; }

footer {
  margin-top: 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--c-text-3);
  font-family: var(--ff-head);
  letter-spacing: .02em;
}

@media (max-width: 480px) {
  .card { padding: 32px 24px 28px; border-radius: 16px; }
  .lang { top: 14px; right: 14px; }
  .scopes { max-height: 40vh; }
}
/* Short viewports: shrink the scroll region further so the buttons stay on screen. */
@media (max-height: 680px) {
  .scopes { max-height: 34vh; }
}
