/* ==========================================================================
   BUTRAN COLLEGE - OFFICIAL TYPOGRAPHY SYSTEM
   Premium University Typography Design for English & Arabic
   ========================================================================== */

/* ========== FONT STACK DEFINITIONS ========== */
:root {
  /* English Font Stack - Primary: Montserrat, Fallback: Poppins, System Fonts */
  --font-family-en-sans: 'Sora', 'DM Sans', 'Segoe UI', Arial, sans-serif;
  --font-family-en-serif: 'Marcellus', Georgia, serif;

  /* Arabic Font Stack - Cairo (real variable font, bundled locally as cairo-var.ttf) */
  --font-family-ar-sans: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;

  /* Assigned based on language */
  --font-family-heading: var(--font-family-en-sans);
  --font-family-body: var(--font-family-en-sans);
  --font-family-display: var(--font-family-en-sans);
}

/* Arabic Language Specific Typography */
html[lang="ar"],
html[dir="rtl"] {
  --font-family-heading: var(--font-family-ar-sans);
  --font-family-body: var(--font-family-ar-sans);
  --font-family-display: var(--font-family-ar-sans);
}

/* ========== FONT WEIGHTS ========== */
:root {
  /* Weights used across the design system */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
}

/* ========== LINE HEIGHT ========== */
:root {
  /* Headings - Tighter line height for visual hierarchy */
  --line-height-heading: 1.2;
  --line-height-heading-lg: 1.25;

  /* Body - Comfortable reading line height */
  --line-height-body: 1.6;
  --line-height-body-comfortable: 1.8;

  /* Lists and dense content */
  --line-height-dense: 1.4;
}

/* Arabic needs slightly increased line height for readability */
html[lang="ar"],
html[dir="rtl"] {
  --line-height-body: 1.8;
  --line-height-body-comfortable: 1.95;
}

/* ========== LETTER SPACING ========== */
:root {
  /* English headings - subtle letter spacing for elegance */
  --letter-spacing-heading: -0.02em;
  --letter-spacing-heading-lg: -0.015em;
  --letter-spacing-subtitle: 0.02em;
  --letter-spacing-uppercase: 0.08em;

  /* Arabic - NO additional letter spacing (breaks proper rendering) */
  --letter-spacing-ar-heading: 0;
  --letter-spacing-ar-body: 0;
}

/* Arabic text should NEVER have additional letter spacing */
html[lang="ar"] {
  --letter-spacing-heading: 0 !important;
  --letter-spacing-heading-lg: 0 !important;
  --letter-spacing-subtitle: 0 !important;
  --letter-spacing-uppercase: 0 !important;
}

/* ========== TYPOGRAPHY SCALE - DISPLAY & HEADINGS ========== */

/* Display 1 - Hero sections, key page headlines */
.display-1,
h1.display-1 {
  font-family: var(--font-family-display);
  font-size: 56px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading-lg);
  margin: 1.5rem 0 1rem;
}

/* Display 2 - Section heroes */
.display-2,
h2.display-2 {
  font-family: var(--font-family-display);
  font-size: 48px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading-lg);
  margin: 1.5rem 0 1rem;
}

/* Heading 1 - Page titles */
h1 {
  font-family: var(--font-family-heading);
  font-size: 40px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  margin: 1.5rem 0 1rem;
}

/* Heading 2 - Section titles */
h2 {
  font-family: var(--font-family-heading);
  font-size: 32px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  margin: 1.25rem 0 0.75rem;
}

/* Heading 3 - Subsection titles */
h3 {
  font-family: var(--font-family-heading);
  font-size: 28px;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  margin: 1rem 0 0.5rem;
}

/* Heading 4 - Card titles, highlights */
h4 {
  font-family: var(--font-family-heading);
  font-size: 24px;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading-lg);
  letter-spacing: var(--letter-spacing-heading);
  margin: 0.75rem 0 0.5rem;
}

/* Heading 5 - Widget titles, emphasis */
h5 {
  font-family: var(--font-family-heading);
  font-size: 20px;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading-lg);
  letter-spacing: 0;
  margin: 0.5rem 0 0.25rem;
}

/* Heading 6 - Small headings, labels */
h6 {
  font-family: var(--font-family-heading);
  font-size: 18px;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading-lg);
  letter-spacing: var(--letter-spacing-uppercase);
  text-transform: uppercase;
  margin: 0.5rem 0 0.25rem;
}

