/* ===========================
   Mae Adventures - Discovery Sheets
   One-page science and engineering explainers.
   Loaded AFTER worksheet-print.css; reuses .ws-page, .ws-actions,
   .ws-screen-title, .ws-footer and the print machinery there.
   Each page sets its accent inline: style="--ds-accent:#4FC3F7"
   =========================== */

.ds-page {
  --ds-accent: #1FBDB2;
  --ds-tint: color-mix(in srgb, var(--ds-accent) 12%, #fff);
  min-height: auto;
  padding: 0.4in 0.5in 0.4in;
  position: relative;
  border: 3px solid var(--ds-accent);
  border-radius: 18px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Title band: framed, tinted banner with a peeking smiling star */
.ds-title {
  position: relative;
  text-align: center;
  background: var(--ds-tint);
  border: 2px solid var(--ds-accent);
  border-radius: 14px;
  padding: 0.4rem 2.4rem 0.5rem;
  margin-bottom: 0.55rem;
}
.ds-title h2 {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.12;
  color: var(--ds-accent);
}
.ds-title::after {
  content: "";
  position: absolute;
  top: -0.7rem;
  right: -0.6rem;
  width: 2.5rem;
  height: 2.5rem;
  background: url(../images/discovery/deco-star.webp) center / contain no-repeat;
  transform: rotate(12deg);
}
.ds-subtitle {
  display: inline-block;
  background: #fff;
  border: 1.5px solid var(--ds-accent);
  border-radius: 999px;
  padding: 0.12rem 0.75rem;
  font-size: 0.8rem;
  color: #555;
  margin: 0.25rem auto 0;
}

/* Hero illustration (text-free generated art) */
.ds-hero {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  margin-bottom: 0.5rem;
  border: 3px solid var(--ds-accent);
}

/* Figure wrapper: shrink-wraps the hero so percentage-positioned number
   markers stay aligned to the image in both screen and print. ds-page is a
   flex column (from .ws-page), so align-self:center collapses the figure to
   the rendered image width. */
.ds-figure {
  position: relative;
  align-self: center;
  max-width: 100%;
  margin-bottom: 0.5rem;
}
.ds-figure .ds-hero {
  max-width: 100%;
  margin: 0;
}
/* Numbered markers overlaid on the diagram, positioned via inline top/left % */
.ds-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--ds-accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Number the label-card grids that pair with overlay markers (opt-in, so
   marker-free sheets like States of Matter keep plain labels) */
.ds-grid--numbered { counter-reset: dsg; }
.ds-grid--numbered li { counter-increment: dsg; }
.ds-grid--numbered li strong::before { content: counter(dsg) ". "; }

/* Numbered steps (water cycle, plant life cycle, rainbows) */
.ds-steps {
  list-style: none;
  counter-reset: ds;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.8rem;
  padding: 0;
}
.ds-steps li {
  counter-increment: ds;
  position: relative;
  background: var(--ds-tint);
  border: 1.5px solid var(--ds-accent);
  border-radius: 10px;
  padding: 0.4rem 0.5rem 0.4rem 2rem;
  font-size: 0.8rem;
  line-height: 1.4;
}
.ds-steps li::before {
  content: counter(ds);
  position: absolute;
  left: 0.45rem;
  top: 0.4rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--ds-accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ds-steps li strong { font-weight: 800; }

/* Label cards (solar system, states of matter, simple machines) */
.ds-grid {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.ds-grid--3 { grid-template-columns: repeat(3, 1fr); }
.ds-grid--4 { grid-template-columns: repeat(4, 1fr); }
.ds-grid li {
  background: var(--ds-tint);
  border: 1.5px solid var(--ds-accent);
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  font-size: 0.74rem;
  line-height: 1.35;
}
.ds-grid li strong { display: block; font-size: 0.78rem; font-weight: 800; color: var(--ds-accent); }

/* Did you know? callout: a fun box with a smiling lightbulb (left) and a
   smiling Sam (right), both decorative CSS backgrounds so every sheet gets
   them automatically. */
.ds-fact {
  margin-top: 0.5rem;
  background:
    url(../images/discovery/deco-bulb.webp) left 0.55rem center / 1.7rem no-repeat,
    url(../images/character-sam-discover.png) right 0.5rem bottom 0.2rem / auto 4.9rem no-repeat,
    #FFF6D8;
  border: 2px dashed var(--ds-accent);
  border-radius: 12px;
  padding: 0.6rem 5rem 0.6rem 2.8rem;
  min-height: 5.3rem;
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  line-height: 1.45;
}
.ds-fact strong { font-weight: 800; color: var(--ds-accent); }

/* Keep accent colors and decorations when printing */
.ds-page, .ds-title, .ds-hero, .ds-steps li, .ds-steps li::before,
.ds-grid li, .ds-fact, .ds-marker {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* One-page print: constrain the hero, tighten padding */
@media print {
  /* Zero page margin removes the browser's auto print header/footer (page
     title, date, and URL). The framed sheet is instead inset from the paper
     by its own margin, so the border still does not touch any edge. */
  @page { margin: 0; }
  .ds-page {
    margin: 0.4in auto;
    padding: 0.3in 0.4in 0.3in;
    border-radius: 16px;
    overflow: hidden;
  }
  .ds-hero {
    max-height: 4.1in;
    width: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  /* Portrait heroes (e.g. the human body) get a taller cap so they do not
     shrink to a thin column when printed. */
  .ds-hero--tall { max-height: 5.1in; }
  /* Inside a figure the height cap drives the width so the figure (and its
     markers) shrink with the image; margins handled by the centered figure. */
  .ds-figure .ds-hero {
    margin-left: 0;
    margin-right: 0;
  }
  .ds-page .ws-footer { padding-top: 0.15in; }
}

/* Small screens: callouts stack to one column */
@media (max-width: 560px) {
  .ds-steps { grid-template-columns: 1fr; }
  .ds-grid--3, .ds-grid--4 { grid-template-columns: 1fr 1fr; }
}
