/* ============================================================================
   netdrop — styles
   Identity: Persian turquoise (فیروزه) tilework on calm ink-and-paper neutrals.
   The 6-digit code, rendered as tiles (کاشی), is the signature element.
   Light + dark themes, full RTL.
   ========================================================================== */

/* ── Fonts (self-hosted Vazirmatn, SIL OFL) ──────────────────────────────── */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* Palette — light */
  --paper: #f3f5f3;      /* background: soft green-gray paper */
  --surface: #ffffff;    /* cards */
  --surface-2: #eef1ef;  /* insets, tiles background */
  --ink: #14201c;        /* primary text: dark teal-charcoal */
  --muted: #5c6b65;      /* secondary text */
  --faint: #8b9a93;      /* tertiary / placeholders */
  --line: #e2e7e3;       /* hairline borders */
  --accent: #0f9a9a;     /* Persian turquoise (فیروزه) */
  --accent-strong: #0b7c7c;
  --accent-soft: #d7efec; /* tinted fills */
  --danger: #c1543f;
  --ok: #2f8f6b;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-tile: 14px;
  --shadow: 0 1px 2px rgba(20, 32, 28, 0.04), 0 8px 24px rgba(20, 32, 28, 0.06);
  --shadow-lift: 0 2px 6px rgba(20, 32, 28, 0.08), 0 18px 40px rgba(20, 32, 28, 0.12);

  --tap: 44px; /* min touch target */
}

[data-theme='dark'] {
  --paper: #0e1512;
  --surface: #15201c;
  --surface-2: #1b2823;
  --ink: #e8edea;
  --muted: #9aada5;
  --faint: #6f827a;
  --line: #263630;
  --accent: #34c9bd;
  --accent-strong: #4bd6cb;
  --accent-soft: #14322e;
  --danger: #e07a63;
  --ok: #58c495;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 8px rgba(0, 0, 0, 0.4), 0 22px 48px rgba(0, 0, 0, 0.5);
}
/* theme-init.js resolves the OS preference and always sets data-theme, so the
   dark palette lives in one place — no duplicated prefers-color-scheme block. */

/* ── Reset & base ────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: 'Vazirmatn', system-ui, 'Segoe UI', Tahoma, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Tabular, aligned digits everywhere numbers matter. */
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page {
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 28px) 40px;
  flex: 1 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(28px, 6vw, 52px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.brand__mark {
  width: 30px;
  height: 30px;
  flex: none;
}
.brand__name {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.brand__name b {
  color: var(--accent);
  font-weight: 700;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.session-foot {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

/* ── Hero: your code as tiles ────────────────────────────────────────────── */
.hero {
  text-align: center;
}
.hero__lead {
  color: var(--muted);
  font-size: 15px;
  margin: 0 auto 26px;
  max-width: 34ch;
}

.code {
  display: inline-flex;
  gap: clamp(6px, 2vw, 10px);
  direction: ltr; /* keep digit order stable regardless of page direction */
}
.code__tile {
  width: clamp(44px, 12vw, 60px);
  height: clamp(58px, 16vw, 78px);
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-tile);
  box-shadow: var(--shadow);
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 700;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
/* A faint tilework glaze on each digit. */
.code__tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, var(--accent-soft) 0%, transparent 55%);
  opacity: 0.6;
  pointer-events: none;
}
.code__digit {
  position: relative;
}

.code.is-live .code__tile {
  animation: tilePulse 2.4s ease-in-out infinite;
}
.code.is-live .code__tile:nth-child(2) { animation-delay: 0.15s; }
.code.is-live .code__tile:nth-child(3) { animation-delay: 0.3s; }
.code.is-live .code__tile:nth-child(4) { animation-delay: 0.45s; }
.code.is-live .code__tile:nth-child(5) { animation-delay: 0.6s; }
.code.is-live .code__tile:nth-child(6) { animation-delay: 0.75s; }

@keyframes tilePulse {
  0%, 100% { border-color: var(--line); }
  50% { border-color: var(--accent); }
}

.code-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
}

.hero__hint {
  margin-top: 10px;
  color: var(--faint);
  font-size: 13px;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  font-size: 13px;
  margin: clamp(28px, 6vw, 40px) 0;
}
.divider::before,
.divider::after {
  content: '';
  height: 1px;
  background: var(--line);
  flex: 1;
}

/* ── Cards / sections ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 24px);
}
.card + .card {
  margin-top: 16px;
}
.card__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
}
.card__sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

/* ── Connect input ───────────────────────────────────────────────────────── */
.connect {
  display: flex;
  gap: 10px;
}
.input {
  flex: 1;
  min-width: 0;
  height: var(--tap);
  padding: 0 16px;
  font: inherit;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-align: center;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.input::placeholder {
  color: var(--faint);
  letter-spacing: 0.2em;
  font-weight: 400;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 0 20px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-strong);
}
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.btn--danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  padding-inline: 12px;
}
.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.btn--sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Connection status pill ──────────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.status[data-state='connecting'] .status__dot { background: #d9a13a; animation: blink 1.2s infinite; }
.status[data-state='online'] .status__dot { background: var(--ok); }
.status[data-state='connected'] .status__dot { background: var(--accent); }
.status[data-state='offline'] .status__dot { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }

/* ── Dropzone ────────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: clamp(28px, 8vw, 44px) 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.dropzone:hover,
.dropzone.is-drag {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.dropzone__icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--accent);
}
.dropzone__title {
  font-weight: 500;
  color: var(--ink);
}
.dropzone.is-drag .dropzone__title,
.dropzone:hover .dropzone__title {
  color: var(--accent);
}
.dropzone__hint {
  font-size: 13px;
  margin-top: 4px;
}

/* ── Transfers ───────────────────────────────────────────────────────────── */
.transfers {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.transfer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.transfer__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.transfer__name {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.transfer__dir {
  font-size: 12px;
  color: var(--faint);
  flex: none;
}
.transfer__dir--up { color: var(--accent); }
.transfer__dir--down { color: var(--ok); }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0 8px;
}
.bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}
.transfer.is-done .bar__fill { background: var(--ok); }
.transfer.is-error .bar__fill { background: var(--danger); }

.transfer__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.transfer__meta .sep { color: var(--faint); }
.transfer__cancel { margin-inline-start: 8px; }

/* ── Modal (accept/reject) ───────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  z-index: 50;
  animation: fade 0.15s ease;
}
.modal[hidden] {
  display: none;
}
.modal__card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 28px 24px 22px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: pop 0.18s ease;
}
.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
}
.modal__text {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 22px;
}
.modal__code {
  color: var(--accent);
  font-weight: 700;
}
.modal__actions {
  display: flex;
  gap: 10px;
}
.modal__actions .btn {
  flex: 1;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 60;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lift);
  animation: pop 0.18s ease;
  max-width: calc(100% - 40px);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 24px 20px 32px;
  color: var(--faint);
  font-size: 13px;
}
.site-footer a {
  color: var(--muted);
}
.site-footer .dot {
  margin-inline: 8px;
  opacity: 0.5;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }

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