/* =====================================================================
   tools.css — components for the IslamicLearnings13 utility tools.
   Uses the existing design tokens from styles.css (colours, radii,
   shadows, fonts). Loaded AFTER styles.css so it extends, never
   overrides, the site theme. RTL-friendly (logical properties).
   ===================================================================== */

/* ---------- shared shell ---------- */
.tool-shell { display: grid; gap: 22px; }
.tool-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tool-bar .spacer { flex: 1 1 auto; }
.tool-sub { color: var(--muted); font-size: .95rem; margin: 0; }
.tool-panel { background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.tool-panel--flat { box-shadow: none; }
.tool-grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool-grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .tool-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tool-grid-2, .tool-grid-3 { grid-template-columns: 1fr; } }
.tool-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tool-kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.tool-kv:last-child { border-bottom: 0; }
.tool-kv strong { color: var(--ink); }
.tool-kv span { color: var(--muted); }
.tool-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--brand-050); color: var(--brand-800); border: 1px solid var(--brand-200); }
.tool-tag--mint { background: var(--mint-050); color: var(--mint-700); border-color: var(--mint-100); }
.tool-note { font-size: .86rem; color: var(--muted); background: var(--brand-050); border: 1px solid var(--brand-100); border-radius: var(--radius-sm); padding: 12px 14px; line-height: 1.55; }
.tool-note--warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.tool-danger { color: var(--danger-ink); }
.tool-empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--brand-500); outline-offset: 1px; border-color: var(--brand-400); }
.textarea { min-height: 96px; resize: vertical; }
.btn--sm { padding: 7px 13px; font-size: .88rem; }
.btn--icon { padding: 8px 10px; line-height: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--brand-200); border-top-color: var(--brand-700); border-radius: 50%; animation: ilspin .8s linear infinite; vertical-align: -2px; }
@keyframes ilspin { to { transform: rotate(360deg); } }

/* ---------- progress ring ---------- */
.ring { --val: 0; width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--brand-600) calc(var(--val) * 1%), var(--brand-100) 0);
  display: grid; place-items: center; position: relative; }
.ring::after { content: ""; position: absolute; inset: 12px; background: var(--bg-3); border-radius: 50%; }
.ring__label { position: relative; z-index: 1; text-align: center; line-height: 1.1; }
.ring__label b { font-size: 1.7rem; color: var(--ink); display: block; }
.ring__label span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- salaah tracker ---------- */
.salah-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 780px) { .salah-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .salah-grid { grid-template-columns: 1fr; } }
.salah-card { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 14px; text-align: center; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.salah-card:hover { transform: translateY(-3px); }
.salah-card.is-done { background: var(--mint-050); border-color: var(--mint-500); }
.salah-card__icon { font-size: 1.5rem; }
.salah-card__name { font-weight: 700; color: var(--ink); margin-top: 6px; }
.salah-card__time { font-size: .82rem; color: var(--muted); min-height: 1.1em; }
.salah-card__btn { margin-top: 10px; width: 100%; }
.salah-card.is-done .salah-card__btn { background: var(--mint-600); border-color: var(--mint-600); color: #fff; }
.day-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.day-strip__day { flex: 0 0 auto; width: 62px; text-align: center; }
.day-strip__dots { display: flex; gap: 3px; justify-content: center; margin: 6px 0; }
.day-strip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-100); }
.day-strip__dot.on { background: var(--mint-600); }
.day-strip__day.is-today { outline: 2px solid var(--brand-400); outline-offset: 3px; border-radius: 10px; }

/* ---------- calendar grids (fasting, journal history, etc.) ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; padding: 4px 0; }
.cal__cell { aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 10px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; padding: 3px; font: inherit; color: var(--ink); position: relative; }
.cal__cell:hover { border-color: var(--brand-400); }
.cal__cell.is-out { opacity: .35; cursor: default; }
.cal__cell.is-suggest { background: var(--brand-050); border-color: var(--brand-200); }
.cal__cell.is-fast { background: var(--mint-100); border-color: var(--mint-500); }
.cal__cell.is-today { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.cal__cell small { font-size: .58rem; color: var(--muted); }
.cal__cell b { font-size: .95rem; }
.cal__cell .hij { font-size: .6rem; color: var(--brand-800); }

/* ---------- flashcard ---------- */
.flash-scene { perspective: 1200px; }
.flashcard { position: relative; width: 100%; min-height: 260px; transform-style: preserve-3d; transition: transform .5s; cursor: pointer; }
.flashcard.is-flipped { transform: rotateY(180deg); }
.flashface { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-3); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px; }
.flashface--back { transform: rotateY(180deg); background: var(--brand-050); }
.flashface .q { font-size: 2rem; font-weight: 700; color: var(--ink); word-break: break-word; }
.flashface .ar { font-family: var(--arabic); font-size: 2.6rem; direction: rtl; }
.flashface .hint { font-size: .8rem; color: var(--muted); margin-top: 12px; }
.deck-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.deck-card { text-align: start; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; }
.deck-card:hover { border-color: var(--brand-400); }
.deck-card h3 { margin: 6px 0 4px; }
.deck-card .n { font-size: .78rem; color: var(--muted); }

