/* Access gate (assets/js/access-gate.js): a code prompt shown instead of
   the page. While the gate is locked everything else in <body> is hidden.
   A courtesy lock, not security: see the note in the script.

   In the components layer like every other part. An !important in an
   earlier layer wins over one in a later layer, so pages and utilities
   cannot show the page while the gate is locked. */

@layer components {
  html[data-access-gate='locked'] body > :not(.access-gate) {
    display: none !important;
  }

  .access-gate {
    display: grid;

    /* minmax(0, 1fr) here and on the form: an auto column takes the
       input's intrinsic width and overflows phones narrower than 350px. */
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    min-height: 100dvh;
    padding: var(--theme-space-lg) var(--theme-gutter);
    background: var(--theme-color-background);
    color: var(--theme-color-text);
  }

  .access-gate__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--theme-space-xs);
    justify-items: center;
    width: min(100%, 26rem);
    text-align: center;
  }

  .access-gate__logo {
    width: min(100%, 12rem);
    height: auto;
    margin-block-end: var(--theme-space-2xs);
  }

  .access-gate__row {
    display: flex;
    gap: var(--theme-space-2xs);
    width: 100%;
  }

  .access-gate__input {
    flex: 1;
    min-width: 0;
    min-height: 3rem;
    padding: 0.75rem 1.25rem;
    border: var(--theme-border-width) solid var(--theme-color-border);
    border-radius: var(--theme-radius-pill);
    background: var(--theme-color-surface);
    color: var(--theme-color-text);
    font: inherit;
  }

  .access-gate__input::placeholder {
    color: var(--theme-color-text-muted);
  }

  .access-gate__input[aria-invalid='true'] {
    border-color: var(--theme-color-border-strong);
  }

  .access-gate__button {
    min-height: 3rem;
    padding: 0.75rem 1.5rem;
    border: var(--theme-border-width) solid var(--theme-color-primary);
    border-radius: var(--theme-radius-pill);
    background: var(--theme-color-primary);
    color: var(--theme-color-on-dark);
    font: inherit;
    font-weight: var(--theme-weight-semibold);
    font-size: var(--theme-text-sm);
    cursor: pointer;
    transition:
      background-color var(--theme-duration) var(--theme-ease-signature),
      color var(--theme-duration) var(--theme-ease-signature);
  }

  .access-gate__button:hover {
    background: transparent;
    color: var(--theme-color-primary);
  }

  .access-gate__input:focus-visible,
  .access-gate__button:focus-visible {
    outline: 2px solid var(--theme-color-focus);
    outline-offset: 3px;
  }

  .access-gate__error {
    min-height: 1.5em;
    margin: 0;
    font-size: var(--theme-text-sm);
    color: var(--theme-color-text);
  }

  @media (prefers-reduced-motion: reduce) {
    .access-gate__button {
      transition: none;
    }
  }
}
