/* CORE ENTERTAINMENT — Content Upload
   Tokens mirror coreWeb/design-system.css so this form reads as part of the
   same product. Doctrine: black is the canvas, red is a decision.
   Inter only -- the brand display face (AkiraExpanded) is not vendored here,
   so headings use tight-tracked heavy Inter rather than a wrong substitute. */

:root {
  /* Surfaces */
  --bg-base: #0A0A0A;
  --bg-elevated: #111111;
  --bg-card: #161616;
  --bg-inset: #0D0D0D;

  /* The red -- one decision per view */
  --accent: #E5181B;
  --accent-light: #FF2222;
  --accent-dim: rgba(229, 24, 27, 0.10);
  --accent-glow: rgba(229, 24, 27, 0.30);

  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0A0;
  --text-muted: #5A5A5A;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);

  /* States */
  --success: #22C55E;
  --warning: #F59E0B;
  --error: #E5181B;

  --font-body: "Inter", system-ui, -apple-system, "Helvetica Neue", sans-serif;

  /* Base-8 spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --tracking-wide: 0.06em;
  --tracking-widest: 0.14em;

  --duration-fast: 150ms;
  --duration-base: 250ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.8);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: var(--space-12) var(--space-4);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Atmosphere: a single dim red bloom behind the card, so the black reads as
     lit rather than flat. Fixed so it doesn't drift while the page scrolls. */
  background-image:
    radial-gradient(ellipse 60% 45% at 50% 0%, rgba(229, 24, 27, 0.07), transparent 70%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(255, 255, 255, 0.02), transparent 70%);
  background-attachment: fixed;
}

/* ---------- Card ---------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
  animation: card-in var(--duration-base) var(--ease-out) both;
}

/* The one red decision on the card itself: a hairline across the top edge. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(229, 24, 27, 0.15) 60%, transparent);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.logo {
  display: block;
  width: 200px;
  max-width: 70%;
  height: auto;
  margin: 0 auto var(--space-8);
}

h1 {
  margin: 0 0 var(--space-2) 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0 auto var(--space-8);
  max-width: 38ch;
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: center;
}

/* ---------- Form fields ---------- */

label {
  display: block;
  margin: 0 0 var(--space-2) 0;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--text-muted);
}

.field {
  margin-bottom: var(--space-5);
}

select,
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

select {
  /* Custom caret -- the native one renders light-on-light on dark selects. */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235A5A5A' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

select:hover,
input[type="text"]:hover,
input[type="password"]:hover {
  border-color: var(--border-strong);
}

select:focus,
input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder {
  color: var(--text-muted);
}

/* ---------- Drop zone ---------- */

#dropLabel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 108px;
  padding: var(--space-6);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

#dropLabel::before {
  content: "";
  width: 22px;
  height: 22px;
  background: currentColor;
  opacity: 0.5;
  /* Upload glyph, masked so it inherits the label's colour on every state. */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E") center / contain no-repeat;
}

#dropLabel:hover,
#dropLabel.is-dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-primary);
}

#dropLabel.has-file {
  border-style: solid;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

#dropLabel.has-file::before {
  opacity: 1;
  color: var(--success);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
  background: var(--success);
}

input[type="file"] {
  display: none;
}

/* ---------- OR divider ---------- */

.or-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ---------- Buttons ---------- */

