/*
 * Growfox auth pages — "Signature Orange"
 * Shared by staff login, client login, signed-out, forgot password (email → OTP → new password)
 * and the first-login password change. Layout lives in templates/accounts/auth_base.html.
 * Contrast notes: text on the orange field is chocolate (#1F0D03, ≥4.6:1); cream is used only
 * for display-size words (≥3:1). White text never sits on #FF6801 (2.9:1).
 */

:root {
  --gf-orange: #FF6801;
  --gf-orange-deep: #E85A00;
  --gf-field-hi: #F26300;
  --gf-field: #E65A00;
  --gf-field-lo: #DA5400;
  --gf-choc: #1F0D03;
  --gf-cream: #FFF8F1;
  --gf-card: #FFFBF6;
  --gf-ink: #221710;
  --gf-ink-2: #3A2E26;
  --gf-muted: #5E554D;
  --gf-muted-2: #6F635B;
  --gf-input: #F4ECE3;
  --gf-input-line: #E9DDD1;
  --gf-line: #EFE5DA;
  --gf-link: #B84A00;
  --gf-link-hover: #8F3A00;
  --gf-danger: #B42318;
  --gf-font: "Prompt", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  --gf-pad-x: clamp(20px, 4.5vw, 64px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.gf-auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-color: var(--gf-field);
  background-image: radial-gradient(110% 110% at 70% 55%, var(--gf-field-hi) 0%, var(--gf-field) 50%, var(--gf-field-lo) 100%);
  background-attachment: fixed;
  color: var(--gf-choc);
  font-family: var(--gf-font);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Brand field ---------- */

.gf-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.gf-bg__stripes {
  position: absolute;
  top: -380px;
  left: -300px;
  width: 1500px;
  max-width: none;
  height: 1500px;
  opacity: 0.22;
}

.gf-bg__grain {
  position: absolute;
  inset: 0;
  background: url("../img/auth/grain.png") repeat;
  background-size: 128px 128px;
  opacity: 0.22;
}

.gf-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 52px var(--gf-pad-x) 0;
}

.gf-top__logo {
  display: inline-flex;
  border-radius: 6px;
}

.gf-top__logo img {
  display: block;
  width: auto;
  height: 32px;
}

.gf-top__label {
  color: var(--gf-choc);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.gf-main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  align-content: center;
  align-items: start;
  column-gap: clamp(40px, 6vw, 112px);
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px clamp(20px, 7.2vw, 104px) 40px var(--gf-pad-x);
}

/* Pinned just below the card's top edge (fox height + 26px) so tall cards don't push the headline down */
.gf-brand {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 760px;
  margin-top: 156px;
}

.gf-brand__eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-wrap: balance;
}

.gf-brand__title {
  margin: 0;
  font-size: clamp(40px, 4.1vw, 66px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.gf-hl {
  color: var(--gf-cream);
}

/* narrow columns break "We GROW / your brand / like a FOX", never leave "brand" alone */
.gf-nowrap {
  white-space: nowrap;
}

.gf-brand__sub {
  max-width: 460px;
  margin: 0;
  font-size: 18px;
  line-height: 1.65;
}

/* ---------- Card + peeking fox ---------- */

.gf-panel {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 460px;
  padding-top: 130px;
}

.gf-fox {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 0;
  width: 250px;
  margin-left: -125px;
  pointer-events: none;
}

.gf-fox img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 10px 18px rgba(90, 30, 0, 0.35));
  animation: gf-peek 4.5s ease-in-out infinite;
}

.gf-fox--hop img {
  animation: gf-hop 2.8s cubic-bezier(0.3, 0.7, 0.4, 1) infinite;
}

@keyframes gf-peek {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes gf-hop {
  0%, 55%, 100% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-22px) rotate(-4deg); }
  35% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-8px) rotate(2deg); }
}

.gf-card {
  position: relative;
  z-index: 1;
  padding: 48px 44px 40px;
  border-radius: 28px;
  background: var(--gf-card);
  box-shadow: 0 44px 90px -30px rgba(70, 20, 0, 0.55);
  color: var(--gf-ink);
}

.gf-card__title {
  margin: 0;
  color: var(--gf-ink);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-align: center;
}

.gf-card__sub {
  max-width: 350px;
  margin: 8px auto 0;
  color: var(--gf-muted);
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
  text-wrap: pretty;
}

.gf-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
  margin: 24px 0 0;
}

.gf-card__foot--split {
  justify-content: space-between;
}

.gf-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #FFF1E4;
  color: var(--gf-link);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gf-account {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 16px auto 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--gf-input);
  color: var(--gf-ink-2);
  font-size: 14px;
  font-weight: 500;
}

.gf-account svg {
  flex-shrink: 0;
}

.gf-account span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gf-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--gf-muted-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.gf-steps__bars {
  display: flex;
  gap: 6px;
}

.gf-steps__bar {
  width: 26px;
  height: 4px;
  border-radius: 4px;
  background: #EADFD4;
}

.gf-steps__bar.is-done {
  background: var(--gf-orange-deep);
}

/* ---------- Messages ---------- */

