/* ============================================================
   USA Money Worksheets — built on the Count & Color reference
   visual language (count_color.css), plus the Pre-K /
   Kindergarten level selector this page needs.
   ============================================================ */
:root {
  --brand-blue: #2f5fee;
  --text-primary: #0e2770;
  --text-secondary: #334155;
  --border-color: #e2e8f0;
  --stage-pad: 0.85rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
body {
  background: #ffffff;
  font-family: var(--smw-font-stack);
  color: var(--text-secondary);
}

img { max-width: 100%; }

.ico { flex-shrink: 0; }

.ico-ws {
  width: 1.35rem;
  height: 1.35rem;
}

/* Container & Main Grid Layout */
.main-col-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.main-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid rgba(50, 53, 62, .11);
  min-width: 0;
  border-radius: 10px;
  box-shadow: 0 6px 5px -5px #8FABD9;

}

.main-col:first-of-type { padding-top: 0.5rem; }
.main-col:last-child {
  border-bottom: none;
  padding-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .main-col {
    grid-template-columns: 200px 1fr;
    align-items: start;
    gap: 1.5rem;
  }

  .viewer { justify-content: flex-start; }
  .stage { justify-content: flex-start; }
}

@media (min-width: 1024px) {
  .main-col {
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    padding: 1rem 0;
  }
}

@media (min-width: 1280px) {
  .main-col-container { padding: 0; }
  .main-col { grid-template-columns: 260px 1fr; }
}

/* Breadcrumb & Header */
.counting-main .breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.counting-main .breadcrumb a {
  color: var(--brand-blue);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
}

.counting-main .breadcrumb a:hover { text-decoration: underline; }

.counting-main .breadcrumb .current {
  color: #0f172a;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.counting-main .page-header.counting-header-strip {
  padding: 1.125rem 1.25rem;
  background: oklch(0.95 0.03 264);
  border: 2px solid oklch(0.75 0.12 264);
  border-radius: 1rem;
  margin-bottom: 0rem;
  box-sizing: border-box;
}

.counting-main .counting-header-strip .title {
  font-family: var(--smw-font-stack);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #0e2770;
  text-align: center;
  margin: 0 0 0.5rem 0;
}

.counting-main .counting-header-strip .subtitle {
  font-size: 15px;
  line-height: 1.55;
  color: #0b205f;
  font-weight: 500;
  margin: 0;
  width: 100%;
  max-width: 100%;
  text-align: left;
}

/* ============================================================
   LEVEL SELECTOR (Pre-K / Kindergarten) — new for this page
   Scoped to .banner-level-selector so it cannot leak into any
   other page's styling.
   ============================================================ */
.banner-controls-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.banner-level-selector {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.35rem;
  background: #ffffff;
  border: 1.5px solid oklch(0.75 0.12 264);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(47, 95, 238, 0.08);
}

.banner-level-selector .level-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.banner-level-selector .level-btn:hover {
  background: oklch(0.95 0.03 264);
}

.banner-level-selector .level-btn.is-active {
  background: var(--brand-blue);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(47, 95, 238, 0.3);
}

.banner-level-selector .level-btn:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .banner-level-selector {
    width: 100%;
    justify-content: center;
    flex-direction: column;
    border-radius: 16px;
  }

  .banner-level-selector .level-btn {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* Left Thumbnail Section */
.viewer {
  display: flex;
  justify-content: center;
  width: 100%;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  padding: var(--stage-pad);
  border-radius: 14px;
}

@media (min-width: 768px) {
  .stage {
    max-width: 100%;
    margin: 0;
  }
}

.stage-preview-link {
  display: flex;
  justify-content: center;
  width: auto;
  text-decoration: none;
}

.stage img {
  box-shadow: 2px 2px 10px oklch(75.075% 0.1194 263.698 / 0.911), -2px -2px 10px oklch(75.075% 0.1194 263.698 / 0.911);
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  width: 190px;
  height: 250px;
}

.stage img:hover {
  box-shadow: 2px 2px 10px #55BAFF, -2px -2px 10px #55BAFF;
}

.info {
  padding-top: var(--stage-pad);
  min-width: 0;
}

.worksheet-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.worksheet-description {
  font-size: 16px;
  line-height: 1.6;
  color: #0b205f;
  margin: 0 0 1.1rem 0;
  max-width: 62ch;
  font-weight: 500;
}

.worksheet-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
}

