/* ========== C01: PAGE DEFAULTS ==========
   The universal selector includes padding and borders in declared widths.
   Body typography is inherited. rem is relative to the root font size. */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', Arial, sans-serif;
  color: #172b42;
  background: #fff;
  line-height: 1.65;
}

h1, h2, h3 {
  line-height: 1.15;
}

h1 {
  font-size: 3rem;
  letter-spacing: -0.04em;
  margin: 0 0 1rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.25rem;
}

p {
  max-width: 65ch;
}

a {
  color: #155a9c;
  text-underline-offset: 0.2em;
}

a:hover {
  color: #943617;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font: inherit;
}

button, summary {
  cursor: pointer;
}

/* ========== C02: SHARED PAGE SHELL (COPIED FOR INDEPENDENCE) ==========
   .container centers content with auto margins. Flexbox arranges navigation.
   This block is deliberately repeated in each page CSS: no hidden imports. */
.container {
  width: 90%;
  max-width: 1120px;
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid #dbe3eb;
  background: white;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 0;
  flex-wrap: wrap;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  color: #172b42;
}

.brand ion-icon {
  color: #c04e28;
  vertical-align: middle;
  font-size: 1.5rem;
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

nav a {
  color: inherit;
  text-decoration: none;
  font-size: 0.95rem;
}

nav a[aria-current='page'] {
  color: #a93917;
  border-bottom: 2px solid currentColor;
}

main {
  min-height: 65vh;
}

section {
  padding: 2.5rem 0;
}

.page-heading {
  padding: 3.5rem 0 1rem;
}

.eyebrow {
  color: #a93917;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.lead {
  font-size: 1.2rem;
  color: #42586e;
}

.site-footer {
  background: #102d49;
  color: white;
  padding: 2.5rem 0;
  margin-top: 3rem;
}

.site-footer a {
  color: #d7e9fa;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ========== C03: BASIC REUSABLE ELEMENTS ==========
   A class can style many elements. Padding is inside; margin is outside.
   Use a link for navigation and a button for an action. */
.button, button {
  display: inline-block;
  background: #174f7e;
  color: white;
  padding: 0.7rem 1.2rem;
  border: 1px solid #174f7e;
  border-radius: 4px;
  text-decoration: none;
}

.button:hover, button:hover {
  background: #113b60;
  color: white;
}

.secondary {
  color: #174f7e;
  background: white;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.card {
  border: 1px solid #dbe3eb;
  border-radius: 6px;
  overflow: hidden;
  background: white;
}

.card-body {
  padding: 1.25rem;
}

.card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.note {
  background: #eef5fa;
  border-left: 4px solid #276493;
  padding: 1rem;
}

.tag {
  display: inline-block;
  font-size: 0.85rem;
  background: #edf3f8;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}

/* ========== C04: KEYBOARD ACCESS ==========
   :focus-visible makes keyboard focus clear. The skip link appears on focus. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #bd481e;
  outline-offset: 4px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  background: white;
  padding: 0.8rem;
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
}

/* ========== C30: FLEX CONTAINER AND ITEMS ==========
   TEACH: Main-axis alignment uses justify-content; cross-axis alignment uses align-items. Flex items can grow, shrink and set a basis. */
.flex-demo {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  align-items: center;
  align-content: space-around;
  gap: 1rem;
  min-height: 150px;
  background: #edf4fa;
  padding: 1rem;
}

.flex-demo > div {
  flex: 1 1 180px;
  padding: 1rem;
  background: #d4e3ef;
}

.flex-demo > div:nth-child(2) {
  flex-grow: 2;
  align-self: stretch;
}

@media (max-width: 700px) {
  .flex-demo {
    flex-direction: column;
    align-items: stretch;
  }

  .flex-demo > div {
    flex-basis: auto;
  }

}

/* ========== C31: GRID TRACKS, ITEMS AND NAMED AREAS ==========
   TEACH: Grid uses rows and columns. Named areas place content; gap separates tracks. Preserve reading order when changing visual order. */
.grid-demo {
  display: grid;
  grid-template-columns: [start] 1fr [middle] 2fr [end];
  grid-template-rows: auto 100px auto;
  grid-template-areas: 'title title' 'menu content' 'foot foot';
  gap: 12px;
  justify-content: center;
  align-items: stretch;
}

.grid-demo > div {
  background: #edf4fa;
  padding: 1rem;
}

.grid-title {
  grid-area: title;
}

.grid-menu {
  grid-area: menu;
}

.grid-content {
  grid-area: content;
  align-self: center;
  justify-self: stretch;
}

.grid-foot {
  grid-area: foot;
}

.twelve-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  margin-top: 1rem;
}

.twelve-grid span {
  background: #d4e3ef;
  padding: 1rem;
  grid-column: span 4;
}

.twelve-grid span + span {
  grid-column: span 8;
}

@media (max-width: 700px) {
  .grid-demo {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: 'title' 'menu' 'content' 'foot';
  }

}

/* ========== C32: 3D TRANSFORMS ==========
   TEACH: Perspective controls depth. A checkbox triggers the flip without hover. The cube and carousel are static geometry demonstrations. */
.flip-stage {
  perspective: 700px;
  width: 240px;
  height: 150px;
  margin: 1rem 0;
}

.flip-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.flip-card > div {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  background: #d4e3ef;
}

.flip-card .back {
  transform: rotateY(180deg);
  background: #f8dbb9;
}

/* :has lets the parent react to its checked descendant. Unsupported browsers show the front. */
#l32:has(#flip-toggle:checked) .flip-card {
  transform: rotateY(180deg);
}

.cube-stage {
  perspective: 500px;
  margin: 3rem;
  height: 130px;
}

.cube {
  position: relative;
  width: 90px;
  height: 90px;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(30deg);
}

.cube span {
  position: absolute;
  width: 90px;
  height: 90px;
  background: #d4e3efee;
  border: 1px solid #174f7e;
  text-align: center;
  padding-top: 25px;
}

.cube-front {
  transform: translateZ(45px);
}

.cube-back {
  transform: rotateY(180deg) translateZ(45px);
}

.cube-left {
  transform: rotateY(-90deg) translateZ(45px);
}

.cube-right {
  transform: rotateY(90deg) translateZ(45px);
}

.cube-top {
  transform: rotateX(90deg) translateZ(45px);
}

.cube-bottom {
  transform: rotateX(-90deg) translateZ(45px);
}

.carousel-stage {
  perspective: 500px;
  height: 150px;
  margin: 3rem;
}

.carousel {
  position: relative;
  width: 100px;
  height: 70px;
  transform-style: preserve-3d;
  transform: rotateY(-20deg);
}

.carousel span {
  position: absolute;
  width: 100px;
  height: 70px;
  background: #d4e3ef;
  border: 1px solid #174f7e;
  padding: 1rem;
}

.carousel span:nth-child(1) {
  transform: rotateY(0deg) translateZ(60px);
}

.carousel span:nth-child(2) {
  transform: rotateY(120deg) translateZ(60px);
}

.carousel span:nth-child(3) {
  transform: rotateY(240deg) translateZ(60px);
}

@media (prefers-reduced-motion: reduce) {
  .flip-card {
    transition: none;
  }

}

/* ========== C33: VERTICAL NAVIGATION, STICKY AND PAGINATION ==========
   TEACH: Sticky stays within its scrolling container. Pagination links navigate to real separate pages. */
.sticky-demo {
  height: 240px;
  overflow: auto;
  border: 1px solid #ccd8e2;
}

.vertical-nav {
  position: sticky;
  top: 0;
  background: #edf4fa;
  padding: 0.6rem;
  z-index: 2;
}

.vertical-nav a {
  display: block;
  padding: 0.3rem;
}

.tall-demo {
  min-height: 300px;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination a {
  padding: 0.5rem 1rem;
  border: 1px solid #ccd8e2;
}

.fixed-help {
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 3;
  padding: 0.4rem;
  background: #fff;
  border: 1px solid #ccd8e2;
}

/* ========== C34: RESPONSIVE FLOAT GRID AND FRAMEWORK COMPARISON ==========
   TEACH: A percentage float grid demonstrates older responsive layouts. Frameworks provide premade classes; this project stays plain CSS. */
.float-grid::after {
  content: '';
  display: table;
  clear: both;
}

.float-grid > div {
  float: left;
  width: 33.333%;
  padding: 1rem;
  border: 1px solid #ccd8e2;
}

.float-grid > div + div {
  width: 66.667%;
}

@media (max-width: 700px) {
  .float-grid > div, .float-grid > div + div {
    width: 100%;
  }

}

/* ========== C90: RESPONSIVE LAYOUT ==========
   This rule applies only at 700px or narrower. Source order matters. */
@media (max-width: 700px) {
  h1 {
    font-size: 2.2rem;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .header-row {
    align-items: flex-start;
  }

  nav ul {
    gap: 0.8rem;
  }

}

/* ========== C91: PRINT ==========
   Print removes navigation and dark backgrounds to save ink. */
@media print {
  .site-header, .site-footer, .skip-link, button {
    display: none;
  }

  body {
    color: black;
    background: white;
  }

  .container {
    width: 100%;
  }

  a {
    color: black;
  }

}

/* ========== C35: NON-INTERACTIVE VISUAL ORDER DEMO ==========
   order changes visual placement, not reading/tab order. Never use this to repair bad HTML order. */
.order-demo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.order-demo span {
  padding: 1rem;
  background: #edf4fa;
}

.order-demo span:first-child {
  order: 2;
}

.order-demo span:last-child {
  order: 1;
}
