/*
 * Sign-in, create account, email link and join dialogs (prototypes/auth-dialogs.html),
 * shared by the landing page (hero.html) and the app's welcome screen (app-welcome.html).
 * Uses the page's brand tokens (--primary, --white, --space-*, --radius-*, --shadow-floating,
 * --font, --spring, --ease-out) and its .btn-primary / .btn-line button styles.
 */
/* ═══════════════════════════════════════════
   JOIN SEMESTER DIALOG (floating layer)
═══════════════════════════════════════════ */
.join-dialog {
  width: min(440px, calc(100% - 2 * var(--space-4)));
  max-height: calc(100% - 2 * var(--space-4));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: #FFFFFF;
  color: var(--primary);
  font-family: var(--font);
  line-height: 1.7;
  box-shadow: var(--shadow-floating);
}
.join-dialog::backdrop { background: rgba(4, 20, 8, .48); }
.join-dialog[open] { animation: join-in 520ms var(--ease-out) both; }
.join-dialog[open]::backdrop { animation: join-fade 300ms ease both; }
.join-dialog.is-closing { animation: join-out 200ms ease both; }
.join-dialog.is-closing::backdrop { animation: join-fade 200ms ease reverse both; }
@keyframes join-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes join-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(12px) scale(.98); }
}
@keyframes join-fade { from { opacity: 0; } to { opacity: 1; } }

.join-inner { padding: var(--space-6); display: grid; gap: var(--space-5); }
.join-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.join-top img { display: block; height: 22px; width: auto; }
.join-close {
  appearance: none;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px var(--primary);
  transition: transform 240ms var(--spring);
}
.join-close::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, .06);
  opacity: 0;
  transition: opacity 160ms ease;
}
.join-close:hover::after { opacity: 1; }
.join-close:active { transform: scale(.92); }
.join-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.join-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.join-text { margin: var(--space-2) 0 0; font-size: .9rem; color: var(--dark-gray); }

.join-form { display: grid; gap: var(--space-3); }
.join-form label { font-size: .8rem; font-weight: 600; line-height: 1.4; }
.code-field {
  width: 100%;
  height: 64px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 16px;
  background: var(--white);
  color: var(--primary);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-align: center;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.code-field::placeholder { color: var(--light-gray); letter-spacing: .18em; }
.code-field:hover { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4); }
.code-field:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.code-field[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--primary); }
.code-field.is-shaking { animation: join-shake 360ms var(--ease-out); }
@keyframes join-shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.join-msg {
  margin: 0;
  min-height: 1.6em;
  font-size: .82rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--dark-gray);
}
.join-msg:not(:empty) { display: flex; gap: var(--space-2); align-items: flex-start; }
.join-msg:not(:empty)::before {
  content: "!";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--white);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
}

.join-dialog .btn-primary {
  width: 100%;
  justify-content: center;
  min-height: 48px;
  font-size: .92rem;
}
.join-dialog .btn-primary:focus-visible { outline-color: var(--primary); }
.join-dialog .btn-primary[aria-busy="true"] { cursor: progress; }
.join-dialog .btn-primary[aria-busy="true"]::after { opacity: 1; }
.spinner {
  width: 16px;
  height: 16px;
  margin-right: var(--space-2);
  border-radius: 50%;
  border: 2px solid rgba(249, 249, 249, .3);
  border-top-color: var(--brand-green);
  animation: join-spin 700ms linear infinite;
}
@keyframes join-spin { to { transform: rotate(360deg); } }

.join-help { margin: 0; font-size: .78rem; line-height: 1.6; color: var(--gray); }

