/* ============================================================
   BASE + COMPONENTS — משתמש אך ורק ב-tokens.css.
   אין כאן ערכי צבע/גופן קשיחים (hardcoded).
   ============================================================ */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--gradient-bg);
  background-size: 300% 100%;
  background-attachment: fixed;
  background-position: 0% 50%;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
  animation: bg-pan 22s ease-in-out infinite alternate;
}
/* הגרדיאנט זז לאט מצד לצד */
@keyframes bg-pan {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* תאורת אווירה — כתמי זוהר סגולים איטיים מעל הגרדיאנט */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 620px at 85% -5%, rgba(168, 85, 247, 0.14), transparent 65%),
    radial-gradient(ellipse 800px 600px at 8% 108%, rgba(109, 40, 217, 0.16), transparent 65%),
    radial-gradient(ellipse 520px 420px at 45% 45%, rgba(236, 72, 153, 0.06), transparent 70%);
  animation: ambient-drift 26s ease-in-out infinite alternate;
}
@keyframes ambient-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-3%, 2%) scale(1.07); }
}

.wrap {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
}

/* ---------- header ---------- */
.hero { margin-bottom: var(--space-4); }
.hero h1 {
  font-size: var(--fs-xl);
  font-weight: 800;
  margin: 0 0 var(--space-1);
  letter-spacing: -0.01em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  width: fit-content;
}
.hero h1 .working-name {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--color-text-faint);
  vertical-align: super;
  margin-inline-start: var(--space-1);
}
.hero p {
  color: var(--color-text-muted);
  margin: 0;
  max-width: 52ch;
  line-height: 1.55;
}

/* ---------- card (זכוכית) ---------- */
.card {
  background: linear-gradient(var(--glass-bg), var(--glass-bg)), var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-3) var(--space-3);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(var(--glass-blur));
}
.card h2 {
  font-size: var(--fs-base);
  font-weight: 600;
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
}
.card h2 .step-num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--color-on-accent);
  background: var(--gradient-cta);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- form elements ---------- */
label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
input[type="password"],
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: var(--space-2) var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  margin-bottom: var(--space-2);
}
input:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }

button {
  padding: var(--space-2) var(--space-3);
  border: none;
  background: var(--gradient-cta);
  color: var(--color-on-accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
  transition: box-shadow 0.18s ease, transform 0.12s ease, filter 0.18s ease;
}
button:hover:not(:disabled) { box-shadow: var(--glow-accent); filter: brightness(1.08); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  color: var(--color-text-faint);
  cursor: not-allowed;
}
button.ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  font-weight: 500;
}
button.ghost:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
  color: var(--color-text);
  box-shadow: none;
  filter: none;
}
button.block { width: 100%; }

/* ---------- segmented control ---------- */
.segmented {
  display: grid;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-1);
}
.segmented.cols-2 { grid-template-columns: repeat(2, 1fr); }
.segmented.cols-3 { grid-template-columns: repeat(3, 1fr); }
.segmented.cols-4 { grid-template-columns: repeat(4, 1fr); }
.segmented button {
  border: none;
  border-radius: 0;
  border-left: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: var(--space-2) 4px;
}
.segmented button:first-child { border-left: none; }
.segmented button.active { background: var(--color-accent); color: var(--color-on-accent); font-weight: 600; }
.segmented button:hover:not(.active) { background: var(--color-surface-2); color: var(--color-text); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-3);
  text-align: center;
  cursor: pointer;
  font-size: var(--fs-base);
  color: var(--color-text-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
  color: var(--color-text);
}
.dropzone input { display: none; }
.dropzone .fname {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  direction: ltr;
}

/* ---------- misc ---------- */
.hint {
  font-size: var(--fs-sm);
  color: var(--color-text-faint);
  line-height: 1.5;
  margin-top: var(--space-1);
}
.status {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-success);
  min-height: 16px;
}
.status.error { color: var(--color-danger); white-space: pre-wrap; }

.progress-track {
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--space-2);
  display: none;
}
.progress-track .progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.row-actions { display: flex; gap: var(--space-2); }
.row-actions button { flex: 1; }
.row-actions input { margin-bottom: 0; }

a.download-link {
  display: block;
  text-align: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-success);
  color: var(--color-bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--fs-base);
  margin-top: var(--space-2);
}

/* ---------- caption editor ---------- */
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}
.editor-rows {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.editor-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.editor-row:last-child { border-bottom: none; }
.editor-row .time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
  direction: ltr;
  flex-shrink: 0;
}
.editor-row input {
  flex: 1;
  margin-bottom: 0;
  border: 1px solid transparent;
  background: transparent;
  padding: var(--space-1) var(--space-1);
}
.editor-row input:hover { border-color: var(--color-border); }
.editor-row input:focus { background: var(--color-bg); }
.editor-row .del {
  background: transparent;
  border: none;
  color: var(--color-text-faint);
  font-size: var(--fs-base);
  padding: 2px 6px;
  flex-shrink: 0;
}
.editor-row .del:hover { color: var(--color-danger); background: transparent; }

/* ---------- pauses ---------- */
.pause-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.pause-row .pause-range { color: var(--color-text-muted); direction: ltr; }
.pause-row .pause-duration { color: var(--color-accent); font-weight: 700; }
.pause-empty { color: var(--color-text-faint); font-size: var(--fs-sm); }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 1px 6px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text-faint);
  margin-inline-start: var(--space-1);
  font-weight: 400;
}

