html {
  font-size: 16px; /* default browser font size */
}

@media (min-width: 1024px) {
  main {
    font-size: 18px; /* larger font on bigger screens */
  }
}

/*fonts*/
body {
  font-family: "Roboto", sans-serif;
  background-color: hsl(192, 15%, 94%); /* Main content background */
  color: hsl(210, 29%, 24%); /* Default text color */
  padding-top: 4rem; /* Push content below the fixed menu */
}

/* Header styling */
.main-header {
  text-align: center;
}

.main-header h1 {
  margin: 0;
}

.main-header h2 {
  margin: 0.625rem 0 0 0;
}

/* Footer styling */
footer {
  text-align: center;
}

h1,
h2,
h3,
h4 {
  font-family: "Merriweather", serif;
}

/* Main page header overrides */
.main-header h1 {
  font-size: 2.5rem;
}

.main-header h2 {
  font-size: 1.5rem;
  font-weight: 400;
  color: hsl(210, 20%, 35%);
}

main section h2 {
  font-weight: 600;
}

/* Horizontal menu */
header nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: hsl(208, 32%, 76%);
  z-index: 1000;
  margin: 0; /* remove any default margin */
  padding: 0; /* remove any default padding */
}

.menu {
  /* Menu list styling */
  list-style: none;
  display: flex;
  gap: 2.2rem;
  margin: 0; /* remove default margin from ul */
  padding: 0 1.25rem; /* horizontal padding inside menu */
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto; /* allow horizontal scroll */
  overflow-y: hidden; /* avoid vertical scrollbars */
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
}

@media (max-width: 768px) {
  .menu {
    gap: 1rem; /* smaller gap for menu links on mobile */
  }
}

