/* More Grammar home page - responsive at every viewport and browser display scale. */
html, body { width:100%; height:100%; margin:0; }
body.home-page {
  overflow:hidden;
  background:
    radial-gradient(circle at 83% 10%, rgba(188,224,250,.90), transparent 43%),
    radial-gradient(circle at 8% 91%, rgba(255,237,218,.78), transparent 45%),
    linear-gradient(135deg,#fbfdff 0%,#f4f8fc 48%,#fffaf4 100%);
  color:#252525;
  font-family:"Segoe UI",Arial,sans-serif;
}
.home-page *, .home-page *::before, .home-page *::after { box-sizing:border-box; }
.home-page a { -webkit-tap-highlight-color:transparent; }

.home-shell {
  position:relative;
  width:100%;
  height:100dvh;
  min-height:320px;
  overflow:hidden;
  isolation:isolate;
  padding:clamp(12px,2.5vh,24px) clamp(16px,2.4vw,34px) clamp(10px,1.8vh,18px);
}

.home-header {
  position:relative;
  z-index:5;
  height:clamp(30px,7.5vh,62px);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
}
.macmillan-link { display:block; width:clamp(82px,10vw,126px); }
.macmillan-link img { display:block; width:100%; height:auto; object-fit:contain; }
.more-grammar-logo { display:block; width:clamp(155px,18vw,230px); height:auto; object-fit:contain; margin-top:1px; }

.grade-section { position:relative; z-index:5; }
.grade-section h1,
.series-section h2 {
  margin:0;
  font-weight:800;
  letter-spacing:-.025em;
  color:#303235;
}
.grade-section h1 {
  font-size:clamp(21px,2.55vw,34px);
  line-height:1.1;
  margin:clamp(6px,1.2vh,14px) 0 clamp(11px,1.7vh,18px);
}

.grade-carousel {
  position:relative;
  width:calc(100% + clamp(32px,4.8vw,68px));
  margin-left:clamp(-34px,-2.4vw,-16px);
  padding:0;
}
.grade-grid {
  display:flex;
  flex-wrap:nowrap;
  gap:clamp(10px,1.25vw,18px);
  width:100%;
  overflow:hidden;
  padding:clamp(8px,1vh,12px) 0 clamp(14px,1.8vh,20px);
}
.grade {
  /* First view: five full cards + half of Grade 6. */
  flex:0 0 calc((100% - clamp(50px,6.25vw,90px)) / 5.5);
  min-width:0;
  height:clamp(250px,30vh,300px);
  border-radius:clamp(15px,1.4vw,22px);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  padding:clamp(9px,1.2vh,14px) clamp(7px,.7vw,11px) clamp(11px,1.2vh,15px);
  text-decoration:none;
  color:#4b4b4b;
  border:1px solid rgba(0,0,0,.025);
  box-shadow:0 3px 9px rgba(20,30,45,.10);
  transform-origin:center center;
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease;
  position:relative;
  z-index:1;
  scroll-snap-align:center;
}
.grade:hover,
.grade:focus-visible {
  transform:scale(1.08);
  z-index:20;
  box-shadow:0 14px 30px rgba(20,30,45,.20);
  filter:saturate(1.03);
  outline:none;
}
.grade:active { transform:scale(1.05); }
.grade img {
  width:clamp(72px,7.5vw,108px);
  height:clamp(66px,8.5vh,92px);
  object-fit:contain;
  display:block;
  margin:auto auto clamp(7px,1vh,11px);
  flex:0 0 auto;
}
.grade span {
  display:block;
  width:100%;
  text-align:center;
  white-space:nowrap;
  font-size:clamp(13px,1.35vw,19px);
  line-height:1.05;
  font-weight:700;
}
.grade-arrow {
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:clamp(42px,4vw,58px);
  height:clamp(42px,4vw,58px);
  border:0;
  border-radius:50%;
  background:rgba(255,255,255,.96);
  box-shadow:0 5px 18px rgba(20,30,45,.16);
  color:#555;
  cursor:pointer;
  z-index:30;
  display:grid;
  place-items:center;
  transition:transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  line-height:1;
}
.grade-next { right:0; }
.grade-prev { left:0; }
.grade-arrow:hover { transform:translateY(-50%) scale(1.06); box-shadow:0 8px 22px rgba(20,30,45,.22); }
.grade-arrow span { font-size:clamp(30px,3vw,44px); line-height:1; font-weight:400; margin-top:-3px; }
.grade-arrow.is-hidden { opacity:0; pointer-events:none; }
.grade-grid.page-two .grade:nth-child(-n+5) { display:none; }
.grade-grid:not(.page-two) .grade:nth-child(n+7) { display:none; }
.grade-grid.page-two .grade { flex-basis:calc((100% - clamp(20px,2.5vw,36px)) / 3); }
.grade-grid.page-two { gap:clamp(10px,1.25vw,18px); justify-content:center; }
.grade-1{background:#e7f6f8}.grade-2{background:#FDF9D4}.grade-3{background:#edf9e9}.grade-4{background:#f7cbe3}.grade-5{background:#fff7dc}.grade-6{background:#FAD9EE}.grade-7{background:#FDF9D4}.grade-8{background:#edf9e9}

.series-section {
  position:relative;
  z-index:5;
  margin-top:clamp(12px,2.3vh,25px);
}
.series-section h2 {
  font-size:clamp(21px,2.55vw,34px);
  line-height:1.1;
  margin-bottom:clamp(8px,1.4vh,15px);
}
.series-grid {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,clamp(82px,10vw,145px)));
  gap:clamp(10px,1.9vw,26px);
  align-items:start;
  width:max-content;
  max-width:60%;
}
.series-grid img {
  display:block;
  width:100%;
  height:auto;
  max-height:clamp(105px,22vh,190px);
  object-fit:contain;
  object-position:top center;
  filter:drop-shadow(0 4px 6px rgba(24,32,40,.10));
}
.student-art {
  position:absolute;
  z-index:2;
  right:clamp(-45px,0vw,0px);
  bottom:clamp(-18px,-1vh,0px);
  width:clamp(230px,40vw,590px);
  max-height:52vh;
  object-fit:contain;
  object-position:right bottom;
  pointer-events:none;
  mix-blend-mode:multiply;
}

