/* Front of House: Backstage's design tokens (copied by scripts/copy-tokens.mjs), and the few
   components a form site needs. Mobile first: most students will open this on a phone. */
@import url("tokens/colors.css");
@import url("tokens/typography.css");
@import url("tokens/spacing.css");
@import url("tokens/elevation.css");
@import url("tokens/motion.css");
@import url("tokens/base.css");

:root {
  --page-max: 680px;
  --field-height: 48px;
}

body {
  background: var(--surface-subtle);
  font-size: 15px;
  line-height: var(--leading-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Sized so a page title ("Your student ID request") stays on one line on a phone (360-430 px wide). */
h1 {
  font-size: clamp(1.375rem, 0.9rem + 2vw, 1.875rem);
  margin-bottom: var(--space-3);
  text-wrap: balance;
}
h2 {
  font-size: var(--text-md);
  margin-bottom: var(--space-3);
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  background: var(--amda-white);
  color: var(--text-brand);
  padding: var(--space-2) var(--space-4);
  z-index: 10;
}
.skip:focus {
  top: var(--space-2);
}

/* --- The bar ------------------------------------------------------------------------------- */
.bar {
  background: var(--gradient-brand);
  color: var(--text-on-brand);
}
.bar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-4) var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.bar-home {
  display: inline-flex;
}
.wordmark {
  height: 28px;
  width: auto;
}
.bar-title {
  font-family: var(--font-wordmark);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  border-left: 1px solid var(--border-on-inverse);
  padding-left: var(--space-4);
}
.dev-banner {
  margin: 0;
  background: var(--status-warning-soft);
  color: var(--status-warning);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  padding: var(--space-2) var(--gutter);
}

/* --- The page ------------------------------------------------------------------------------ */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-8) var(--gutter) var(--space-16);
}
.lede {
  font-size: var(--text-base);
  color: var(--text-body);
}
.aside {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-6);
}
/* A link under the sentence that leads to it, not at the end of it. */
.aside .own-line {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}
.hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}
.optional {
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}
.foot {
  text-align: center;
  text-wrap: balance; /* even lines on a phone, not one long and one short */
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-6) var(--gutter);
}
.foot-quiet {
  color: var(--text-disabled);
}
.foot-part {
  white-space: nowrap;
}

/* --- Blocks and cards ---------------------------------------------------------------------- */
.block,
.card,
.record,
.mail {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.cards {
  list-style: none;
  padding: 0;
  margin: var(--space-6) 0 0;
}
.card h2 {
  font-size: var(--text-lg);
}
.card p {
  margin: 0;
}
.record-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-heading);
  margin: 0;
}
.record-campus {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
}
.facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin: 0 0 var(--space-4);
}
.facts dt {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.facts dd {
  margin: 0 0 var(--space-2);
  font-weight: var(--weight-semibold);
  color: var(--text-heading);
}
.signed-in {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.rules {
  background: var(--surface-brand-soft);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}
.rules ul {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}
.rules p:last-child {
  margin-bottom: 0;
}

/* --- Fields -------------------------------------------------------------------------------- */
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-5);
  min-width: 0;
}
legend {
  font-weight: var(--weight-semibold);
  color: var(--text-heading);
  padding: 0;
  margin-bottom: var(--space-2);
}
.field {
  margin-bottom: var(--space-5);
}
.field label {
  display: block;
  font-weight: var(--weight-semibold);
  color: var(--text-heading);
  margin-bottom: var(--space-2);
}
input[type="text"],
input[type="email"],
input:not([type]),
input[inputmode] {
  width: 100%;
  min-height: var(--field-height);
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-size: var(--text-base); /* 16px: phones don't zoom in on focus */
  color: var(--text-body);
  background: var(--surface-card);
  border: var(--border-width-thick) solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.input-short {
  max-width: 14ch;
}
.input-code {
  /* Room for all six digits: each digit, the spacing after it, the box's own padding and border, and a
     little for the caret. A plain 10ch left the padding out, so the sixth digit was cut off. */
  max-width: calc(6ch + 6 * 0.3em + 2 * var(--space-4) + 2 * var(--border-width-thick) + 1ch);
  font-size: var(--text-xl) !important;
  letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums;
}
input[type="file"] {
  font: inherit;
  font-size: var(--text-sm);
  max-width: 100%;
}
/* The browser's own "Choose file" button, as one of ours: what someone without JavaScript sees. */
input[type="file"]::file-selector-button {
  min-height: var(--field-height);
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-wordmark);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-button);
  text-transform: uppercase;
  color: var(--action-primary);
  background: transparent;
  border: var(--border-width-thick) solid var(--action-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-color);
}
input[type="file"]::file-selector-button:hover {
  background: var(--surface-brand-soft);
}

/* --- Choosing a photo ---------------------------------------------------------------------- */
/* photo.js adds .upload-enhanced and shows the panel; the file box stays in the page, out of sight but
   still what the keyboard and a screen reader land on, and the panel is its label. */