/* Success step */
.join-done { display: grid; gap: var(--space-5); text-align: center; justify-items: center; }
.join-done .join-text { max-width: 32ch; }
.done-mark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-green);
  color: var(--primary);
  box-shadow: 0 0 0 8px rgba(124, 249, 122, .25), 0 8px 24px rgba(47, 214, 44, .3);
  animation: done-pop 600ms var(--spring) both;
}
@keyframes done-pop {
  from { opacity: 0; transform: scale(.5); }
  to   { opacity: 1; transform: none; }
}
.semester-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: 16px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
  text-align: left;
}
.semester-card strong { display: block; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.semester-card strong + span { display: block; font-size: .76rem; color: var(--gray); line-height: 1.4; }

@media (max-width: 600px) {
  .join-dialog { margin: auto auto var(--space-4); }
  .join-inner { padding: var(--space-5); }
}
@media (prefers-reduced-motion: reduce) {
  .join-dialog[open], .join-dialog[open]::backdrop,
  .join-dialog.is-closing, .join-dialog.is-closing::backdrop,
  .code-field, .done-mark { animation: none !important; }
}

/* ═══════════════════════════════════════════
   SIGN IN DIALOG (same floating layer as the join dialog)
═══════════════════════════════════════════ */
button.btn-ghost {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  padding: 0 0 0 var(--space-1);
  cursor: pointer;
}

.signin-form { gap: var(--space-4); }
.signin-field { display: grid; gap: var(--space-2); }

/* "New to Rekuro?" footer: divider label, outline Create account button, join link */
.signin-new { display: grid; gap: var(--space-3); justify-items: center; text-align: center; }
.signin-new-label {
  margin: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: .78rem;
  color: var(--gray);
}
.signin-new-label::before,
.signin-new-label::after { content: ""; flex: 1; height: 1px; background: var(--light-gray); opacity: .6; }
.signin-create { width: 100%; color: var(--primary); }
.signin-create svg { transition: transform 280ms var(--spring); }
.signin-create:hover svg { transform: translateX(3px); }

/* Wide screens (website only): Apple / Google on the left, email form on the right, the
   title above and "New to Rekuro?" below both. Stacked while resetting the password or
   when the buttons are hidden. */
@media (min-width: 860px) {
  html:not(.in-app) #signin-dialog:not(.is-reset):has(.oauth:not([hidden])) {
    width: min(820px, calc(100% - 2 * var(--space-4)));
  }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
    grid-template-areas: "top top top" "intro intro intro" "oauth line form" "new new new";
    column-gap: var(--space-6);
    padding: var(--space-6) var(--space-7) var(--space-7);
  }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden]))::before {
    content: "";
    grid-area: line;
    background: var(--light-gray);
    opacity: .6;
  }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) > .join-top { grid-area: top; }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) > div:not([class]) { grid-area: intro; }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) > .oauth { grid-area: oauth; align-self: center; margin-top: 0; }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) > .signin-form { grid-area: form; }
  html:not(.in-app) #signin-dialog:not(.is-reset) .join-inner:has(> .oauth:not([hidden])) > .signin-new { grid-area: new; }
  html:not(.in-app) #signin-dialog:not(.is-reset) .oauth-or { display: none; }
}

/* ---------- Create account dialog (floating) ---------- */
.reg-dialog {
  width: min(980px, calc(100% - 2 * var(--space-4)));
  max-height: calc(100dvh - 2 * var(--space-4));
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--white);
  color: var(--primary);
  /* Clip to the rounded corners; scrolling happens inside, only if ever needed */
  overflow: hidden;
  box-shadow:
    0 2px 6px rgba(4, 33, 10, .12),
    0 24px 60px rgba(4, 33, 10, .28),
    0 60px 120px rgba(10, 107, 28, .18);
}
.reg-dialog[open] { display: flex; flex-direction: column; }
.reg-dialog::backdrop { background: rgba(0, 0, 0, .62); }
.reg-dialog[open] { animation: reg-in 460ms var(--ease-out) both; }
.reg-dialog[open]::backdrop { animation: reg-fade 260ms ease both; }
.reg-dialog.is-closing { animation: reg-out 180ms ease both; }
.reg-dialog.is-closing::backdrop { animation: reg-fade 180ms ease reverse both; }
@keyframes reg-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes reg-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes reg-fade { from { opacity: 0; } to { opacity: 1; } }

.reg-inner { padding: var(--space-6); display: grid; gap: var(--space-5); overflow-y: auto; min-height: 0; }
.reg-inner[hidden] { display: none; }

/* Wide screens: intro on the left, form on the right, so it fits without scrolling */
@media (min-width: 860px) {
  .reg-dialog { max-width: 980px; }
  #reg-step-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    grid-template-areas: "top top" "intro form" "switch form";
    grid-template-rows: auto auto 1fr;
    column-gap: var(--space-7);
    padding: var(--space-6) var(--space-7) var(--space-7);
  }
  #reg-step-form .reg-top { grid-area: top; }
  #reg-step-form .reg-intro { grid-area: intro; align-self: start; padding-top: var(--space-2); }
  #reg-step-form .reg-form { grid-area: form; }
  #reg-step-form .reg-switch { grid-area: switch; align-self: end; text-align: left; }
  .reg-title { font-size: 2rem; }
  .reg-form .name-email { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
}
.reg-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.reg-top img { display: block; height: 22px; width: auto; }
.reg-close {
  appearance: none;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--primary);
  color: var(--primary);
  cursor: pointer;
  position: relative;
  transition: transform 240ms var(--spring);
}
.reg-close::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, .08);
  opacity: 0;
  transition: opacity 160ms ease;
}
.reg-close:hover::after { opacity: 1; }
.reg-close:active { transform: scale(.92); }
.reg-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.reg-title { margin: 0; font-size: 1.6rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.03em; }
.reg-text { margin: var(--space-2) 0 0; font-size: .9rem; color: var(--dark-gray); }

