/* styles.css — History of the Internet in Pakistan */
/* No frameworks, just plain CSS. Museum/editorial look. */

/* ===== CSS variables ===== */
:root {
  /* Color palette */
  --ptcl-green: #005930;
  --slate: #2b2d42;
  --cream: #f7f9f6;
  --white: #ffffff;
  --accent-gold: #c5a55a;
  --muted: #5a6168;
  --focus-ring: #005930;
  --border: #d1d5db;
  --ptcl-green-light: #e6f0ea;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --error-border: #fecaca;
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.06);

  /* Fonts */
  --font-heading: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Layout */
  --max-width: 1200px;
  --border-radius: 4px;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--cream);
  color: var(--slate);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--ptcl-green);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  text-decoration: underline;
}

/* ===== Focus styles — visible ring on all interactive elements ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== Skip link ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--ptcl-green);
  color: var(--white);
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  z-index: 1000;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--slate);
  line-height: 1.3;
  font-weight: 600;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: var(--space-md);
}

h2 {
  font-size: 1.75rem;
  margin-bottom: var(--space-md);
}

h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

p {
  margin-bottom: var(--space-md);
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.main-content {
  flex: 1;
  padding: var(--space-xl) 0;
}

section {
  margin-bottom: var(--space-2xl);
}

/* ===== Header & nav ===== */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-subtle);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ptcl-green);
}

.site-logo img {
  width: 36px;
  height: 36px;
}

/* Desktop nav */
.main-nav {
  display: flex;
  align-items: center;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: var(--space-lg);
  align-items: center;
}

.nav-list a {
  color: var(--slate);
  font-weight: 500;
  padding: var(--space-xs) 0;
  border-bottom: 2px solid transparent;
  transition: border-color var(--transition), color var(--transition);
}

.nav-list a:hover {
  color: var(--ptcl-green);
  text-decoration: none;
}

.nav-list a[aria-current="page"] {
  color: var(--ptcl-green);
  border-bottom-color: var(--ptcl-green);
  font-weight: 600;
}

/* Hamburger toggle — hidden on desktop, shown on mobile */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-sm);
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  width: 40px;
  height: 40px;
  justify-content: center;
  align-items: center;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--slate);
  transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle:hover {
  background: var(--ptcl-green-light);
}

/* Animate hamburger to X when menu is open */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Hero ===== */
.hero {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2xl) 0;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
}

.hero p {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 700px;
  margin: 0 auto var(--space-lg);
}

.hero img {
  display: block;
  margin: 0 auto;
  max-width: 800px;
  width: 100%;
}

/* ===== Timeline cards (Page 1) ===== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.timeline-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  border-left: 4px solid var(--ptcl-green);
  transition: box-shadow var(--transition);
}

.timeline-card:hover {
  box-shadow: var(--shadow-subtle);
}

.timeline-card .card-year {
  display: inline-block;
  background: var(--ptcl-green);
  color: var(--white);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 2px var(--space-sm);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-sm);
}

.timeline-card .card-category {
  display: inline-block;
  background: var(--ptcl-green-light);
  color: var(--ptcl-green);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px var(--space-sm);
  border-radius: var(--border-radius);
  margin-left: var(--space-sm);
}

.timeline-card .card-source {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: var(--space-sm);
}

/* ===== Metric cards (Page 2) ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  text-align: center;
  transition: box-shadow var(--transition);
}

.metric-card:hover {
  box-shadow: var(--shadow-subtle);
}

.metric-card .metric-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ptcl-green);
  margin-bottom: var(--space-xs);
}

.metric-card .metric-unit {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.metric-card .metric-label {
  font-weight: 600;
  color: var(--slate);
  margin-bottom: var(--space-xs);
}

.metric-card .metric-year {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.metric-card .metric-source {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

/* ===== Comparison table (Page 2) ===== */
/* overflow-x so the table scrolls horizontally on small screens */
.comparison-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.comparison-table th,
.comparison-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.comparison-table thead {
  background: var(--ptcl-green);
}

.comparison-table thead th {
  color: var(--white);
  font-weight: 600;
}

.comparison-table tbody tr:nth-child(even) {
  background: var(--cream);
}

.comparison-table tbody tr:hover {
  background: var(--ptcl-green-light);
}

/* ===== Quote cards / oral histories (Page 3) ===== */
.oral-histories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.quote-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  border-top: 4px solid var(--accent-gold);
}

.quote-card blockquote {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--slate);
  line-height: 1.7;
  margin-bottom: var(--space-md);
  position: relative;
  padding-left: var(--space-md);
  border-left: 3px solid var(--ptcl-green-light);
}

.quote-card cite {
  display: block;
  font-style: normal;
  font-size: 0.9rem;
  color: var(--muted);
}

.quote-card cite strong {
  color: var(--slate);
  font-weight: 600;
}

/* ===== Fintech cards (Page 3) ===== */
.fintech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.fintech-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  border-left: 4px solid var(--accent-gold);
}

.fintech-card h3 {
  color: var(--ptcl-green);
}

/* ===== Error state (failed data fetch or validation) ===== */
.error-state {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  color: var(--error-text);
  text-align: center;
  font-weight: 500;
}

.error-state[role="alert"] {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Loading state ===== */
.loading-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--muted);
  font-style: italic;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--slate);
  color: var(--cream);
  padding: var(--space-xl) 0;
  margin-top: auto;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-lg);
}

.site-footer h2,
.site-footer h3 {
  color: var(--cream);
  font-size: 1.1rem;
}

.site-footer p {
  color: #b0b3b8;
  font-size: 0.9rem;
  max-width: 400px;
}

.site-footer a {
  color: var(--accent-gold);
}

.footer-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.footer-nav a {
  color: #b0b3b8;
  font-size: 0.9rem;
}

.footer-nav a:hover {
  color: var(--accent-gold);
}

.footer-bottom {
  text-align: center;
  padding-top: var(--space-lg);
  border-top: 1px solid #4a4d62;
  margin-top: var(--space-lg);
  font-size: 0.85rem;
  color: #9ca0ad;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 1024px) {
  .hero h1 {
    font-size: 2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* Mobile */
@media (max-width: 767px) {
  /* Show hamburger, hide desktop nav */
  .nav-toggle {
    display: flex;
  }

  .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-subtle);
    /* max-height transition animates the dropdown */
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition);
  }

  .nav-list.nav-open {
    max-height: 300px;
  }

  .nav-list li {
    width: 100%;
  }

  .nav-list a {
    display: block;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
  }

  .nav-list a[aria-current="page"] {
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--ptcl-green);
  }

  /* Adjust hero */
  .hero {
    padding: var(--space-xl) 0;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  /* Stack grids to single column */
  .stats-grid,
  .oral-histories,
  .fintech-grid {
    grid-template-columns: 1fr;
  }

  /* Footer stacks */
  .site-footer .container {
    flex-direction: column;
  }

  /* Tighter spacing on mobile */
  section {
    margin-bottom: var(--space-xl);
  }

  .main-content {
    padding: var(--space-lg) 0;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.4rem;
  }
}

/* Large desktop */
@media (min-width: 1200px) {
  .container {
    padding: 0 var(--space-xl);
  }
}

/* ===== Print ===== */
@media print {
  .site-header,
  .nav-toggle,
  .site-footer {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .timeline-card,
  .metric-card,
  .quote-card,
  .fintech-card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}
