:root {
  --navy: #0d2f63;
  --primary: #2f80ed;
  --primary-dark: #1c63c7;
  --green: #2e9e7b;
  --yellow: #f5c542;
  --bg: #f4f8fd;
  --card: #ffffff;
  --text: #1c2a3d;
  --muted: #5b6b80;
  --border: #d5e2f2;
  --error: #b00020;
  --error-bg: #fdecea;
  --success: #1a7f37;
  --success-bg: #e8f6ee;
}

* {
  box-sizing: border-box;
}

/* Author display rules (e.g. display:flex) would otherwise override the
   browser's default [hidden] styling and keep hidden elements visible. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #f7faff 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Faint dotted "world map" texture behind the hero */
.bg-map {
  position: absolute;
  inset: 0 0 auto 0;
  height: 620px;
  background-image: radial-gradient(#c9d9ee 1.2px, transparent 1.3px);
  background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(ellipse 75% 50% at 50% 35%, #000 20%, transparent 80%);
  mask-image: radial-gradient(ellipse 75% 50% at 50% 35%, #000 20%, transparent 80%);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  /* Full width: no max-width cap, only a slim gutter so text doesn't
     touch the screen edge. Fills at least the full viewport height. */
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 40px clamp(16px, 3vw, 56px) 32px;
  display: flex;
  flex-direction: column;
}

/* ─── Hero ──────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: 24px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.title-underline {
  display: block;
  width: 110px;
  height: 6px;
  margin: 18px 0 20px;
  border-radius: 3px;
  background: var(--yellow);
}

.tagline {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  line-height: 1.4;
  color: #26374f;
  max-width: 560px;
}

.accent {
  color: var(--green);
  font-weight: 700;
}

.hero-art {
  display: flex;
  justify-content: flex-end;
}

.hero-art svg {
  width: 100%;
  /* On very wide screens, keep the illustration from growing huge */
  max-height: 46vh;
  height: auto;
  display: block;
}

/* ─── Upload panel ──────────────────────────────────────────────────── */

.upload-panel {
  position: relative;
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 26px 28px;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px dashed #b9cde8;
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(31, 79, 143, 0.08);
  backdrop-filter: blur(4px);
}

.bubble {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: var(--green);
  color: #fff;
  font-family: "Noto Sans Bengali", sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(46, 158, 123, 0.3);
}

.bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 26px;
  border-width: 10px 10px 0 0;
  border-style: solid;
  border-color: var(--green) transparent transparent transparent;
}

.dropzone {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 14px 18px;
  border: 2px dashed transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropzone:hover {
  background: #f3f8ff;
}

/* Active while a file is dragged over the zone */
.dropzone.dragover {
  background: #e9f2ff;
  border-color: var(--primary);
}

.dropzone.has-file .dz-file {
  color: var(--navy);
  font-weight: 600;
}

.dropzone.invalid {
  border-color: var(--error);
  background: #fff6f6;
}

.dropzone:has(input:disabled) {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Visually hidden but still focusable, so keyboard users can reach it. */
.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.cloud-icon {
  flex: 0 0 auto;
  width: 84px;
}

.cloud-icon svg {
  width: 100%;
  display: block;
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.dz-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
}

.dz-file {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dz-meta {
  color: #3d4d63;
  font-size: 0.95rem;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

button {
  font: inherit;
  cursor: pointer;
}

.btn-primary {
  flex: 0 0 auto;
  min-width: 210px;
  padding: 18px 34px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(47, 128, 237, 0.3);
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:disabled {
  background: #a9c3e6;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-download,
.btn-secondary {
  display: block;
  padding: 13px 18px;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  text-decoration: none;
}

.btn-download {
  background: var(--green);
  color: #fff;
}

.btn-download:hover {
  background: #23835f;
}

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-secondary:hover {
  background: #eef5ff;
}

/* Visible keyboard focus */
button:focus-visible,
.btn-download:focus-visible,
.dropzone:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* ─── Status + results ──────────────────────────────────────────────── */

.status {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #eaf2ff;
  color: var(--text);
}

.status-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #bcd3f5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.status.error,
.status.success {
  font-weight: 500;
}

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

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

.status.error .spinner,
.status.success .spinner {
  display: none;
}

.elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.9rem;
}

.result-actions {
  margin-top: 16px;
  display: flex;
  gap: 14px;
}

.result-actions > * {
  flex: 1;
}

.preview-card {
  margin-top: 22px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(31, 79, 143, 0.06);
}

.preview-card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--navy);
  overflow-wrap: anywhere;
}

#pdf-preview {
  width: 100%;
  height: 80vh;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafcff;
}

.preview-note {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ─── Footer notes ──────────────────────────────────────────────────── */

.notes {
  /* Pushes the notes to the bottom of the screen when content is short */
  margin-top: auto;
  padding-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.note {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 1.1rem;
  color: var(--text);
}

.note.warn {
  font-size: 0.95rem;
  color: #3d4d63;
}

.note-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.note-icon.lang {
  background: var(--navy);
  border-radius: 50%;
}

.note-icon svg {
  width: 26px;
  height: 26px;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-art {
    max-width: 440px;
    margin: 0 auto;
  }

  .upload-panel {
    flex-direction: column;
    align-items: stretch;
    padding-top: 34px;
  }

  .btn-primary {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 24px 12px;
  }

  .dropzone {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .dropzone-text {
    align-items: center;
  }

  .result-actions {
    flex-direction: column;
  }
}