.menu a {
  /* Menu links styling */
  display: block;
  text-decoration: none;
  color: hsl(210, 29%, 24%);
  font-weight: 600;
  padding: 0.9375rem 0.625rem;
  flex: 0 0 auto; /* prevents shrinking, keeps width */
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.menu a:hover,
.menu a:focus {
  /* Hover effect */
  background: hsl(209, 26%, 69%);
  color: hsl(210, 29%, 24%);
}

/*Grid layout for articles - index.html*/
.topics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.topic {
  /* Individual topic block (clickable) */
  display: block;
  min-height: 9rem; /* makes all blocks same height */
  background: hsl(0, 0%, 98%); /* light card background */
  padding: 1.25rem;
  border-radius: 10px;
  box-shadow: 0 2px 6px hsla(0, 0%, 0%, 0.1);
  text-decoration: none; /* removes underline if using <a> */
  color: inherit; /* inherits text color */
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.topic:hover {
  /* Hover effect */
  transform: translateY(-5px) scale(1.02); /* lift and subtle zoom */
  box-shadow: 0 8px 15px hsla(0, 0%, 0%, 0.2);
  background: hsl(208, 100%, 97%); /* light highlight background */
}

.topic h3 {
  /* Topic headings */
  font-size: 1.2rem;
  margin-bottom: 10px;
  transition: color 0.2s ease;
}

.topic:hover h3 {
  /* Hover heading color change */
  color: hsl(205, 100%, 40%); /* accent color */
}

.topic p {
  /* Topic paragraph */
  font-size: 0.95rem;
  line-height: 1.5;
}

/* media for grid */
@media (max-width: 768px) {
  .topics {
    grid-template-columns: 1fr; /* stack blocks on smaller screens */
  }
}

/* ol and li styling */
main ol {
  padding-left: 1.25rem;
}

main li {
  margin-bottom: 0.9375rem;
  line-height: 1.5;
}

/* bibliography styling */
.bibliography {
  list-style: none; /* remove default numbering */
  counter-reset: ref-counter;
}

.bibliography li {
  counter-increment: ref-counter;
  margin-bottom: 0.5em;
  scroll-margin-top: 5rem; /* Offset this element by the height of the fixed menu so that 
                              when a link to it is clicked, the element is not hidden behind the menu */
}

.bibliography li::before {
  content: "[" counter(ref-counter) "] ";
  font-weight: bold;
}

/* Styling for 2 Tables in Stats Page */
.tables-container {
  display: flex;
  justify-content: center;
  gap: 2.5rem; /* space between the two tables */
  flex-wrap: wrap; /* stack vertically if screen is too narrow */
  margin: 1.25rem 0;
}

table {
  border-collapse: collapse;
  font-size: 0.95rem;
  background: hsl(0, 0%, 100%);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

caption {
  caption-side: top;
  font-weight: bold;
  text-align: center;
  margin-bottom: 0.625rem;
}

.mena-table,
.lebanon-table {
  width: 100%;
  max-width: 40rem;
}

th,
td {
  border: 1px solid hsl(0, 0%, 80%);
  padding: 0.5rem 0.75rem;
  text-align: center;
}

th {
  background-color: hsl(0, 0%, 95%);
  font-weight: bold;
}

tfoot td {
  text-align: center;
  font-size: 0.85rem;
  padding: 0.375rem;
}

tfoot a {
  color: hsl(210, 100%, 40%);
  text-decoration: none;
}

tfoot a:hover {
  text-decoration: underline;
}

/* General figcaption styling for all figures */
figcaption {
  font-size: 0.9em;
  color: hsl(0, 0%, 33%); /* consistent gray color */
  margin-top: 0.3125rem; /* spacing above caption */
  text-align: center; /* center captions */
  font-weight: 550;
}

/* Three-column layout */
.text-image-block.three-columns {
  display: flex;
  gap: 1.25rem; /* space between text and images */
  align-items: flex-start;
  flex-wrap: wrap; /* stack on small screens */
}

.text-image-block.three-columns .text-column {
  /* Text column */
  flex: 1;
  min-width: 15.625rem; /* prevent text from being too narrow */
}

.text-image-block.three-columns .images-column {
  /* Images column */
  flex: 1;
  display: flex;
  flex-direction: row; /* images side by side */
  gap: 1.25rem; /* space between images */
  justify-content: flex-start;
  align-items: flex-start;
}

.images-column figure:first-child {
  flex: 1; /* NeXT image*/
}

.images-column figure:last-child {
  flex: 3; /* Tim image*/
}

.text-image-block.three-columns .images-column figure {
  /* Each figure */
  flex: 1; /* equal width for images */
  margin: 0;
  text-align: center;
}

.text-image-block.three-columns img {
  /* Images */
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Responsive: stack vertically on small screens */
@media (max-width: 768px) {
  .text-image-block.three-columns {
    flex-direction: column;
    gap: 0.9375rem;
  }

  .text-image-block.three-columns .text-column,
  .text-image-block.three-columns .images-column {
    width: 100%;
    flex: none;
  }

  .text-image-block.three-columns .images-column {
    flex-direction: row; /* images side by side on mobile */
    justify-content: center;
    gap: 0.625rem;
  }

  .text-image-block.three-columns .images-column figure {
    flex: 1;
  }
}

.centered-figure {
  /* Centers figures with captions, makes images responsive, and adds spacing */
  margin: 1.25rem auto; /* vertical spacing + center horizontally */
  text-align: center; /* centers caption text */
  max-width: 90%; /* optional: prevent image from being too wide */
}

.centered-figure img {
  max-width: 60%; /* responsive image */
  height: auto; /* maintain aspect ratio */
}

#browser-market-share-image {
  max-width: 40%;
  height: auto;
}

@media (max-width: 768px) {
  #browser-market-share-image {
    max-width: 90%;
  }
  #cyber-attacks-image {
    max-width: 100%;
  }
}

.full-width-figure {
  margin: 1.25rem 0; /* vertical spacing */
  text-align: center; /* centers caption if added */
}

.full-width-figure img {
  width: 100%; /* takes full width of container/screen */
  height: auto; /* maintains aspect ratio */
  display: block; /* removes small inline spacing */
}

.round-image-corners {
  border-radius: 1.25rem;
}

@media (max-width: 768px) {
  .round-image-corners {
    border-radius: 0.625rem; /* less rounding on mobile */
  }
}

/* Styling for preformatted text */
pre {
  font-family: monospace; /* better font for code */
  font-size: 1.1rem; /* slightly larger */
  font-weight: 600; /* semi-bold */
  color: hsl(0, 0%, 9%); /* black text */
  padding: 0.5rem 1rem; /* extra horizontal padding */
  border-left: 4px solid hsl(0, 0%, 9%); /* subtle gray highlight */
}

/* Custom bullet points for CSS at-rules list */
ul.at-rules {
  list-style-type: none; /* remove default bullets */
  padding-left: 1rem; /* spacing from left */
}

ul.at-rules li::before {
  content: "→";
  color: hsl(210, 100%, 20%);
  font-weight: bold;
  margin-right: 0.5rem; /* space between arrow and text */
}

/* Text and image side by side with image on right */
.text-image-right {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap; /* Allows wrapping on smaller screens */
}

.text-image-right p {
  flex: 1;
  margin: 0;
  min-width: 300px; /* Ensures text has minimum space before wrapping */
}

.float-right {
  flex: 0 0 300px; /* Don't grow or shrink, fixed at 300px */
  order: 2; /* Ensures image appears on the right */
  margin: 0 10rem 0 0;
}

.float-right img {
  width: 100%;
  height: auto;
  max-height: 260px; /* Limits the maximum height */
  object-fit: cover; /* Maintains aspect ratio while cropping if needed */
  display: block;
  border-radius: 8px;
}

.float-right figcaption {
  font-size: 0.875rem;
  color: #666;
  text-align: center;
  margin-top: 0.5rem;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .text-image-right {
    flex-direction: column;
  }

  .text-image-right p {
    min-width: auto;
  }

  .float-right {
    flex: none;
    max-width: 250px;
    margin: 1rem auto 0;
    order: 1;
  }
}