.reg-form { display: grid; gap: var(--space-4); }
.name-email { display: grid; gap: var(--space-4); }
.field { display: grid; gap: var(--space-1); }
.field label { font-size: .8rem; font-weight: 600; line-height: 1.4; }
.field .optional { font-weight: 400; color: var(--gray); }
.input-wrap { position: relative; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-s);
  border: 1px solid rgba(0, 0, 0, .14);
  background: #FFFFFF;
  color: var(--primary);
  font: inherit;
  font-size: .95rem;
}
.field input:hover { border-color: rgba(0, 0, 0, .28); }
.field input:focus-visible { outline: 2px solid var(--grad-2); outline-offset: 1px; border-color: transparent; }
.field input[aria-invalid="true"] { border-color: #C62828; }
.input-wrap input { padding-right: 76px; }
.reveal-pw {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--primary);
  color: var(--primary);
  font: inherit;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 200ms var(--spring);
}
.reveal-pw:hover { background: rgba(0, 0, 0, .09); }
.reveal-pw:active { transform: scale(.94); }
.reveal-pw:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hint { margin: 0; font-size: .74rem; color: var(--gray); line-height: 1.5; }
.error { margin: 0; font-size: .76rem; color: #B71C1C; line-height: 1.5; }
.error:empty { display: none; }

/* Required terms checkbox (never pre-ticked) */
.check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  font-size: .84rem;
  line-height: 1.55;
  cursor: pointer;
}
.check input {
  appearance: none;
  margin: 2px 0 0;
  padding: 0;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(0, 0, 0, .35);
  background: #FFFFFF;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: translateY(-1px) rotate(-45deg) scale(.4);
  opacity: 0;
  transition: opacity 120ms ease, transform 220ms var(--spring);
}
.check input:checked { background: var(--brand-green); border-color: var(--grad-2); }
.check input:checked::after { opacity: 1; transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.check input[aria-invalid="true"] { border-color: #C62828; }
.reg-link { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; border-radius: 3px; }
.reg-link:hover { color: var(--grad-3); }
.reg-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.reg-resend { appearance: none; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; cursor: pointer; }
.reg-resend:active { opacity: .7; }
.reg-resend:disabled { color: var(--gray); text-decoration: none; cursor: default; opacity: 1; }
#reg-resend-msg:empty { display: none; }

/* Privacy notice (information under Art. 13 GDPR, not a consent) */
.notice {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-s);
  background: rgba(0, 0, 0, .04);
  font-size: .76rem;
  line-height: 1.6;
  color: var(--dark-gray);
}

.reg-submit {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 50px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--white);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: transform 260ms var(--spring);
}
.reg-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(124, 249, 122, .2);
  opacity: 0;
  transition: opacity 160ms ease;
}
.reg-submit:hover::after { opacity: 1; }
.reg-submit:active { transform: scale(.98); }
.reg-submit:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.reg-submit[aria-busy="true"] { cursor: progress; }
.reg-submit[aria-busy="true"]::after { opacity: 1; }

.reg-switch { margin: 0; font-size: .8rem; color: var(--gray); text-align: center; }

.reg-done { display: grid; gap: var(--space-4); justify-items: center; text-align: center; }
.reg-done .reg-text { max-width: 34ch; }

@media (max-width: 520px) {
  .reg-dialog { margin: auto auto var(--space-2); width: calc(100% - 2 * var(--space-2)); }
  .reg-inner { padding: var(--space-5); }
}
.signin-field-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }

.text-field {
  width: 100%;
  height: 52px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 14px;
  background: var(--white);
  color: var(--primary);
  font: inherit;
  font-size: 1rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.text-field::placeholder { color: var(--light-gray); }
.text-field:hover { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4); }
.text-field:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.text-field[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--primary); }
.text-field.is-shaking { animation: join-shake 360ms var(--ease-out); }

.password-wrap { position: relative; }
.password-wrap .text-field { padding-right: 76px; }
.pw-toggle {
  appearance: none;
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--dark-gray);
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 240ms var(--spring);
}
.pw-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, .06);
  opacity: 0;
  transition: opacity 160ms ease;
}
.pw-toggle:hover::after { opacity: 1; }
.pw-toggle:active { transform: scale(.94); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.text-link {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, .3);
  text-underline-offset: 3px;
  border-radius: 4px;
  cursor: pointer;
}
.text-link:hover { text-decoration-color: currentColor; }
.text-link:active { opacity: .7; }
.text-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .text-field { animation: none !important; }
}

/* Elements focused by script (headings and boxes with tabindex="-1") show no focus ring; links, buttons and fields keep theirs */
[tabindex="-1"]:focus { outline: none; }
