/* Dipexer app. Layout: a calm work surface (navy/teal brand) around 16:9 slides that mirror the PowerPoint export. */
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/IBMPlexSansArabic-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("/static/fonts/IBMPlexSansArabic-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("/static/fonts/ReadexPro.ttf") format("truetype"); font-weight: 160 700; font-display: swap; }
/* slide fonts: the family names PowerPoint and LibreOffice see in the export */
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("/static/fonts/IBMPlexSansArabic-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("/static/fonts/IBMPlexSansArabic-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/static/fonts/Tajawal-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tajawal"; src: url("/static/fonts/Tajawal-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("/static/fonts/Almarai-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("/static/fonts/Almarai-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("/static/fonts/Amiri-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("/static/fonts/Amiri-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --navy: #14283f; --teal: #00857d; --teal-2: #19b3a6; --ink: #1b2430; --muted: #5b6670;
  --bg: #f3f5f4; --surface: #ffffff; --paper: #f6f7f5; --line: #dfe4e2; --danger: #b42318; --warn-bg: #fff4e5; --ok-bg: #e3f3f1;
  --display: "Readex Pro", "Plex Arabic", system-ui, sans-serif;
  --body: "Plex Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.65; }
a { color: var(--teal); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1160px; margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.page { padding-block: 28px 64px; display: grid; gap: 24px; }
h1, h2 { font-family: var(--display); line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h2 { font-size: 1.2rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.brand img { display: block; height: 32px; width: auto; }
.nav { display: flex; align-items: center; gap: 18px; font-size: 0.95rem; }
.nav a { color: var(--ink); text-decoration: none; }
.nav .who { color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav form { margin: 0; }
.nav a[aria-current="page"] { color: var(--teal); font-weight: 600; }
@media (max-width: 560px) { .nav { gap: 14px; } .nav .who { display: none; } }

/* --- hub (/) ---------------------------------------------------------------------------------- */
.hub-head { display: grid; gap: 6px; }
.products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.product { position: relative; display: grid; gap: 12px; align-content: start; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; text-decoration: none; color: var(--ink); }
.product:hover { border-color: var(--teal); }
.product p { color: var(--muted); }
.product .btn { justify-self: start; margin-top: 4px; }
.product-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--ok-bg); color: var(--teal); display: grid; place-items: center; }
.product-icon svg { width: 26px; height: 26px; }
.product.soon .product-icon { background: #e8edf2; color: var(--navy); }
.product-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.88rem; color: var(--muted); }
.product .tag { position: absolute; inset-block-start: 22px; inset-inline-end: 22px; font-size: 0.78rem; font-weight: 600; color: var(--navy);
  background: #e8edf2; border-radius: 999px; padding: 2px 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head a { font-size: 0.92rem; text-decoration: none; }
@media (max-width: 720px) { .products { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 14px; }
.narrow { max-width: 560px; }
.auth .page { place-items: center; min-height: calc(100vh - 70px); }
.auth-card { width: min(440px, 100%); }
.form { display: grid; gap: 8px; }
.form label { font-weight: 600; font-size: 0.95rem; margin-top: 6px; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid #cfd6d4; border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-2); outline-offset: 1px; border-color: var(--teal); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid #cfd6d4; background: var(--surface); color: var(--ink); border-radius: 10px; padding: 10px 18px; white-space: nowrap; }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: #006f68; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 6px 12px; font-size: 0.88rem; font-weight: 500; }
.link { font: inherit; background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; }
.link.danger { color: var(--danger); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--teal-2); outline-offset: 2px; }
.alert { background: var(--warn-bg); color: #8a4b00; border-radius: 10px; padding: 10px 14px; }

.create-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.quota { font-size: 0.85rem; background: var(--ok-bg); color: var(--teal); border-radius: 999px; padding: 3px 12px; font-weight: 600; }
.quota.full { background: var(--warn-bg); color: #8a4b00; }
.row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 4px; }
.row > div { display: grid; gap: 6px; min-width: 140px; }
.grow { flex: 1 1 180px; }

.decks { display: grid; gap: 12px; }
.deck-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.deck-item { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; text-decoration: none; color: var(--ink); }
.deck-item:hover { border-color: var(--teal); }
.deck-title { font-weight: 600; }
.deck-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); }
.status { font-weight: 600; }
.s-ready { color: var(--teal); } .s-failed { color: var(--danger); }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed #cfd6d4; border-radius: 12px; padding: 22px; text-align: center; }

/* --- editor ---------------------------------------------------------------------------------- */
.deck-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.deck-bar-title { display: grid; gap: 2px; min-width: 0; }
.back { font-size: 0.88rem; text-decoration: none; }
.deck-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.save-state { font-size: 0.85rem; color: var(--muted); }
.steps { margin: 0; padding-inline-start: 1.3em; display: grid; gap: 6px; color: var(--muted); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--teal); }
.hint { color: var(--muted); font-size: 0.92rem; }
.slides-list { display: grid; gap: 26px; }
.slide-block { display: grid; gap: 8px; max-width: 980px; }
.slide-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.slide-no { font-size: 0.8rem; color: var(--muted); margin-inline-end: auto; font-variant-numeric: tabular-nums; }
.rewrite { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rewrite input { width: min(280px, 100%); padding: 6px 10px; font-size: 0.9rem; }
.busy { opacity: 0.55; pointer-events: none; }
.notes summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.notes textarea { margin-top: 6px; min-height: 90px; font-size: 0.92rem; }
.danger-zone { margin-top: 10px; }

/* --- slides: positioned elements from layout.py (inches -> cqw; the PowerPoint export draws the same elements) --- */
.slide { container-type: inline-size; position: relative; aspect-ratio: 16 / 9; width: 100%; max-width: 100%; overflow: hidden;
  border-radius: 10px; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(20, 40, 63, 0.06); }
.slide .e { position: absolute; box-sizing: border-box; margin: 0; }
.slide .img { background-size: cover; background-position: center; background-color: rgba(0, 0, 0, 0.06); }
.slide .ic { -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center; }
.slide .ln { transform-origin: 0 50%; }
.slide .tri.left { clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.slide .tri.right { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.slide .logo { width: auto; pointer-events: none; }
.slide .tx { display: flex; flex-direction: column; }
.slide .tx.a-middle { justify-content: center; }
.slide .tx.a-bottom { justify-content: flex-end; }
.slide .tx-in { white-space: pre-wrap; overflow-wrap: normal; word-break: normal; min-width: 0; }
.slide .tbl { display: grid; align-content: start; }
.slide .tbl .cell { display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 1.1cqw; min-width: 0; }
.slide .tbl .cell:not(.num) { justify-content: flex-start; text-align: start; }   /* first column reads from the start, as in the export */
.slide .chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.slide [contenteditable] { border-radius: 3px; outline: none; cursor: text; }
.slide [contenteditable]:hover { box-shadow: 0 0 0 1px rgba(25, 179, 166, 0.6); }
.slide [contenteditable]:focus { box-shadow: 0 0 0 2px var(--teal-2); background: rgba(25, 179, 166, 0.08); }
.slide .img-busy { position: absolute; inset-block-end: 3cqw; inset-inline-end: 3cqw; background: rgba(20, 40, 63, 0.85); color: #fff;
  font-size: 1.3cqw; padding: 0.6cqw 1.2cqw; border-radius: 999px; z-index: 5; }
.slide-tools .lay { width: auto; padding: 5px 10px; font-size: 0.88rem; }
.theme-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.theme-pick select { width: auto; padding: 6px 10px; font-size: 0.9rem; }

/* --- admin ------------------------------------------------------------------------------------------ */
.admin-form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 0; }
.admin-form legend { font-weight: 600; padding: 0 6px; }
.admin-form select { min-width: 220px; }
.table-wrap { overflow-x: auto; }
.runs { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.runs th, .runs td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.runs th { color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
  .slide.with-photo .body { grid-template-columns: 1fr 34%; }
  .deck-actions { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .deck-item, .product { transition: border-color .15s, background-color .15s; } }
