@font-face {
  font-family: "Lalezar";
  src: url("./assets/Lalezar-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("./assets/Vazirmatn-wght-.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #fbf3e2;
  --surface: #fdf9f0;
  --surface-raised: #ffffff;
  --surface-sunken: #f5ead3;
  --cream-300: #ebdabb;
  --cream-400: #dac39c;
  --ink: #1f0f08;
  --ink-soft: #5a3826;
  --ink-muted: #785441;
  --brand: #8b2414;
  --brand-deep: #4a1206;
  --brand-soft: #f4d2c7;
  --accent: #dca92f;
  --positive: #5e7a3a;
  --danger: #9e2b25;
  --info: #4a6e78;
  --shadow: 0 20px 50px rgba(74, 18, 6, 0.09);
  --radius-panel: 28px;
  --radius-control: 16px;
  --font-display: "Lalezar", "Vazirmatn", system-ui, sans-serif;
  --font-text: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 22%, rgba(220, 169, 47, 0.10), transparent 28rem),
    var(--canvas);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
}

button,
textarea {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
.drop-zone:focus-visible,
.drop-zone:focus-within {
  outline: 4px solid rgba(220, 169, 47, 0.48);
  outline-offset: 3px;
}

.topbar {
  position: relative;
  z-index: 10;
  width: min(1400px, calc(100% - 40px));
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--cream-300);
}

.brand {
  display: grid;
  grid-template-columns: 42px auto;
  grid-template-rows: 27px 15px;
  column-gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  grid-row: 1 / 3;
  position: relative;
  width: 42px;
  height: 42px;
  display: block;
}

.brand-mark span {
  position: absolute;
  top: 7px;
  width: 22px;
  height: 28px;
  border: 2px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
}

.brand-mark span:first-child {
  left: 2px;
  transform: rotate(-7deg);
}

.brand-mark span:last-child {
  right: 2px;
  background: var(--brand);
  transform: rotate(7deg);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1;
}

.brand-latin {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.topbar-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.runtime-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  border: 1px solid var(--cream-400);
  border-radius: 999px;
  background: rgba(253, 249, 240, 0.75);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
}

.runtime-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.runtime-badge[data-state="offline"] .runtime-light {
  background: var(--positive);
}

.runtime-badge[data-state="connected"] .runtime-light {
  background: var(--info);
}

.runtime-badge[data-state="missing"] .runtime-light {
  background: var(--danger);
}

.language-toggle,
.text-action,
.mode-tab {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.language-toggle {
  min-width: 74px;
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid var(--brand-soft);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font-weight: 750;
}

.app-shell {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
  padding: 50px 0 28px;
}

.intro {
  min-height: 310px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: center;
  gap: 7vw;
  padding: 8px clamp(10px, 4vw, 62px) 46px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.intro h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(56px, 7vw, 104px);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.025em;
}

[dir="rtl"] .intro h1 {
  line-height: 1.08;
  letter-spacing: 0;
}

.intro-text {
  max-width: 590px;
  margin: 23px 0 0;
  color: var(--ink-soft);
  font-size: clamp(18px, 1.6vw, 24px);
  line-height: 1.55;
}

.translation-glyph {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 28px);
}

.glyph-page {
  width: clamp(108px, 11vw, 158px);
  aspect-ratio: 0.78;
  display: grid;
  place-items: center;
  border: 2px solid var(--brand);
  border-radius: 22px;
  font-family: var(--font-display);
  font-size: clamp(58px, 7vw, 94px);
  box-shadow: 10px 12px 0 var(--cream-300);
}

.glyph-page-source {
  background: var(--surface);
  color: var(--brand);
  transform: rotate(-4deg);
}

.glyph-page-target {
  background: var(--brand);
  color: var(--surface);
  transform: rotate(4deg);
}

.glyph-motion {
  color: var(--accent);
  font-size: 42px;
  font-weight: 700;
}

[dir="rtl"] .glyph-motion,
[dir="rtl"] .translate-button span:last-child,
[dir="rtl"] .direction-arrow {
  transform: rotate(180deg);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  overflow: hidden;
  border: 1px solid var(--cream-300);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-pane,
.result-pane {
  min-height: 650px;
  padding: clamp(24px, 3.4vw, 48px);
}

.source-pane {
  border-inline-end: 1px solid var(--cream-300);
}

.result-pane {
  display: flex;
  flex-direction: column;
  background: rgba(245, 234, 211, 0.54);
}

.pane-heading {
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.pane-index {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.pane-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 400;
  line-height: 1.1;
}

.mode-switch {
  display: flex;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-sunken);
}

.mode-tab {
  min-width: 66px;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 11px;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 700;
}

.mode-tab.is-active {
  background: var(--surface-raised);
  color: var(--brand);
  box-shadow: 0 4px 13px rgba(74, 18, 6, 0.08);
}

.direction-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.direction-option {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--cream-400);
  border-radius: var(--radius-control);
  background: transparent;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.direction-option:hover,
.direction-option.is-selected {
  border-color: var(--brand);
  background: rgba(244, 210, 199, 0.28);
}

.direction-option:active,
.translate-button:active,
.language-toggle:active,
.text-action:active {
  transform: translateY(1px);
}

.language-code {
  font-size: 18px;
  font-weight: 800;
}

.direction-arrow {
  display: inline-block;
  color: var(--brand);
  font-size: 20px;
}

.drop-zone {
  min-height: 255px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 28px;
  border: 2px dashed var(--cream-400);
  border-radius: 22px;
  background: var(--surface-raised);
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--brand);
  background: rgba(244, 210, 199, 0.18);
  transform: translateY(-2px);
}