/* ---------- top nav ---------- */
.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--fs-sm);
}
.topnav a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.topnav a:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.topnav .crumb { color: var(--color-text-faint); }

/* ---------- splash (מסך פתיחה) ---------- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--gradient-bg);
  background-size: 300% 100%;
  animation: bg-pan 22s ease-in-out infinite alternate;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease;
}
#splash.done { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-logo {
  font-size: clamp(46px, 11vw, 96px);
  font-weight: 800;
  letter-spacing: 0.04em;
  direction: ltr;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: splash-logo-in 1s cubic-bezier(0.16, 1, 0.3, 1) both;
  filter: drop-shadow(0 0 34px rgba(168, 85, 247, 0.45));
}
@keyframes splash-logo-in {
  0%   { opacity: 0; letter-spacing: 0.45em; transform: scale(0.92); }
  100% { opacity: 1; letter-spacing: 0.04em; transform: scale(1); }
}
.splash-sub {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--fs-lg);
  animation: splash-sub-in 0.7s ease-out 0.55s both;
}
@keyframes splash-sub-in {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------- brand ---------- */
.brand-logo {
  font-weight: 800;
  direction: ltr;
  display: inline-block;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- home categories ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}
/* כניסה מדורגת של הקטגוריות אחרי מסך הפתיחה */
.reveal-on-load .hero,
.reveal-on-load .category-card {
  opacity: 0;
}
.reveal-on-load.revealed .hero { animation: rise-in 0.55s ease-out both; }
.reveal-on-load.revealed .category-card { animation: rise-in 0.55s ease-out both; }
.reveal-on-load.revealed .category-card:nth-child(1) { animation-delay: 0.12s; }
.reveal-on-load.revealed .category-card:nth-child(2) { animation-delay: 0.24s; }
.reveal-on-load.revealed .category-card:nth-child(3) { animation-delay: 0.36s; }
@keyframes rise-in {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}
a.category-card {
  display: block;
  background: linear-gradient(var(--glass-bg), var(--glass-bg)), var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-3);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
a.category-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-3px);
  box-shadow: var(--glow-accent);
}
a.category-card:active { transform: translateY(-1px) scale(0.98); }
.category-card .cat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--gradient-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  box-shadow: 0 4px 18px rgba(236, 72, 153, 0.35);
}
.category-card .cat-icon svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.category-card h3 { margin: 0 0 var(--space-1); font-size: var(--fs-lg); font-weight: 600; }
.category-card p { margin: 0; color: var(--color-text-muted); font-size: var(--fs-sm); line-height: 1.5; }
.category-card .cat-badge {
  display: inline-block;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--color-accent);
}

/* ---------- editor layout ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--space-3);
  align-items: start;
}
@media (max-width: 860px) { .editor-layout { grid-template-columns: 1fr; } }

.preview-stage {
  position: relative;
  background: #000;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-stage video { max-width: 100%; max-height: 100%; }
.preview-stage .caption-overlay {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 88%;
  text-align: center;
  font-size: clamp(13px, 2.6vw, 22px);
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  white-space: pre-wrap;
}
.preview-stage .caption-overlay:empty { display: none; }
.preview-stage .stage-empty { color: var(--color-text-faint); font-size: var(--fs-base); }

.transport {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.transport .tc {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  direction: ltr;
}
.transport .spacer { flex: 1; }

/* ---------- timeline ---------- */
.timeline {
  margin-top: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  position: relative;
  overflow: hidden;
  user-select: none;
}
.tl-ruler {
  height: 22px;
  position: relative;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--color-text-faint);
  cursor: pointer;
  direction: ltr;
}
.tl-ruler .tick {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid var(--color-border);
  padding-left: 3px;
  padding-top: 4px;
}
.tl-track {
  position: relative;
  height: 40px;
  border-bottom: 1px solid var(--color-border);
  direction: ltr;
}
.tl-track:last-child { border-bottom: none; }
.tl-track .tl-label {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  z-index: 3;
  direction: rtl;
}
.tl-block {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 4px;
  overflow: hidden;
  font-size: var(--fs-xs);
  color: var(--color-on-accent);
  padding: 2px 6px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tl-block.clip { background: var(--track-clip); opacity: 0.9; }
.tl-block.cut-region { background: var(--color-danger); opacity: 0.65; top: 2px; bottom: 2px; }
.tl-block.caption-block { background: var(--track-caption); opacity: 0.85; color: var(--color-bg); }
.tl-block.music-block { background: var(--track-music); opacity: 0.85; }
.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-text);
  z-index: 5;
  pointer-events: none;
}

/* ---------- side panel ---------- */
.side-panel .card { position: sticky; top: var(--space-3); }
.side-panel h3 {
  font-size: var(--fs-base);
  font-weight: 600;
  margin: 0 0 var(--space-2);
}
.side-panel select {
  width: 100%;
  padding: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-2);
}
input[type="range"] { width: 100%; accent-color: var(--color-accent); }

footer.buildinfo {
  text-align: center;
  margin-top: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
}

/* ---------- mobile ---------- */
@media (max-width: 480px) {
  .wrap { padding: var(--space-3) var(--space-2) var(--space-4); }
  .hero h1 { font-size: 22px; }
  .segmented.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .segmented.cols-4 button:nth-child(-n+2) { border-bottom: 1px solid var(--color-border); }
  .segmented.cols-4 button:nth-child(3) { border-left: none; }
  .editor-row .time { display: none; }
}
