/* ============================================================
   University of Jeddah — Registration form
   Global tokens, layout, and component styles.
   ============================================================ */

:root {
  --blue-950: #07293a;
  --blue-900: #0c3a50;
  --blue-800: #114c66;
  --blue-700: #1b6285;
  --blue-600: #2b7ba0;
  --sky: #80cded;
  --sky-soft: #bfe4f5;
  --slate: #6e96a2;
  --paper: #ffffff;
  --ink: #132630;
  --muted: #5d7683;
  --field: #f2f6f8;
  --field-line: #d6e2e8;
  --danger: #b23b2e;
  --radius: 16px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 85% -10%, #176f92 0%, transparent 55%),
    radial-gradient(130% 100% at 10% 110%, #08283a 0%, transparent 55%),
    linear-gradient(160deg, var(--blue-900), var(--blue-950));
}

/* ---------- Background decoration ---------- */
.waves {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .55;
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Language switch ---------- */
.lang {
  position: fixed;
  top: 22px;
  inset-inline-end: 24px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(128, 205, 237, .4);
  border-radius: 999px;
  padding: 4px;
  backdrop-filter: blur(8px);
}

.lang button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #eaf5fb;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 7px 16px;
  border-radius: 999px;
  transition: .25s var(--ease);
}

.lang button[aria-pressed="true"] {
  background: var(--sky);
  color: var(--blue-950);
}

/* ---------- Card ---------- */
.card {
  position: relative;
  z-index: 2;
  width: min(430px, 100%);
  background: var(--paper);
  border-radius: calc(var(--radius) + 8px);
  overflow: hidden;
  padding: 36px 36px 34px;
  box-shadow:
    0 40px 80px -30px rgba(4, 25, 35, .6),
    0 2px 0 rgba(255, 255, 255, .5) inset;
  animation: rise .7s var(--ease) both;
}

.card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 5px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(90deg, var(--blue-700), var(--sky), var(--blue-700));
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 26px;
}

.brand-logo {
  width: 78px;
}

.brand-logo svg {
  display: block;
  width: 100%;
  height: auto;
}

.subtitle {
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- Form ---------- */
form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 4px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.field label .req {
  color: var(--blue-600);
  margin-inline-start: 2px;
}

.control {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  border: 1.5px solid var(--field-line);
  border-radius: var(--radius);
  padding: 0 14px;
  height: 54px;
  transition:
    border-color .2s var(--ease),
    box-shadow .2s var(--ease),
    background .2s var(--ease);
}

.control:focus-within {
  background: #fff;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(43, 123, 160, .16);
}

.control svg {
  width: 20px;
  height: 20px;
  color: var(--slate);
  flex: none;
}

.control input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  height: 100%;
  min-width: 0;
}

.control input::placeholder {
  color: #9db2bc;
}

.phone-prefix {
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-800);
  padding-inline-end: 10px;
  border-inline-end: 1.5px solid var(--field-line);
  direction: ltr;
}

#phone {
  direction: ltr;
  text-align: start;
}

/* ---------- Field validation states ---------- */
.error {
  display: none;
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 6px;
}

.field.invalid .control {
  border-color: var(--danger);
  background: #fdf5f4;
}

.field.invalid .control svg {
  color: var(--danger);
}

.field.invalid .error {
  display: block;
}

/* ---------- Submit button ---------- */
.proceed {
  margin-top: 8px;
  position: relative;
  overflow: hidden;
  font-family: inherit;
  font-size: 16.5px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  height: 56px;
  width: 100%;
  background: linear-gradient(180deg, var(--blue-700), var(--blue-800));
  box-shadow:
    0 12px 24px -10px rgba(17, 76, 102, .75),
    0 -1px 0 rgba(255, 255, 255, .15) inset;
  transition:
    transform .18s var(--ease),
    box-shadow .25s var(--ease),
    filter .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.proceed:hover {
  filter: brightness(1.08);
  box-shadow: 0 16px 30px -10px rgba(17, 76, 102, .85);
}

.proceed:active {
  transform: translateY(1px);
}

.proceed:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

.proceed[disabled] {
  opacity: .75;
  cursor: progress;
  filter: none;
}

.proceed .arrow {
  transition: transform .25s var(--ease);
  transform: scaleX(var(--flip, -1));
}

.proceed:hover .arrow {
  transform: scaleX(var(--flip, -1)) translateX(4px);
}

html[dir="rtl"] .proceed { --flip: -1; }
html[dir="ltr"] .proceed { --flip: 1; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin .7s linear infinite;
}

.proceed.loading .spinner { display: block; }
.proceed.loading .arrow { display: none; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Form-level feedback ---------- */
.form-error {
  display: none;
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  background: #fdf5f4;
  border: 1px solid #e6c4bf;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}

.form-error.show { display: block; }

.footnote {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 18px;
}

/* ---------- Success state ---------- */
.done {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 10px 0 4px;
  animation: rise .5s var(--ease) both;
}

.done.show { display: flex; }
.form-wrap.hide { display: none; }

.check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(17, 76, 102, .1);
  display: grid;
  place-items: center;
  color: var(--blue-700);
}

.check svg {
  width: 34px;
  height: 34px;
}

.done h2 {
  font-family: "Reem Kufi", serif;
  font-size: 22px;
  color: var(--blue-800);
}

html[dir="ltr"] .done h2 {
  font-family: "IBM Plex Sans Arabic", sans-serif;
}

.done p {
  font-size: 14px;
  color: var(--muted);
}

/* "Redirecting you…" — quieter than the thank-you line. */
.redirect-note {
  font-size: 12.5px;
  color: var(--slate);
  opacity: .85;
}

/* Manual "continue now" fallback link (in case auto-redirect is blocked). */
.continue-btn {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 26px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--blue-700), var(--blue-800));
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 20px -10px rgba(17, 76, 102, .75);
  transition: filter .2s var(--ease), transform .18s var(--ease);
}

.continue-btn:hover {
  filter: brightness(1.08);
}

.continue-btn:active {
  transform: translateY(1px);
}

.continue-btn:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

.again {
  margin-top: 6px;
  background: none;
  border: 0;
  color: var(--blue-700);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .card {
    padding: 30px 22px 26px;
  }
  .lang {
    inset-inline-end: 16px;
    top: 16px;
  }
}
