/* Practical Ibadah — app styles. Tokens follow the design handoff (high-contrast ink, oklch topic colours). */
:root {
  --ink: #0d1111;
  --paper: #ffffff;
  --desk: #e7e4dc;
  --desk-2: #f4f2ec;
  --cream: #fff6d6;
  --cream-line: #e2cf8f;
  --gold: #7a5000;
  --star-gold: #b8860b;
  --toolbar: #0d1a17;
  --print: #ffd76a;
  --link: #0f4a3c;
  --link-hover: #08261f;
  --danger: #8f1d1d;
  --star-off: #b3afa6;
  --hub-tint: oklch(0.93 0.045 165);
  --font: 'Atkinson Hyperlegible', 'Helvetica Neue', Arial, sans-serif;
  --arabic: 'Noto Naskh Arabic', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk-2);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
a { color: var(--ink); }
a:hover { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[lang="ar"] { font-family: var(--arabic); font-weight: 500; }
.boot { padding: 40px 24px; font-size: 18px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .08em; font-weight: 700; }
.muted { font-size: 15px; }
[hidden] { display: none !important; }
.print-only { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ layout */
.wrap { max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px 24px 60px; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; }

.page-head { background: var(--hub-tint); border-bottom: 2px solid var(--ink); }
.page-head .wrap { padding: 32px 24px 28px; display: flex; flex-direction: column; gap: 8px; }
.kicker, .section-label { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kicker { letter-spacing: .1em; }
.display { font-size: clamp(30px, 4.5vw, 46px); font-weight: 700; line-height: 1.05; }
.lede { font-size: 17px; line-height: 1.45; max-width: 720px; text-wrap: pretty; }

/* ------------------------------------------------------------ top bar */
.topnav {
  position: relative; z-index: 30;
  background: var(--toolbar); color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 8px 18px; font-size: 15px;
}
.topnav .brand { font-weight: 700; font-size: 17px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.topnav .brand .dot { width: 10px; height: 10px; background: var(--print); transform: rotate(45deg); }
.topnav nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav nav a {
  color: #fff; text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 999px;
  border: 1.5px solid transparent; min-height: 40px; display: inline-flex; align-items: center;
}
.topnav nav a:hover { border-color: #fff; color: #fff; }
.topnav nav a[aria-current="page"] { background: #fff; color: var(--ink); }
.topnav .who { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topnav .who span { font-weight: 700; }
.topnav .role { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; border: 1.5px solid #fff; border-radius: 999px; padding: 1px 8px; }
.topnav :focus-visible, .tbar :focus-visible { outline-color: var(--print); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 10px; padding: 10px 14px; min-height: 44px;
  background: #fff; color: var(--ink);
}
.btn:hover { color: var(--ink); background: #f2f0ea; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: #26302e; color: #fff; }
.btn-yellow { background: var(--print); border-color: var(--print); color: var(--ink); }
.btn-yellow:hover { background: #ffcd45; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #6e1414; color: #fff; }
.btn-sm { font-size: 14px; border-radius: 8px; padding: 6px 10px; min-height: 38px; }
.btn-ghost { border-color: transparent; background: transparent; text-decoration: underline; padding-left: 6px; padding-right: 6px; }
.btn-ghost:hover { background: transparent; color: var(--link); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { font-weight: 700; font-size: 14px; padding: 4px; }

/* ------------------------------------------------------------ cards, callouts, chips */
.card { background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 18px 20px; }
.callout { background: var(--cream); border: 2px solid var(--ink); border-radius: 12px; padding: 12px 16px; font-size: 15px; line-height: 1.5; }
.error-card { border-color: var(--danger); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; border: 1.5px solid var(--ink); border-radius: 999px; padding: 1px 10px; white-space: nowrap; background: #fff; }
.chip-yellow { background: var(--print); border-color: var(--ink); }
.chip-ink { background: var(--ink); color: #fff; }
.error { color: var(--danger); font-weight: 700; min-height: 0; }
.error:empty { display: none; }
.empty { padding: 18px; border: 2px dashed var(--ink); border-radius: 14px; background: #fff; font-size: 16px; }

/* ------------------------------------------------------------ hub */
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.book-btn { text-align: left; cursor: pointer; border: 2px solid var(--ink); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.book-btn .t { font-size: 22px; font-weight: 700; }
.book-btn .s { font-size: 15px; }
.book-btn .c { font-size: 13px; font-weight: 700; margin-top: 4px; }
.year-btn { font-weight: 700; font-size: 16px; cursor: pointer; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 16px; min-width: 64px; min-height: 44px; }
.year-panel { background: #fff; border: 2px solid var(--ink); border-radius: 18px; overflow: hidden; }
.year-panel-head { padding: 20px 22px; display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: space-between; border-bottom: 2px solid var(--ink); }
.year-panel-body { padding: 18px 22px 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.lesson { border: 2px solid var(--ink); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.banner { color: #fff; padding: 6px 14px; display: flex; align-items: center; gap: 10px; }
.diamond { width: 9px; height: 9px; background: #fff; transform: rotate(45deg); flex: none; }
.lesson-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.num-circle { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; flex: none; }
.lesson-title { font-size: 18px; font-weight: 700; line-height: 1.25; text-wrap: pretty; }
.pill-link { text-decoration: none; font-weight: 700; font-size: 14px; border-radius: 8px; padding: 8px 12px; display: inline-flex; align-items: center; min-height: 40px; }
.pill-link.solid { color: #fff; }
.pill-link.solid:hover { color: #fff; filter: brightness(.85); }
.pill-link.outline { background: #fff; color: var(--ink); border: 2px solid var(--ink); padding: 6px 10px; }
.pill-link.ink { background: var(--ink); color: #fff; }
.pill-link.ink:hover { color: #fff; background: #26302e; }

/* ------------------------------------------------------------ login */
.login-card { max-width: 420px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.pin-input {
  width: 100%; font-size: 34px; font-weight: 700; letter-spacing: .4em; text-align: center;
  border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; background: #fff;
}
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button {
  font-size: 26px; font-weight: 700; min-height: 64px; border: 2px solid var(--ink); border-radius: 14px;
  background: var(--hub-tint); cursor: pointer;
}
.pinpad button:hover { background: oklch(0.89 0.06 165); }
.pinpad button.alt { font-size: 16px; background: #fff; }

/* ------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px 18px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select, textarea {
  border: 2px solid var(--ink); border-radius: 8px; padding: 10px 12px; background: #fff; font-weight: 400; font-size: 16px; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; }
label.check input { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
fieldset { border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px 12px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; }
.checks .mark { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; border: 2px solid var(--ink); }
.checks .ok .mark { background: oklch(0.9 0.08 150); }
.checks .bad .mark { background: #f6d2d2; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 2px solid var(--ink); border-radius: 14px; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1.5px solid #cfcac0; vertical-align: middle; }
.tbl thead th { background: var(--ink); color: #fff; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.archived td { background: #f1efe9; }
.tbl .actions { white-space: nowrap; text-align: right; }

/* progress grid */
.grid-tbl th.topic { color: #fff; font-size: 13px; text-transform: none; letter-spacing: 0; min-width: 92px; text-align: center; border-left: 2px solid #fff; vertical-align: bottom; }
.grid-tbl th.topic .ar { display: block; font-size: 15px; }
.grid-tbl td.cell { text-align: center; border-left: 1.5px solid #e2ded5; padding: 4px; }
.grid-tbl td.name { font-weight: 700; white-space: nowrap; }
.grid-tbl td.total { font-weight: 700; white-space: nowrap; text-align: center; }
.star-cell {
  font-size: 30px; line-height: 1; background: none; border: 2px solid transparent; border-radius: 12px;
  width: 52px; height: 48px; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.star-cell:hover { border-color: var(--ink); }
.star-cell.ready { border-color: var(--ink); background: var(--print); }

/* ------------------------------------------------------------ tracker */
.tbar {
  position: sticky; top: 0; z-index: 25; background: var(--toolbar); color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 18px; font-size: 14px;
}
.tbar .ttl { font-weight: 700; font-size: 16px; }
.tbar .grp { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.tbar button, .tbar a, .tbar select {
  font-weight: 700; border: 1.5px solid #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  background: transparent; color: #fff; text-decoration: none; min-height: 36px;
}
.tbar select option { color: var(--ink); }
.tbar .sq { border-radius: 6px; }
.tbar [aria-pressed="true"] { background: #fff; color: var(--ink); }
.tbar .print-btn { background: var(--print); border-color: var(--print); color: var(--ink); border-radius: 6px; padding: 6px 14px; }
.tinfo { background: var(--cream); padding: 8px 18px; font-size: 14px; border-bottom: 1.5px solid var(--cream-line); }
.sheetstack { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 28px 12px 60px; background: var(--desk); min-height: 70vh; }
.tpage { max-width: 100%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18), 0 10px 30px rgba(0,0,0,.08); }
.star-btn { background: none; border: 0; padding: 2px; line-height: 1; cursor: pointer; flex: none; user-select: none; border-radius: 8px; }
.star-btn:hover { transform: scale(1.08); }
.ready-btn {
  align-self: flex-start; margin-top: 4px; font-weight: 700; font-size: 14px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 999px; padding: 6px 12px; background: var(--print); min-height: 40px;
}
.ready-btn[aria-pressed="true"] { background: #fff; }
.ready-chip { align-self: flex-start; margin-top: 3px; font-weight: 700; font-size: 12px; border: 1.5px solid var(--ink); border-radius: 999px; padding: 1px 9px; background: var(--print); }
.review-box { width: 100%; border: 2px solid var(--ink); background: transparent; resize: vertical; font-size: inherit; padding: 8px 10px; }
.review-print { display: none; white-space: pre-wrap; }

/* ------------------------------------------------------------ dialogs + toast */
dialog.modal { border: 2px solid var(--ink); border-radius: 18px; padding: 22px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
dialog.modal::backdrop { background: rgba(13, 17, 17, .55); }
dialog.modal h2 { font-size: 22px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.pin-show { font-size: 40px; font-weight: 700; letter-spacing: .25em; text-align: center; background: var(--hub-tint); border: 2px solid var(--ink); border-radius: 14px; padding: 10px; }
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(140%);
  background: var(--ink); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 12px; z-index: 100;
  max-width: calc(100vw - 32px); transition: transform .18s ease, opacity .18s ease;
  opacity: 0; visibility: hidden; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
#toast.bad { background: var(--danger); }

/* tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { text-decoration: none; font-weight: 700; border: 2px solid var(--ink); border-radius: 999px; padding: 8px 16px; background: #fff; min-height: 42px; display: inline-flex; align-items: center; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }

/* progress bars on pupil home */
.meter { display: flex; gap: 3px; flex-wrap: wrap; }
.meter span { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; }
.bignum { font-size: 40px; font-weight: 700; line-height: 1; }

/* star grid: keep pupil names visible while scrolling sideways */
.grid-tbl thead th:first-child, .grid-tbl td.name { position: sticky; left: 0; z-index: 1; }
.grid-tbl td.name { background: #fff; box-shadow: 2px 0 0 #e2ded5; }
.grid-tbl thead th:first-child { background: var(--ink); }

/* Screen-only so the A5 print layout is never affected */
@media screen and (max-width: 640px) {
  .wrap { padding: 18px 16px 48px; }
  .page-head .wrap { padding: 22px 16px 18px; }
  .lede { font-size: 16px; }
  .topnav { padding: 8px 12px; gap: 6px 10px; }
  .topnav .brand { font-size: 16px; }
  .topnav nav a { padding: 6px 10px; }
  .topnav .who { margin-left: 0; width: 100%; justify-content: space-between; }
  .book-btn { padding: 12px 14px; }
  .book-btn .t { font-size: 19px; }
  .year-btn { padding: 8px 12px; min-width: 0; font-size: 15px; }
  .year-panel-head, .year-panel-body { padding-left: 14px; padding-right: 14px; }
  .year-panel-head .btn { flex: 1 1 auto; }
  .year-panel-body { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .tbar { padding: 8px 12px; position: static; gap: 8px 10px; }
  .tinfo { padding: 8px 12px; }
  .sheetstack { padding: 14px 0 40px; gap: 16px; }
  .grid-tbl td.name { white-space: normal; min-width: 104px; max-width: 132px; }
  .grid-tbl th.topic { min-width: 70px; }
  .star-cell { width: 44px; height: 44px; font-size: 26px; }
  #q { flex: 1 1 160px; min-width: 0; }
  dialog.modal { padding: 18px 16px; }
  .pin-show { font-size: 34px; }

  /* list tables turn into cards */
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards tr { padding: 12px 14px; border-bottom: 1.5px solid #cfcac0; }
  .tbl-cards tbody tr:last-child { border-bottom: 0; }
  .tbl-cards td { border: 0; padding: 2px 0; display: flex; gap: 10px; align-items: baseline; }
  .tbl-cards td.lead { font-size: 17px; padding-bottom: 6px; flex-wrap: wrap; }
  .tbl-cards td[data-label]::before { content: attr(data-label); flex: 0 0 104px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
  .tbl-cards td.actions { display: flex; flex-wrap: wrap; gap: 6px; text-align: left; white-space: normal; padding-top: 10px; }
}

/* Very narrow phones: let the tracker's sign-off sit under the star and text */
@media screen and (max-width: 520px) {
  .award { flex-wrap: wrap; }
  .award-sign { flex: 1 1 100% !important; }
  .award-sign > span:last-child { width: auto !important; }
  .pinpad button { min-height: 58px; }
}

@media print {
  body { background: #fff !important; }
  [data-noprint], .topnav, #toast, dialog { display: none !important; }
  .sheetstack { padding: 0 !important; gap: 0 !important; display: block !important; background: #fff !important; min-height: 0; }
  .tpage { box-shadow: none !important; width: auto !important; break-after: page; }
  .review-box { display: none !important; }
  .review-print { display: block !important; }
  .print-only { display: inline !important; }
  .screen-only { display: none !important; }
}