.gf-alerts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.gf-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.gf-alert svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.gf-alert--error { border-color: #F7C6C0; background: #FDECEA; color: #912018; }
.gf-alert--success { border-color: #BCE2CA; background: #E8F5EC; color: #1B6B40; }
.gf-alert--warning { border-color: #F3DA9C; background: #FFF4DB; color: #7A4F00; }
.gf-alert--info { border-color: #C7D9F3; background: #EAF1FB; color: #1D4F91; }

/* ---------- Form ---------- */

.gf-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 30px 0 0;
}

.gf-alerts + .gf-form,
.gf-account + .gf-form {
  margin-top: 22px;
}

.gf-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gf-field__label {
  color: var(--gf-ink-2);
  font-size: 13px;
  font-weight: 500;
}

.gf-field__control {
  position: relative;
}

.gf-field__icon {
  position: absolute;
  top: 50%;
  left: 17px;
  display: flex;
  color: var(--gf-muted-2);
  transform: translateY(-50%);
  pointer-events: none;
}

.gf-field__control input,
.gf-otp {
  display: block;
  width: 100%;
  margin: 0;
  border: 1px solid var(--gf-input-line);
  border-radius: 14px;
  background: var(--gf-input);
  color: var(--gf-ink);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.gf-field__control input {
  height: 54px;
  padding: 0 18px 0 50px;
  font: 400 15px/1.2 var(--gf-font);
}

.gf-field--password .gf-field__control input {
  padding-right: 56px;
}

.gf-otp {
  height: 66px;
  padding: 0 16px 0 calc(16px + 0.5em);
  font: 600 28px/1 var(--gf-font);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5em;
  text-align: center;
}

.gf-field__control input::placeholder,
.gf-otp::placeholder {
  color: var(--gf-muted-2);
  opacity: 1;
}

.gf-field__control input:focus,
.gf-otp:focus {
  border-color: var(--gf-orange-deep);
  outline: none;
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(232, 90, 0, 0.16);
}

.gf-field__control input:-webkit-autofill {
  box-shadow: 0 0 0 1000px var(--gf-input) inset;
  caret-color: var(--gf-ink);
  -webkit-text-fill-color: var(--gf-ink);
}

.gf-field__control input:-webkit-autofill:focus {
  box-shadow: 0 0 0 1000px #FFFFFF inset, 0 0 0 4px rgba(232, 90, 0, 0.16);
}

.gf-field--invalid .gf-field__control input,
.gf-field--invalid .gf-otp {
  border-color: #D92D20;
  background: #FFF6F5;
}

.gf-field__error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: var(--gf-danger);
  font-size: 13px;
  line-height: 1.5;
}

.gf-field__error svg,
.gf-hint svg {
  flex-shrink: 0;
}

.gf-field__error svg {
  margin-top: 2px;
}

.gf-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  margin: 0;
  color: var(--gf-muted-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.gf-hint.is-ok { color: #1B6B40; }
.gf-hint.is-bad { color: var(--gf-danger); }

.gf-eye {
  position: absolute;
  top: 50%;
  right: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--gf-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.gf-eye:hover {
  background: rgba(34, 23, 16, 0.06);
  color: var(--gf-ink);
}

.gf-eye__on { display: flex; }
.gf-eye__off { display: none; }
.gf-eye.is-on .gf-eye__on { display: none; }
.gf-eye.is-on .gf-eye__off { display: flex; }

.gf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -8px;
}

.gf-check {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--gf-ink-2);
  font-size: 14px;
  cursor: pointer;
}

.gf-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid #8A7E75;
  border-radius: 6px;
  background: #FFFFFF;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.gf-check input[type="checkbox"]:checked {
  border-color: var(--gf-orange-deep);
  background: var(--gf-orange-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFBF6' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}

.gf-link {
  border-radius: 4px;
  color: var(--gf-link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.gf-link:hover {
  color: var(--gf-link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gf-link--back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gf-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 56px;
  margin: 0;
  padding: 0 24px;
  border: 0;
  border-radius: 14px;
  background: var(--gf-ink);
  box-shadow: 0 14px 30px -14px rgba(34, 23, 16, 0.7);
  color: var(--gf-cream);
  font: 600 16px/1 var(--gf-font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.gf-btn:hover {
  background: #3A2A20;
  color: var(--gf-cream);
}

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

.gf-btn__arrow {
  display: flex;
  color: #FF8A3D;
  transition: transform 0.2s ease;
}

.gf-btn:hover .gf-btn__arrow {
  transform: translateX(3px);
}

.gf-btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.gf-btn.is-loading .gf-btn__arrow {
  opacity: 0;
}

.gf-btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2.5px solid rgba(255, 248, 241, 0.3);
  border-top-color: var(--gf-cream);
  border-radius: 50%;
  animation: gf-spin 0.8s linear infinite;
}

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

.gf-actions {
  margin-top: 28px;
}

.gf-auth a:focus-visible,
.gf-auth button:focus-visible,
.gf-check input:focus-visible {
  outline: 2px solid var(--gf-orange-deep);
  outline-offset: 3px;
}

.gf-top a:focus-visible {
  outline-color: var(--gf-choc);
}

.gf-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 0;
  color: var(--gf-muted-2);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.gf-note svg {
  flex-shrink: 0;
}

/* Password strength + rules */
.gf-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 18px;
  color: var(--gf-muted-2);
  font-size: 12.5px;
}

.gf-meter__bars {
  display: flex;
  gap: 4px;
}

.gf-meter__bars span {
  width: 32px;
  height: 4px;
  border-radius: 4px;
  background: #EADFD4;
  transition: background-color 0.2s ease;
}

.gf-meter[data-level="1"] .gf-meter__bars span:nth-child(-n+1) { background: #D92D20; }
.gf-meter[data-level="2"] .gf-meter__bars span:nth-child(-n+2) { background: #E07A00; }
.gf-meter[data-level="3"] .gf-meter__bars span:nth-child(-n+3) { background: #3A9D5D; }
.gf-meter[data-level="4"] .gf-meter__bars span:nth-child(-n+4) { background: #1B7A45; }

.gf-reqs {
  margin: 0;
  padding: 12px 14px 12px 32px;
  border-radius: 12px;
  background: #F7EFE6;
  color: var(--gf-muted);
  font-size: 12.5px;
  line-height: 1.7;
}

/* Signed-out auto redirect */
.gf-countdown {
  margin: 22px 0 0;
  color: var(--gf-muted-2);
  font-size: 13px;
  text-align: center;
}

.gf-countdown p {
  margin: 0;
}

.gf-countdown strong {
  color: var(--gf-ink);
  font-variant-numeric: tabular-nums;
}

.gf-progress {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--gf-line);
}

.gf-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--gf-orange-deep);
  transform-origin: left center;
  animation: gf-drain 5s linear forwards;
}

@keyframes gf-drain {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.gf-foot {
  position: relative;
  z-index: 1;
  padding: 0 var(--gf-pad-x) 36px;
  color: var(--gf-choc);
  font-size: 12px;
  font-weight: 500;
}

/* ---------- Responsive ---------- */

/* Short laptop screens: keep the whole card above the fold */
@media (min-width: 1024px) and (max-height: 800px) {
  .gf-top { padding-top: 32px; }
  .gf-main { padding-top: 20px; padding-bottom: 20px; }
  .gf-brand { margin-top: 138px; }
  .gf-panel { padding-top: 112px; }
  .gf-fox { width: 216px; margin-left: -108px; }
  .gf-card { padding: 36px 40px 30px; }
  .gf-form { gap: 14px; margin-top: 22px; }
  .gf-foot { padding-bottom: 22px; }
}

/* Tablet: stack brand over card */
@media (max-width: 1023.98px) {
  .gf-top { padding-top: 32px; }

  .gf-main {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    row-gap: 24px;
    max-width: 620px;
    padding: 32px var(--gf-pad-x) 40px;
  }

  .gf-brand {
    align-items: center;
    gap: 14px;
    margin-top: 0;
    text-align: center;
  }

  .gf-brand__title { font-size: clamp(34px, 6vw, 48px); }
  .gf-brand__sub { font-size: 16px; }
  .gf-panel { justify-self: center; }
  .gf-foot { text-align: center; }
}

/* Phone: card becomes a bottom sheet, fox peeks over its edge */
@media (max-width: 599.98px) {
  body.gf-auth {
    background-image: radial-gradient(120% 80% at 50% 20%, var(--gf-field-hi) 0%, var(--gf-field) 55%, var(--gf-field-lo) 100%);
  }

  .gf-bg__stripes {
    top: -170px;
    left: -180px;
    width: 750px;
    height: 750px;
  }

  .gf-top { padding: 24px 24px 0; }
  .gf-top__logo img { height: 28px; }
  .gf-top__label { font-size: 10px; letter-spacing: 0.18em; }

  .gf-main {
    display: flex;
    flex-direction: column;
    max-width: none;
    padding: 24px 0 0;
  }

  .gf-brand {
    align-items: flex-start;
    gap: 10px;
    padding: 0 24px;
    text-align: left;
  }

  .gf-brand__eyebrow,
  .gf-brand__sub { display: none; }
  .gf-brand__title { font-size: 32px; line-height: 1.12; }

  .gf-panel {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    max-width: none;
    margin-top: 18px;
    padding-top: 104px;
  }

  .gf-fox { width: 200px; margin-left: -100px; }

  .gf-card {
    flex: 1 0 auto;
    padding: 36px 24px calc(28px + env(safe-area-inset-bottom, 0px));
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -20px 50px -20px rgba(70, 20, 0, 0.45);
  }

  .gf-card__title { font-size: 26px; }
  .gf-card__sub { font-size: 14px; }
  .gf-form { gap: 14px; margin-top: 22px; }
  .gf-row { margin-top: -6px; }

  /* 16px stops iOS Safari from zooming into the field on focus */
  .gf-field__control input { height: 52px; font-size: 16px; }
  .gf-btn { height: 54px; }
  .gf-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gf-fox img,
  .gf-progress span { animation: none; }

  .gf-btn,
  .gf-btn__arrow,
  .gf-field__control input,
  .gf-otp { transition: none; }
}
