/*
 * App Tahfiz typography contract, 22 Nov 2026.
 * Keep visual typography in this file. Do not set new one-off font-size
 * values in app-template.php or feature stylesheets.
 * Quran verses, SVG/chart labels and camera overlays are deliberate exceptions.
 */
:root {
  --tmf-type-caption:12px;
  --tmf-type-label:13px;
  --tmf-type-body:14px;
  --tmf-type-emphasis:15px;
  --tmf-type-card:16px;
  --tmf-type-section:18px;
  --tmf-type-page:27px;
  --tmf-type-metric:28px;
  --tmf-type-avatar-lg:21px;
  --tmf-type-camera-name:26px;
  --tmf-type-brand-title:12px;
  --tmf-type-brand-title-mobile:12px;
  --tmf-type-brand-title-small:12px;
  --tmf-type-brand-school:10px;
  --tmf-type-brand-school-mobile:9px;
  --tmf-type-brand-place:9px;
  --tmf-type-brand-place-mobile:8px;
  --tmf-type-brand-version:8px;
  --tmf-leading-body:1.6;
  --tmf-leading-heading:1.35;
}

/* Baseline. Inputs retain their own contrast and colors in dark mode. */
body {font-size:var(--tmf-type-body)}
.app-frame,.login-screen,dialog:not(.tmf-camera-dialog) {
  font-size:var(--tmf-type-body);
  line-height:var(--tmf-leading-body);
}
.app-frame :is(input,select,textarea),
.login-screen :is(input,select,textarea),
dialog:not(.tmf-camera-dialog) :is(input,select,textarea) {
  font-size:var(--tmf-type-body);
  line-height:1.5;
}
.app-frame .main,
.app-frame .dialog-body {font-size:var(--tmf-type-body)}

/* Heading hierarchy: page > section > card > supporting copy. */
.app-frame :is(.page-heading h1,h1.page-title),
.login-screen .login-card h1 {font-size:var(--tmf-type-page);line-height:var(--tmf-leading-heading)}
.app-frame :is(
  .section-head h2,.panel-header h2,.capaian-leaderboard h2,
  .school-goal h2,.attendance-panel>header h2,
  .greeting h2,.detail-top h2,.target-panel h2
),
dialog:not(.tmf-camera-dialog) .dialog-head h2 {
  font-size:var(--tmf-type-section);
  line-height:var(--tmf-leading-heading);
}
.app-frame :is(
  .student-card h3,.halaqah-card h3,.form-panel h2,.record-card h3,
  .followup-title strong,.feedback-ticket-top h3,.task-panel h2,
  .task-row strong,.version-head h2,.attendance-history h3,
  .peer-progress-head strong,.recap-top h3,.school-goal-child h3
),
dialog:not(.tmf-camera-dialog) :is(.dialog-body h3,.quran-toolbar strong) {
  font-size:var(--tmf-type-card);
  line-height:1.45;
}

/* Regular content: avoid the old 9-11px body copy. */
.app-frame :is(
  .page-heading p,.section-head p,.panel-header p,.capaian-leaderboard p,
  .greeting p,.target-panel p,.form-panel>p,.record-card p,
  .student-card p,.target-line p,.task-row p,.followup-body,
  .followup-reply p,.feedback-entry p,.feedback-ticket-message,
  .feedback-response p,.feedback-execution p,.recap-text,.recap-notes,
  .recap-review,.school-goal p,.school-goal-next,.school-goal-footer,
  .info-box,.list-notes,.notes-content,.notes-review,.text-list,
  .empty-state p,.error-banner,.success-box,.login-note,
  .juz-auto-info,.guardian-setoran-teacher-note,.guardian-activity-card p
),
.login-screen :is(.demo-login p,.login-note),
dialog:not(.tmf-camera-dialog) :is(
  .dialog-head p,.dialog-body p,.peer-intro,.quran-bottom,
  .tasmi-invitation p,.form-divider
) {
  font-size:var(--tmf-type-body);
  line-height:var(--tmf-leading-body);
}

