/* style.css - Daily Presence by Bat Sheva - Mobile-first, RTL-ready */
/* Design: matches batshevadesta.co.il - white, sage green, Fredoka */

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #ededed;
  --bg-dark: #14171c;
  --text-primary: #2b2b2b;
  --text-secondary: #313131;
  --text-muted: #666666;
  --accent-primary: #9db228;
  --accent-secondary: #ab641d;
  --accent-gold: #c28e34;
  --accent-green: #77b978;
  --accent-coral: #f37262;

  /* Buttons */
  --btn-bg: #9db228;
  --btn-text: #ffffff;
  --btn-hover-bg: #ab641d;
  --btn-border-radius: 3px;

  /* Card category colors */
  --gold-border: #C5A55A;
  --gold-card-bg: #FFF8E7;
  --green-border: #5AA55A;
  --green-card-bg: #E7F8E7;
  --rose-border: #C55A7A;
  --rose-card-bg: #F8E7EF;
  --blue-border: #5A7AC5;
  --blue-card-bg: #E7EFF8;
  --purple-border: #7A5AC5;
  --purple-card-bg: #EFE7F8;

  --card-size: min(70vw, 320px);
  --font-primary: 'Fredoka', Arial, Helvetica, sans-serif;
  --font-accent: 'Rubik', Arial, Helvetica, sans-serif;
}

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

body {
  font-family: var(--font-primary);
  font-weight: 400;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
}

[lang="en"] body {
  font-family: var(--font-primary);
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* Language Toggle */
.lang-toggle {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: 100;
  display: flex;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 1rem;
  padding: 0.2rem;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-primary);
  letter-spacing: 0.5px;
}

.lang-btn.active {
  background: rgba(157, 178, 40, 0.15);
  color: var(--accent-primary);
}

/* Landing Screen */
#screen-landing {
  gap: 2rem;
}

.welcome-back-area {
  text-align: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  max-width: 320px;
}

.welcome-back-area.visible {
  opacity: 1;
}

.welcome-text {
  display: block;
  font-size: 1.2rem;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.yesterday-card {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.yesterday-card em {
  font-style: normal;
  color: var(--text-primary);
}

/* Card Back (Landing) */
.card-back-wrapper {
  position: relative;
  width: var(--card-size);
  height: var(--card-size);
}

.card-back {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 3px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Mandala pattern on card back */
.card-back::before {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  border: 1px solid rgba(157, 178, 40, 0.15);
}

.card-back::after {
  content: '';
  position: absolute;
  width: 55%;
  height: 55%;
  border-radius: 50%;
  border: 1px solid rgba(157, 178, 40, 0.12);
}

.card-back-inner {
  position: relative;
  z-index: 1;
}

.card-back-symbol {
  font-size: 2.5rem;
  color: var(--accent-primary);
  opacity: 0.6;
}

.card-back-mandala {
  position: absolute;
  inset: 10%;
  border: 1px solid rgba(157, 178, 40, 0.08);
  border-radius: 50%;
}

.card-back-mandala::before {
  content: '';
  position: absolute;
  inset: 15%;
  border: 1px solid rgba(157, 178, 40, 0.06);
  border-radius: 50%;
}

/* Draw Button */
.draw-btn {
  background: var(--btn-bg);
  border: none;
  color: var(--btn-text);
  font-family: var(--font-primary);
  font-size: 17px;
  font-weight: 500;
  padding: 0.75rem 2rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.draw-btn:hover:not(.disabled) {
  background: var(--btn-hover-bg);
}

.draw-btn:active:not(.disabled) {
  transform: translateY(1px);
}

.draw-btn.disabled {
  opacity: 0.4;
  cursor: default;
  background: var(--text-muted);
  color: var(--bg-primary);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
}

/* Streak Display */
.streak-display {
  opacity: 0;
  transition: opacity 0.6s ease;
  text-align: center;
}

.streak-display.visible {
  opacity: 1;
}

.streak-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  max-width: 200px;
  margin-inline: auto;
}

.streak-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-secondary);
  transition: background 0.3s ease;
}

.streak-dot.filled {
  background: var(--accent-primary);
}

.streak-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Card Draw Screen */
#screen-card {
  gap: 1.5rem;
}

.card-flip-scene {
  width: var(--card-size);
  height: var(--card-size);
  perspective: 800px;
}

.card-flip-container {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-in-out;
}

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

[dir="rtl"] .card-flip-container.flipped {
  transform: rotateY(-180deg);
}

.card-flip-back,
.card-flip-front {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-flip-back {
  background: var(--bg-secondary);
  border: 3px solid var(--accent-primary);
}

.card-flip-back .card-back-symbol {
  font-size: 2.5rem;
  color: var(--accent-primary);
  opacity: 0.6;
}

.card-flip-front {
  transform: rotateY(180deg);
  border: 3px solid var(--accent-primary);
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bg-primary);
  box-shadow: 0 3px 6px -5px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
}