/* ---------- journal / documents ---------- */
.entry-list { display: grid; gap: 12px; }
.entry { background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.entry__head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.entry__title { font-weight: 700; color: var(--ink); margin: 0; }
.entry__meta { font-size: .78rem; color: var(--muted); }
.entry__body { margin: 8px 0 0; white-space: pre-wrap; color: var(--ink); }
.entry__notes { margin: 6px 0 0; color: var(--muted); font-size: .9rem; white-space: pre-wrap; }
.entry__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.folder-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.folder-pill { border: 1px solid var(--brand-200); background: var(--brand-050); color: var(--brand-800); border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: .85rem; }
.folder-pill.active { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

/* ---------- budget ---------- */
.budget-summary { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.budget-stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.budget-stat .l { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.budget-stat .n { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.budget-bar { height: 14px; border-radius: 999px; background: var(--brand-100); overflow: hidden; }
.budget-bar > span { display: block; height: 100%; background: var(--brand-600); }
.budget-bar > span.over { background: var(--danger-ink); }

/* ---------- mosque finder ---------- */
.mosque-layout { display: grid; gap: 18px; grid-template-columns: 1.1fr .9fr; }
@media (max-width: 900px) { .mosque-layout { grid-template-columns: 1fr; } }
.map-frame { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); min-height: 360px; }
.map-frame iframe { width: 100%; border: 0; display: block; }
.mosque-list { display: grid; gap: 12px; max-height: 560px; overflow: auto; padding-inline-end: 4px; }
.mosque { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; background: var(--bg-3); }
.mosque.is-active { border-color: var(--brand-500); box-shadow: var(--shadow-sm); }
.mosque__row { display: flex; justify-content: space-between; gap: 10px; }
.mosque__dist { color: var(--brand-800); font-weight: 700; white-space: nowrap; }
.mosque a { color: var(--brand-700); }

/* ---------- arabic academy ---------- */
#la-app { --arScale: 1; }
.letter-stage { text-align: center; }
.letter-stage .glyph { font-family: var(--arabic); font-size: calc(clamp(4rem, 16vw, 8rem) * var(--arScale, 1)); line-height: 1; color: var(--ink); }
.forms-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.form-cell { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.form-cell .g { font-family: var(--arabic); font-size: calc(2rem * var(--arScale, 1)); direction: rtl; }
.form-cell .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.vocab-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.vocab-card .ar { font-family: var(--arabic); font-size: calc(2rem * var(--arScale, 1)); direction: rtl; color: var(--ink); }
.quiz-options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin-top: 12px; }
.opt { font-family: var(--arabic); font-size: 1.6rem; padding: 14px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); cursor: pointer; }
.opt.correct { background: var(--mint-100); border-color: var(--mint-600); }
.opt.wrong { background: var(--danger-bg); border-color: var(--danger-line); }
.audio-btn { display: inline-flex; align-items: center; gap: 8px; }
.vocab-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ---------- jumu'ah ---------- */
.checklist { display: grid; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-3); }
.check-item.is-done { background: var(--mint-050); border-color: var(--mint-500); }
.check-item input { width: 18px; height: 18px; }
.check-item .t { flex: 1; }
.counter-big { text-align: center; padding: 12px; }
.counter-big .n { font-size: 3rem; font-weight: 800; color: var(--brand-800); }
.counter-big .t { color: var(--muted); font-size: .85rem; }
.tap-btn { width: 132px; height: 132px; border-radius: 50%; border: 0; background: var(--brand-700); color: #fff; font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.tap-btn:active { transform: scale(.96); }

/* ---------- misc ---------- */
.print-only { display: none; }
@media print {
  .ticker, .site-header, .site-footer, .no-print, .quick-links, .header-search { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .tool-panel, .card { box-shadow: none; border: 1px solid #ccc; }
}