/* ========== TYPOGRAPHY SCALE - BODY TEXT ========== */

/* Body Large - Feature text, emphasis */
.body-large,
.lead {
  font-family: var(--font-family-body);
  font-size: 18px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body-comfortable);
  letter-spacing: 0;
}

/* Body - Default paragraph text */
body,
p {
  font-family: var(--font-family-body);
  font-size: 16px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  letter-spacing: 0;
}

/* Small - Secondary text, captions */
.small,
small {
  font-family: var(--font-family-body);
  font-size: 14px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-dense);
  letter-spacing: 0;
}

/* Caption - Very small text, labels */
.caption {
  font-family: var(--font-family-body);
  font-size: 12px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-dense);
  letter-spacing: 0;
  opacity: 0.75;
}

/* ========== COMPONENT TYPOGRAPHY ========== */

/* Buttons */
.btn,
button,
input[type="button"],
input[type="submit"] {
  font-family: var(--font-family-heading);
  font-size: 15px;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
}

/* Navigation Links */
nav a,
.nav-link,
.nav-menu a {
  font-family: var(--font-family-heading);
  font-size: 15px;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
  letter-spacing: 0;
}

/* Form Labels */
label,
.form-label {
  font-family: var(--font-family-body);
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
}

/* Form Input */
input,
textarea,
select {
  font-family: var(--font-family-body);
  font-size: 16px;
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
  letter-spacing: 0;
}

/* Card Titles */
.card-title,
.card h4 {
  font-family: var(--font-family-heading);
  font-size: 20px;
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-heading-lg);
  letter-spacing: 0;
}

/* Card Description */
.card-text,
.card p {
  font-family: var(--font-family-body);
  font-size: 14px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  letter-spacing: 0;
}

/* Table */
table {
  font-family: var(--font-family-body);
  font-size: 14px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-dense);
}

table th {
  font-weight: var(--font-weight-semibold);
  font-size: 14px;
}

/* Breadcrumb */
.breadcrumb {
  font-family: var(--font-family-heading);
  font-size: 14px;
  font-weight: var(--font-weight-regular);
  line-height: 1.4;
}

/* List */
ul, ol {
  font-family: var(--font-family-body);
  font-size: 16px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
}

/* Blockquote */
blockquote {
  font-family: var(--font-family-body);
  font-size: 18px;
  font-weight: var(--font-weight-regular);
  font-style: italic;
  line-height: var(--line-height-body-comfortable);
}

blockquote cite {
  font-family: var(--font-family-heading);
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  font-style: normal;
  line-height: 1.4;
}

/* ========== RESPONSIVE TYPOGRAPHY SCALE ========== */

/* Tablet (768px and up) */
@media (max-width: 767px) {
  .display-1,
  h1.display-1 {
    font-size: 44px;
  }

  .display-2,
  h2.display-2 {
    font-size: 40px;
  }

  h1 {
    font-size: 36px;
  }

  h2 {
    font-size: 28px;
  }

  h3 {
    font-size: 24px;
  }

  h4 {
    font-size: 20px;
  }

  h5 {
    font-size: 18px;
  }

  h6 {
    font-size: 16px;
  }

  .body-large,
  .lead {
    font-size: 16px;
  }

  body,
  p {
    font-size: 15px;
  }

  .small,
  small {
    font-size: 13px;
  }

  .caption {
    font-size: 11px;
  }

  .btn,
  button {
    font-size: 14px;
  }

  nav a,
  .nav-link {
    font-size: 14px;
  }

  .card-title,
  .card h4 {
    font-size: 18px;
  }

  blockquote {
    font-size: 16px;
  }
}

