﻿@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 04 Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 05 Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 05 Medium.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 06 Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 06 Bold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "YekanTicket";
  src: url("../fonts/yekan/Yekan Bakh FaNum 07 Heavy.ttf") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   1. CSS Variables & Visual Identity (پالت رنگ و تنظیمات اصلی بلیت مرجع)
   ========================================================================== */
:root {
  --ticket-primary-color: #6F2DA8;
  --ticket-button-color: #6F2DA8;
  --ticket-button-hover-color: #5B238B;
  --ticket-button-pressed-color: #481C6E;
  --modal-close-color: #6F2DA8;
  --modal-close-hover-color: #5B238B;
  --ticket-detail-color: #8953B4;
  --ticket-frame-color: #6F2DA8;
  --ticket-frame-thickness: 2px;
  --ticket-frame-visible: true;
  --ticket-perforation-color: #6F2DA8;
  --ticket-detail-surface-color: #D9B8F0;
  --ticket-inner-surface-color: #EBDCF7;
  --ticket-content-surface-color: #F8F3FC;
  --text-primary-color: #321A42;
  --text-secondary-color: #624875;
  --page-background-color: #F5EFF9;
  --surface-white-color: #FFFFFF;

  --modal-backdrop: rgba(35, 15, 48, 0.64);
  --ticket-drop-shadow:
    drop-shadow(0 14px 28px rgba(58, 25, 78, 0.24))
    drop-shadow(0 3px 8px rgba(58, 25, 78, 0.14));

  --ticket-max-width: 384px;
  --ticket-corner-scoop: 18px;
  --ticket-notch-radius: 14px;

  --font-fa: "YekanTicket", "Yekan", Tahoma, sans-serif;
  --ease-ticket: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-step: 280ms;
  --duration-fast: 170ms;
}

@media (max-width: 400px) {
  :root {
    --ticket-corner-scoop: 15px;
    --ticket-notch-radius: 12px;
  }
}

.ticket-modal,
.ticket-modal *,
.ticket-modal *::before,
.ticket-modal *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-fa);
}

.ticket-modal .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;
}

/* ==========================================================================
   Modal Backdrop & Container
   ========================================================================== */
.ticket-modal {
  position: fixed;
  inset: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
  direction: rtl;
  color: var(--text-primary-color);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 240ms var(--ease-ticket),
    visibility 240ms var(--ease-ticket);
}

.ticket-modal[aria-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ticket-modal__dialog {
  position: relative;
  width: 100%;
  max-width: var(--ticket-max-width);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(0) scale(1);
  transition: transform 280ms var(--ease-ticket);
}

.ticket-modal[aria-hidden="true"] .ticket-modal__dialog {
  transform: translateY(14px) scale(0.96);
}

.ticket-modal__topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 8px;
  padding: 0 2px;
}

.ticket-modal__close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--modal-close-color);
  color: var(--surface-white-color);
  border: 2px solid var(--ticket-detail-surface-color);
  box-shadow: 0 4px 12px rgba(35, 15, 48, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}

.ticket-modal__close:hover {
  background: var(--modal-close-hover-color);
  transform: scale(1.06);
}

.ticket-modal__close:active {
  transform: scale(0.96);
}

.ticket-modal__close:focus-visible {
  outline: 3px solid var(--ticket-detail-surface-color);
  outline-offset: 2px;
}

/* ==========================================================================
   Portrait Graphic Ticket Component (هسته اصلی طراحی بلیت)
   ========================================================================== */
.ticket-shadow-wrap {
  filter: var(--ticket-drop-shadow);
  width: 100%;
}

.ticket {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  user-select: none;
}

.ticket__svg {
  position: absolute;
  inset: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

.ticket__stub {
  position: relative;
  z-index: 2;
  padding: 28px 34px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.ticket__stub-emblem {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 360ms var(--ease-ticket);
}

.ticket--celebrate .ticket__stub-emblem {
  animation: emblemCelebrate 650ms var(--ease-ticket) 1;
}

@keyframes emblemCelebrate {
  0% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.08) rotate(-3deg); }
  75% { transform: scale(1.03) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.ticket__stub-icon {
  width: 78px;
  height: 48px;
  display: block;
  overflow: visible;
}

.ticket__stub-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.ticket__ornament-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ticket-detail-color);
  opacity: 0.65;
  flex-shrink: 0;
}

.ticket__stub-title {
  font-size: 1.06rem;
  font-weight: 800;
  color: var(--text-primary-color);
  letter-spacing: -0.01em;
  line-height: 1.5;
}

.ticket__perforation-spacer {
  position: relative;
  z-index: 2;
  height: 2px;
  width: 100%;
  pointer-events: none;
}

.ticket__body {
  position: relative;
  z-index: 2;
  padding: 26px 34px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 390px) {
  .ticket__stub {
    padding: 24px 26px 18px;
  }
  .ticket__body {
    padding: 22px 24px 28px;
  }
}

.ticket__body-crest {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  opacity: 0.72;
  pointer-events: none;
}

.ticket__body-crest-line {
  width: 28px;
  height: 1.5px;
  background: var(--ticket-detail-color);
  border-radius: 2px;
}

.ticket__body-crest-star {
  color: var(--ticket-primary-color);
  font-size: 0.72rem;
  line-height: 1;
}

.ticket__stage-viewport {
  position: relative;
  width: 100%;
  transition: height var(--duration-step) var(--ease-ticket);
}

