/* ========================================
   PRIORITY 1: TYPOGRAPHY SYSTEM
   Darja Rihla Design System v0.1
   ======================================== */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&display=swap');

/* ========================================
   ROOT: DESIGN TOKENS
   ======================================== */

:root {
  /* Typography */
  --font-serif: 'Playfair Display', Georgia, serif;

  /* Light mode (Editorial Light) */
  --color-text-primary-light: #2C2519;
  --color-text-secondary-light: #566671;
  --color-bg-light: #F2EADC;

  /* Dark mode (Inverse-Dark) */
  --color-text-primary-dark: #F5F1E8;
  --color-text-secondary-dark: #C8C4BC;
  --color-bg-dark: #1A1815;

  /* Accent (persistent across modes) */
  --color-accent: #0a66c2;

  /* Default to light mode */
  --current-text: var(--color-text-primary-light);
  --current-text-secondary: var(--color-text-secondary-light);
  --current-bg: var(--color-bg-light);
}

/* ========================================
   BODY: BASE STYLES
   ======================================== */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--current-text);
  background-color: var(--current-bg);
  transition: background-color 0.3s ease, color 0.3s ease;
  margin: 0;
  padding: 0;
}

/* ========================================
   THEME MODE: LIGHT (default)
   ======================================== */

body.theme-light {
  --current-text: var(--color-text-primary-light);
  --current-text-secondary: var(--color-text-secondary-light);
  --current-bg: var(--color-bg-light);
}

/* ========================================
   THEME MODE: DARK
   ======================================== */

body.theme-dark {
  --current-text: var(--color-text-primary-dark);
  --current-text-secondary: var(--color-text-secondary-dark);
  --current-bg: var(--color-bg-dark);
}

/* ========================================
   ROLE 1: H1 (Display/Hero)
   Scaling: clamp(2rem, 8vw, 5.5rem)
   ======================================== */

h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 8vw, 5.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem 0;
  color: var(--current-text);
}

/* ========================================
   ROLE 2: H2 (Section heading)
   Scaling: clamp(1.5rem, 6vw, 3rem)
   ======================================== */

h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 6vw, 3rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 2rem 0 1rem 0;
  color: var(--current-text);
}

/* ========================================
   ROLE 3: H3 (Subsection)
   Scaling: clamp(1.25rem, 4.5vw, 2rem)
   ======================================== */

h3 {
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 4.5vw, 2rem);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0em;
  margin: 1.5rem 0 0.75rem 0;
  color: var(--current-text);
}

/* ========================================
   H4, H5, H6 (smaller headings)
   ======================================== */

h4 {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
  margin: 1rem 0 0.5rem 0;
  color: var(--current-text);
}

h5 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  margin: 0.875rem 0 0.5rem 0;
  color: var(--current-text);
}

h6 {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0.75rem 0 0.5rem 0;
  color: var(--current-text-secondary);
}

/* ========================================
   ROLE 4: LEAD (Intro paragraph)
   Scaling: clamp(1.125rem, 2vw, 1.5rem)
   ======================================== */

.lead,
.intro,
p.intro {
  font-family: var(--font-serif);
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: 400;
  line-height: 1.6;
  margin: 1.5rem 0;
  color: var(--current-text);
}

/* ========================================
   ROLE 5: BODY (Main prose)
   Scaling: clamp(1rem, 3vw, 1.125rem)
   ======================================== */

p {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 3vw, 1.125rem);
  font-weight: 400;
  line-height: 1.7;
  margin: 0 0 1rem 0;
  color: var(--current-text);
}

p + p {
  margin-top: 1rem;
}

/* ========================================
   ROLE 6: UI (Buttons, labels, controls)
   Fixed: 0.875rem
   ======================================== */

button,
.button,
.btn,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--current-text);
  background-color: transparent;
  border: 2px solid var(--color-accent);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
}

button:hover,
.button:hover,
.btn:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
  background-color: var(--color-accent);
  color: white;
}

button:focus,
.button:focus,
.btn:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ========================================
   ROLE 7: CAPTION (Image captions)
   Desktop: 0.875rem | Mobile: 0.8125rem
   ======================================== */

figcaption,
.caption,
.fig-caption {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--current-text-secondary);
  margin-top: 0.5rem;
}

@media (max-width: 768px) {
  figcaption,
  .caption,
  .fig-caption {
    font-size: 0.8125rem;
  }
}

/* ========================================
   ROLE 8: META / BYLINE
   Fixed: 0.75rem
   ======================================== */

.meta,
.byline,
.publication-meta,
time {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--current-text-secondary);
}

/* ========================================
   LINKS
   ======================================== */

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ========================================
   CODE & PREFORMATTED TEXT
   ======================================== */

code,
pre,
samp {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  color: var(--current-text);
}

body.theme-dark code,
body.theme-dark pre,
body.theme-dark samp {
  background-color: rgba(255, 255, 255, 0.08);
}

pre {
  padding: 1rem;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* ========================================
   BLOCKQUOTES
   ======================================== */

blockquote {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-style: italic;
  line-height: 1.8;
  margin: 2rem 0;
  padding-left: 1.5rem;
  border-left: 4px solid var(--color-accent);
  color: var(--current-text);
}

blockquote p {
  margin: 0.5rem 0;
}

/* ========================================
   LISTS
   ======================================== */

ul,
ol {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 3vw, 1.125rem);
  line-height: 1.7;
  margin: 1rem 0;
  padding-left: 1.5rem;
  color: var(--current-text);
}

li {
  margin-bottom: 0.5rem;
}

/* ========================================
   EMPHASIS & STRONG
   ======================================== */

em,
i {
  font-style: italic;
}

strong,
b {
  font-weight: 700;
  color: var(--current-text);
}

/* ========================================
   HORIZONTAL RULE
   ======================================== */

hr {
  border: none;
  border-top: 1px solid var(--current-text-secondary);
  margin: 2rem 0;
  opacity: 0.5;
}

/* ========================================
   TABLES
   ======================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.9375rem;
  color: var(--current-text);
}

th {
  background-color: rgba(0, 0, 0, 0.05);
  font-weight: 700;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--color-accent);
}

body.theme-dark th {
  background-color: rgba(255, 255, 255, 0.08);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--current-text-secondary);
  opacity: 0.8;
}

/* ========================================
   FORMS
   ======================================== */

label {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--current-text);
  display: block;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  border: 2px solid var(--current-text-secondary);
  border-radius: 4px;
  background-color: var(--current-bg);
  color: var(--current-text);
  transition: border-color 0.2s ease;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.1);
}

/* ========================================
   ACCESSIBILITY: REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

@media print {
  body {
    background-color: white;
    color: #000;
  }

  a {
    color: #0066cc;
  }

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

  p {
    orphans: 3;
    widows: 3;
  }

  blockquote {
    border-left-color: #ccc;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

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

.text-muted {
  color: var(--current-text-secondary);
  opacity: 0.8;
}

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