/* Zen Resume — app styles on top of the prebuilt Tailwind file (style.css).
 * Text size, top bar, light/dark theme, resume "paper" (font / size / accent), Arabic + RTL. */

/* ---------- Text size: like Facebook (15px), large option for accessibility ---------- */
html { font-size: 15px; }
html[data-ui-size="large"] { font-size: 17px; }
html[lang="ar"] { font-size: 16px; }                    /* Arabic glyphs need a little more */
html[lang="ar"][data-ui-size="large"] { font-size: 18px; }
.zen-input { font-size: max(16px, 1.0667rem); }         /* ≥ 16px: iPhone doesn't zoom on focus */
h2.text-xl { font-size: 1.2rem; }                       /* step titles */

/* Arabic interface font (downloaded only in Arabic; falls back to system Arabic fonts offline) */
html[lang="ar"] body { font-family: 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif; }

/* ---------- Theme tokens ---------- */
:root {
  --bg: #f9fafb; --surface: #ffffff; --text: #1f2937; --muted: #6b7280;
  --border: #f3f4f6; --line: #e5e7eb; --hover: rgba(17, 24, 39, 0.06);
  --brand: #111827; --brand-text: #ffffff; --link: #2563eb;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1120; --surface: #111827; --text: #e5e7eb; --muted: #9ca3af;
  --border: #1f2937; --line: #374151; --hover: rgba(255, 255, 255, 0.08);
  --brand: #f3f4f6; --brand-text: #111827; --link: #60a5fa;
  color-scheme: dark;
}
body { background: var(--bg) !important; color: var(--text); }