/* Form labels and filter fields share one scale, regardless of feature. */
.app-frame :is(
  .field label,.capaian-filters label,.capaian-filters label span,
  .attendance-toolbar label,.attendance-manual-form .attendance-field,
  .log-date-range label,.form-grid label,.date-filters label,
  .toolbar label,.backup-grid label,.filter-label
),
dialog:not(.tmf-camera-dialog) :is(.field label,.form-grid label,.checkbox-row) {
  font-size:var(--tmf-type-label);
  line-height:1.5;
  font-weight:700;
}
.app-frame :is(
  .capaian-filters input,.capaian-filters select,
  .global-search input,.toolbar select,.date-filters input,
  .log-toolbar .log-date-select,.log-date-range input,
  .log-toolbar-right .student-filter-select,
  .heading-actions .student-filter-select,
  .attendance-toolbar select,.attendance-manual select,
  .attendance-manual-form input,.attendance-manual-form select
) {font-size:var(--tmf-type-body)}
.app-frame .capaian-filters :is(input,select) {
  font-family:var(--font);
  font-weight:500;
}
.app-frame .capaian-filters label {font-weight:700}

/* Buttons and navigation: labels are neither tiny nor headline-sized. */
.app-frame :is(
  .nav-item,.sidebar-add,.sidebar-toggle,.mobile-nav button,
  .button,.chip,.tab,.filter-chips button,.preview-role button,
  .heading-actions .button,.target-line .button,.student-card-foot .button,
  .quran-open-button,.guardian-task-cta,.guardian-task-done,
  .capaian-rank-row .button,.attendance-launch .button,
  .attendance-manual .button,.face-register-row .button
),
.login-screen :is(.button,.demo-login .button),
dialog:not(.tmf-camera-dialog) :is(.button,.tab,.chip) {
  font-size:var(--tmf-type-body);
  line-height:1.45;
}
.app-frame :is(.nav-label,.sidebar-summary-title,.sidebar-summary-head) {
  font-size:var(--tmf-type-caption);
  line-height:1.45;
  letter-spacing:.04em;
}
.app-frame :is(.sidebar-summary .small,.sidebar-footer,.sidebar-summary p) {
  font-size:var(--tmf-type-caption);
  line-height:1.5;
}

/* Tables and student records: standard data cells 13, emphasis 14. */
.app-frame :is(
  th,.table-wrap th,.table-wrap td,td,
  .attendance-history-row strong,.attendance-history-row span,
  .student-card-line,.student-cell strong,.student-cell span:not(.avatar),
  .table-surah,.notes-content,.guardian-setoran-summary-item
) {font-size:var(--tmf-type-label);line-height:1.55}
.app-frame :is(
  .table-sub,.source-label,.student-card-foot .card-foot-hint,
  .student-card-foot .small,.chart-foot,.chart-legend,
  .attendance-history-row small
) {font-size:var(--tmf-type-caption);line-height:1.5}
.app-frame th,.app-frame .table-wrap th {letter-spacing:.035em}
.app-frame :is(.student-cell strong,.capaian-rank-row strong,.student-card h3) {
  font-size:var(--tmf-type-body);
}

