/*
 * The scanner — and the only place in the product its status colours exist, copied from
 * docs/brand-guide.md §3. --gate-ok is deliberately NOT brand green: brand green carries buttons and
 * active UI everywhere else, so "valid" uses a visibly brighter green with dark text, and brightness —
 * not hue — separates the two. BrandRulesTests fails the build if one of these appears anywhere
 * outside this library. Ink chrome around them, so they are the only colour on the screen.
 */
:root {
  --gate-ok: #3ddc84;
  --gate-ok-fg: #04240f;
  --gate-invalid: #b42318;
  --gate-pending: #7a4c00;
  --gate-pending-on-dark: #ffbe5a;
  --gate-line: rgba(255, 255, 255, 0.2);
}

.gate-root {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink-900);
  color: #ffffff;
}

/* ------------------------------------------------------------- controls */

.gate-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.55); border-radius: var(--radius-ctrl);
  background: transparent; color: #ffffff;
  font-weight: 700; font-size: 16px; text-decoration: none;
}
.gate-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #ffffff; }
.gate-btn:disabled { border-color: rgba(255, 255, 255, 0.25); color: rgba(255, 255, 255, 0.45); }
.gate-btn--lg { min-height: 56px; font-size: 17px; }
.gate-btn--solid { border-color: #ffffff; background: #ffffff; color: var(--ink-900); }
.gate-btn--solid:hover:not(:disabled) { background: rgba(255, 255, 255, 0.85); color: var(--ink-900); }

/* On a status surface. Bright green needs a dark button; white on it has no visible edge. */
.gate-btn--on-ok { border-color: var(--gate-ok-fg); background: var(--gate-ok-fg); color: #ffffff; }
.gate-btn--on-ok:hover:not(:disabled) { background: var(--ink-900); color: #ffffff; }
.gate-btn--on-invalid { border-color: #ffffff; background: #ffffff; color: var(--ink-900); }
.gate-btn--on-invalid:hover:not(:disabled) { background: rgba(255, 255, 255, 0.85); color: var(--ink-900); }

/* Brand green on ink is too dark to see as a focus ring. */
.gate-root :focus-visible { outline: 3px solid #ffffff; outline-offset: 2px; }
.gate__result--ok :focus-visible { outline-color: var(--gate-ok-fg); }

.gate-input {
  flex: 1; min-width: 0; min-height: 52px; padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.55); border-radius: var(--radius-ctrl);
  background: rgba(255, 255, 255, 0.08); color: #ffffff; font-size: 17px; letter-spacing: 0.04em;
}
.gate-input::placeholder { color: var(--ink-on-dark); letter-spacing: 0; }
.gate-input:focus { border-color: #ffffff; }

/* ---------------------------------------------------------------- frame */

.gate {
  display: flex; flex-direction: column; gap: 10px;
  height: 100vh; height: 100dvh;
  max-width: 560px; margin: 0 auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
}

.gate__header { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.gate__event { flex: 1; min-width: 0; }
.gate__title {
  margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gate__meta { display: flex; flex-wrap: wrap; gap: 0 12px; margin: 0; font-size: 13px; color: var(--ink-on-dark); }
.gate__camera-state {
  flex: none; padding: 4px 10px; border: 1px solid var(--gate-line); border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
}
.gate__close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: #ffffff; }

/* --------------------------------------------------------------- camera */

.gate__camera {
  position: relative; flex: 1; min-height: 240px;
  border-radius: var(--radius-card); overflow: hidden; background: #1b221e;
}
.gate__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.gate__aim {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  pointer-events: none;
}
/* The QR-Auge corners, all four in white: the frame says where to hold the code. */
.gate__frame {
  position: relative; width: min(64vw, 260px); aspect-ratio: 1;
  box-shadow: 0 0 0 100vmax rgba(16, 21, 18, 0.45);
  border-radius: 14px;
}
.gate__frame i { position: absolute; width: 22%; height: 22%; border: 4px solid #ffffff; }
.gate__frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.gate__frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.gate__frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.gate__frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.gate__hint { margin: 0; font-size: 15px; color: var(--ink-on-dark); }

.gate__camera-off {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; background: rgba(16, 21, 18, 0.88);
}
.gate__camera-off p { margin: 0; }
.gate__pending-text { color: var(--gate-pending-on-dark); font-size: 14px; }

.gate__checking {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); margin: 0;
  padding: 6px 14px; border-radius: var(--radius-pill); background: rgba(16, 21, 18, 0.85); font-weight: 600;
}

/* --------------------------------------------------------------- answer */

/* The answer rises from the bottom of the camera: colour, one large word, then the detail. */
.gate__result {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 22px 20px; cursor: pointer;
}
.gate__result--ok { background: var(--gate-ok); color: var(--gate-ok-fg); }
.gate__result--invalid { background: var(--gate-invalid); color: #ffffff; }
/* Let in on this device's word, not the server's: amber, with dark text for the same reason green has it. */
.gate__result--pending { background: var(--gate-pending-on-dark); color: #2b1a00; }

.gate__verdict {
  margin: 0; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(44px, 12vw, 56px); line-height: 1; letter-spacing: -0.03em;
}
.gate__detail { margin: 8px 0 0; font-size: 19px; font-weight: 700; }
.gate__sub { margin: 0; font-size: 15px; }

/* ------------------------------------------------------------- controls */

.gate__scan { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.gate__scan[hidden] { display: none; }
.gate__manual { display: flex; gap: 8px; }
.gate__type {
  align-self: center; min-height: 44px; padding: 0 16px; border: 0; background: none;
  color: rgba(255, 255, 255, 0.85); font-weight: 600; font-size: 15px;
  text-decoration: underline; text-underline-offset: 3px;
}
.gate__error {
  margin: 0; padding: 10px 12px; border: 1px solid var(--gate-line); border-radius: var(--radius-ctrl);
  color: #ffffff; font-size: 14px;
}

/* Online or offline, as a dot and a word. */
.gate__net {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 5px 10px; border-radius: var(--radius-pill);
  background: rgba(61, 220, 132, 0.16); color: var(--gate-ok); font-size: 12px; font-weight: 700;
}
.gate__net i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.gate__net--off { background: rgba(255, 190, 90, 0.18); color: var(--gate-pending-on-dark); }
.gate__tool {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.08); color: #ffffff;
}
.gate__tool[aria-pressed="true"] { background: #ffffff; color: var(--ink-900); }

/* Scannen or Kassa: the current one in the signal colour, so a glance says which mode this is. */
.gate__nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gate__navitem {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px;
  border: 0; border-radius: 16px; background: rgba(255, 255, 255, 0.1); color: #ffffff;
  font-weight: 700; font-size: 17px;
}
.gate__navitem[aria-current="page"] { background: var(--gate-ok); color: var(--gate-ok-fg); font-weight: 800; }
.gate__navitem:focus-visible { outline-offset: -3px; }

/* ----------------------------------------------------------- abendkassa */

/* The Abendkassa is a light surface between the Ink header and navigation: money is counted here,
   not shown to a queue, and black on white reads fastest for that. */
.door {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto;
  margin: 0 -12px; padding: 14px 16px 12px; background: var(--surface); color: var(--ink-900);
}
.door :focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.door__title { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.door__note { margin: 0; color: var(--ink-600); }
.door__cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.door__cat {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  min-height: 112px; padding: 14px; border: 2px solid var(--line); border-radius: 18px;
  background: var(--card); color: var(--ink-900); text-align: left;
}
.door__cat--on { border-color: var(--brand-500); background: var(--brand-25); }
.door__cat:disabled { opacity: 0.6; }
.door__catname { font-size: 16px; font-weight: 700; }
.door__catprice { font-family: var(--font-display); font-size: 24px; font-weight: 800; }
.door__count {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px;
  border-radius: var(--radius-pill); background: var(--brand-500); color: #ffffff; font-weight: 800; font-size: 16px;
}
.door__basket { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14px; color: var(--ink-600); }
.door__basket span { flex: 1; }
.door__clear { min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--brand-700); font-weight: 700; font-size: 14px; }
.door__label { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--ink-600); }
.door__notes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.door__notebtn { min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink-900); font-weight: 700; font-size: 15px; }
.door__notebtn[aria-pressed="true"] { border-color: var(--brand-500); }
.door__change { margin: 10px 0 0; font-size: 16px; }
.door__error { margin: 0; padding: 10px 12px; border-radius: var(--radius-ctrl); background: var(--danger-bg); color: var(--danger-ink); font-size: 14px; }
.door__book {
  margin-top: auto; min-height: 60px; border: 0; border-radius: 16px; background: var(--brand-500); color: #ffffff;
  font-weight: 800; font-size: 18px;
}
.door__book:disabled { background: var(--surface-2); color: var(--ink-600); }
.door__done {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 32px; background: var(--brand-500); color: #ffffff; text-align: center;
}
.door__done p { margin: 0; font-size: 17px; }
.door__donetitle { font-family: var(--font-display); font-size: 40px !important; font-weight: 800; letter-spacing: -0.03em; }
.door__donehint { font-size: 14px !important; opacity: 0.85; max-width: 32ch; }
.door__next { min-width: 240px; min-height: 56px; margin-top: 20px; border: 0; border-radius: 14px; background: #ffffff; color: var(--brand-700); font-weight: 800; font-size: 17px; }
.door__done :focus-visible { outline-color: #ffffff; }

/* -------------------------------------------------------------- message */

.gate-message { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.gate-message__card { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; max-width: 420px; }
.gate-message__card h1 { margin: 0; font-family: var(--font-display); font-size: 26px; }
.gate-message__card p { margin: 0; color: var(--ink-on-dark); }

/* ----------------------------------------------------------------- join */

/* The helper link's landing page: light, because it is read once at home, not at the turnstile. */
.join {
  display: flex; flex-direction: column; gap: 6px; min-height: 100vh; min-height: 100dvh; max-width: 480px; margin: 0 auto;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--ink-900);
}
.gate-root:has(.join) { background: var(--surface); }
.join :focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.join__lead { margin: 28px 0 0; font-size: 15px; font-weight: 600; color: var(--ink-600); }
.join__title { margin: 0; font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.08; }
.join__match {
  display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 16px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--card);
}
.join__matchtitle { display: block; font-size: 17px; font-weight: 700; }
.join__matchwhen { display: block; font-size: 14px; color: var(--ink-600); }
.join__form { flex: 1; display: flex; flex-direction: column; margin-top: 16px; }
.join__label { font-size: 15px; font-weight: 700; }
.join__input {
  min-height: 54px; margin-top: 8px; padding: 0 14px; border: 1px solid var(--hairline); border-radius: 14px;
  background: var(--card); color: var(--ink-900); font-size: 17px; font-weight: 500;
}
.join__input[aria-invalid="true"] { border: 2px solid var(--danger); }
.join__hint { margin: 8px 0 0; font-size: 14px; color: var(--ink-600); }
.join__hint--center { text-align: center; font-size: 13px; }
.join__promises { display: flex; flex-direction: column; gap: 10px; margin: auto 0 18px; padding: 24px 0 0; list-style: none; font-size: 14px; color: var(--ink-600); }
.join__promises li { padding-left: 28px; background: no-repeat left 2px / 18px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A7A4C' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E"); }
.join__error { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-ctrl); background: var(--danger-bg); color: var(--danger-ink); font-size: 14px; }
.join__start { min-height: 58px; border: 0; border-radius: 16px; background: var(--brand-500); color: #ffffff; font-weight: 800; font-size: 18px; }
.join__start:disabled { opacity: 0.6; }
