/* ========================================================
   بطاقات معايدة - أكاديمية مهد الرياضية
   ======================================================== */

@font-face {
  font-family: 'Janna';
  src: local('Janna LT'), local('Janna'), local('JannaLT');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Janna';
  src: local('Janna LT Bold'), local('Janna Bold'), local('JannaLT-Bold');
  font-weight: bold;
  font-style: normal;
}

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

:root {
  --mahd-purple: #4a2d7a;
  --mahd-purple-dark: #3a2264;
  --mahd-gold: #c8a84e;
  --mahd-white: #ffffff;

  --ui-bg: #f0edf5;
  --ui-surface: #ffffff;
  --ui-text: #2c2040;
  --ui-text-muted: #7a6b8a;
  --ui-border: #ddd5e8;
  --ui-radius: 12px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Janna', 'Noto Kufi Arabic', 'Tahoma', 'Arial', sans-serif;
  background-color: var(--ui-bg);
  color: var(--ui-text);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* LTR overrides */
html[dir="ltr"] body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html[dir="ltr"] .control-group input[type="text"] {
  direction: ltr;
  text-align: left;
}

html[dir="ltr"] .next-btn svg {
  transform: scaleX(-1);
}

html[dir="ltr"] .back-btn svg {
  transform: scaleX(-1);
}

/* --- Header --- */
.site-header {
  width: 100%;
  background: var(--mahd-purple);
}

.header-img {
  width: 100%;
  display: block;
  height: auto;
}

/* --- Main Layout --- */
.app-container {
  display: flex;
  gap: 2.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2rem 3rem;
  flex: 1;
}

/* --- Controls Panel --- */
.controls-panel {
  flex: 0 0 300px;
  background: var(--ui-surface);
  border-radius: var(--ui-radius);
  padding: 2rem;
  box-shadow: 0 2px 12px rgba(74, 45, 122, 0.08);
  border: 1px solid var(--ui-border);
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.panel-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  color: var(--mahd-purple);
}

.control-group {
  margin-bottom: 1.5rem;
}

.control-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ui-text-muted);
  margin-bottom: 0.5rem;
}

.control-group input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ui-text);
  background: #faf8fd;
  transition: border-color 0.2s, box-shadow 0.2s;
  direction: rtl;
  text-align: right;
}

.control-group input[type="text"]:focus {
  outline: none;
  border-color: var(--mahd-purple);
  box-shadow: 0 0 0 3px rgba(74, 45, 122, 0.12);
}

.control-group input[type="text"]::placeholder {
  color: #b0a3c0;
}

.drag-hint {
  font-size: 0.8rem;
  color: var(--ui-text-muted);
  margin-bottom: 1.5rem;
  padding: 0.6rem 0.8rem;
  background: #f5f0fa;
  border-radius: 8px;
  text-align: center;
}

/* Buttons */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.action-btn:active {
  transform: scale(0.98);
}

.download-btn {
  background: var(--mahd-purple);
  color: #fff;
}

.download-btn:hover {
  background: var(--mahd-purple-dark);
  box-shadow: 0 4px 14px rgba(74, 45, 122, 0.3);
}

.share-btn {
  background: var(--mahd-gold);
  color: #fff;
}

.share-btn:hover {
  background: #b89840;
  box-shadow: 0 4px 14px rgba(200, 168, 78, 0.3);
}

.next-btn {
  background: var(--mahd-purple);
  color: #fff;
  margin-top: 0.5rem;
}

.next-btn:hover {
  background: var(--mahd-purple-dark);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  color: var(--mahd-purple);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
}

.back-btn:hover {
  opacity: 0.7;
}

/* --- Preview Section --- */
.preview-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ui-text-muted);
  margin-bottom: 1rem;
  align-self: flex-start;
}

.card-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* --- Greeting Card --- */
.greeting-card {
  width: 480px;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 20px rgba(74, 45, 122, 0.15),
    0 12px 40px rgba(0, 0, 0, 0.1);
  user-select: none;
}

.card-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.card-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Draggable text */
.draggable-text {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  cursor: grab;
  padding: 0.5rem 1.5rem;
  white-space: nowrap;
}

.draggable-text.dragging {
  cursor: grabbing;
}

.card-sender {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--mahd-white);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.mobile-actions {
  margin-top: 1.5rem;
  width: 100%;
  max-width: 480px;
}

/* --- Footer --- */
.site-footer {
  width: 100%;
  background: var(--mahd-purple);
}

.footer-img {
  width: 100%;
  display: block;
  height: auto;
}

/* --- Language Toggle --- */
.lang-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--mahd-white);
  color: var(--mahd-purple);
  border: 2px solid var(--mahd-purple);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, box-shadow 0.2s;
}

.lang-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* --- Page Instruction --- */
.page-instruction {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--mahd-purple);
  padding: 1.5rem 1rem 0;
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Mobile/Desktop visibility --- */
.mobile-only {
  display: none;
}

/* --- Responsive: Mobile Wizard --- */
@media (max-width: 860px) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: flex;
  }

  .drag-hint.mobile-only {
    display: block;
  }

  .back-btn.mobile-only {
    display: flex;
  }

  .app-container {
    flex-direction: column;
    padding: 1rem;
    gap: 0;
  }

  .controls-panel {
    flex: none;
    width: 100%;
    position: static;
  }

  /* Step 2 hidden by default on mobile */
  .preview-section {
    width: 100%;
    display: none;
  }

  .preview-section.active {
    display: flex;
  }

  /* Step 1 hidden when step 2 is shown */
  .controls-panel.hidden {
    display: none;
  }

  .greeting-card {
    width: 100%;
    max-width: 480px;
  }

  .preview-label {
    align-self: center;
  }
}

@media (max-width: 480px) {
  .greeting-card {
    border-radius: 8px;
  }

  .card-sender {
    font-size: 1.1rem;
  }

  .controls-panel {
    padding: 1.5rem;
  }
}