/* Supporting text and status labels. Minimum reading size is 12px. */
.app-frame :is(
  .small,small,.muted.small,.status,.stat-label,.stat-foot,
  .table-sub,.count-pill,.chart-foot,.chart-legend,.preview-strip,
  .preview-note,.preview-copy,.page-footer,.today-label,
  .user-meta span,.user-meta strong,.brand-sub,.brand-place,.brand-version,
  .source-label,.target-panel .ring-center span,.ring-center span,
  .family-card small,.family-card-meta,.family-card-current,
  .family-card-task,.task-row small,.feedback-ticket-meta,
  .feedback-response small,.feedback-entry small,.recap-type,.recap-top p,
  .recap-metrics span,.feedback-metrics span,.school-goal-status,
  .school-goal-label,.school-goal-pills span,.school-goal-child small,
  .school-goal-juz-note,.peer-progress-privacy,.peer-progress-head small,
  .attendance-summary-card span,.attendance-parent-preview p,
  .guardian-activity-status,.guardian-setoran-task-badge,
  .juz-certificate-footer,.juz-certificate-overline,.biodata-table dt,
  .backup-item-title small,.quran-title-block small
),
.login-screen :is(small,.brand-sub,.brand-place,.brand-version),
dialog:not(.tmf-camera-dialog) :is(
  small,.field small,.quran-toolbar small,.quran-footer span,
  .quran-counter,.quran-title-block small,.peer-progress-privacy
) {font-size:var(--tmf-type-caption);line-height:1.5}
.app-frame .brand-name,
.login-screen .brand-name {font-size:var(--tmf-type-card);line-height:1.25}
.app-frame :is(.nav-label,.sidebar-footer) {opacity:.88}

/* Standard classes for dynamically rendered content. */
.app-frame .tmf-toolbar-helper,
dialog:not(.tmf-camera-dialog) .tmf-dialog-warning {
  font-size:var(--tmf-type-body);
  line-height:var(--tmf-leading-body);
}
/* Legacy feature labels, alerts and small controls missed by broad groups. */
.app-frame :is(
  .eyebrow,.halaqah-card .tiny-label,.halaqah-bottom,.panel-footer,
  .target-student-info strong,.mobile-cards td[data-col=date],
  .recap-attention,.feedback-history-details,.notification-copy small,
  .notification-copy p,.target-choice-row small,.tasmi-invite-header span,
  .juz-auto-row small
) {font-size:var(--tmf-type-caption);line-height:1.5}
.app-frame :is(
  .chart-empty,.form-error,.surah-tile,.surah-tile strong,
  .surah-tile span,.version-entry ul
) {font-size:var(--tmf-type-label);line-height:1.55}
.app-frame :is(
  .period-select,.heading-actions .period-select,.button.link,
  .demo-banner .demo-exit,.quran-size-btn,.quran-size-reset
),
dialog:not(.tmf-camera-dialog) :is(.quran-size-btn,.quran-size-reset) {
  font-size:var(--tmf-type-body);
  line-height:1.45;
}
/* Information hierarchy and numeric metrics. */
.app-frame :is(.stat-value,.ring-center strong,.target-panel .ring-center strong) {
  font-size:var(--tmf-type-metric);line-height:1.2;
  font-variant-numeric:tabular-nums;
}
.app-frame :is(
  .recap-metrics strong,.feedback-metrics strong,
  .attendance-summary-card strong,.detail-summary strong
) {font-size:24px;line-height:1.25;font-variant-numeric:tabular-nums}
.app-frame :is(
  .attendance-panel>header p,.attendance-history p,
  .attendance-privacy,.attendance-note,.attendance-manual summary,
  .face-register-person span,.attendance-parent-preview p
) {font-size:var(--tmf-type-body);line-height:1.55}
.app-frame :is(.attendance-summary-card span,.attendance-history h3 span) {
  font-size:var(--tmf-type-caption)
}

/* Avatars and the scanner are presentation-specific, not body text. */
.app-frame .avatar.small-avatar {font-size:var(--tmf-type-caption)}
.app-frame .avatar.large {font-size:var(--tmf-type-avatar-lg)}
.tmf-camera-dialog :is(.tmf-camera-bottom p,.tmf-camera-top strong) {
  font-size:var(--tmf-type-emphasis);
}
.tmf-camera-dialog .face-confirm-name {font-size:var(--tmf-type-camera-name)}
.tmf-camera-dialog :is(.tmf-camera-actions .button,.face-consent,.tmf-camera-close) {
  font-size:var(--tmf-type-body)
}