/* Mobile (360px to 575px) */
@media (max-width: 575px) {
  .display-1,
  h1.display-1 {
    font-size: 36px;
  }

  .display-2,
  h2.display-2 {
    font-size: 32px;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 20px;
  }

  h4 {
    font-size: 18px;
  }

  h5 {
    font-size: 16px;
  }

  h6 {
    font-size: 14px;
    letter-spacing: 0.05em;
  }

  .body-large,
  .lead {
    font-size: 15px;
  }

  body,
  p {
    font-size: 14px;
    line-height: var(--line-height-body-comfortable);
  }

  .small,
  small {
    font-size: 12px;
  }

  .caption {
    font-size: 10px;
  }

  .btn,
  button {
    font-size: 13px;
    padding: 12px 20px;
  }

  nav a,
  .nav-link {
    font-size: 13px;
  }

  .card-title,
  .card h4 {
    font-size: 16px;
  }

  blockquote {
    font-size: 15px;
  }

  /* Ensure form inputs are readable on mobile (16px prevents zoom) */
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ========== ARABIC SPECIFIC TYPOGRAPHY ========== */

html[lang="ar"],
html[dir="rtl"] {
  /* Increased line height for Arabic readability */
  --line-height-body: 1.8;
  --line-height-body-comfortable: 1.95;
  --line-height-dense: 1.5;

  /* No letter spacing for Arabic text */
  --letter-spacing-heading: 0;
  --letter-spacing-heading-lg: 0;
  --letter-spacing-subtitle: 0;
  --letter-spacing-uppercase: 0;
}

/* Arabic headings - increase line height slightly */
html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4,
html[lang="ar"] h5,
html[lang="ar"] h6 {
  line-height: 1.3;
}

/* Arabic body - comfortable reading */
html[lang="ar"] p,
html[lang="ar"] body {
  line-height: 1.8;
}

/* Arabic lists - proper spacing */
html[lang="ar"] ul,
html[lang="ar"] ol {
  line-height: 1.8;
  margin-right: 2rem;
  margin-left: 0;
}

/* Arabic blockquotes */
html[lang="ar"] blockquote {
  line-height: 1.95;
  border-right: 4px solid currentColor;
  border-left: none;
  padding-right: 1.5rem;
  padding-left: 0;
  margin-right: 0;
  margin-left: 1.5rem;
}

/* ========== FONT LOADING OPTIMIZATION ========== */

/* Ensure fonts load without blocking page rendering */
@font-face {
  font-family: 'Sora';
  src: url('../fonts/font-5.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/font-0.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Cairo';
  src: url('../fonts/cairo-var.ttf') format('truetype-variations');
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0600-U+06FF, U+0750-U+077F, U+08A0-U+08FF, U+FB50-U+FDFF, U+FE70-U+FEFF, U+0660-U+0669;
}

/* ========== ACCESSIBILITY ENHANCEMENTS ========== */

/* Ensure minimum readable font sizes */
body {
  font-size: 16px;
  min-height: 100vh;
}

/* Links have proper font styling */
a {
  font-family: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid;
  outline-offset: 2px;
}

/* Emphasis and strong text */
em {
  font-style: italic;
}

strong,
b {
  font-weight: var(--font-weight-bold);
}

/* Code blocks readable */
code,
pre {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* ========== UTILITY CLASSES FOR TYPOGRAPHY ========== */

.text-uppercase {
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-uppercase);
}

.text-lowercase {
  text-transform: lowercase;
}

.text-capitalize {
  text-transform: capitalize;
}

.text-bold {
  font-weight: var(--font-weight-bold);
}

.text-semibold {
  font-weight: var(--font-weight-semibold);
}

.text-medium {
  font-weight: var(--font-weight-medium);
}

.text-regular {
  font-weight: var(--font-weight-regular);
}

.text-light {
  font-weight: var(--font-weight-light);
}

.line-height-tight {
  line-height: var(--line-height-heading);
}

.line-height-normal {
  line-height: var(--line-height-body);
}

.line-height-loose {
  line-height: var(--line-height-body-comfortable);
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

/* Justify text carefully */
.text-justify {
  text-align: justify;
  text-align-last: auto;
}

/* Prevent text overflow */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-wrap {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ========== PARAGRAPH STYLING ========== */

p {
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}

/* Comfortable paragraph spacing */
p + p {
  margin-top: 1rem;
}

/* List styling */
ul,
ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

li {
  margin-bottom: 0.5rem;
}

li:last-child {
  margin-bottom: 0;
}

/* Description list */
dt {
  font-weight: var(--font-weight-semibold);
  margin-top: 1rem;
}

dd {
  margin-left: 2rem;
  margin-bottom: 0.5rem;
}

/* ========== FOCUS INDICATOR ACCESSIBILITY ========== */

/* Ensure focus indicators are always visible */
*:focus-visible {
  outline: 2px solid;
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid;
  outline-offset: 3px;
}

/* ========== PRINT STYLES ========== */

@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  p {
    page-break-inside: avoid;
  }

  ul, ol {
    page-break-inside: avoid;
  }
}

/* ========== END TYPOGRAPHY SYSTEM ========== */