/* Short desktop / 125% / 150% CSS viewports. */
@media (min-width:801px) and (max-height:650px) {
  .home-shell { padding-top:10px; padding-bottom:8px; }
  .home-header { height:40px; }
  .grade-section h1 { margin:4px 0 8px; }
  .grade { height:clamp(74px,16vh,104px); }
  .grade img { height:clamp(28px,6vh,43px); margin-bottom:3px; }
  .series-section { margin-top:8px; }
  .series-section h2 { margin-bottom:5px; }
  .series-grid { grid-template-columns:repeat(4,minmax(60px,88px)); gap:12px; }
  .series-grid img { max-height:112px; }
   .student-art {width:min(37vw,390px);max-height: 39vh; }
}

/* Tablet and narrow desktop. */
@media (max-width:1000px) and (min-width:601px) {
  .grade { flex-basis:calc((100% - 75px) / 5.5); height:clamp(125px,18vh,165px); }
  .grade img { width:clamp(58px,8vw,82px); height:clamp(48px,7vh,68px); }
  .grade span { font-size:clamp(12px,1.8vw,16px); }
  .series-grid { max-width:55%; grid-template-columns:repeat(4,minmax(58px,90px)); }
   .student-art { width:min(39vw,410px); max-height:48vh; }
}

/* Phones: 2 x 4 grade layout; the page itself never scrolls. */
@media (max-width:600px) {
  .home-shell { padding:10px 12px 7px; }
  .home-header { height:clamp(28px,7vh,42px); }
  .macmillan-link { width:86px; }
  .more-grammar-logo { width:150px; }
  .grade-section h1 { font-size:clamp(20px,6vw,27px); margin:5px 0 9px; }
  .grade-carousel { padding:0; }
  .grade-grid { gap:7px; padding-top:5px; padding-bottom:10px; }
  .grade { flex-basis:calc((100% - 25px) / 5.5); height:clamp(95px,16vh,125px); border-radius:12px; padding:5px 3px 7px; }
  .grade img { width:clamp(39px,10vw,55px); height:clamp(34px,7vh,45px); margin-bottom:3px; }
  .grade span { font-size:clamp(10px,3vw,14px); }
  .grade:hover,.grade:focus-visible { transform:scale(1.06); }
  .grade-arrow { width:38px; height:38px; border-radius:50%; }
  .grade-grid.page-two .grade { flex-basis:calc((100% - 14px) / 3); }
  .grade-arrow span { font-size:30px; margin-top:-2px; }
  .series-section { margin-top:9px; }
  .series-section h2 { font-size:clamp(20px,6vw,27px); margin-bottom:5px; }
  .series-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:clamp(5px,2vw,12px); width:58%; max-width:58%; }
  .series-grid img { max-height:17vh; }
   .student-art { width:64vw; max-width:none; max-height:43vh; right:-7vw; bottom:-1vh; opacity:.98; }
}

