/*
 * The "Request access" dialog. Uses the page's tokens (--primary, --card, …);
 * the field colours match the howClutch app's inputs.
 */
.access {
  --input: oklch(1 0 0 / 14%);
  --input-hover: oklch(1 0 0 / 26%);
  --danger: oklch(0.704 0.191 22.216);
  --field-radius: 0.625rem;

  width: min(100% - 2rem, 32rem);
  max-width: none;
  max-height: min(100dvh - 2rem, 56rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 40px 80px -30px rgb(0 0 0 / 0.9);
  overflow: hidden;
}

.access::backdrop {
  background: rgb(0 0 0 / 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

html:has(.access[open]) {
  overflow: hidden;
}

/* Fields come and go with the answers; [hidden] has to win over display rules. */
.access [hidden] {
  display: none !important;
}

/* Phones: a sheet from the bottom edge. */
@media (max-width: 39.99rem) {
  .access {
    width: 100%;
    max-height: calc(100dvh - 0.75rem);
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 1.25rem 1.25rem 0 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .access,
  .access::backdrop {
    transition:
      opacity 0.25s var(--ease),
      translate 0.35s var(--ease),
      overlay 0.35s allow-discrete,
      display 0.35s allow-discrete;
  }

  .access:not([open]) {
    opacity: 0;
    translate: 0 1.5rem;
  }

  .access:not([open])::backdrop {
    opacity: 0;
  }

  @starting-style {
    .access[open] {
      opacity: 0;
      translate: 0 1.5rem;
    }

    .access[open]::backdrop {
      opacity: 0;
    }
  }
}

.access__panel {
  position: relative;
  max-height: inherit;
  padding: 1.75rem clamp(1.25rem, 5vw, 2rem) 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.access__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: oklch(1 0 0 / 4%);
  color: var(--label);
  cursor: pointer;
}

.access__close:hover {
  border-color: oklch(1 0 0 / 30%);
  color: var(--fg);
}

.access__close svg {
  width: 1.125rem;
  height: 1.125rem;
}

.access__head {
  display: grid;
  gap: 0.625rem;
  margin-bottom: 1.75rem;
  padding-right: 3rem;
}

.access__head h2 {
  font-size: clamp(2.25rem, 8vw, 2.75rem);
}

.access__head p {
  color: var(--label);
}

.access__form {
  display: grid;
  gap: 1.25rem;
}

/* ---------- Fields ---------- */

.field {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* A field that appeared because of an answer above it. */
.field--follow {
  padding-left: 0.875rem;
  border-left: 2px solid color-mix(in oklch, var(--primary), transparent 55%);
}

.field__label {
  padding: 0;
  font: 700 0.6875rem/1.3 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
}

.field__label .req {
  color: var(--primary);
}

.field__label .opt {
  font: 400 0.875rem/1 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.field__help {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.field__error {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--danger);
}

.field__error:empty {
  display: none;
}

.input {
  appearance: none;
  width: 100%;
  min-height: 3rem;
  margin: 0;
  padding: 0 0.875rem;
  border: 1px solid var(--input);
  border-radius: var(--field-radius);
  background: var(--card);
  color: var(--fg);
  font: 400 1rem/1.4 var(--font-sans); /* 16px keeps iOS from zooming in on focus */
  transition: border-color 0.15s var(--ease);
}

.input::placeholder {
  color: color-mix(in oklch, var(--muted), transparent 30%);
}

.input:hover {
  border-color: var(--input-hover);
}

.input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary), transparent 75%);
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

select.input {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b3aba4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 0.875rem center;
  background-repeat: no-repeat;
  background-size: 1.125rem;
  cursor: pointer;
}

/* The "Choose your club" placeholder. */
select.input:has(option[value='']:checked) {
  color: color-mix(in oklch, var(--muted), transparent 30%);
}

select.input option {
  background: var(--card);
  color: var(--fg);
}

select.input option:disabled {
  color: var(--muted);
}

/* ---------- Role ---------- */

.seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
}

.seg label,
.chip {
  position: relative;
}

.seg input,
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: grid;
  place-items: center;
  min-height: 3rem;
  height: 100%;
  padding: 0.5rem;
  border: 1px solid var(--input);
  border-radius: var(--field-radius);
  background: var(--card);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--label);
  transition:
    border-color 0.15s var(--ease),
    background-color 0.15s var(--ease),
    color 0.15s var(--ease);
}

.seg label:hover span,
.chip:hover span {
  border-color: var(--input-hover);
}

.seg input:checked + span,
.chip input:checked + span {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary), transparent 84%);
  color: var(--fg);
}

.seg input:focus-visible + span,
.chip input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.seg[aria-invalid='true'] span {
  border-color: var(--danger);
}

/* ---------- Teams ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border: 1px solid var(--input);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--label);
  transition:
    border-color 0.15s var(--ease),
    background-color 0.15s var(--ease),
    color 0.15s var(--ease);
}

.chip input:checked + span::before {
  content: '';
  width: 0.3125rem;
  height: 0.625rem;
  margin: -0.125rem 0.0625rem 0 0.125rem;
  border: solid var(--primary);
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}

/* ---------- Notice ---------- */

.access__notice {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Off-screen for people, still there for form-filling bots. */
.hp {
  position: absolute;
  left: -100vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Submit and outcome ---------- */

.access__alert {
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in oklch, var(--danger), transparent 50%);
  border-radius: var(--field-radius);
  background: color-mix(in oklch, var(--danger), transparent 88%);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.access__submit {
  width: 100%;
  min-height: 3.25rem;
  margin-top: 0.25rem;
  cursor: pointer;
}

.access__submit:disabled {
  cursor: progress;
  opacity: 0.7;
}

.access__done {
  display: grid;
  gap: 1rem;
  justify-items: center;
  padding: 2.5rem 0 0.5rem;
  text-align: center;
}

.access__done:focus {
  outline: none;
}

.access__tick {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: color-mix(in oklch, var(--primary), transparent 84%);
  color: var(--primary);
}

.access__tick svg {
  width: 1.75rem;
  height: 1.75rem;
}

.access__done h2 {
  font-size: clamp(2.25rem, 8vw, 2.75rem);
}

.access__done p {
  max-width: 24rem;
  color: var(--label);
}

.access__done .btn {
  margin-top: 0.5rem;
  cursor: pointer;
}

.access__done .access__preview {
  font: 700 0.6875rem/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warning);
}