/* ============================================================
   Download Pill + Answer Key circle (copied from count_color.css)
   ============================================================ */
.ws-item {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem; /* Gap between the pill and key circle */
  width: fit-content;
  max-width: 100%;
}

.btn-ws-dl {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  height: 2.75rem;
  padding: 0 1.1rem 0 0.85rem;
  background: #F4F8FF;
  color: #121052;
  border: 1.5px solid #BFD8FF;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(59, 114, 196, 0.12);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.btn-ws-dl .ws-label {
  font-family: var(--smw-font-stack);
  letter-spacing: -0.01em;
}

.btn-ws-dl:hover {
  background: #EBF3FF;
  box-shadow: 0 8px 20px rgba(59, 114, 196, 0.18);
  transform: translateY(-2px);
}

.btn-ws-dl:active { transform: translateY(0); }

/* Separate Right Answer Key Circle Button */
.btn-key-dl {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;  /* Exact same height as pill button */
  height: 2.75rem;
  border-radius: 50%;
  background: #FFF0F5;
  border: 1.5px solid #FDC2D6;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(244, 37, 82, 0.12);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}

.btn-key-dl:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(244, 37, 82, 0.18);
  background: #FFE4ED;
}

.btn-key-dl:active { transform: translateY(0); }

/* Key icon sits inside the circle at a fixed size (not full-bleed) */
.ico-key {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.ico-key path {
  fill: #EC2251;
}

/* Proportional size bump on larger screens */
@media (min-width: 768px) {
  .btn-ws-dl {
    height: 2.875rem;
    padding: 0 1.25rem 0 0.95rem;
    font-size: 1.05rem;
    gap: 0.6rem;
  }

  .btn-key-dl {
    width: 2.875rem;
    height: 2.875rem;
  }

  .ico-ws {
    width: 1.45rem;
    height: 1.45rem;
  }

  .ico-key {
    width: 1.2rem;
    height: 1.2rem;
  }
}

@media (min-width: 1024px) {
  .btn-ws-dl {
    height: 3rem;
    padding: 0 1.4rem 0 1rem;
    font-size: 1.1rem;
    gap: 0.65rem;
  }

  .btn-key-dl {
    width: 3rem;
    height: 3rem;
  }

  .ico-ws {
    width: 1.55rem;
    height: 1.55rem;
  }

  .ico-key {
    width: 1.3rem;
    height: 1.3rem;
  }
}

/* Mobile safety — same guard the reference page uses */
@media (max-width: 767px) {
  .main-col-container {
    overflow-x: hidden;
    overflow-x: clip; /* modern browsers: clips x only, never creates a y-scroll box */
  }

  .counting-main .page-header.counting-header-strip {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    border: 2px solid oklch(0.75 0.12 264);
  }
}

.print-layer { display: none; }

/* ============================================================
   MONEY TITLE ROW + COUNTRY SELECTOR (flag + full country name)
   Scoped to .money-header-row / .money-topbar / .money-country-* so
   the shared .counting-header-strip / .title / .breadcrumb rules used
   by Count & Color and other pages are NOT changed.
   ============================================================ */

/* Title row inside the header strip (title only; left aligned). */
.counting-main .money-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.counting-main .money-header-row .title {
  text-align: center;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

/* Breadcrumb on the left, country selector on the right. */
.counting-main .money-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 12px;
}

.counting-main .money-topbar .breadcrumb {
  margin-bottom: 0;
}

.money-country-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.money-country-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.money-country-dropdown {
  position: relative;
}

/* Closed state: flag + country name, same pill look as the level selector. */
.money-country-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.85rem 0.4rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  background: #ffffff;
  border: 1.5px solid oklch(0.75 0.12 264);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(47, 95, 238, 0.08);
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.money-country-trigger {
  max-width: 100%;
}

.money-country-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money-country-trigger::-webkit-details-marker { display: none; }
.money-country-trigger::marker { content: ""; }

.money-country-trigger:hover {
  background: oklch(0.95 0.03 264);
}

.money-country-trigger:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.money-country-dropdown[open] > .money-country-trigger {
  box-shadow: 0 0 0 3px rgba(47, 95, 238, 0.15);
}

.money-country-chevron {
  flex-shrink: 0;
  transition: transform 0.2s var(--ease);
}

.money-country-dropdown[open] .money-country-chevron {
  transform: rotate(180deg);
}

/* Flag icons (157x92 SVGs). */
.money-country-flag {
  display: block;
  flex-shrink: 0;
  width: 28px;
  height: auto;
  aspect-ratio: 157 / 92;
  border-radius: 3px;
}

/* Open state: list of all countries, current one highlighted. */
.money-country-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 100%;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(20, 30, 60, 0.14);
}