/* Do not squeeze primary reading sizes on phone screens. */
@media(max-width:800px) {
  .app-frame :is(.page-heading h1,h1.page-title) {
    font-size:24px;
    line-height:1.3;
  }
  .app-frame .topbar :is(.brand-sub,.brand-place,.brand-version) {
    font-size:var(--tmf-type-caption);
    line-height:1.3;
  }
  .app-frame .topbar .brand-name {font-size:var(--tmf-type-emphasis)}
  .app-frame :is(.mobile-nav button,.button,.chip) {
    font-size:var(--tmf-type-label);
  }
  .app-frame .capaian-filters :is(input,select) {
    font-size:var(--tmf-type-body);
  }
}
@media(max-width:380px) {
  .app-frame .topbar :is(.brand-sub,.brand-place,.brand-version) {
    font-size:var(--tmf-type-caption);
  }
  .app-frame .topbar .brand-name {font-size:var(--tmf-type-emphasis)}
}
/* Header brand is proportionate to the right account identity: 36px icon, 12px name. */
body:has(.app-frame) .topbar .brand {
  display:flex;align-items:center;align-self:center;
  flex:0 0 auto;min-width:0;max-width:180px;
  gap:8px;padding-block:0!important;min-height:0!important;
}
body:has(.app-frame) .topbar .brand-mark {
  width:36px!important;height:36px!important;flex:0 0 36px!important;
  border-radius:10px!important;
}
body:has(.app-frame) .topbar .brand-mark .icon {width:22px!important;height:22px!important}
body:has(.app-frame) .topbar .brand-copy {
  display:flex;flex-direction:column;justify-content:center;
  gap:1px!important;min-width:0;flex:0 1 auto;
}
body:has(.app-frame) .topbar .brand-name {
  font-size:var(--tmf-type-brand-title)!important;
  font-weight:800;line-height:1.25!important;letter-spacing:0;
}
body:has(.app-frame) .topbar .brand-sub {
  font-size:var(--tmf-type-brand-school)!important;
  line-height:1.25!important;font-weight:650;letter-spacing:0;
}
body:has(.app-frame) .topbar .brand-place {
  font-size:var(--tmf-type-brand-place)!important;
  line-height:1.25!important;font-weight:550;
  gap:4px;letter-spacing:0;flex-wrap:nowrap;
}
body:has(.app-frame) .topbar .brand-version {
  font-size:var(--tmf-type-brand-version)!important;
  line-height:1.2!important;font-weight:600;padding:1px 3px;
}
@media(max-width:800px) {
  body:has(.app-frame) .topbar .brand {flex:1 1 auto;gap:7px;max-width:none}
  /* Account avatar is 32px on phones; keep the logo exactly equal. */
  body:has(.app-frame) .topbar .brand-mark {
    width:32px!important;height:32px!important;flex:0 0 32px!important;
  }
  body:has(.app-frame) .topbar .brand-mark .icon {width:20px!important;height:20px!important}
  body:has(.app-frame) .topbar .brand-name {font-size:var(--tmf-type-brand-title-mobile)!important}
  body:has(.app-frame) .topbar .brand-sub {font-size:var(--tmf-type-brand-school-mobile)!important}
  body:has(.app-frame) .topbar .brand-place {font-size:var(--tmf-type-brand-place-mobile)!important}
}
@media(max-width:380px) {
  body:has(.app-frame) .topbar .brand {gap:6px}
  body:has(.app-frame) .topbar .brand-name {font-size:var(--tmf-type-brand-title-small)!important}
}
/* Global header search uses the same compact font as other secondary controls. */
body:has(.app-frame) .topbar .global-search input {
  font-family:var(--font);
  font-size:var(--tmf-type-caption)!important;
  font-weight:500;
  line-height:1.5;
}
/* Qur'an Arabic reading, certificate typography and chart SVG labels stay separate. */
