/* ==========================================================================
   SupertutorTV — login & signup
   Loaded after main.css and reuses its tokens, buttons and kicker.
   Layout: header bar, then one centred form card on a full-width page with
   the homepage hero's soft background.
   ========================================================================== */

.auth-page { min-height: 100vh; background: var(--paper); }
.auth-page [hidden] { display: none !important; }

/* Background: same soft glows and grid as the homepage hero */
.auth-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ab-blob { position: absolute; border-radius: 50%; }
.ab-a { right: -12vw; top: -18vw; width: 56vw; aspect-ratio: 1; background: radial-gradient(circle, rgba(16, 159, 218, .22), transparent 66%); }
.ab-b { left: -16vw; bottom: -22vw; width: 52vw; aspect-ratio: 1; background: radial-gradient(circle, rgba(237, 129, 46, .16), transparent 66%); }
.ab-c { left: 35%; top: 20%; width: 34vw; aspect-ratio: 1; background: radial-gradient(circle, rgba(147, 52, 124, .07), transparent 70%); }
.ab-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(14, 26, 47, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(14, 26, 47, .045) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 35%, #000 25%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 35%, #000 25%, transparent 72%);
}

.auth { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* --- Form side --- */
.auth-main {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: calc(var(--container) + var(--gutter) * 2);
  margin: 0 auto; padding: 0 var(--gutter);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1.5rem; padding: 1.25rem 0; }
.auth-brand img { width: 150px; }
.auth-back, .auth-switch a {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .9rem; color: var(--ink); text-decoration: none;
}
.auth-back { padding: .5rem .9rem; border-radius: var(--r-pill); border: 1.5px solid var(--line-strong); background: rgba(255, 255, 255, .7); transition: border-color .2s, box-shadow .2s; }
.auth-back:hover { border-color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-switch { font-size: .9rem; color: var(--muted); }
.auth-switch a { color: var(--blue-ink); }
.auth-switch a:hover { text-decoration: underline; }

/* The form card */
.auth-card {
  width: 100%; max-width: 560px;
  margin: auto;
  padding: clamp(1.75rem, 1.2rem + 1.6vw, 2.75rem);
  border-radius: var(--r-xl);
  background: var(--card);
  border: 1px solid rgba(14, 26, 47, .06);
  box-shadow: 0 2px 6px rgba(14, 26, 47, .04), 0 30px 70px -30px rgba(14, 26, 47, .28);
}
.auth-card-wide { max-width: 600px; }
.auth-card .kicker { margin-bottom: 0; }
.auth-card h1 { margin-top: .9rem; font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.3rem); }
.auth-sub { margin-top: .5rem; color: var(--muted); font-size: 1rem; }

/* Role switch (segmented radio) */
.role-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem; margin-top: 1.5rem; padding: .3rem; border-radius: 16px; background: var(--paper-2); }
.role-switch-signup { margin-top: 0; }
.role-switch label { position: relative; cursor: pointer; }
.role-switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.role-switch span {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; border-radius: 12px;
  font-weight: 700; font-size: .9rem; color: var(--ink-3);
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.role-switch .icon { width: 18px; height: 18px; }
.role-switch label:hover span { color: var(--ink); }
.role-switch input:checked + span { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.role-switch input:checked + span .icon { color: var(--blue-ink); }
.role-switch input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Fields */
.auth-form { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
.a-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.a-fieldset legend, .a-field label, .a-label-row label { display: block; margin-bottom: .45rem; padding: 0; font-size: .88rem; font-weight: 700; color: var(--ink); }
.a-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.a-field { min-width: 0; }
.a-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.a-input { position: relative; display: flex; align-items: center; }
.a-input > .icon { position: absolute; left: 1rem; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.a-input input {
  width: 100%; min-height: 52px;
  padding: .75rem 1rem .75rem 2.75rem;
  border: 1.5px solid var(--line-strong); border-radius: 14px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: .98rem;
  transition: border-color .2s, box-shadow .2s;
}
.a-input-plain input { padding-left: 1rem; }
.a-input input::placeholder { color: #98A1B1; }
.a-input input:hover { border-color: var(--ink-3); }
.a-input input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(16, 159, 218, .18); }
.a-input:focus-within > .icon { color: var(--blue-ink); }
.a-input input[aria-invalid="true"] { border-color: #B42318; }
.a-input input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(180, 35, 24, .15); }
.a-input:has(.a-reveal) input { padding-right: 3.2rem; }
.a-reveal { position: absolute; right: .45rem; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--muted); }
.a-reveal:hover { background: var(--paper-2); color: var(--ink); }
.a-reveal .icon { width: 19px; height: 19px; }

.a-error { display: none; margin-top: .4rem; font-size: .8rem; font-weight: 600; color: #B42318; }
.a-error.is-shown { display: block; }
.a-help { margin-top: .4rem; font-size: .8rem; color: var(--muted); }
.a-link { font-size: .84rem; font-weight: 700; color: var(--blue-ink); }
.a-link:hover { text-decoration: underline; }

/* Password strength */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: .55rem; }
.pw-meter span { height: 5px; border-radius: 4px; background: var(--line); transition: background-color .25s; }
.pw-meter[data-level="1"] span:nth-child(-n+1) { background: #B42318; }
.pw-meter[data-level="2"] span:nth-child(-n+2) { background: var(--orange); }
.pw-meter[data-level="3"] span:nth-child(-n+3) { background: var(--yellow); }
.pw-meter[data-level="4"] span { background: #2F7D4F; }

/* Checkboxes */
.a-check { position: relative; display: flex; align-items: flex-start; gap: .65rem; cursor: pointer; font-size: .9rem; color: var(--text); line-height: 1.45; }
.a-check input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.a-box { display: grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--card); color: transparent; transition: background-color .2s, border-color .2s; }
.a-box .icon { width: 14px; height: 14px; stroke-width: 3; }
.a-check input:checked + .a-box { background: var(--ink); border-color: var(--ink); color: #fff; }
.a-check input:focus-visible + .a-box { outline: 3px solid var(--blue); outline-offset: 2px; }
.a-check input[aria-invalid="true"] + .a-box { border-color: #B42318; }
.a-check a { font-weight: 700; color: var(--blue-ink); }

/* Course picker */
.course-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.course-pick label { position: relative; cursor: pointer; }
.course-pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.cp-card {
  display: grid; justify-items: start; gap: .2rem; height: 100%;
  padding: .85rem .8rem;
  border: 1.5px solid var(--line-strong); border-radius: 14px;
  background: var(--card);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.cp-icon { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: .25rem; border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, #fff); color: var(--c); }
.cp-icon .icon { width: 18px; height: 18px; }
.cp-card strong { font-family: var(--font-display); font-size: .9rem; font-weight: 600; color: var(--ink); line-height: 1.2; }
.cp-card small { font-size: .74rem; color: var(--muted); }
.course-pick label:hover .cp-card { border-color: var(--ink-3); }
.course-pick input:checked + .cp-card { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.course-pick input:focus-visible + .cp-card { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Submit + secondary */
.a-submit { width: 100%; margin-top: .25rem; }
.a-submit.is-loading { pointer-events: none; opacity: .85; }
.a-submit.is-loading .icon { animation: auth-spin .8s linear infinite; }
.a-notice { display: flex; align-items: flex-start; gap: .55rem; padding: .75rem .9rem; border-radius: 12px; background: var(--blue-soft); color: var(--blue-ink); font-size: .86rem; font-weight: 600; }
.a-notice .icon { margin-top: .1rem; }
.auth-fine { text-align: center; font-size: .8rem; color: var(--muted); }

.auth-alt { display: grid; gap: .75rem; margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); text-align: center; font-size: .9rem; color: var(--muted); }
.auth-alt .btn { width: 100%; }
.auth-demo { display: flex; align-items: flex-start; gap: .5rem; margin-top: 1.5rem; padding: .75rem .9rem; border-radius: 12px; background: var(--paper-2); font-size: .8rem; color: var(--muted); }
.auth-demo .icon { margin-top: .15rem; color: var(--blue-ink); }

/* Success state */
.auth-success { display: grid; justify-items: center; gap: .25rem; text-align: center; padding: 1rem 0; }
.auth-success:focus { outline: none; }
.auth-success .a-submit { margin-top: 1.25rem; }
.success-mark { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: #2F7D4F; color: #fff; box-shadow: 0 0 0 10px #E4F3EA; animation: auth-pop .5s var(--ease-out); }
.success-mark .icon { width: 34px; height: 34px; stroke-width: 2.6; }

.auth-foot { padding: 2rem 0 1.25rem; text-align: center; font-size: .74rem; color: var(--muted); }

@keyframes auth-spin { to { transform: rotate(360deg); } }
@keyframes auth-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Responsive --- */
@media (max-width: 640px) {
  .auth-main { padding: 0 1rem; }
  .auth-top { padding: .9rem 0; }
  .auth-card { margin: .5rem auto 0; padding: 1.75rem 1.25rem; border-radius: var(--r-lg); }
  .auth-foot { padding-top: 1.5rem; }
}

@media (max-width: 480px) {
  .auth-brand img { width: 128px; }
  .auth-back { padding: .45rem .75rem; font-size: .84rem; }
  .auth-switch { width: 100%; }
  .a-row { grid-template-columns: minmax(0, 1fr); }
  .course-pick { grid-template-columns: minmax(0, 1fr); }
  .cp-card { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .75rem; align-items: center; }
  .cp-icon { grid-row: span 2; margin: 0; }
  .role-switch span { font-size: .84rem; gap: .35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .a-submit.is-loading .icon, .success-mark { animation: none; }
}