.ticket-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 220ms var(--ease-ticket),
    transform 220ms var(--ease-ticket);
}

.ticket-step--active {
  display: flex;
}

.ticket-step--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Typography & Graphic Form Controls Inside Ticket
   ========================================================================== */
.ticket-step__title {
  font-size: 1.03rem;
  font-weight: 800;
  color: var(--text-primary-color);
  line-height: 1.75;
  margin-bottom: 8px;
  max-width: 285px;
}

.ticket-step__subtitle {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-secondary-color);
  line-height: 1.7;
  margin-bottom: 12px;
  max-width: 280px;
}

.ticket-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.ticket-field-wrap {
  position: relative;
  width: 100%;
}

.ticket-input {
  width: 100%;
  height: 50px;
  padding: 8px 16px;
  background: var(--ticket-content-surface-color);
  color: var(--text-primary-color);
  border: 2px solid var(--ticket-detail-color);
  border-radius: 8px;
  box-shadow:
    inset 0 2px 0 rgba(137, 83, 180, 0.06),
    0 2px 0 rgba(111, 45, 168, 0.12);
  font-size: 1.14rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  direction: ltr;
  user-select: text;
  transition:
    border-color var(--duration-fast) ease,
    background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.ticket-input::placeholder {
  color: rgba(50, 26, 66, 0.38);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.ticket-input:focus {
  outline: none;
  background: var(--surface-white-color);
  border-color: var(--ticket-primary-color);
  box-shadow:
    0 0 0 3px rgba(111, 45, 168, 0.16),
    0 2px 0 rgba(111, 45, 168, 0.16);
}

.ticket-input[aria-invalid="true"] {
  border-color: var(--ticket-primary-color);
  background: var(--ticket-inner-surface-color);
  animation: ticketShake 320ms ease;
}

@keyframes ticketShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.ticket-feedback {
  min-height: 22px;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ticket-primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ticket-feedback:empty {
  display: none;
}

.ticket-feedback__box {
  padding: 5px 11px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(111, 45, 168, 0.35);
}

.ticket-btn {
  position: relative;
  width: 100%;
  min-height: 48px;
  padding: 10px 18px;
  background: var(--ticket-button-color);
  color: var(--surface-white-color);
  border: 2px solid var(--ticket-button-pressed-color);
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 3px 0 var(--ticket-button-pressed-color);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    background-color var(--duration-fast) ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.ticket-btn:hover:not(:disabled) {
  background: var(--ticket-button-hover-color);
}

.ticket-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 0 var(--ticket-button-pressed-color);
}

.ticket-btn:focus-visible {
  outline: 3px solid var(--text-primary-color);
  outline-offset: 2px;
}

.ticket-btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.ticket-btn--copied {
  background: var(--ticket-button-hover-color);
  border-color: var(--ticket-button-pressed-color);
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: ticketSpin 0.65s linear infinite;
}

.ticket-btn.is-loading .btn-spinner {
  display: inline-block;
}

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

.coupon-reveal-wrap {
  position: relative;
  width: 100%;
  margin: 10px 0 18px;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition:
    opacity 360ms var(--ease-ticket),
    transform 420ms var(--ease-ticket);
}

.coupon-reveal-wrap.is-revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.coupon-code-box {
  position: relative;
  min-height: 82px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px 20px;
  border: 2px dashed var(--ticket-primary-color);
  border-radius: 10px;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.42), transparent 34%),
    linear-gradient(135deg, var(--ticket-content-surface-color) 0%, var(--ticket-inner-surface-color) 54%, var(--ticket-detail-surface-color) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 5px 12px rgba(58, 25, 78, 0.12);
  transition:
    box-shadow 220ms ease,
    border-color 220ms ease,
    transform 220ms ease;
}

.coupon-code-box::before,
.coupon-code-box::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 2px solid var(--ticket-primary-color);
  border-radius: 50%;
  background: var(--ticket-inner-surface-color);
  transform: translateY(-50%);
}

.coupon-code-box::before { right: -9px; }
.coupon-code-box::after { left: -9px; }

.coupon-code-box__sheen {
  position: absolute;
  inset: -40% auto -40% -50%;
  top: -40%;
  bottom: -40%;
  left: -50%;
  width: 42%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}

.coupon-reveal-wrap.is-revealed .coupon-code-box__sheen {
  animation: couponSheen 900ms ease-out 240ms 1 both;
}

.coupon-code-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  direction: ltr;
  color: var(--ticket-primary-color);
  font-size: clamp(1.35rem, 7vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
  user-select: all;
}

.coupon-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(10px) scale(0.75);
}

.coupon-reveal-wrap.is-revealed .coupon-char {
  animation: couponCharReveal 420ms var(--ease-ticket) calc(110ms + var(--char-index) * 65ms) both;
}

.coupon-code-box.is-copied-pulse {
  border-color: var(--ticket-button-hover-color);
  box-shadow:
    0 0 0 4px rgba(111, 45, 168, 0.12),
    0 7px 16px rgba(58, 25, 78, 0.18);
  transform: scale(1.02);
}

@keyframes couponCharReveal {
  60% { opacity: 1; transform: translateY(-3px) scale(1.08); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes couponSheen {
  from { left: -50%; }
  to { left: 125%; }
}

.ticket-enjoy-note {
  margin-top: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary-color);
  line-height: 1.6;
}

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

  .coupon-reveal-wrap,
  .coupon-char {
    opacity: 1 !important;
    transform: none !important;
  }
}
