/* =========================================================
   QUNDIR — retro theme
   Colors are variables at the top: change them in one place.
   ========================================================= */

/* ---------- Fonts (self-hosted, no Google requests) ---------- */
@font-face {
  font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/press-start-2p-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/press-start-2p-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "VT323"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/vt323-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "VT323"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/vt323-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Reem Kufi"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/reem-kufi-arabic-400-normal.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Reem Kufi"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(../fonts/reem-kufi-arabic-700-normal.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ---------- Colors ---------- */
:root {
  --bg: #efe6cf;
  --dots: #d9cdaf;
  --paper: #fffaf0;
  --ink: #1d1a24;
  --muted: #554e60;
  --line: #1d1a24;
  --shadow: #1d1a24;
  --accent: #ff5d3a;     /* title bars, buttons */
  --accent-2: #ffd23f;   /* highlights */
  --accent-3: #7fd1ae;   /* tags */
  --on-accent: #1d1a24;
  --link: #1f4fd6;
  --ok: #1e7a4c;
  --bad: #b3261e;

  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: "VT323", "Courier New", monospace;
  --radius: 0;
  --gap: clamp(12px, 2.5vw, 24px);
  --max: 1120px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131c;
    --dots: #24202f;
    --paper: #1f1b2a;
    --ink: #f3ecd8;
    --muted: #bdb4cb;
    --line: #f3ecd8;
    --shadow: #000;
    --accent: #ff7a59;
    --accent-2: #ffd23f;
    --accent-3: #7fd1ae;
    --on-accent: #15131c;
    --link: #9bbcff;
    --ok: #7fd1ae;
    --bad: #ff8a80;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dots) 1px, transparent 1px);
  background-size: 8px 8px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1.2rem, 1.1rem + 0.35vw, 1.4rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Arabic: readable system font for text, Reem Kufi (blocky, retro feel) for titles */
[dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", sans-serif; font-size: clamp(1.05rem, 1rem + 0.25vw, 1.15rem); line-height: 1.75; }
[dir="rtl"] [lang]:not([lang="ar"]) { font-family: var(--font-body); }
[dir="rtl"] .prose[lang]:not([lang="ar"]), [dir="rtl"] .card-body[lang]:not([lang="ar"]) { font-size: 1.15em; line-height: 1.35; }

[hidden] { display: none !important; }
img { max-width: 100%; height: auto; display: block; }

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px dashed var(--accent); outline-offset: 3px; }

h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; font-weight: 400; }
h1 { font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.8rem); }
h2 { font-size: clamp(1.6rem, 1.4rem + 0.8vw, 2rem); }
h3 { font-size: 1.35em; }
p { margin: 0 0 .9em; }

.h-pixel, .hero h1, .logo-text, .win-bar, .btn, .footer-name, .card-noimg {
  font-family: var(--font-pixel);
  letter-spacing: 0;
}
.h-pixel { font-size: clamp(.95rem, .8rem + .8vw, 1.35rem); line-height: 1.6; text-transform: uppercase; }
.h-small { font-family: var(--font-pixel); font-size: .8rem; text-transform: uppercase; margin-top: 1.5em; }

[dir="rtl"] .h-pixel, [dir="rtl"] .hero h1, [dir="rtl"] .win-bar, [dir="rtl"] .btn, [dir="rtl"] .h-small {
  font-family: "Reem Kufi", "Segoe UI", Tahoma, sans-serif;
  font-weight: 700;
  text-transform: none;
}
[dir="rtl"] .h-pixel { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.8rem); }
[dir="rtl"] .arrow { display: inline-block; transform: scaleX(-1); }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: 16px; }
main.wrap { flex: 1; padding-block: var(--gap) calc(var(--gap) * 2); }
main:focus { outline: none; }

.muted { color: var(--muted); }
.small { font-size: .9em; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.skip {
  position: absolute; inset-inline-start: 8px; top: -100px; z-index: 100;
  background: var(--accent-2); color: #1d1a24; padding: 8px 12px; border: 3px solid var(--line);
}
.skip:focus { top: 8px; }

/* ---------- Window (the main retro box) ---------- */
.win {
  background: var(--paper);
  border: 3px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  min-width: 0;
}
[dir="rtl"] .win { box-shadow: -6px 6px 0 var(--shadow); }

.win-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  background: var(--accent);
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.08) 0 2px, transparent 2px 4px);
  color: var(--on-accent);
  border-bottom: 3px solid var(--line);
  font-size: .62rem;
  line-height: 1.4;
  overflow: hidden;
}
.win-bar > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btns { display: inline-flex; gap: 5px; flex-shrink: 0; }
.win-btns i { width: 12px; height: 12px; border: 2px solid var(--on-accent); background: var(--paper); display: block; }
.win-body { padding: clamp(14px, 3vw, 28px); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--paper);
  border-bottom: 3px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.bar { display: flex; align-items: center; gap: 12px 20px; padding-block: 10px; flex-wrap: wrap; }

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo-mark {
  width: 22px; height: 22px; background: var(--accent); border: 3px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
}
.logo-text { font-size: .9rem; }

