/* ══ كِتابي — design tokens (neo-brutalist editorial, light-first) ══ */
:root {
  --font-display: 'Baloo Bhaijaan 2', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;

  --red: #E14434;
  --yellow: #F5B301;
  --violet: #7C6CF0;
  --teal: #1FA9A0;
  --sky: #3FA9F5;
  --leaf: #4F9D3A;
  --pink: #E85D9B;
  --clay: #92400E;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --border-w: 3px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

:root[data-theme="light"] {
  --bg: #FFFBEB;
  --bg-soft: #FFF4D6;
  --surface: #FFFFFF;
  --surface-2: #F6F6F6;
  --ink: #111827;
  --muted: #57534E;
  --accent: #D97706;
  --accent-2: #92400E;
  --on-accent: #FFFFFF;
  --border: #111827;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --success: #2F8F4E;
  --danger: #DC2626;
  --ring: #D97706;
}

:root[data-theme="dark"] {
  --bg: #15141A;
  --bg-soft: #1D1B23;
  --surface: #201E26;
  --surface-2: #26242D;
  --ink: #F8F3E6;
  --muted: #B9B2A6;
  --accent: #F5B301;
  --accent-2: #F0A500;
  --on-accent: #14120F;
  --border: #F8F3E6;
  --shadow: 6px 6px 0 #000000;
  --shadow-sm: 4px 4px 0 #000000;
  --success: #55C46F;
  --danger: #FF6B6B;
  --ring: #F5B301;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
#paper-noise {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(17,24,39,.10) 1px, transparent 1px);
  background-size: 22px 22px;
}
:root[data-theme="dark"] #paper-noise { background-image: radial-gradient(rgba(248,243,230,.09) 1px, transparent 1px); }

/* ══ Typography ══ */
h1, h2, h3, h4, .brand-text { font-family: var(--font-display); font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2.3rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: .95rem; }
p { color: var(--muted); }
a { color: inherit; text-decoration: none; }
strong { font-weight: 700; }
.muted { color: var(--muted); }
.kick {
  display: inline-block; font-family: var(--font-display); font-size: .8rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent-2);
  background: var(--bg-soft); border: var(--border-w) solid var(--border);
  border-radius: 999px; padding: .2rem .85rem; margin-bottom: .9rem;
}
:root[data-theme="dark"] .kick { color: var(--accent); }
.hl { display: inline-block; padding: 0 .35rem; border: var(--border-w) solid var(--border); border-radius: 8px; transform: rotate(-1.4deg); }
.hl-red { background: var(--red); color: #FFF; }
.hl-yellow { background: var(--yellow); color: #14120F; transform: rotate(1.2deg); }
.hl-violet { background: var(--violet); color: #FFF; }

/* ══ Layout ══ */
.section { max-width: 1200px; margin: 0 auto; padding: 4.5rem 1.5rem; position: relative; }
.section-head { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-end; justify-content: space-between; margin-bottom: 2rem; }
.section-head.center { justify-content: center; text-align: center; }
.section-head.center .muted { max-width: 640px; margin: .5rem auto 0; }
.grid { display: grid; gap: 1.35rem; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }

/* ══ Surfaces ══ */
.card, .panel {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.pill, .badge, .count {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 700;
  padding: .16rem .6rem; border-radius: 999px; border: 2px solid var(--border);
  background: var(--bg-soft); color: var(--ink);
}
.badge { background: var(--surface); border-radius: 999px; font-size: .78rem; padding: .3rem .85rem; }
.pill { background: var(--surface-2); }
.count { min-width: 1.5rem; justify-content: center; background: var(--accent); color: var(--on-accent); border-color: var(--border); }

/* ══ Buttons ══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-display); font-size: .95rem; font-weight: 700;
  padding: .62rem 1.3rem; border-radius: 999px; cursor: pointer;
  border: var(--border-w) solid var(--border); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), background .18s var(--ease);
  min-height: 44px;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ink { background: var(--ink); color: var(--bg); }
.btn-ghost { background: var(--surface); }
.btn-soft { background: var(--bg-soft); }
.btn-lg { font-size: 1.05rem; padding: .8rem 1.7rem; }
.btn-block { width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  font-family: var(--font-body); font-size: .8rem; font-weight: 600;
  padding: .35rem .8rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink);
  border: 2px solid var(--border);
  transition: transform .14s var(--ease), background .18s var(--ease), color .18s var(--ease);
  min-height: 36px;
}
.chip:hover { transform: translateY(-2px); background: var(--bg-soft); }
.chip.active { background: var(--ink); color: var(--bg); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: var(--border-w) solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.icon-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.btn i, .chip i, .icon-btn i { width: 18px; height: 18px; }
.btn-lg i { width: 20px; height: 20px; }

/* ══ Fields ══ */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > span { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: .95rem; color: var(--ink);
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .85rem; outline: none;
  transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
textarea { resize: vertical; line-height: 1.7; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
.chip:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
input.error, textarea.error { border-color: var(--danger); box-shadow: 4px 4px 0 var(--danger); }
.field-error { font-size: .78rem; font-style: normal; color: var(--danger); font-weight: 600; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }

/* ══ Toast ══ */
.toast-wrap { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; }
.toast {
  display: flex; align-items: center; gap: .55rem;
  padding: .7rem 1.1rem; font-size: .9rem; font-weight: 600;
  background: var(--surface); color: var(--ink);
  border: var(--border-w) solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); animation: pop .22s var(--ease);
}
.toast.success { background: var(--success); color: #FFF; }
.toast.error { background: var(--danger); color: #FFF; }
.toast.info { background: var(--ink); color: var(--bg); }
.toast i { width: 18px; height: 18px; }

/* ══ Modal ══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(17,24,39,.55); backdrop-filter: blur(3px);
  animation: fade .18s var(--ease);
}
.modal {
  width: 100%; max-width: 520px; max-height: 84vh; overflow: auto;
  background: var(--surface); border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.4rem;
  animation: pop .22s var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; border-bottom: 2px dashed var(--border); padding-bottom: .8rem; }
.modal-head h3 { display: flex; align-items: center; gap: .5rem; }

/* ══ Empty + skeleton ══ */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }
.empty i { width: 42px; height: 42px; margin-bottom: .6rem; }
.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-soft) 50%, var(--surface-2) 75%); background-size: 220%; animation: shimmer 1.3s infinite linear; }

/* ══ Animations ══ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes wiggle { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.reveal { opacity: 0; }
.reveal.in { animation: fadeUp .55s var(--ease) forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; }
}