.drop-symbol {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 18px;
  background: var(--brand);
  color: var(--surface);
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
}

.drop-zone strong {
  font-size: clamp(21px, 2vw, 27px);
}

.drop-zone > span:last-child {
  max-width: 340px;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.5;
}

.selected-file {
  min-height: 82px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--cream-300);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
}

.file-extension {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
}

.file-details {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.file-details strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-details span {
  color: var(--ink-muted);
  font-size: 13px;
}

.text-action {
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--brand);
  font-weight: 750;
}

.text-action:hover:not(:disabled) {
  background: var(--brand-soft);
}

.text-action:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
  opacity: 0.45;
}

.text-label {
  display: block;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 255px;
  resize: vertical;
  padding: 20px;
  border: 1px solid var(--cream-400);
  border-radius: 22px;
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.7;
}

textarea::placeholder {
  color: #806958;
  opacity: 1;
}

.translate-button {
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 14px 24px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--brand);
  color: var(--surface);
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(139, 36, 20, 0.18);
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.translate-button:hover:not(:disabled) {
  background: var(--brand-deep);
}

.translate-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.translate-button span:last-child {
  display: inline-block;
  font-size: 26px;
}

.result-heading {
  margin-bottom: 20px;
}

.output-empty,
.output-loading,
.output-text {
  flex: 1;
  min-height: 430px;
}

.output-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-type {
  color: var(--cream-400);
  font-family: var(--font-display);
  font-size: clamp(58px, 7vw, 92px);
}

.output-empty p {
  margin: 20px 0 4px;
  font-size: 20px;
  font-weight: 750;
}

.output-empty > span:last-child {
  color: var(--ink-muted);
  font-size: 15px;
}

.output-loading {
  padding-top: 34px;
}

.output-loading span {
  display: block;
  height: 24px;
  margin-bottom: 18px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--cream-300) 25%, #f8edda 48%, var(--cream-300) 72%);
  background-size: 240% 100%;
  animation: shimmer 1.4s infinite linear;
}

.output-loading span:nth-child(2) { width: 88%; }
.output-loading span:nth-child(3) { width: 94%; }
.output-loading span:nth-child(4) { width: 61%; }

.output-text {
  overflow: auto;
  margin: 0;
  padding: 14px 4px 28px;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: clamp(20px, 1.7vw, 25px);
  font-weight: 480;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-bar {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--cream-300);
}

.status {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.status[data-state="success"] { color: var(--positive); }
.status[data-state="error"] { color: var(--danger); }
.status[data-state="working"] { color: var(--brand); }

.output-language {
  min-width: 42px;
  padding: 5px 8px;
  border-radius: 9px;
  background: var(--surface);
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.trust-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 26px 14px 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.trust-line p {
  margin: 0;
}

.trust-line strong {
  color: var(--ink-soft);
}

.platform-line {
  direction: ltr;
  text-align: end;
  letter-spacing: 0.02em;
}

[hidden] {
  display: none !important;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (max-width: 920px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 18px;
    padding-inline: 8px;
  }

  .translation-glyph {
    min-height: 170px;
    justify-content: flex-start;
  }

  [dir="rtl"] .translation-glyph {
    justify-content: flex-start;
  }

  .glyph-page {
    width: 108px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .source-pane {
    min-height: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--cream-300);
  }

  .result-pane {
    min-height: 570px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .topbar,
  .app-shell {
    width: min(100% - 24px, 1400px);
  }

  .topbar {
    height: 68px;
  }

  .brand {
    grid-template-columns: 38px auto;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-mark span {
    width: 20px;
    height: 25px;
  }

  .brand-name {
    font-size: 24px;
  }

  .runtime-badge {
    width: 38px;
    min-width: 38px;
    padding: 0;
    justify-content: center;
  }

  .runtime-badge span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .language-toggle {
    min-width: 62px;
    padding-inline: 11px;
  }

  .app-shell {
    padding-top: 34px;
  }

  .intro {
    min-height: auto;
    padding: 0 4px 34px;
  }

  .intro h1 {
    font-size: clamp(49px, 15vw, 68px);
  }

  .intro-text {
    margin-top: 16px;
    font-size: 18px;
  }

  .translation-glyph {
    min-height: 132px;
  }

  .glyph-page {
    width: 82px;
    border-radius: 17px;
    box-shadow: 7px 8px 0 var(--cream-300);
    font-size: 50px;
  }

  .glyph-motion {
    font-size: 30px;
  }

  .workspace {
    border-radius: 22px;
  }

  .source-pane,
  .result-pane {
    padding: 22px 18px;
  }

  .pane-heading {
    align-items: center;
    margin-bottom: 22px;
  }

  .pane-heading h2 {
    font-size: 30px;
  }

  .mode-tab {
    min-width: 55px;
    padding-inline: 8px;
  }

  .direction-switch {
    gap: 8px;
  }

  .direction-option {
    min-height: 58px;
    gap: 8px;
  }

  .language-code {
    font-size: 16px;
  }

  .drop-zone,
  textarea {
    min-height: 228px;
  }

  .drop-zone {
    padding-inline: 18px;
  }

  .selected-file {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .selected-file .text-action {
    grid-column: 2;
    justify-self: start;
    padding-inline: 0;
  }

  .result-heading {
    align-items: flex-start;
  }

  .result-actions {
    gap: 0;
  }

  .output-empty,
  .output-loading,
  .output-text {
    min-height: 390px;
  }

  .trust-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-inline: 4px;
  }

  .platform-line {
    text-align: start;
    line-height: 1.7;
  }
}

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