.menu { display: flex; flex-wrap: wrap; gap: 4px; margin-inline-start: auto; }
.menu a {
  color: var(--ink); text-decoration: none; padding: 4px 10px; border: 2px solid transparent;
  font-size: 1.15em;
}
.menu a:hover { border-color: var(--line); }
.menu a[aria-current="page"] { background: var(--accent-2); color: #1d1a24; border-color: var(--line); }

.langs { position: relative; }
.langs summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--line); padding: 3px 10px; background: var(--paper); font-size: 1.1em;
}
.langs summary::-webkit-details-marker { display: none; }
.langs summary::after { content: "\25BE"; }
.globe {
  width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 50%;
  background: linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat,
              linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
}
.langs ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--paper); border: 3px solid var(--line); box-shadow: 4px 4px 0 var(--shadow);
  min-width: 160px; z-index: 30;
}
.langs li a { display: block; padding: 4px 8px; color: var(--ink); text-decoration: none; }
.langs li a:hover, .langs li a:focus-visible { background: var(--accent-2); color: #1d1a24; }
.langs li a[aria-current="true"] { font-weight: 700; text-decoration: underline; }

@media (max-width: 640px) {
  .bar { gap: 8px 12px; }
  .menu { order: 3; width: 100%; margin-inline-start: 0; justify-content: space-between; }
  .menu a { padding: 4px 6px; }
  .langs { margin-inline-start: auto; }
}
@media (max-width: 400px) {
  .menu a { padding: 4px 3px; font-size: 1.05em; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  background: var(--accent); color: var(--on-accent);
  border: 3px solid var(--line); box-shadow: 4px 4px 0 var(--shadow);
  font-size: .68rem; line-height: 1.4; text-transform: uppercase; text-decoration: none;
  cursor: pointer; text-align: center;
}
.btn:hover { background: var(--accent-2); color: #1d1a24; }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--shadow); }
.btn-brand { text-transform: none; }
.btn-alt { background: var(--paper); color: var(--ink); }
[dir="rtl"] .btn { box-shadow: -4px 4px 0 var(--shadow); font-size: 1rem; }
[dir="rtl"] .btn:active { transform: translate(-4px, 4px); }

.linklike {
  background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 1em 0 1.2em; }

/* ---------- Hero ---------- */
.hero { margin-bottom: calc(var(--gap) * 2); }
.hero-body { padding-block: clamp(24px, 6vw, 56px); }
.prompt { color: var(--muted); font-size: 1.2em; margin-bottom: 1em; }
.cursor {
  display: inline-block; width: .6em; height: 1em; margin-inline-start: 4px; vertical-align: -0.12em;
  background: currentColor; animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.hero h1 { font-size: clamp(1.15rem, .8rem + 2.4vw, 2.4rem); line-height: 1.5; max-width: 22ch; }
[dir="rtl"] .hero h1 { font-size: clamp(1.7rem, 1.2rem + 2.4vw, 3rem); max-width: 26ch; }
.lead { font-size: 1.2em; color: var(--muted); max-width: 60ch; }

/* ---------- Sections / grids ---------- */
.block { margin-bottom: calc(var(--gap) * 2.2); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.more { font-size: 1.05em; }
.page-head { margin-bottom: var(--gap); }

.grid { display: grid; gap: calc(var(--gap) + 6px); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-form { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .grid-form { grid-template-columns: 1fr; } }

.service h3 { font-size: 1.4em; }
.service p { margin: 0; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  display: flex; flex-direction: column;
  background: var(--paper); border: 3px solid var(--line); box-shadow: 6px 6px 0 var(--shadow);
  transition: transform .12s steps(2), box-shadow .12s steps(2);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--shadow); }
[dir="rtl"] .card { box-shadow: -6px 6px 0 var(--shadow); }
[dir="rtl"] .card:hover { transform: translate(2px, -2px); box-shadow: -8px 8px 0 var(--shadow); }
.card-link { color: inherit; text-decoration: none; display: flex; flex-direction: column; flex: 1; }
.card-link:hover .card-title { text-decoration: underline; }
.card-img { aspect-ratio: 16 / 10; border-bottom: 3px solid var(--line); background: var(--accent-2); overflow: hidden; display: grid; place-items: center; }
.card-img img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.card-noimg { font-size: 2.4rem; color: #1d1a24; }
.card-body { padding: 14px 16px 6px; flex: 1; }
.card-title { font-size: 1.65rem; margin-bottom: .3em; }
[dir="rtl"] .card-title { font-size: 1.15rem; }
.card-body p { color: var(--muted); margin: 0; }
.card .tags { padding: 8px 16px 16px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tags li { direction: ltr; unicode-bidi: isolate; background: var(--accent-3); color: #1d1a24; border: 2px solid var(--line); padding: 0 8px; font-size: .9em; }

/* ---------- Post / page ---------- */
.crumbs { margin-bottom: 14px; }
.post-head h1 { margin-bottom: .2em; }
.meta { color: var(--muted); }
.post-head .tags { margin-bottom: 1em; }
.cover { margin: 0 0 1em; border: 3px solid var(--line); }
.cover img { width: 100%; max-height: 520px; object-fit: cover; }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.4em; }
.prose h3 { margin-top: 1.2em; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: 0 0 1em; }
.prose li { margin-bottom: .25em; }
.prose ul { list-style: square; }
.prose img { border: 3px solid var(--line); margin: 1em 0; }
.prose blockquote { margin: 1em 0; padding: 8px 16px; border-inline-start: 6px solid var(--accent); background: var(--bg); }
.prose code { background: var(--bg); padding: 0 4px; border: 1px solid var(--line); }
.prose .table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 3px solid var(--line); -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; min-width: 560px; background: var(--paper); }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; text-align: start; vertical-align: top; }
.prose th { background: var(--bg); }
.table-wrap:focus { outline: 3px solid var(--link); outline-offset: 2px; }
.prose pre { background: #1d1a24; color: #f3ecd8; padding: 14px; overflow-x: auto; border: 3px solid var(--line); }
.prose pre code { background: none; border: 0; padding: 0; }
.prose hr { border: 0; border-top: 3px dashed var(--line); margin: 1.6em 0; }
.page { max-width: 900px; margin-inline: auto; }
.note { background: var(--accent-2); color: #1d1a24; border: 2px solid var(--line); padding: 6px 10px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; margin: 1em 0; }
.gallery a { display: block; border: 3px solid var(--line); background: var(--bg); }
.gallery img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }

.embed { position: relative; aspect-ratio: 16 / 9; border: 3px solid var(--line); background: #000; margin: 1em 0; display: grid; place-items: center; overflow: hidden; }
.embed img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.embed .embed-play { position: relative; }
.embed-note { position: absolute; bottom: 6px; inset-inline: 8px; margin: 0; color: #fff; font-size: .85em; text-align: center; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- CTA ---------- */
.cta { background: var(--accent-2); color: #1d1a24; text-align: center; }
.cta .win-body { padding-block: clamp(24px, 5vw, 48px); }
.cta p { max-width: 55ch; margin-inline: auto; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 4px; }
input[type="text"], input[type="email"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 3px solid var(--line); padding: 8px 10px; border-radius: 0;
}
textarea { resize: vertical; min-height: 140px; }
.field.check { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.field.check input { width: 22px; height: 22px; margin: 4px 0 0; accent-color: var(--accent); }
.field.check label { margin: 0; }
.field.check .err { grid-column: 1 / -1; }
.has-error input, .has-error textarea { border-color: var(--bad); }
.err { color: var(--bad); margin: 4px 0 0; }
.alert { border: 3px solid var(--line); padding: 10px 14px; margin-bottom: 16px; color: #1d1a24; }
.alert.ok { background: var(--accent-3); }
.alert.bad { background: #ffc9c2; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.side .social { margin-top: 10px; }

/* ---------- Social ---------- */
.prose .social, .social { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 10px 0 0; }
.social li { margin: 0; }
.social a {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 3px solid var(--line); background: var(--paper); color: var(--ink);
  text-decoration: none; font-family: var(--font-pixel); font-size: .6rem;
  box-shadow: 3px 3px 0 var(--shadow);
}
.social a:hover { background: var(--accent-2); color: #1d1a24; }

/* ---------- Footer ---------- */
.footer { background: var(--paper); border-top: 3px solid var(--line); padding-block: 28px 18px; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-name, .footer-head { font-family: var(--font-pixel); font-size: .75rem; margin-bottom: .8em; }
.footer-head { text-transform: uppercase; }
[dir="rtl"] .footer-head, [dir="rtl"] .footer-name { font-family: "Reem Kufi", "Segoe UI", Tahoma, sans-serif; font-weight: 700; font-size: 1rem; }
.footer-links { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 20px; }
.footer-links li { margin-bottom: 4px; break-inside: avoid; }
.copy { margin: 20px 0 0; padding-top: 12px; border-top: 2px dashed var(--line); color: var(--muted); font-size: .95em; }

/* ---------- Consent ---------- */
.consent { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 50; max-width: 560px; }
.consent[hidden] { display: none; }
.consent .win-body { padding: 16px; }
.consent p { margin-bottom: 12px; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.consent-actions .btn { flex: 1 1 180px; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .footer, .consent, .actions, .skip { display: none !important; }
  .win, .card { box-shadow: none; }
}

/* Links on always-light boxes (yellow / green / pink) stay dark in both themes */
.cta a:not(.btn), .note a, .alert a { color: #1d1a24; }
