/* downly. — minimal, mono, sombre */

:root {
  --bg: #000000;
  --text: #e1e1e1;
  --text-dim: #8d8d8d;
  --border: #383838;
  --surface: #131313;
  --surface-hover: #222222;
  --accent: #ffffff;
  --accent-text: #000000;
  --danger: #ff5c5c;
  --radius: 11px;
  --font: "IBM Plex Mono", "Noto Sans Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

body.light {
  --bg: #ffffff;
  --text: #282828;
  --text-dim: #737373;
  --border: #e0e0e0;
  --surface: #f4f4f4;
  --surface-hover: #e9e9e9;
  --accent: #000000;
  --accent-text: #ffffff;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

/* ---------- barre du haut ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}

body.light .logo img,
body.light .logo-badge {
  filter: invert(1);
}

.icon-btn {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
}
.icon-btn:hover { background: var(--surface); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang-btn {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---------- zone centrale ---------- */

.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hero {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- animations d'entrée ---------- */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(3px); }
}

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

.hero-logo   { animation: fadeUp 0.55s ease both; }
.input-wrap  { animation: fadeUp 0.55s ease 0.1s both; }
.actions-row { animation: fadeUp 0.55s ease 0.18s both; }
.services    { animation: fadeUp 0.55s ease 0.26s both; }

.hero-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  text-align: center;
  position: relative;
}

/* halo lumineux qui respire derrière le logo */
.hero-logo::before {
  content: '';
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.09) 0%, transparent 65%);
  animation: glowPulse 5s ease-in-out infinite;
  pointer-events: none;
}

body.light .hero-logo::before {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.07) 0%, transparent 65%);
}

.logo-badge {
  width: 140px;
  height: 140px;
  filter: drop-shadow(0 8px 28px rgba(255, 255, 255, 0.12));
  animation: float 6s ease-in-out infinite;
  transition: transform 0.25s ease;
}

.logo-badge:hover {
  transform: scale(1.06) rotate(-3deg);
}

body.light .logo-badge {
  filter: invert(1) drop-shadow(0 8px 28px rgba(0, 0, 0, 0.25));
}

.hero-logo h1 {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
}

.hero-logo .tagline {
  font-size: 13px;
  color: var(--text-dim);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  height: 48px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within {
  border-color: var(--text);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.07);
}

body.light .input-wrap:focus-within {
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06);
}

.link-icon {
  flex-shrink: 0;
  color: var(--text-dim);
  transition: color 0.25s ease;
  transform-origin: center;
}

/* l'icône pulse à chaque frappe */
@keyframes iconPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35) rotate(-8deg); }
  100% { transform: scale(1); }
}
.link-icon.pop { animation: iconPop 0.25s ease; }

/* icône allumée quand le lien est valide */
.input-wrap.valid .link-icon { color: var(--text); }

/* reflet qui balaie la barre quand on colle */
@keyframes sweep {
  from { transform: translateX(-110%); }
  to   { transform: translateX(110%); }
}
.input-wrap {
  position: relative;
  overflow: hidden;
}
.input-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.16) 50%, transparent 70%);
  transform: translateX(-110%);
  pointer-events: none;
}
body.light .input-wrap::after {
  background: linear-gradient(105deg, transparent 30%, rgba(0, 0, 0, 0.08) 50%, transparent 70%);
}
.input-wrap.pasted::after { animation: sweep 0.55s ease; }

/* la croix d'effacement apparaît en pop */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}
#clearBtn:not(.hidden) { animation: popIn 0.18s ease; }

#urlInput {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
#urlInput::placeholder { color: var(--text-dim); }

.mini-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 7px 11px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.mini-btn:hover { background: var(--surface-hover); }
.mini-btn:active { transform: scale(0.95); }

/* ---------- rangée d'actions ---------- */

.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.primary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
.primary-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.primary-btn:active { transform: scale(0.96); }
.primary-btn:disabled { opacity: 0.4; cursor: default; }

/* flèche qui rebondit pendant l'analyse */
.primary-btn.loading svg {
  animation: bounceDown 0.7s ease-in-out infinite;
}

/* ---------- statut ---------- */

.status {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  animation: fadeUp 0.3s ease both;
}
.status.error { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
.status.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* ---------- carte résultat ---------- */

.card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pop 0.25s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-media {
  position: relative;
  background: var(--surface);
}
.card-media img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.45s ease, transform 0.6s ease;
}

.card-media img.loaded {
  opacity: 1;
  transform: scale(1);
}
.card-media img[src=""] { display: none; }

.badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
}
.badge:empty { display: none; }

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-body h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.source-tag {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  text-transform: lowercase;
}
.source-tag:empty { display: none; }

/* ---------- boutons de qualité ---------- */

.qualities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.q-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  padding: 10px 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.q-btn { animation: fadeUp 0.35s ease both; }
.q-btn:hover { background: var(--surface-hover); border-color: var(--border); transform: translateY(-2px); }
.q-btn:active { transform: scale(0.97); }
.q-btn:disabled { opacity: 0.4; cursor: default; }

.q-btn .q-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
}
.q-btn .q-detail { font-size: 11.5px; color: var(--text-dim); }

/* ---------- progression ---------- */

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: var(--surface);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 40%, rgba(255, 255, 255, 0.55) 50%, var(--accent) 60%);
  background-size: 200% 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
  animation: shimmer 1.6s linear infinite;
}

body.light .progress-bar {
  background: linear-gradient(90deg, var(--accent) 40%, rgba(80, 80, 80, 0.75) 50%, var(--accent) 60%);
  background-size: 200% 100%;
}

#progressText {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 90px;
  text-align: right;
}

/* ---------- divers ---------- */

.services {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
  margin-top: 6px;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.visit-count {
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  opacity: 0.8;
}
.visit-count:empty { display: none; }

/* ---------- onglets d'outils ---------- */

.tool-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  animation: fadeUp 0.55s ease 0.06s both;
}

.tool-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tool-tab:hover { color: var(--text); }
.tool-tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

/* ---------- transcription ---------- */

.transcript-box {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: pop 0.25s ease;
}

.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  flex-wrap: wrap;
}

.transcript-meta { font-size: 12px; color: var(--text-dim); }

.transcript-actions { display: flex; gap: 6px; }

.transcript-text {
  margin: 0;
  padding: 14px;
  max-height: 340px;
  overflow-y: auto;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---------- dons ---------- */

.donate-top {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.donate-top:hover { background: var(--surface); }

.donate-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
  animation: fadeUp 0.55s ease 0.3s both;
}
.donate-card:hover {
  border-color: var(--text-dim);
  transform: translateY(-2px);
}

.donate-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface);
}

.donate-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.donate-body strong { font-size: 13.5px; }
.donate-body span { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }

.donate-cta {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius);
  padding: 9px 15px;
  font-size: 12.5px;
  font-weight: 700;
}

@media (max-width: 560px) {
  .donate-card { flex-wrap: wrap; }
  .donate-cta { width: 100%; text-align: center; }
}

.hidden { display: none !important; }

/* respecte les préférences d'accessibilité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  .actions-row { flex-direction: column; align-items: stretch; }
  .segmented { justify-content: center; }
  .primary-btn { justify-content: center; }
  .footer { justify-content: center; text-align: center; }
}
