/* ============================================================
   Flip Card Component — RankRent Design System
   Pure CSS 3D flip. No JS framework. No dependencies.
   
   Usage: Add <div class="flip-card"> with .flip-inner, 
   .flip-front, .flip-back, and .flip-success children.
   Toggle with checkbox hack or JS class toggle.
   
   Accessible: respects prefers-reduced-motion.
   ============================================================ */

/* --- Container --- */
.flip-card {
  perspective: 1000px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.flip-card.flip-wide  { max-width: 480px; }
.flip-card.flip-narrow { max-width: 300px; }

/* --- Inner wrapper (the thing that rotates) --- */
.flip-inner {
  position: relative;
  width: 100%;
  min-height: 420px;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-inner {
  transform: rotateY(180deg);
}

/* --- Faces --- */
.flip-front,
.flip-back,
.flip-success {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 1rem;
  overflow: hidden;
  
  /* RankRent design system */
  background: oklch(98.5% 0.008 85); /* warm cream paper */
  border: 1px solid rgba(35, 75, 51, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
  
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.75rem;
}

/* --- Front face --- */
.flip-front {
  text-align: center;
}

.flip-front .flip-illustration {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 2rem;
}

.flip-front .flip-illustration.flip-illus-pine {
  background: #234b33;
  color: #f3ead9;
}

.flip-front .flip-illustration.flip-illus-clay {
  background: #c0673a;
  color: #fff;
}

.flip-front .flip-illustration.flip-illus-green {
  background: #2f6243;
  color: #f3ead9;
}

.flip-front .flip-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #234b33;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.flip-front .flip-desc {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.95rem;
  color: #5a6e5f;
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.flip-front .flip-features {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
  text-align: left;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.9rem;
  color: #3d5543;
}

.flip-front .flip-features span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flip-front .flip-features span::before {
  content: '';
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  background: #2f6243;
  border-radius: 50%;
  flex-shrink: 0;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  mask-size: 80%;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  -webkit-mask-size: 80%;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  background: #2f6243;
}

/* --- Back face (form) --- */
.flip-back {
  transform: rotateY(180deg);
  padding-top: 1.5rem;
  justify-content: flex-start;
}

/* --- Success face (also at 180deg, toggled via opacity) --- */
.flip-success {
  transform: rotateY(180deg);
  opacity: 0;
  pointer-events: none;
  text-align: center;
}

.flip-card.flip-success .flip-back {
  opacity: 0;
  pointer-events: none;
}

.flip-card.flip-success .flip-success {
  opacity: 1;
  pointer-events: auto;
}

.flip-back .flip-back-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #234b33;
  margin: 0 0 0.25rem;
}

.flip-back .flip-back-desc {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.9rem;
  color: #5a6e5f;
  margin: 0 0 1.25rem;
}

.flip-back .flip-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.flip-back .flip-form label {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #234b33;
}

.flip-back .flip-form input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid rgba(35, 75, 51, 0.2);
  border-radius: 0.5rem;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.95rem;
  color: #234b33;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.flip-back .flip-form input:focus {
  outline: none;
  border-color: #c0673a;
  box-shadow: 0 0 0 3px rgba(192, 103, 58, 0.15);
}

.flip-back .flip-form input::placeholder {
  color: #9aaf9f;
}

.flip-back .flip-error {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.8rem;
  color: #d64040;
  margin: 0;
}

/* --- Success face child styles (after opacity toggle) --- */

.flip-success .flip-illustration {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: #2f6243;
  color: #f3ead9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  font-size: 2rem;
}

.flip-success .flip-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #234b33;
  margin: 0 0 0.5rem;
}

.flip-success .flip-desc {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.95rem;
  color: #5a6e5f;
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

/* --- Buttons --- */
.flip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: 0.5rem;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  width: 100%;
  box-sizing: border-box;
}

.flip-btn:active {
  transform: scale(0.97);
}

.flip-btn-primary {
  background: #c0673a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(192, 103, 58, 0.3);
}

.flip-btn-primary:hover {
  background: #a8552e;
  box-shadow: 0 4px 12px rgba(192, 103, 58, 0.4);
}

.flip-btn-outline {
  background: transparent;
  color: #234b33;
  border: 1.5px solid rgba(35, 75, 51, 0.25);
}

.flip-btn-outline:hover {
  background: rgba(35, 75, 51, 0.05);
  border-color: #234b33;
}

.flip-btn-pine {
  background: #234b33;
  color: #f3ead9;
  box-shadow: 0 2px 8px rgba(35, 75, 51, 0.3);
}

.flip-btn-pine:hover {
  background: #1a3a28;
  box-shadow: 0 4px 12px rgba(35, 75, 51, 0.4);
}

.flip-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.flip-btn .spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: flip-spin 0.6s linear infinite;
}

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

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  .flip-inner {
    transition: none;
  }
}

/* --- Checkbox hack (for pure-CSS toggle) --- */
.flip-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.flip-checkbox-label {
  cursor: pointer;
}

/* Back button style */
.flip-back-link {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 0.9rem;
  color: #5a6e5f;
  text-decoration: underline;
  cursor: pointer;
  margin-top: 0.75rem;
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
}

.flip-back-link:hover {
  color: #234b33;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .flip-card {
    max-width: 100%;
  }
  
  .flip-front,
  .flip-back,
  .flip-success {
    padding: 1.5rem 1.25rem;
  }
  
  .flip-inner {
    min-height: 400px;
  }
}