/* Very small phones. */
@media (max-width:380px) {
  .home-shell { padding-left:9px; padding-right:9px; }
  .macmillan-link { width:73px; }
  .more-grammar-logo { width:128px; }
  .grade-grid { gap:5px; }
  .grade { flex-basis:calc((100% - 25px) / 5.5); height:72px; }
  .grade-grid.page-two .grade { flex-basis:calc((100% - 10px) / 3); }
  .grade img { width:31px; height:27px; }
  .grade span { font-size:9px; }
  .series-grid { width:62%; max-width:62%; gap:4px; }
  .series-grid img { max-height:15vh; }
  .student-art { width:66vw; }
}

/* Landscape phones: use the available width and keep everything in one viewport. */
@media (max-height:500px) and (orientation:landscape) {
  .home-shell { padding:6px 14px; }
  .home-header { height:30px; }
  .macmillan-link { width:80px; }
  .more-grammar-logo { width:145px; }
  .grade-section h1 { font-size:18px; margin:2px 0 5px; }
  .grade-grid { gap:5px; }
  .grade { flex-basis:calc((100% - 25px) / 5.5); height:clamp(70px,23vh,95px); padding-bottom:5px; }
  .grade img { width:34px; height:29px; margin-bottom:1px; }
  .grade span { font-size:9px; }
  .grade-carousel { padding:0; }
  .grade-arrow { width:34px; height:34px; border-radius:50%; }
  .grade-grid.page-two .grade { flex-basis:calc((100% - 10px) / 3); }
  .series-section {margin-top: 15px;}
  .series-section h2 { font-size:18px; margin-bottom:3px; }
  .series-grid { grid-template-columns:repeat(4,65px); gap:8px; }
  .series-grid img { max-height:23vh; }
  .student-art {width: 45.4vw;max-height: 19.7vh;bottom: -10.3px;}
}

/* Keyboard focus is visible without changing the layout. */
.grade:focus-visible { box-shadow:0 0 0 3px rgba(43,126,191,.35), 0 14px 30px rgba(20,30,45,.20); }

/* ===== Final grade carousel refinements ===== */
/* Slightly taller grade cards while keeping every grade the same width. */
@media (min-width:1001px) and (min-height:651px) {
  .grade { height:clamp(205px,27vh,255px); }
}

/* Second page uses exactly the same card width as grades 1–5 on page one. */
.grade-grid.page-two .grade {
  flex-basis:calc((100% - clamp(50px,6.25vw,90px)) / 5.5);
}
.grade-grid.page-two {
  justify-content:flex-start;
}

/* Keep the four series books flush with the left edge of the screen. */
.series-grid {
  margin-left:calc(-1 * clamp(16px,2.4vw,34px));
}

@media (max-width:1000px) and (min-width:601px) {
  .grade-grid.page-two .grade { flex-basis:calc((100% - 75px) / 5.5); }
}

@media (max-width:600px) {
  .grade-grid.page-two .grade { flex-basis:calc((100% - 25px) / 5.5); }
  .series-grid { margin-left:calc(-1 * 12px); }
}

@media (max-width:380px) {
  .grade-grid.page-two .grade { flex-basis:calc((100% - 25px) / 5.5); }
  .series-grid { margin-left:calc(-1 * 9px); }
}

/* ===== Grade icon centering: keep the icon visually centered inside every card ===== */
.grade {
  justify-content: center;
}
.grade img {
  margin: 0 auto;
}
.grade span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(11px,1.2vh,15px);
}
@media (max-width:600px) {
  .grade span { bottom: 7px; }
}
@media (max-height:500px) and (orientation:landscape) {
  .grade span { bottom: 5px; }
}


/* ===== Fix: keep Grade 1 and Grade 6 cards away from viewport edges ===== */
.home-shell { box-sizing: border-box; }
.grade-carousel {
  width: 100%;
  margin-left: 0;
  padding: 0 clamp(38px, 4vw, 54px);
  box-sizing: border-box;
}
.grade-grid {
  box-sizing: border-box;
  padding-left: 8px;
  padding-right: 8px;
  overflow: hidden;
}
.grade { box-sizing: border-box; }
.grade-prev { left: 0; }
.grade-next { right: 0; }