[dir="rtl"] .card-flip-front {
  transform: rotateY(-180deg);
}

.card-category-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.card-text {
  font-family: var(--font-primary);
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 0 0.5rem;
  font-weight: 500;
}

[lang="en"] .card-text {
  font-size: 1.2rem;
}

.card-infinity {
  color: var(--accent-primary);
  font-size: 1.8rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}

/* Reflect question */
.reflect-question {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.6s ease;
}

.reflect-question.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Insight button */
.insight-btn {
  background: var(--btn-bg);
  border: none;
  color: var(--btn-text);
  font-family: var(--font-primary);
  font-size: 17px;
  font-weight: 500;
  padding: 0.7rem 2rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.6s ease;
}

.insight-btn.visible {
  opacity: 1;
  transform: translateY(0);
}

.insight-btn:hover {
  background: var(--btn-hover-bg);
}

/* AI Response Screen */
#screen-ai {
  gap: 1.5rem;
  justify-content: flex-start;
  padding-top: 3rem;
}

.ai-response-area {
  max-width: 360px;
  width: 100%;
}

.ai-response-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-line;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ai-response-text.visible {
  opacity: 1;
}

/* AI Disclosure */
.ai-disclosure {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-accent);
  font-style: italic;
  margin-top: 0.75rem;
}

/* Share button */
.share-btn {
  background: transparent;
  border: 1.5px solid var(--accent-primary);
  color: var(--accent-primary);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  padding: 0.4rem 1.2rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  opacity: 0;
  transition: all 0.4s ease;
  align-self: flex-end;
}

.share-btn.visible {
  opacity: 1;
}

.share-btn:hover {
  background: var(--accent-primary);
  color: var(--btn-text);
}

/* Journal Section */
.journal-section {
  width: 100%;
  max-width: 360px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.6s ease;
  margin-top: 1rem;
}

.journal-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.journal-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: block;
}

.journal-input {
  width: 100%;
  background: var(--bg-primary);
  border: 2px solid var(--bg-secondary);
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  resize: none;
  line-height: 1.6;
  min-height: 5rem;
  transition: border-color 0.3s ease;
}

.journal-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.journal-input::placeholder {
  color: var(--text-muted);
}

.journal-save {
  background: var(--btn-bg);
  border: none;
  color: var(--btn-text);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 2rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  margin-top: 0.75rem;
  transition: background 0.3s ease;
}

.journal-save:hover {
  background: var(--btn-hover-bg);
}

.journal-feedback {
  font-size: 0.85rem;
  color: var(--accent-primary);
  margin-top: 0.75rem;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.journal-feedback.visible {
  opacity: 1;
}

/* Draw again button */
.draw-again-btn {
  background: transparent;
  border: 1.5px solid var(--accent-primary);
  color: var(--accent-primary);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  padding: 0.5rem 1.5rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  opacity: 0;
  transition: all 0.4s ease;
  margin-top: 1rem;
}

.draw-again-btn.visible {
  opacity: 1;
}

.draw-again-btn:hover {
  background: var(--accent-primary);
  color: var(--btn-text);
}

/* Email Modal */
.email-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 1.5rem;
}

.email-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.email-modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--bg-secondary);
  border-radius: var(--btn-border-radius);
  padding: 2rem 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 3px 6px -5px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
}

.email-streak-msg {
  font-size: 0.95rem;
  color: var(--accent-primary);
  margin-bottom: 1rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.email-streak-msg.visible {
  opacity: 1;
}

.email-prompt-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.email-input {
  width: 100%;
  background: var(--bg-primary);
  border: 2px solid var(--bg-secondary);
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  text-align: center;
  direction: ltr;
  margin-bottom: 1rem;
}

.email-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.email-modal-submit {
  background: var(--btn-bg);
  border: none;
  color: var(--btn-text);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 2rem;
  border-radius: var(--btn-border-radius);
  cursor: pointer;
  transition: background 0.3s ease;
}

.email-modal-submit:hover {
  background: var(--btn-hover-bg);
}

.email-no-spam {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.email-feedback {
  font-size: 0.9rem;
  color: var(--accent-primary);
  margin-top: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.email-feedback.visible {
  opacity: 1;
}

.email-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 1rem;
  padding: 0.3rem 0.8rem;
}

.email-close:hover {
  color: var(--text-secondary);
}

/* Offline banner */
.offline-banner {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  background: var(--accent-primary);
  color: var(--btn-text);
  text-align: center;
  padding: 0.5rem;
  font-size: 0.8rem;
  z-index: 300;
  display: none;
}

body.offline .offline-banner {
  display: block;
}

/* Accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive */
@media (min-width: 480px) {
  :root {
    --card-size: 320px;
  }

  .card-text {
    font-size: 1.5rem;
  }
}

@media (min-width: 768px) {
  :root {
    --card-size: 360px;
  }

  .ai-response-area {
    max-width: 440px;
  }

  .journal-section {
    max-width: 440px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