.money-country-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease);
}

.money-country-option .money-country-flag {
  width: 32px;
}

.money-country-option:hover {
  background: oklch(0.95 0.03 264);
}

.money-country-option.is-current {
  background: oklch(0.93 0.05 264);
  color: var(--brand-blue);
  font-weight: 700;
}

.money-country-option:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: -2px;
}

/* ------------------------------------------------------------
   RESPONSIVE FIXES for the top bar, country selector and header.

   Root cause of the old mobile bug: .money-topbar is flex-wrap: wrap.
   When it became a column on phones, its single line was sized by the
   WIDEST child (the full one-line breadcrumb / the nowrap dropdown),
   not by the screen, so everything stayed wider than the screen and
   was clipped. Phones now use a non-wrapping column, so every child is
   exactly as wide as the container and long text wraps.
   ------------------------------------------------------------ */

/* Tablet (768px - 1023px): keep one row, let the breadcrumb shrink. */
@media (min-width: 768px) {
  .counting-main .money-topbar .breadcrumb {
    flex: 1 1 280px;
    min-width: 0;
  }

  .money-country-picker {
    flex: 0 1 auto;
    min-width: 0;
  }

  .money-country-list {
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* Phones and small tablets (up to 767px). */
@media (max-width: 767px) {
  .counting-main .money-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .counting-main .money-topbar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.75rem;
    min-width: 0;
    width: 100%;
  }

  .counting-main .money-topbar .breadcrumb {
    min-width: 0;
    max-width: 100%;
  }

  /* Label on its own line, dropdown full width underneath. */
  .money-country-picker {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-left: 0;
    min-width: 0;
    width: 100%;
  }

  .money-country-dropdown {
    width: 100%;
    min-width: 0;
  }

  .money-country-trigger {
    display: flex;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
  }

  .money-country-name {
    flex: 1 1 auto;
    text-align: left;
  }

  .money-country-list {
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
  }

  .money-country-option {
    white-space: normal;
  }

  /* Header strip: smaller title and padding so it never dominates a phone. */
  .counting-main .page-header.counting-header-strip {
    padding: 1rem;
  }

  .counting-main .counting-header-strip .title {
    font-size: clamp(1.5rem, 6.6vw, 1.875rem);
    overflow-wrap: anywhere;
  }

  .counting-main .counting-header-strip .subtitle {
    font-size: 14.5px;
  }
}

/* Very narrow phones (<= 340px): drop the "(current)" suffix so the name never truncates. */
@media (max-width: 340px) {
  .money-country-current { display: none; }
}