/* Mobile first: the base styles are for small screens, media queries add more. */
:root {
  --bg: #fbfaf7;
  --card: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --accent: #c2410c;
  --on-accent: #ffffff;
}

/* Media query 1: follow the system dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --card: #1f1c18;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --line: #3a3530;
    --accent: #fb923c;
    --on-accent: #1c1917;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

.breakpoint {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  margin: 0;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.breakpoint::after {
  content: "Phone layout";
}

.masthead {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  color: var(--accent);
}

.masthead ul {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.masthead a {
  display: block;
  padding: 0.5rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.masthead a:hover,
.masthead a:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.layout {
  display: grid;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
}

main {
  display: grid;
  gap: 1rem;
}

.post {
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--tone);
  border-radius: 10px;
}

.post h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

.post p {
  margin-bottom: 0;
  color: var(--muted);
}

.sidebar {
  padding: 1.25rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px dashed var(--accent);
}

.sidebar h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.footer {
  padding: 1rem 1rem 4rem;
  text-align: center;
  color: var(--muted);
}

/* Media query 2: tablets get a horizontal menu and two cards per row */
@media (min-width: 600px) {
  .breakpoint::after {
    content: "Tablet layout";
  }

  .masthead ul {
    flex-direction: row;
    justify-content: center;
  }

  main {
    grid-template-columns: 1fr 1fr;
  }
}

/* Media query 3: desktops add the sidebar on the right */
@media (min-width: 900px) {
  .breakpoint::after {
    content: "Desktop layout";
  }

  .masthead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-inline: 2rem;
  }

  h1 {
    margin: 0;
  }

  .layout {
    grid-template-columns: 3fr 1fr;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
  }

  .sidebar {
    align-self: start;
    position: sticky;
    top: 1rem;
  }
}

/* Media query 4: printing hides the menu and the badge */
@media print {
  .breakpoint,
  .masthead nav {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
