/* ============================================================
   HandReferral.com — East Bay Hand Medical Center
   Mobile-first • Teal brand • Professional medical aesthetic
   ============================================================ */

:root {
  --teal:        #4FBDA2;
  --teal-dark:   #3A9B84;
  --teal-deep:   #2D7E6B;
  --teal-light:  #E8F7F3;
  --teal-subtle: #F2FBF8;

  --green:       #2E8B57;
  --green-bg:    #ECFDF5;
  --red:         #C53030;
  --red-bg:      #FEF2F2;

  --white:       #FFFFFF;
  --gray-50:     #FAFAFA;
  --gray-100:    #F4F4F5;
  --gray-200:    #E4E4E7;
  --gray-300:    #D4D4D8;
  --gray-400:    #A1A1AA;
  --gray-500:    #71717A;
  --gray-600:    #52525B;
  --gray-700:    #3F3F46;
  --gray-800:    #27272A;
  --gray-900:    #18181B;

  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.05),
                 0 4px 12px rgba(0,0,0,0.04),
                 0 12px 36px rgba(0,0,0,0.06);
  --shadow-input: 0 1px 2px rgba(0,0,0,0.05);
}

/* ---- Reset ---- */

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

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

body {
  font-family: var(--font-body);
  color: var(--gray-800);
  background: linear-gradient(168deg, #FAFAFA 0%, #F0F2F5 50%, #F4F4F5 100%);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ---- Loading skeleton shimmer ---- */

body.loading .form-card {
  position: relative;
}

body.loading .form-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.6) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  z-index: 10;
  border-radius: inherit;
  pointer-events: none;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Subtle grain texture overlay */
.page-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ---- Header ---- */

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  justify-content: center;
}

.logo-link {
  display: block;
  transition: opacity 0.2s;
}

.logo-link:hover { opacity: 0.8; }

.logo {
  display: block;
  height: 56px;
  width: auto;
}

.availability-banner {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: var(--white);
  text-align: center;
  padding: 14px 24px;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.banner-dot {
  width: 8px;
  height: 8px;
  background: var(--white);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.8); }
}

/* ---- Main ---- */

.main-content {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 32px 16px 48px;
}

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

.form-card {
  width: 100%;
  max-width: 540px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 24px 28px;
  position: relative;
  overflow: hidden;
  animation: card-enter 0.5s ease-out;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
}

.form-title {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-top: 4px;
  letter-spacing: -0.01em;
}

.form-subtitle {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-top: 6px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---- HIPAA inline badge ---- */

.hipaa-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 8px 14px;
  background: var(--teal-subtle);
  border: 1px solid rgba(79, 189, 162, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--teal-deep);
  letter-spacing: 0.02em;
}

.hipaa-badge-sm {
  height: 28px;
  width: auto;
}

/* ---- Success / Error banners ---- */

.success-message,
.error-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 24px;
  animation: banner-in 0.35s ease-out;
}

.success-message {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid #BBF7D0;
}

.error-message {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #FECACA;
}

.success-message svg,
.error-message svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.success-message[hidden],
.error-message[hidden] {
  display: none;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.required {
  color: var(--teal);
  margin-left: 1px;
  font-weight: 700;
}

input[type="text"],
input[type="tel"],
input[type="date"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--gray-800);
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-input);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(79, 189, 162, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-400);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2371717A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* Validation error state */
input.invalid,
select.invalid,
textarea.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.1);
}

.field-error {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 4px;
  display: none;
  animation: banner-in 0.25s ease-out;
}

.field-error.visible {
  display: block;
}

/* ---- Character counter ---- */

.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 4px;
  transition: color 0.2s;
}

.char-counter.near-limit {
  color: var(--red);
}

/* DOB + Sex row — stacks on mobile, side-by-side at 480px */
.form-row {
  display: flex;
  flex-direction: column;
}

.form-group--sex {
  min-width: 120px;
}

/* ---- Honeypot (invisible to humans) ---- */

.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  height: 0;
  width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* ---- Submit button ---- */

.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  background: var(--teal);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.01em;
  margin-top: 4px;
}

.submit-btn:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 189, 162, 0.3);
}

.submit-btn:active {
  transform: scale(0.985) translateY(0);
  box-shadow: none;
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loading[hidden] { display: none; }
.btn-text[hidden]    { display: none; }

.spinner {
  animation: spin 0.7s linear infinite;
}

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

/* ---- Thank you state ---- */

.thank-you {
  text-align: center;
  padding: 24px 0;
  animation: banner-in 0.4s ease-out;
}

.thank-you[hidden] {
  display: none;
}

.thank-you-icon {
  margin-bottom: 16px;
}

.thank-you-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.thank-you-text {
  color: var(--gray-600);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 28px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Submission reference ID ---- */

.submission-ref {
  font-size: 0.82rem;
  color: var(--gray-500);
  margin-bottom: 20px;
}

.submission-ref[hidden] {
  display: none;
}

.submission-ref strong {
  color: var(--gray-700);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.submit-btn--outline {
  background: var(--white);
  color: var(--teal);
  border: 2px solid var(--teal);
}

.submit-btn--outline:hover {
  background: var(--teal-light);
  color: var(--teal-dark);
  box-shadow: 0 4px 12px rgba(79, 189, 162, 0.2);
}

/* ---- PDF download link ---- */

.form-footer-link {
  text-align: center;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--gray-200);
}

.form-footer-link .download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  color: var(--teal-deep);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--teal);
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.form-footer-link .download-btn:hover {
  background: var(--teal-light);
  color: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 189, 162, 0.15);
}

.form-footer-link .download-btn:active {
  transform: scale(0.985) translateY(0);
  box-shadow: none;
}

/* ---- Footer ---- */

.site-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 28px 24px;
  text-align: center;
}

.footer-inner {
  max-width: 540px;
  margin: 0 auto;
}

.footer-address {
  font-size: 0.85rem;
  color: var(--gray-600);
  line-height: 1.5;
}

.footer-contact {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 4px;
}

.footer-contact a {
  color: var(--teal-deep);
  text-decoration: none;
  font-weight: 500;
}

.footer-contact a:hover {
  text-decoration: underline;
}

.footer-sep {
  margin: 0 8px;
  color: var(--gray-400);
}

.footer-badge {
  margin-top: 16px;
  margin-bottom: 4px;
}

.hipaa-badge {
  height: 64px;
  width: auto;
}

.footer-copyright {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 12px;
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* 480px — DOB/Sex side-by-side */
@media (min-width: 480px) {
  .form-row {
    flex-direction: row;
    gap: 16px;
  }

  .form-row .form-group {
    flex: 1;
  }

  .form-group--sex {
    flex: 0 0 140px;
  }
}

/* 640px — more generous spacing */
@media (min-width: 640px) {
  .main-content {
    padding: 48px 24px 64px;
  }

  .form-card {
    padding: 40px 36px 32px;
  }

  .form-title {
    font-size: 1.875rem;
  }

  .logo {
    height: 68px;
  }

  .availability-banner {
    font-size: 1.125rem;
    padding: 16px 24px;
  }
}