button {
  width: 100%;
  padding: var(--space-4) var(--space-8);
  margin-top: var(--space-6);
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

button:hover:not(:disabled) {
  background: var(--accent-light);
  box-shadow: 0 0 24px var(--accent-glow);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 24px var(--accent-glow);
}

button:disabled {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------- Chosen file list ---------- */

.file-list {
  margin-top: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  overflow: hidden;
}

.file-list[hidden] { display: none; }

.file-list__items {
  margin: 0;
  padding: var(--space-2) 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
}

.file-list__items li {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 5px var(--space-4);
  font-size: 0.75rem;
}

.file-list__name {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.file-list__dir {
  color: var(--text-muted);
  font-size: 0.6875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.file-list__size {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.6875rem;
  white-space: nowrap;
  flex: none;
}

.file-list__toggle,
.file-list__clear {
  width: 100%;
  margin: 0;
  padding: var(--space-3);
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: none;
  letter-spacing: normal;
}

.file-list__toggle:hover:not(:disabled),
.file-list__clear:hover:not(:disabled) {
  background: var(--bg-base, rgba(255, 255, 255, 0.03));
  color: var(--text-primary);
  box-shadow: none;
}

.file-list__toggle[hidden] { display: none; }

/* ---------- Large-batch advice ---------- */

.batch-advice {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border-left: 3px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.6;
}

.batch-advice[hidden] { display: none; }

/* ---------- Working indicator ----------
   A determinate bar sitting at 100% is indistinguishable from a frozen one.
   Anywhere the page is busy but can't say how busy, show motion instead. */

.working {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-primary);
}

.working__spinner,
.upload-panel__spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .working__spinner,
  .upload-panel__spinner {
    animation-duration: 2s;
  }
}

/* ---------- In-flight upload panel ---------- */

.upload-panel {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.upload-panel[hidden] { display: none; }

.upload-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
}

.upload-panel__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.upload-panel__count {
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
}

.upload-panel__pct {
  color: var(--accent);
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.upload-panel__bytes,
.upload-panel__current {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.upload-panel__warning {
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ---------- Success state ----------
   Deliberately oversized. The failure mode this prevents is a submitter who
   isn't sure it worked, and either uploads everything twice or messages
   someone to check. */

.success-panel {
  text-align: center;
  padding: var(--space-8) var(--space-5) var(--space-6);
}

.success-panel[hidden] { display: none; }

.success-panel__check {
  width: 88px;
  height: 88px;
  margin: 0 auto var(--space-5);
}

.success-panel__check svg { width: 100%; height: 100%; }

.success-panel__circle {
  stroke: var(--success, #22c55e);
  stroke-width: 2;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: success-circle 0.5s var(--ease-out, ease-out) forwards;
}

.success-panel__tick {
  stroke: var(--success, #22c55e);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: success-tick 0.35s var(--ease-out, ease-out) 0.4s forwards;
}

@keyframes success-circle { to { stroke-dashoffset: 0; } }
@keyframes success-tick   { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .success-panel__circle,
  .success-panel__tick {
    animation: none;
    stroke-dashoffset: 0;
  }
}

.success-panel__headline {
  margin: 0 0 var(--space-3);
  color: var(--text-primary);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.success-panel__sub {
  margin: 0 auto var(--space-6);
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.success-panel .secondary-action { width: auto; padding: var(--space-3) var(--space-6); }

/* ---------- Access request panel ---------- */

.access-panel {
  margin-top: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.access-panel[hidden] { display: none; }

.access-panel__title {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  color: var(--text-primary);
}

.access-panel__steps {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--text-muted);
}

.access-panel__steps li + li { margin-top: var(--space-2); }

/* The browser default (blue, underlined) is unreadable on this dark card. */
.access-panel a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.access-panel a:hover { color: var(--accent-light); }

.access-panel code {
  padding: 2px 6px;
  border-radius: var(--radius-sm, 4px);
  background: var(--bg-base, rgba(0, 0, 0, 0.25));
  color: var(--text-primary);
  font-size: 0.8125rem;
  word-break: break-all;
}

.copy-btn {
  width: auto;
  margin: 0 0 0 var(--space-2);
  padding: 2px 10px;
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: none;
  letter-spacing: normal;
}

.copy-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--text-primary);
  box-shadow: none;
}

/* Quiet alternative to the drop zone, for people whose footage is a folder.
   Deliberately understated -- drag-and-drop stays the primary path. */
.secondary-action {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.75rem;
  font-weight: 500;
}

.secondary-action:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: none;
}

/* ---------- Progress ---------- */

.progress {
  margin-top: var(--space-5);
  height: 3px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.progress.is-active {
  opacity: 1;
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--duration-base) var(--ease-out);
}

/* Upload finished, analysis still running -- sweep instead of a stalled 100%. */
.progress.is-indeterminate .progress__bar {
  width: 40%;
  animation: sweep 1.4s var(--ease-out) infinite;
}

@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---------- Status ---------- */

#statusMsg {
  margin-top: var(--space-4);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

#statusMsg:empty {
  margin-top: 0;
}

.status-success { color: var(--success); }
.status-error   { color: var(--error); }

#analysisNote {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted);
}

#analysisNote:empty {
  margin-top: 0;
}

/* Status dot -- the one piece of dashboard vocabulary that earns its place. */
#analysisNote::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 0.4em;
  border-radius: 50%;
  background: currentColor;
}

.analysis-running {
  color: var(--warning);
}

.analysis-running::before {
  animation: pulse 1.6s var(--ease-out) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

.analysis-done   { color: var(--success); }
.analysis-failed { color: var(--error); }

#gateError:empty {
  display: none;
}

/* ---------- Motion preferences ---------- */

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

/* ---------- Small screens ---------- */

@media (max-width: 520px) {
  body {
    padding: var(--space-6) var(--space-3);
    align-items: flex-start;
  }

  .card {
    padding: var(--space-6);
  }
}
