/* ==========================================================================
   Survey (نظرسنجی) — standalone, self-contained.
   Formal / corporate gray–red theme. RTL, Persian, compact & responsive.
   Fonts are self-hosted (Vazirmatn, SIL OFL) — no CDN.
   ========================================================================== */

/* ------------------------------ Local fonts ------------------------------ */
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/Vazirmatn-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./fonts/Vazirmatn-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/Vazirmatn-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("./fonts/Vazirmatn-ExtraBold.woff2") format("woff2");
}

:root {
  --red: #c1272d;
  --red-2: #9b1c1f;
  --red-soft: #fbecec;
  --ink: #2b2f36;      /* charcoal text */
  --ink-soft: #5b616b;
  --muted: #98a0ab;
  --line: #e3e6ea;
  --card: #ffffff;
  --panel: #3a3f47;    /* header charcoal */
  --panel-2: #2b2f36;
  --bg: #eef0f2;
  --good: #2e7d32;
  --bad: #c1272d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -14px rgba(35, 40, 48, 0.35);
  --shadow-sm: 0 3px 10px -4px rgba(35, 40, 48, 0.30);
  --font: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #f6f7f8, var(--bg));
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.75;
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01";
}

.app {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2.5vw, 32px);
}

/* ------------------------------ Card ------------------------------------- */
.card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

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

.card__header {
  position: relative;
  padding: 20px 20px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border-top: 3px solid var(--red);
}
.card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  margin-bottom: 12px;
}
.card__titlerow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.card__title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.card__code {
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f0f1f3;
  white-space: nowrap;
}
.card__date {
  margin: 10px 0 0;
  font-size: 12px;
  color: #c9ccd1;
}
.card__date-k { color: #9aa0a9; }
.card__subtitle {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: #c9ccd1;
}

.card__body { padding: 6px 18px 20px; }

/* ------------------------------ Questions -------------------------------- */
.q {
  padding: 15px 2px;
  border-bottom: 1px solid var(--line);
}
.q:last-of-type { border-bottom: 0; }

.q__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}

.q__value {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--red);
  background: var(--red-soft);
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 13px;
  min-width: 38px;
  text-align: center;
}
.q__value.is-empty { color: var(--muted); background: #f1f2f4; }

/* ------------------------------ Brand footer ----------------------------- */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.brand__logo {
  width: 4em;
  height: 4em;
  object-fit: contain;
  display: block;
}
.brand__name {
  font-size: 35px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ------------------------------ Range slider ----------------------------- */
.range { position: relative; padding: 2px; }
.range__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(
    to left,
    var(--red) 0%,
    var(--red) var(--fill, 0%),
    #e6e8eb var(--fill, 0%),
    #e6e8eb 100%
  );
  outline: none;
  cursor: pointer;
  margin: 0;
}
.range__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--red);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform 0.1s ease;
}
.range__input::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }
.range__input::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--red);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
.range__input::-moz-range-track { height: 6px; border-radius: 4px; background: transparent; }

.range__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
  padding: 0 1px;
}

/* ------------------------------ Yes / No --------------------------------- */
.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f1f2f4;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.toggle__opt {
  border: 0;
  background: transparent;
  padding: 10px 8px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle__opt:hover { color: var(--ink); }
.toggle__opt.is-active[data-val="yes"] {
  background: #fff; color: var(--good); box-shadow: var(--shadow-sm);
}
.toggle__opt.is-active[data-val="no"] {
  background: #fff; color: var(--bad); box-shadow: var(--shadow-sm);
}

/* ------------------------------ Submit ----------------------------------- */
.actions { margin-top: 18px; }
.btn {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 800;
  color: #fff;
  background: var(--red);
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(193, 39, 45, 0.7);
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.2s ease;
}
.btn:hover:not(:disabled) { background: var(--red-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; background: #b7bcc3; }
.btn.is-busy { pointer-events: none; opacity: 0.8; }

.form-error {
  margin: 12px 0 0;
  color: var(--bad);
  font-size: 12.5px;
  text-align: center;
  min-height: 16px;
}

/* ------------------------------ Full states ------------------------------ */
.state { text-align: center; padding: 30px 18px; animation: rise 0.35s ease both; }
.state__icon {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 30px;
}
.state__icon--ok   { background: #eaf4ea; color: var(--good); }
.state__icon--warn { background: #fef3e7; color: #c47000; }
.state__icon--err  { background: var(--red-soft); color: var(--bad); }
.state__title { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.state__text  { color: var(--ink-soft); font-size: 13px; line-height: 1.8; margin: 0; }
.muted { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

/* Spinner */
.spinner {
  width: 38px; height: 38px;
  margin: 0 auto;
  border: 3px solid var(--red-soft);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Success check draw-in */
.check { width: 72px; height: 72px; margin: 0 auto 16px; }
.check__circle {
  stroke: var(--good); stroke-width: 5; fill: #eaf4ea;
  stroke-dasharray: 320; stroke-dashoffset: 320;
  animation: draw 0.55s ease forwards;
}
.check__tick {
  stroke: var(--good); stroke-width: 6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 60;
  animation: draw 0.4s 0.4s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ------------------------------ Responsive (compact mobile) -------------- */
@media (max-width: 430px) {
  .app { padding: 0; align-items: stretch; }
  .card {
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }
  .card__header { padding: 16px 16px 14px; }
  .card__title { font-size: 16px; }
  .card__body { padding: 4px 16px 18px; flex: 1; }
  .q { padding: 13px 2px; }
  .q__label { font-size: 13px; margin-bottom: 12px; }
}

/* ------------------------------ Dark mode -------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7e9ec;
    --ink-soft: #b3b8c0;
    --muted: #7d838d;
    --card: #1e2126;
    --red-soft: #3a1d1f;
    --line: #33373d;
    --bg: #14161a;
    --panel: #23262c;
    --panel-2: #191b1f;
  }
  body { background: linear-gradient(180deg, #181a1e, var(--bg)); }
  .range__input { background: linear-gradient(to left, var(--red) 0%, var(--red) var(--fill,0%), #33373d var(--fill,0%), #33373d 100%); }
  .toggle { background: #26292f; }
  .toggle__opt.is-active[data-val="yes"],
  .toggle__opt.is-active[data-val="no"] { background: #33373d; }
  .q__value.is-empty { background: #26292f; }
  .state__icon--ok { background: #16301a; }
  .state__icon--warn { background: #35280f; }
  .check__circle { fill: #16301a; }
}