/* Dark: re-colour the Tailwind classes the app uses (outside the resume paper) */
[data-theme="dark"] .bg-white { background: var(--surface); }
[data-theme="dark"] .bg-gray-50 { background: #0f172a; }
[data-theme="dark"] .bg-gray-100 { background: #1f2937; }
[data-theme="dark"] .bg-gray-200, [data-theme="dark"] .hover\:bg-gray-200:hover { background: #374151; }
[data-theme="dark"] .text-gray-900, [data-theme="dark"] .text-gray-800 { color: #f3f4f6; }
[data-theme="dark"] .text-gray-700, [data-theme="dark"] .text-gray-600 { color: #d1d5db; }
[data-theme="dark"] .text-gray-500 { color: #9ca3af; }
[data-theme="dark"] .text-blue-600 { color: #60a5fa; }
[data-theme="dark"] .border-gray-100, [data-theme="dark"] .border-gray-200 { border-color: var(--border); }
[data-theme="dark"] .zen-input { border-bottom-color: var(--line); color: var(--text); }
[data-theme="dark"] .exp-block .zen-input { border-color: var(--line) !important; }
[data-theme="dark"] #btn-next { background: #f3f4f6; color: #111827; }
[data-theme="dark"] .btn-dark { background: #f3f4f6; color: #111827; }
[data-theme="dark"] dialog.zen-dialog { background: var(--surface); color: var(--text); }
[data-theme="dark"] .resume-item { background: #0f172a; border-color: var(--border); }
[data-theme="dark"] #publish-panel:not(:empty) { background: #172554; color: #dbeafe; }
[data-theme="dark"] .pub-link input { background: #0b1120; color: var(--text); border-color: #1e3a8a; }
[data-theme="dark"] .badge { background: #374151; color: #e5e7eb; }
@media (max-width: 639px) {
  [data-theme="dark"] #wizard-controls { background: rgba(11, 17, 32, 0.94); border-top-color: var(--border); }
}

/* ---------- Top bar: one line, never wraps ---------- */
#app-header.topbar {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.brand { min-width: 0; }
.brand h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
#save-status { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 0.15rem; flex-shrink: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; min-width: 44px; padding: 0 0.7rem; border-radius: 999px;
  font-size: 0.93rem; font-weight: 500; color: var(--text); white-space: nowrap;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--hover); }
.icon-btn svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
#btn-account .lbl { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .icon-btn .lbl { display: none; }   /* phones: icons only, labels stay as aria-label/title */
  .icon-btn { padding: 0; }
}

/* ⋯ menu */
.menu-wrap { position: relative; }
#menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 0.35rem); z-index: 60;
  min-width: 15rem; max-width: calc(100vw - 1.5rem); padding: 0.35rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 0.85rem; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}
#menu[hidden] { display: none; }
#menu .mi {
  display: flex; align-items: center; gap: 0.65rem; width: 100%; min-height: 44px;
  padding: 0 0.75rem; border-radius: 0.55rem; text-align: start; font-size: 0.95rem; color: var(--text);
}
#menu .mi:hover { background: var(--hover); }
#menu .mi svg { width: 1.1rem; height: 1.1rem; opacity: 0.8; }
#menu .mi.danger { color: #dc2626; }
#menu hr { border: 0; border-top: 1px solid var(--border); margin: 0.3rem 0; }
#menu #btn-install { display: none; }
#menu #btn-install.show { display: flex; }

/* Segmented buttons (language, theme, size) */
.seg { display: flex; gap: 0.3rem; }
.seg button {
  flex: 1; min-height: 40px; padding: 0 0.5rem; border-radius: 0.55rem;
  border: 1px solid var(--line); font-size: 0.9rem; color: var(--text); background: transparent;
}
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
#menu .seg { padding: 0.35rem 0.4rem; }
.menu-label { font-size: 0.78rem; color: var(--muted); padding: 0.35rem 0.75rem 0; }

/* ---------- Settings dialog ---------- */
dialog.wide { width: min(40rem, calc(100vw - 1.5rem)); }
.set-section { margin-bottom: 1.5rem; }
.set-section > h3 { font-weight: 600; font-size: 1rem; margin-bottom: 0.15rem; }
.set-section > p.hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
.set-row { margin-bottom: 1rem; }
.set-row > .set-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 0.5rem; }
.font-card {
  display: block; text-align: start; padding: 0.6rem 0.75rem; border: 1px solid var(--line);
  border-radius: 0.7rem; background: transparent; color: var(--text); min-height: 44px;
}
.font-card[aria-pressed="true"] { border-color: var(--link); box-shadow: 0 0 0 2px var(--link) inset; }
.font-card .fc-name { display: block; font-size: 1.05rem; line-height: 1.3; }
.font-card .fc-note { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
.font-card .fc-rec { font-size: 0.68rem; padding: 0.05rem 0.4rem; border-radius: 999px; background: #dcfce7; color: #166534; margin-inline-start: 0.3rem; vertical-align: middle; }
[data-theme="dark"] .font-card .fc-rec { background: #14532d; color: #dcfce7; }
.font-group { font-size: 0.8rem; color: var(--muted); margin: 0.75rem 0 0.4rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch {
  width: 40px; height: 40px; border-radius: 999px; border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.swatch { box-shadow: 0 0 0 1px var(--line), inset 0 0 0 1px rgba(255, 255, 255, 0.35); } /* dark swatch stays visible on a dark page */
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--link), inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
select.zen-select {
  width: 100%; min-height: 44px; padding: 0 0.75rem; border-radius: 0.55rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px;
}

/* ---------- Resume paper: font, size, accent, direction come from the resume's style ---------- */
#resume-output.paper {
  --accent: #111827;
  font-family: var(--resume-font, inherit);
  font-size: var(--resume-size, 15px);
  line-height: 1.55;
  color: #1f2937;
}
#resume-output.paper .text-4xl { font-size: 2.2em; line-height: 1.15; }
#resume-output.paper .text-xl { font-size: 1.25em; line-height: 1.4; }
#resume-output.paper .text-lg { font-size: 1.1em; }
#resume-output.paper .text-sm { font-size: 0.9em; }
#resume-output.paper header { border-bottom: 2px solid var(--accent); }
#resume-output.paper h1 { color: var(--accent); }
#resume-output.paper h2 { color: var(--accent); }
#resume-output.paper[dir="rtl"] h2 { letter-spacing: 0; text-transform: none; }   /* no CAPS in Arabic */
@media (max-width: 639px) {
  #resume-output.paper .text-4xl { font-size: 1.75em; line-height: 1.2; }
}
/* Dark theme: the resume stays a white sheet of paper */
[data-theme="dark"] #resume-output.paper { background: #fff; border-radius: 0.75rem; padding: 1.5rem; }
[data-theme="dark"] #resume-output.paper .text-gray-900 { color: #111827; }
[data-theme="dark"] #resume-output.paper .text-gray-700 { color: #374151; }
[data-theme="dark"] #resume-output.paper .text-gray-600 { color: #4b5563; }
[data-theme="dark"] #resume-output.paper .text-gray-500 { color: #6b7280; }
[data-theme="dark"] #resume-output.paper .bg-gray-100 { background: #f3f4f6; }
[data-theme="dark"] #resume-output.paper .border-gray-200 { border-color: #e5e7eb; }

/* Inputs: let the browser pick direction per field (Arabic name in a French CV, etc.) */
.zen-input[dir="auto"] { text-align: start; }

/* ---------- Print: always light, A4 ---------- */
@page { size: A4; margin: 14mm 16mm; }
@media print {
  :root, [data-theme="dark"] { --bg: #fff; --surface: #fff; }
  body { background: #fff !important; }
  #app > main { box-shadow: none !important; border: 0 !important; padding: 0 !important; background: #fff !important; }
  [data-theme="dark"] #resume-output.paper { padding: 0; }
  #menu, .top-actions { display: none !important; }
}
