/**
 * auth.css — Reader login / OTP card (Heritage Teak & Parchment).
 * Load after main theme CSS.
 */

.auth {
  display: grid; 
  justify-items: center; 
  align-items: start;
  padding: clamp(2.5rem, 8vw, 6rem) var(--gutter, 1.25rem);
  background: var(--parchment, #F1E6CF);
  min-height: 75vh;
}

.auth__card {
  width: min(100%, 460px);
  padding: clamp(1.75rem, 4vw, 2.5rem);
  background: var(--surface, #FAF7F0);
  color: var(--ink, #2A1A10);
  border: 1px solid rgba(169, 121, 43, 0.3);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 12px 32px -8px rgba(43, 29, 20, 0.12), 0 4px 12px -2px rgba(43, 29, 20, 0.08);
  margin: 0 auto;
  position: relative;
}

.auth__icon {
  display: grid; 
  place-items: center; 
  width: 48px; 
  height: 48px; 
  margin: 0 0 1.25rem;
  border: 1px solid rgba(169, 121, 43, 0.4); 
  border-radius: 50%;
  color: var(--brass-text, #7A5416); 
  background: rgba(169, 121, 43, 0.08);
}
.auth__icon svg { width: 22px; height: 22px; }

.auth__title { 
  margin: 0 0 0.5rem; 
  font-family: var(--font-display, "Cormorant Garamond", serif);
  font-size: clamp(1.85rem, 3.2vw, 2.25rem); 
  line-height: 1.15; 
  color: var(--walnut, #3F2A1D);
  font-weight: 600;
}
.auth__lead { 
  margin: 0 0 1.5rem; 
  color: var(--muted, #6B5645); 
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- Form fields ---------- */
.field { 
  display: grid; 
  gap: 0.4rem; 
  margin-bottom: 1.25rem; 
  text-align: left;
}
.field label { 
  font-weight: 600; 
  font-size: 0.9rem; 
  color: var(--ink, #2A1A10); 
}
.field input, .field select, .field textarea {
  width: 100%; 
  height: var(--control-h, 48px);
  min-height: var(--control-h, 48px);
  padding: 0 1rem;
  font: inherit; 
  font-size: 1rem;                 /* 16px: stops iOS zoom */
  color: var(--ink, #2A1A10); 
  background: var(--surface, #FAF7F0);
  border: 1px solid var(--line-strong, rgba(63, 42, 29, 0.28)); 
  border-radius: var(--radius-control, 10px);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  box-sizing: border-box;
}
.field input::placeholder { color: #8A7766; }
@media (hover: hover) { .field input:hover { border-color: var(--walnut, #3F2A1D); } }
.field input:focus {
  outline: none; 
  border-color: var(--brass, #A9792B);
  box-shadow: 0 0 0 3px rgba(169, 121, 43, 0.22);
}
.field input[aria-invalid="true"] { border-color: #9B3B22; }
.field__hint { margin: 0; font-size: 0.85rem; color: var(--muted, #6B5645); line-height: 1.4; }
.field__error { margin: 0; font-size: 0.85rem; color: #9B3B22; }

/* 6-box OTP digits */
.otp-boxes {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-block: 0.5rem 1.25rem;
}
.otp-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-ui, "Inter", sans-serif);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line-strong, rgba(63, 42, 29, 0.35));
  border-radius: var(--radius-control, 10px);
  background-color: var(--surface, #FAF7F0);
  color: var(--ink, #2A1A10);
  padding: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.otp-digit:focus {
  outline: none;
  border-color: var(--brass, #A9792B);
  box-shadow: 0 0 0 3px rgba(169, 121, 43, 0.25);
}
@media (max-width: 380px) {
  .otp-boxes { gap: 6px; }
  .otp-digit { width: 42px; height: 50px; font-size: 1.3rem; }
}

/* Browser autofill override so inputs keep Heritage theme */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px #FAF7F0 inset !important;
  box-shadow: 0 0 0px 1000px #FAF7F0 inset !important;
  -webkit-text-fill-color: #2A1A10 !important;
  transition: background-color 5000s ease-in-out 0s;
}

.btn-block { 
  width: 100%; 
  display: block;
  text-align: center;
  box-sizing: border-box;
  padding: 0 1.25rem;
  height: var(--control-h, 48px);
  min-height: var(--control-h, 48px);
}

.btn__spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Dev mode code pill */
.auth__dev-box {
  background: #FFF9EE;
  border: 1px dashed #A9792B;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #7A5416;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth__dev-box code {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: #6E2B25;
}

/* ---------- Messages ---------- */
.alert {
  margin: 0 0 1.25rem; 
  padding: 0.75rem 1rem; 
  border-radius: var(--radius-control, 10px);
  border: 1px solid transparent; 
  font-size: 0.9rem;
  text-align: left;
  line-height: 1.45;
}
.alert--error   { background: #F6E1DC; border-color: #D9A89C; color: #6E2B25; }
.alert--success { background: #E4EBDD; border-color: #A9BC9A; color: #2F4A25; }
.alert--info    { background: #F1E6CF; border-color: #D6C29B; color: #4A3122; }

/* ---------- Footer row ---------- */
.auth__foot {
  margin: 1.5rem 0 0; 
  padding-top: 1rem; 
  border-top: 1px solid rgba(63, 42, 29, 0.15);
  font-size: 0.85rem; 
  color: var(--muted, #6B5645); 
  text-align: center;
}
.auth__foot a { color: inherit; text-underline-offset: 0.3em; }
@media (hover: hover) { .auth__foot a:hover { color: var(--brass-text, #7A5416); } }

.auth__step[hidden] { display: none; }
.auth__alt { 
  display: flex; 
  justify-content: space-between; 
  gap: 1rem; 
  flex-wrap: wrap; 
  margin-top: 1rem; 
  font-size: 0.875rem; 
}

/* Honeypot */
.hp-field { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 400px) {
  .auth { padding-inline: 1rem; }
}
