/* Lobby check-in screen (public tablet, own hostname). Loaded alone, with the system font (no font files):
   the portal's palette is copied here so it looks like the same clinic. Touch first, big, calm; fluid from a
   phone up to a 1366 px tablet, portrait or landscape. */

:root {
  --navy: #17324a;
  --navy-deep: #0f2233;
  --teal: #2a6482;
  --mint: #bcd8e4;
  --sky: #f3f7f9;
  --blue-soft: #eaf3f7;
  --green: #1d6b43;
  --green-soft: #e4f3ea;
  --red: #b3261e;
  --red-soft: #fdecea;
  --ink: #17324a;
  --ink-soft: #4c5a63;
  --ink-mute: #576671;
  --line: #c6dbe5;
  --focus: #6ea6bf;
  --tap: 64px;
  --field: clamp(60px, 7vh, 72px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
p { margin: 0; }
h1, h2 { margin: 0; line-height: 1.12; letter-spacing: -.02em; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
svg { display: block; }

.k-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 18px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 85% -10%, rgb(188 216 228 / .55), transparent 55%),
    radial-gradient(ellipse at -10% 110%, rgb(188 216 228 / .4), transparent 50%),
    var(--sky);
  /* Safe areas: full-screen / kiosk modes and phones with a notch. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no double-tap zoom on the big buttons */
  overflow-wrap: anywhere;
}

:focus { outline: none; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

/* ---- Language: once kiosk.js runs only the chosen one shows; without JS both, as "Español / English". ---- */
html.js[data-lang="es"] .t[lang="en"],
html.js[data-lang="en"] .t[lang="es"] { display: none; }
html:not(.js) .t + .t::before { content: ' / '; color: var(--ink-mute); font-weight: 500; }

/* ---- Top bar ---- */
.k-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: clamp(14px, 2.5vw, 28px) clamp(16px, 4vw, 44px) 0;
}
.k-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.k-mark {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--navy);
  display: grid;
  place-items: center;
}
.k-mark svg { width: 30px; height: 30px; fill: #fff; }
.k-mark::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--mint);
  border: 2px solid #fff;
}
.k-brand__text { display: flex; flex-direction: column; min-width: 0; }
.k-brand__name { font-size: 1.45rem; font-weight: 700; line-height: 1.15; }
.k-brand__line { font-size: 1rem; color: var(--ink-mute); line-height: 1.3; }

.k-lang {
  display: flex;
  padding: 5px;
  gap: 4px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--line);
}
.k-lang__btn {
  flex: 1 1 0;
  min-height: var(--tap);
  min-width: 8.5rem;
  padding: 8px clamp(14px, 2.5vw, 26px);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.k-lang__btn[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* ---- Screens: one shows at a time (class from the server, then kiosk.js; #k-form:target without JS) ---- */
.k-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 36px) clamp(12px, 3vw, 32px);
  min-width: 0;
}
.screen {
  display: none;
  width: 100%;
  max-width: 46rem;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 3vh, 30px);
}
.screen.is-on, .screen:target { display: flex; }
.k-main:has(.screen:target) .screen.is-on:not(:target) { display: none; }
.screen--form { max-width: 48rem; align-items: stretch; }

/* ---- Welcome / done typography ---- */
.k-hello { font-size: clamp(2.4rem, 7vw, 4.4rem); display: flex; flex-direction: column; gap: .15em; }
.k-hello--sm { font-size: clamp(1.9rem, 5vw, 3rem); }
.k-hello__en { font-size: .62em; font-weight: 600; color: var(--teal); }
.k-lead { font-size: clamp(1.25rem, 2.6vw, 1.6rem); color: var(--ink-soft); display: flex; flex-direction: column; gap: .2em; max-width: 34em; line-height: 1.35; }
.k-lead__en { color: var(--ink-mute); font-size: .9em; }

