/* ── handTalk Sign (Text → Sign) — sign.css ──────────────────────────────────
   Self-contained design tokens mirroring learn.css / style.css.
   ─────────────────────────────────────────────────────────────────────────── */
:root {
  --accent:      #29c49a;
  --accent-2:    #4dd9b4;
  --accent-dim:  rgba(41,196,154,.15);
  --accent-glow: rgba(41,196,154,.30);
  --bg:          #0a0a0f;
  --surface:     #111118;
  --surface-2:   #1a1a24;
  --border:      rgba(255,255,255,.07);
  --border-acc:  rgba(41,196,154,.25);
  --text:        #e8e8ec;
  --text-dim:    #7a7a8e;
  --text-faint:  #3a3a4e;
  --danger:      #e05a5a;
  --radius:      10px;
  --radius-lg:   16px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 3px; }

/* ── Nav (identical to learn.css) ────────────────────────────────────────── */
.ht-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 52px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 20px;
  background: rgba(10,10,15,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.ht-logo {
  font-size: 17px; font-weight: 700; letter-spacing: -.3px;
  color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: 7px;
  margin-right: auto;
}
.ht-logo span { color: var(--accent); }
.nav-link {
  padding: 6px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 500; letter-spacing: .01em;
  color: var(--text-dim); text-decoration: none;
  transition: color .15s, background .15s;
}
.nav-link:hover  { color: var(--text); background: rgba(255,255,255,.05); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

/* ── Page layout ─────────────────────────────────────────────────────────── */
.sign-page {
  padding-top: 52px;
  min-height: 100vh;
  display: flex; flex-direction: column;
  max-width: 860px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.sign-header {
  padding: 32px 0 8px;
}
.sign-header h1 {
  font-size: 26px; font-weight: 800; letter-spacing: -.5px;
  line-height: 1.1;
}
.sign-header h1 span { color: var(--accent); }
.sign-header p {
  font-size: 14px; color: var(--text-dim); margin-top: 6px;
}

/* ── Input card ──────────────────────────────────────────────────────────── */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 20px 0 0;
  display: flex; flex-direction: column; gap: 12px;
}

.textarea-wrap { position: relative; }

.sign-textarea {
  width: 100%;
  min-height: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit; font-size: 16px; line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.sign-textarea:focus { border-color: var(--border-acc); }
.sign-textarea::placeholder { color: var(--text-faint); }

.char-count {
  position: absolute; bottom: 8px; right: 10px;
  font-size: 11px; color: var(--text-faint);
  pointer-events: none;
}

.input-actions {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

.btn-translate {
  flex: 1; min-width: 140px;
  padding: 10px 20px;
  background: var(--accent); color: #000;
  font-size: 14px; font-weight: 700; letter-spacing: .03em;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: opacity .15s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-translate:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-translate:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-voice {
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-voice:hover { border-color: var(--border-acc); color: var(--text); }
.btn-voice.listening {
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse-border 1.2s ease infinite;
}
.btn-voice.no-support { opacity: .35; cursor: not-allowed; }

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%       { box-shadow: 0 0 0 6px transparent; }
}

.btn-clear {
  padding: 10px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint); font-size: 13px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.btn-clear:hover { color: var(--danger); border-color: var(--danger); }

/* Voice status bar */
.voice-status {
  font-size: 12px; color: var(--accent);
  display: none; align-items: center; gap: 6px;
}
.voice-status.show { display: flex; }
.voice-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: blink .8s ease infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── Results area ────────────────────────────────────────────────────────── */
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0 10px;
}
.results-title {
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-dim);
}
.results-meta { font-size: 12px; color: var(--text-faint); }

.results-actions-bar {
  display: flex; gap: 8px;
}

.btn-play-all {
  padding: 8px 18px;
  background: var(--accent-dim);
  border: 1px solid var(--border-acc);
  border-radius: var(--radius);
  color: var(--accent); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s;
  display: flex; align-items: center; gap: 6px;
}
.btn-play-all:hover { background: rgba(41,196,154,.22); }
.btn-play-all:disabled { opacity: .35; cursor: not-allowed; }

.btn-copy {
  padding: 8px 14px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim); font-size: 13px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.btn-copy:hover { color: var(--text); border-color: var(--border-acc); }

/* ── Sign cards grid ─────────────────────────────────────────────────────── */
.sign-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding-bottom: 40px;
}

.sign-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  cursor: default;
}
.sign-result-card:hover {
  border-color: var(--border-acc);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.sign-result-card.playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.sign-result-card.unknown {
  border-color: var(--text-faint);
  opacity: .6;
}

/* Video container — 16:9 aspect ratio */
.card-video {
  position: relative;
  width: 100%;
  padding-top: 75%;   /* 4:3 — better for sign demos */
  background: #000;
  overflow: hidden;
}
.card-video iframe,
.card-video blockquote {
  position: absolute; inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: none; margin: 0;
}

/* No-video placeholder */
.card-no-video {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; color: var(--text-faint); font-size: 12px;
  background: var(--surface-2);
}

/* Card footer */
.card-foot {
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-word {
  font-size: 13px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text);
}
.card-word.unknown-word { color: var(--text-faint); }
.card-index {
  font-size: 11px; color: var(--text-faint);
  background: var(--surface-2);
  padding: 2px 7px; border-radius: 10px;
}

/* Playing indicator */
.card-playing-bar {
  height: 2px; background: var(--surface-2);
}
.card-playing-bar-fill {
  height: 100%; background: var(--accent);
  width: 0%; transition: width .3s linear;
}

/* ── Empty / loading states ──────────────────────────────────────────────── */
.empty-results {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 60px 24px;
  color: var(--text-dim); text-align: center;
}
.empty-results svg  { color: var(--text-faint); }
.empty-results h3   { font-size: 16px; font-weight: 700; }
.empty-results p    { font-size: 13px; max-width: 300px; }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; padding-bottom: 40px;
}
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-video { padding-top: 75%; background: var(--surface-2); }
.skeleton-foot  { height: 40px; background: var(--surface); }
@keyframes shimmer {
  0%,100% { opacity: 1; }
  50%     { opacity: .5; }
}

/* ── Unknown words banner ────────────────────────────────────────────────── */
.unknown-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: rgba(224,90,90,.08);
  border: 1px solid rgba(224,90,90,.2);
  border-radius: var(--radius);
  font-size: 13px; color: var(--text-dim);
  display: none;
}
.unknown-banner.show { display: block; }
.unknown-banner strong { color: #e88; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#sign-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-2); border: 1px solid var(--border-acc);
  color: var(--text); font-size: 13px; font-weight: 500;
  padding: 9px 18px; border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 1000; white-space: nowrap;
}
#sign-toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
#sign-toast.success { border-color: var(--accent);  color: var(--accent); }
#sign-toast.danger  { border-color: var(--danger);  color: var(--danger); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sign-cards, .skeleton-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .sign-header h1 { font-size: 22px; }
}
@media (max-width: 380px) {
  .sign-cards, .skeleton-grid { grid-template-columns: 1fr; }
}