/* Phone layout: show all grades in a neat, touch-friendly 2-column grid. */
@media (max-width: 600px) {
  body.home-page {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .home-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 12px 14px 24px;
  }
  .home-header {
    height: auto;
    min-height: 38px;
    align-items: center;
    gap: 10px;
  }
  .macmillan-link { width: clamp(68px, 23vw, 90px); flex: 0 0 auto; }
  .more-grammar-logo { width: clamp(125px, 43vw, 165px); }
  .grade-section h1 {
    font-size: clamp(21px, 6vw, 28px);
    margin: 16px 0 12px;
    line-height: 1.15;
  }
  .grade-carousel {
    width: 100%;
    margin: 0;
    padding: 0;
  }
  .grade-grid,
  .grade-grid.page-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    overflow: visible;
    padding: 8px 4px 12px;
    justify-content: stretch;
  }
  .grade,
  .grade-grid.page-two .grade {
    display: flex !important;
    flex: initial;
    width: 100%;
    min-width: 0;
    height: clamp(112px, 28vw, 145px);
    padding: 10px 6px;
    border-radius: 14px;
    transform: none;
  }
  .grade img {
    width: clamp(42px, 13vw, 62px);
    height: clamp(42px, 13vw, 62px);
    margin: 0 auto;
    object-fit: contain;
  }
  .grade span {
    position: static;
    width: 100%;
    margin-top: 8px;
    font-size: clamp(12px, 3.5vw, 15px);
    white-space: normal;
    line-height: 1.15;
  }
  .grade:hover,
  .grade:focus-visible,
  .grade:active { transform: none; }
  .grade-arrow { display: none !important; }
  .series-section { margin-top: 16px; }
  .series-grid {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  .series-grid img { max-height: 110px; }
  .student-art {
    position: relative;
    display: block;
    width: min(76vw, 280px);
    max-width: 100%;
    max-height: none;
    margin: 14px auto 0;
    right: auto;
    bottom: auto;
  }
  .student { max-width: 78% !important; }
}

/* Tiny phones: preserve margins and avoid clipped labels. */
@media (max-width: 360px) {
  .home-shell { padding-left: 10px; padding-right: 10px; }
  .grade-grid, .grade-grid.page-two { gap: 9px; padding-left: 3px; padding-right: 3px; }
  .grade, .grade-grid.page-two .grade { height: 108px; }
  .grade span { font-size: 12px; }
}

/* Final refinement: balanced edge spacing and prevent image clipping on phones. */
@media (min-width: 601px) {
  .grade-carousel {
    padding-left: clamp(16px, 1.8vw, 26px);
    padding-right: clamp(16px, 1.8vw, 26px);
  }
  .grade-grid {
    padding-left: 4px;
    padding-right: 4px;
  }
}
@media (max-width: 600px) {
  .home-shell {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
    padding: 10px 12px 24px;
  }
  .grade-carousel {
    padding-left: 0;
    padding-right: 0;
  }
  .grade-grid,
  .grade-grid.page-two {
    padding-left: 2px;
    padding-right: 2px;
    gap: 10px;
  }
  .grade,
  .grade-grid.page-two .grade {
    height: clamp(116px, 30vw, 145px);
    min-height: 116px;
    overflow: visible;
  }
  .grade img {
    flex-shrink: 0;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
  }
  .series-grid {
    align-items: start;
  }
  .series-grid img {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: top center;
  }
  /* The student illustration uses .student in index.html, not .student-art. */
  .student {
    display: block;
    width: min(78%, 300px) !important;
    max-width: min(78%, 300px) !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain;
    object-position: center bottom;
    margin: 14px auto 0 !important;
  }
}
@media (max-width: 360px) {
  .home-shell { padding-left: 9px; padding-right: 9px; }
  .grade-grid, .grade-grid.page-two { gap: 8px; }
  .grade, .grade-grid.page-two .grade { min-height: 110px; height: 110px; }
}




@media (max-height:400px) and (orientation:landscape) {
      .series-section h2{ display: none; }
}

@media (max-height:400px) and (orientation:landscape) {
         .series-grid{ display: none; }
}