/* ---- Buttons ---- */
.k-btn {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 14px 32px;
  border-radius: 999px;
  border: 2px solid transparent;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.k-btn:active { transform: translateY(1px) scale(.985); }
.k-btn--hero {
  flex-direction: column;
  gap: 2px;
  width: min(100%, 30rem);
  min-height: clamp(110px, 16vh, 132px);
  padding: 20px 32px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 22px 44px -22px rgb(15 34 51 / .85);
}
.k-btn__main { font-size: clamp(1.7rem, 3.6vw, 2.15rem); font-weight: 700; }
.k-btn__slash { opacity: .6; }
.k-btn--primary { min-height: 80px; font-size: 1.5rem; background: var(--navy); color: #fff; box-shadow: 0 14px 30px -18px rgb(15 34 51 / .85); }
.k-btn--hero:active, .k-btn--primary:active { background: var(--navy-deep); }
.k-btn--primary[disabled] { opacity: .65; cursor: progress; transform: none; }
.k-btn--ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.k-btn--ghost:active { background: var(--blue-soft); }
/* No sticky hover on touch screens: hover styles only for a real mouse. */
@media (hover: hover) and (pointer: fine) {
  .k-btn--hero:hover, .k-btn--primary:hover { background: #254a66; }
  .k-btn--ghost:hover { border-color: var(--navy); }
}

/* ---- Form card: one column; pairs of fields side by side only on wide landscape screens ---- */
.k-card {
  width: 100%;
  background: #fff;
  border-radius: clamp(20px, 3vw, 28px);
  padding: clamp(20px, 4vw, 40px);
  box-shadow: 0 30px 70px -38px rgb(15 34 51 / .55), 0 1px 2px rgb(23 50 74 / .06);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.5vh, 22px);
  text-align: left;
}
.k-card--narrow { max-width: 34rem; margin: 0 auto; }
.k-stack { display: flex; flex-direction: column; gap: 18px; }
.k-title { font-size: clamp(1.75rem, 4vw, 2.3rem); display: flex; flex-direction: column; gap: .15em; }
.k-title__en { font-size: .7em; font-weight: 600; color: var(--teal); }
.k-note { color: var(--ink-mute); font-size: 1.05rem; }
.k-note > span[lang]:not(.t) + span[lang]:not(.t) { display: block; }
.k-card > .k-title + .k-note { margin-top: -8px; }
.k-note--small { font-size: 1rem; padding-top: 16px; border-top: 1px solid var(--line); }
.k-note--center { display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.k-note__icon { flex: none; width: 20px; height: 20px; fill: var(--teal); }

.k-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: inherit; }
.k-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.k-field__label { padding: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.k-dob { display: block; } /* older Safari lays out a flex fieldset badly */
.k-dob .k-field__label { margin-bottom: 8px; }
.k-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--field);
  padding: 10px 18px;
  font-size: clamp(1.25rem, 2.6vw, 1.5rem); /* 20 px and up: iOS Safari does not zoom in on focus */
  font-weight: 500;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
  scroll-margin-top: 4.5rem; /* kiosk.js scrolls a field into view: keep its label above it visible */
}
.k-input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgb(110 166 191 / .35); outline: none; }
.k-input--code { font-size: 2rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.k-input--code::placeholder { color: #b7c6cf; letter-spacing: .3em; }

/* Date of birth: three selects in one row. appearance: none makes Safari honour the height; the arrow is drawn
   with borders on the wrapper (the CSP allows no images, not even data: URIs). */
/* Type of visit: two large tiles; the radio itself stays focusable (keyboard, screen readers) but is not drawn. */
.k-type { display: block; }
.k-type .k-field__label { margin-bottom: 8px; }
.k-type__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(8px, 1.5vw, 14px); }
.k-tile { position: relative; display: block; min-width: 0; }
.k-tile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.k-tile__box { display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-size: clamp(1.15rem, 2.2vw, 1.35rem); font-weight: 600; text-align: center; }
.k-tile input:checked + .k-tile__box { border-color: var(--navy); background: var(--navy); color: #fff; }
.k-tile input:focus-visible + .k-tile__box { outline: 3px solid var(--teal); outline-offset: 2px; }
.k-dob__row { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 6fr) minmax(0, 5fr); gap: clamp(8px, 1.5vw, 14px); }
.k-sel { position: relative; display: block; min-width: 0; }
.k-sel::after {
  content: '';
  position: absolute;
  right: 16px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -7px;
  border-right: 3px solid var(--teal);
  border-bottom: 3px solid var(--teal);
  transform: rotate(45deg);
  pointer-events: none;
}
.k-sel .k-input { padding-right: 38px; opacity: 1; cursor: pointer; }
.k-sel .k-input:invalid { color: var(--ink-mute); } /* still on the neutral "Día / Day" option */
.k-sel option { color: var(--ink); }

.k-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.k-actions .k-btn--ghost { align-self: center; min-width: 14rem; }

/* ---- Alerts ---- */
.k-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--red-soft);
  border: 1.5px solid #f2c4c0;
  color: var(--red);
  font-size: 1.15rem;
  font-weight: 600;
}
.k-alert__icon { flex: none; width: 28px; height: 28px; fill: currentColor; }
.k-alert__text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.k-alert__text p + p { font-weight: 500; color: #8f1e18; }

/* ---- Done / unavailable ---- */
.k-done__icon {
  width: clamp(96px, 14vh, 120px);
  height: clamp(96px, 14vh, 120px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  box-shadow: 0 0 0 12px rgb(228 243 234 / .55);
}
.k-done__icon svg { width: 56%; height: 56%; fill: var(--green); }
.k-done__icon--info { background: var(--blue-soft); box-shadow: 0 0 0 12px rgb(234 243 247 / .7); }
.k-done__icon--info svg { fill: var(--teal); }
.screen--done .k-btn--ghost { margin-top: 8px; min-width: 16rem; }

/* ---- Footer ---- */
.k-foot { padding: 0 16px clamp(14px, 2.5vw, 26px); text-align: center; color: var(--ink-mute); font-size: 1.05rem; }

/* ---- Wide landscape tablets: pairs of fields side by side, Cancel next to the big button ---- */
@media (min-width: 900px) and (orientation: landscape) {
  .k-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .k-actions { flex-direction: row-reverse; }
  .k-actions .k-btn--primary { flex: 1 1 auto; }
  .k-actions .k-btn--ghost { align-self: stretch; min-width: 12rem; }
}

/* ---- Phones: language buttons full width, brand centred ---- */
@media (max-width: 560px) {
  .k-top { justify-content: center; }
  .k-lang { width: 100%; }
  .k-lang__btn { min-width: 0; }
  .k-sel::after { right: 12px; }
  .k-sel .k-input { padding: 10px 30px 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .k-btn:active { transform: none; }
}