.upload {
  position: relative;
}
.upload-enhanced .upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.field .upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-weight: var(--weight-regular);
  color: var(--text-body);
  background: var(--surface-card);
  border: var(--border-width-thick) dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-color);
}
.field .upload-drop[hidden] {
  display: none;
}
.upload-drop:hover,
.upload-over .upload-drop {
  background: var(--surface-brand-soft);
  border-color: var(--action-primary);
}
.upload-over .upload-drop {
  border-style: solid;
}
.upload-input:focus-visible + .upload-drop {
  box-shadow: var(--ring-focus);
}
.upload-input[aria-invalid="true"] + .upload-drop {
  border-color: var(--status-danger);
}
.upload-icon {
  color: var(--action-primary);
}
/* The label is what's clicked; the button inside it is only how it looks. */
.upload-button {
  pointer-events: none;
}
.upload-drop:hover .upload-button {
  background: var(--surface-card);
}
.upload-or {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.upload-name {
  max-width: 100%;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-heading);
  overflow-wrap: anywhere;
}
.upload-name:empty {
  display: none;
}
/* Once a photo is chosen the panel steps back: the photo itself is just below, in the frame. */
.upload-has-file .upload-drop {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
}
.upload-has-file .upload-icon,
.upload-has-file .upload-or {
  display: none;
}
/* Nothing to drag on a phone. */
@media (hover: none) {
  .upload-or {
    display: none;
  }
}
input[aria-invalid="true"] {
  border-color: var(--status-danger);
}
.choice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) 0;
  cursor: pointer;
}
.choice input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--action-primary);
  flex: none;
}
/* A tick box that opens the field under it ("Use my preferred name"). Pure CSS, so it
   works without JavaScript; the hidden field is display:none, so it's skipped by the keyboard too. */
.reveal-group {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-3);
}
.reveal {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--action-primary);
  flex: none;
  cursor: pointer;
}
.field .reveal-label {
  margin: 0;
  padding: var(--space-3) 0; /* a 44 px tall target with one line of text */
  line-height: var(--leading-snug);
  cursor: pointer;
}
.reveal-target {
  grid-column: 2;
  padding-top: var(--space-1);
}
.reveal:not(:checked) ~ .reveal-target {
  display: none;
}

.field-error {
  color: var(--status-danger);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-2);
}
.error-summary {
  border: var(--border-width-thick) solid var(--status-danger);
  background: var(--status-danger-soft);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}
.error-summary h2 {
  font-size: var(--text-lg);
  color: var(--status-danger);
}
.error-summary ul {
  margin: 0;
  padding-left: var(--space-5);
}
.error-summary a {
  color: var(--status-danger);
  font-weight: var(--weight-semibold);
}

/* --- Notices ------------------------------------------------------------------------------- */
.notice {
  border-left: var(--rule-width) solid var(--status-info);
  background: var(--status-info-soft);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
}
.notice p:last-child {
  margin-bottom: 0;
}
.notice-warning {
  border-color: var(--status-warning);
  background: var(--status-warning-soft);
}
.notice-success {
  border-color: var(--status-success);
  background: var(--status-success-soft);
}
.panel-success {
  background: var(--status-success-soft);
  border-left: var(--rule-width) solid var(--status-success);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
}
.panel-success h1 {
  margin-bottom: var(--space-2);
}
.panel-success p {
  margin: 0;
}
.ref {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.04em;
}
.policy {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding-left: var(--space-5);
}

/* --- Buttons ------------------------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--field-height);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-wordmark);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-button);
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  color: var(--text-on-brand);
  background: var(--action-primary);
  border: var(--border-width-thick) solid var(--action-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-color);
}
.button:hover {
  background: var(--action-primary-hover);
  border-color: var(--action-primary-hover);
  color: var(--text-on-brand);
}
.button-secondary {
  background: transparent;
  color: var(--action-primary);
}
.button-secondary:hover {
  background: var(--surface-brand-soft);
  color: var(--action-primary-hover);
}
.button-large {
  width: 100%;
}
.button[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.choices {
  margin: var(--space-6) 0;
}
.choices .button {
  width: 100%;
}
.choices .hint {
  margin-top: var(--space-2);
  text-align: center;
}
.choices-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.link-button {
  background: none;
  border: 0;
  padding: var(--space-2) 0;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}
.signout {
  margin-top: var(--space-6);
  text-align: center;
}

/* --- The photo cropper --------------------------------------------------------------------- */
.cropper {
  margin-top: var(--space-4);
}
.cropper[hidden] {
  display: none;
}
.cropper-frame {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
  margin: 0 auto var(--space-4);
  background: var(--neutral-100);
  border: var(--border-width-thick) solid var(--border-strong);
}
.cropper-frame::after {
  /* The face guide: an oval for the head, centred a little above the middle. */
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 12%;
  height: 56%;
  border: 2px dashed rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(47, 23, 72, 0.5);
  pointer-events: none;
}
.cropper-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.cropper-frame canvas:active {
  cursor: grabbing;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--action-primary);
  min-height: 44px;
}

/* --- Development outbox -------------------------------------------------------------------- */
.mail-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-2);
}
.mail-subject {
  font-family: var(--font-body);
  font-size: var(--text-md);
}
.mail-body {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin: 0;
}

/* Phones: less padding, so the form has the width. */
@media (max-width: 599px) {
  .page {
    padding: var(--space-6) var(--space-4) var(--space-12);
  }
  .block,
  .card,
  .record,
  .mail {
    padding: var(--space-5) var(--space-4);
  }
  .bar-inner {
    padding: var(--space-3) var(--space-4);
  }
}

@media (min-width: 600px) {
  .facts {
    grid-template-columns: max-content 1fr;
  }
  .facts dd {
    margin: 0;
  }
  .choices .button {
    width: auto;
  }
  .choices .hint {
    text-align: left;
  }
}
