/* ============================================================
   IC GATE — the screens a module page shows before the test
   itself: checking access, sign in, subscribe, and the plain
   notices (offline / no tests / cookies blocked / error).

   These are the first thing a visitor from Google search sees
   on /listening, /reading, /writing and /spelling, so they are
   built as a page of ieltscomputer.com — same palette, same
   type, same sharp edges as the marketing site — and not as a
   modal floating in a black void.

   Loaded from <head> on every module page so the boot state is
   painted correctly before any script runs. Every rule is
   scoped to #icgate: the exam stylesheets below it are large
   and unscoped, and neither side may leak into the other.
   ============================================================ */

#icgate {
  --icg-bg:      #FFFFFF;
  --icg-bg2:     #F3F5F8;
  --icg-ink:     #14161B;
  --icg-body:    #3E434C;
  --icg-muted:   #68707F;
  --icg-line:    #DCE0E7;
  --icg-line2:   #C4CAD4;
  --icg-red:     #CC1802;
  --icg-red2:    #A31302;
  --icg-redsoft: #FBECE9;
  --icg-redline: #EFC7C0;
  --icg-green:   #157F3D;
  --icg-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --icg-head: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  /* The overlay is exactly the viewport and never scrolls itself; .icg-body
     scrolls. That pins .icg-foot to the bottom, so swapping the loading state
     for a taller sign-in or paywall panel cannot push the footer down — that
     movement was the page's whole layout shift (CLS 0.17). */
  overflow: hidden;
  background: linear-gradient(to bottom, var(--icg-bg2), var(--icg-bg) 22rem);
  font-family: var(--icg-sans);
  color: var(--icg-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-align: left;
}
#icgate.icgate-hide { display: none; }
#icgate *, #icgate *::before, #icgate *::after { box-sizing: border-box; }
#icgate h1, #icgate h2, #icgate h3 {
  font-family: var(--icg-head);
  color: var(--icg-ink);
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0;
}
#icgate p { margin: 0; }
#icgate a { color: inherit; text-decoration: none; }
#icgate :focus-visible {
  outline: 2px solid var(--icg-red);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Headings are focused by script when a screen changes, so a screen reader
   announces it. They are not controls, and a ring around the title reads as
   an error box — Safari draws one on a programmatic focus, so take it off. */
#icgate .icg-h1:focus, #icgate .icg-h1:focus-visible,
#icgate .icg-panel-h:focus, #icgate .icg-panel-h:focus-visible { outline: none; }

/* ---------- top bar ---------- */
#icgate .icg-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 2.25rem);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--icg-line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
/* Boot state, before chrome() fills the bar. The height is reserved so that
   filling it does not push .icg-body down — that push was the rest of the
   page's layout shift. Measured from the filled bar: 65px wide-screen, 110px
   below 720px (where the skills row wraps). :empty means this can never
   constrain the real bar; if chrome() ever changes the bar's height, update
   these two numbers. */
#icgate .icg-top:empty { border-bottom: none; padding: 0; min-height: 65px; }
#icgate .icg-brand { display: inline-flex; align-items: center; gap: 0.6rem; flex: none; }
#icgate .icg-brand img { width: 30px; height: 30px; border-radius: 7px; display: block; }
#icgate .icg-brand span {
  font-family: var(--icg-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--icg-ink);
  letter-spacing: -0.01em;
}
#icgate .icg-skills {
  display: flex;
  gap: 2px;
  margin: 0 auto;
  background: #EDF0F4;
  border: 1px solid var(--icg-line);
  border-radius: 2px;
  padding: 2px;
}
#icgate .icg-skills a {
  padding: 0.4rem 0.85rem;
  border-radius: 2px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--icg-muted);
  white-space: nowrap;
}
#icgate .icg-skills a:hover { color: var(--icg-ink); }
#icgate .icg-skills a.on {
  background: #fff;
  color: var(--icg-ink);
  box-shadow: 0 1px 3px rgba(20, 22, 27, 0.14);
}
#icgate .icg-top-app {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--icg-ink);
  border: 1px solid var(--icg-line2);
  border-radius: 2px;
  padding: 0.5rem 0.9rem;
}
#icgate .icg-top-app:hover { border-color: var(--icg-red); color: var(--icg-red); }
#icgate .icg-top-app svg { width: 14px; height: 16px; flex: none; }

/* ---------- body ---------- */
#icgate .icg-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.25rem);
}
#icgate .icg-wrap {
  margin: auto;            /* centres, and collapses to 0 when it overflows */
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  grid-template-areas: 'pitch panel' 'extra panel';
  gap: 1.6rem clamp(2rem, 5vw, 3.5rem);
  align-content: center;
}
#icgate .icg-pitch { grid-area: pitch; align-self: end; }
#icgate .icg-extra { grid-area: extra; align-self: start; }
#icgate .icg-panel { grid-area: panel; align-self: center; }
/* Only the full screens fade in. Spinners and notices swap instantly: a
   loading state that re-animates on every step reads as a flicker. */
#icgate .icg-wrap:not(.icg-solo) { animation: icg-rise 0.4s ease both; }
#icgate .icg-wrap.icg-solo {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'panel';
  width: min(440px, 100%);
  justify-items: stretch;
}
@keyframes icg-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- pitch column ---------- */
#icgate .icg-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--icg-muted);
  margin-bottom: 1rem;
}
#icgate .icg-eyebrow::before {
  content: '';
  width: 12px;
  height: 12px;
  background: var(--icg-red);
  border-radius: 2px;
  flex: none;
}
#icgate .icg-h1 {
  font-size: clamp(1.7rem, 3.3vw, 2.5rem);
  line-height: 1.12;
}
#icgate .icg-h1 em { font-style: normal; color: var(--icg-red); }
#icgate .icg-sub {
  margin-top: 0.9rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--icg-body);
  max-width: 34rem;
}
#icgate .icg-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
#icgate .icg-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--icg-body);
}
#icgate .icg-list li svg { width: 18px; height: 18px; flex: none; margin-top: 0.1rem; color: var(--icg-green); }
#icgate .icg-list li b { color: var(--icg-ink); font-weight: 600; }
/* reassurance, not a warning — same green as the plan badge */
#icgate .icg-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.9rem;
  background: #F1F9F4;
  border: 1px solid #BFE0CB;
  border-radius: 2px;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--icg-green);
}
#icgate .icg-badge svg { width: 15px; height: 15px; flex: none; }

/* ---------- panel ---------- */
#icgate .icg-panel {
  background: #fff;
  border: 1px solid var(--icg-line);
  border-radius: 3px;
  box-shadow: 0 18px 44px rgba(20, 22, 27, 0.10);
  padding: clamp(1.4rem, 3vw, 1.85rem);
}
#icgate .icg-panel-h { font-size: 1.05rem; font-weight: 600; }
#icgate .icg-panel-sub {
  margin-top: 0.35rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--icg-muted);
}
#icgate .icg-panel-solo { text-align: center; }
#icgate .icg-panel-solo .icg-panel-sub { margin-top: 0.5rem; }

/* sign-in buttons */
#icgate .icg-oauth { margin-top: 1.25rem; display: grid; gap: 0.6rem; }
#icgate .icg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 1rem;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--icg-ink);
  background: #fff;
  border: 1px solid var(--icg-line2);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}
#icgate .icg-btn:hover { border-color: var(--icg-ink); }
#icgate .icg-btn:active { transform: translateY(1px); }
#icgate .icg-btn:disabled { opacity: 0.5; cursor: progress; }
#icgate .icg-btn svg { flex: none; }
#icgate .icg-btn.icg-apple { background: #14161B; color: #fff; border-color: #14161B; }
#icgate .icg-btn.icg-apple:hover { background: #000; border-color: #000; }
#icgate .icg-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1.4rem;
  font-family: inherit;
  font-size: 0.97rem;
  font-weight: 700;
  color: #fff;
  background: var(--icg-red);
  border: none;
  border-radius: 2px;
  box-shadow: 0 2px 0 var(--icg-red2);
  cursor: pointer;
  transition: background 0.18s, transform 0.12s;
}
#icgate .icg-cta:hover { background: var(--icg-red2); }
#icgate .icg-cta:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--icg-red2); }
#icgate .icg-cta:disabled { opacity: 0.6; cursor: progress; }
#icgate .icg-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 1.2rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--icg-ink);
  background: #fff;
  border: 1px solid var(--icg-line2);
  border-radius: 2px;
}
#icgate .icg-ghost:hover { border-color: var(--icg-red); color: var(--icg-red); }
#icgate .icg-actions { margin-top: 1.4rem; display: grid; gap: 0.6rem; }

/* small print */
#icgate .icg-fine {
  margin-top: 1.1rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--icg-muted);
}
#icgate .icg-fine a { color: var(--icg-red); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
#icgate .icg-note {
  margin-top: 1.1rem;
  background: #F8F9FB;
  border: 1px solid var(--icg-line);
  border-left: 3px solid var(--icg-red);
  border-radius: 2px;
  padding: 0.75rem 0.9rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--icg-body);
}
#icgate .icg-note b { color: var(--icg-ink); font-weight: 600; }
#icgate .icg-note a { color: var(--icg-red); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
#icgate .icg-warn {
  margin-top: 1.1rem;
  background: #FFF7ED;
  border: 1px solid #FDBA74;
  border-radius: 2px;
  padding: 0.8rem 0.9rem;
  font-size: 0.83rem;
  line-height: 1.55;
  color: #7C2D12;
}
#icgate .icg-err {
  margin-top: 1rem;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 2px;
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #991B1B;
  overflow-wrap: anywhere;
}
#icgate .icg-err[hidden] { display: none; }

/* ---------- plans ---------- */
#icgate .icg-plans { margin-top: 1.1rem; display: grid; gap: 0.5rem; }
#icgate .icg-plan {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 2.6rem 0.85rem 1rem;
  border: 1px solid var(--icg-line2);
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
#icgate .icg-plan:hover { border-color: var(--icg-ink); }
#icgate .icg-plan::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 1px solid var(--icg-line2);
  border-radius: 50%;
  transition: border-color 0.18s, background 0.18s;
}
#icgate .icg-plan.on { border-color: var(--icg-red); background: #FFFBFA; }
#icgate .icg-plan.on::after {
  border-color: var(--icg-red);
  background: var(--icg-red);
  box-shadow: inset 0 0 0 3px #fff;
}
#icgate .icg-plan-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  row-gap: 0.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--icg-ink);
}
#icgate .icg-plan-note { font-size: 0.78rem; color: var(--icg-muted); margin-top: 0.1rem; }
#icgate .icg-plan-tag {
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--icg-green);
  border: 1px solid #BFE0CB;
  background: #F1F9F4;
  border-radius: 2px;
  padding: 0.12rem 0.38rem;
}
#icgate .icg-plan-right { text-align: right; flex: none; }
#icgate .icg-plan-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--icg-ink);
  font-variant-numeric: tabular-nums;
}
#icgate .icg-plan-price[hidden] { display: none; }
#icgate .icg-plan-fallback { font-size: 0.8rem; color: var(--icg-muted); white-space: nowrap; }
#icgate .icg-plan-fallback[hidden] { display: none; }
#icgate .icg-plan-per { display: block; font-size: 0.72rem; color: var(--icg-muted); white-space: nowrap; }
#icgate .icg-plan-per[hidden] { display: none; }

/* ---------- loading ---------- */
#icgate .icg-spin {
  display: block;
  margin: 0 auto 1.1rem;
  width: 30px;
  height: 30px;
  border: 3px solid #E4E7EC;
  border-top-color: var(--icg-red);
  border-radius: 50%;
  animation: icg-spin 0.8s linear infinite;
}
@keyframes icg-spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */
#icgate .icg-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 1.25rem;
  /* the safe-area line is separate on purpose: a browser that does not know
     env() drops only that one and keeps the padding above */
  padding: 1.1rem clamp(1rem, 4vw, 2.25rem);
  padding-bottom: calc(1.1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--icg-line);
  font-size: 0.8rem;
  color: var(--icg-muted);
}
/* Same reason as .icg-top:empty: the boot footer is empty and would be 0px
   tall, so filling it shrinks .icg-body and moves the centred panel. Reserve
   the filled height (57px wide-screen, 83px below 720px, which includes the
   safe-area padding). */
#icgate .icg-foot:empty { border-top: none; padding: 0; min-height: 57px; }
#icgate .icg-foot a { color: var(--icg-muted); }
#icgate .icg-foot a:hover { color: var(--icg-red); }
#icgate .icg-foot .icg-foot-home { color: var(--icg-ink); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  /* one column, and the sign-in panel moves up under the headline: on a phone
     the buttons must not sit below three bullet points */
  #icgate .icg-wrap {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'pitch' 'panel' 'extra';
    gap: 1.5rem;
    width: min(560px, 100%);
  }
  #icgate .icg-pitch, #icgate .icg-extra, #icgate .icg-panel { align-self: auto; }
}
@media (max-width: 420px) {
  /* a 320px phone still has to fit a plan row without sideways scrolling */
  #icgate .icg-body { padding-left: 0.85rem; padding-right: 0.85rem; }
  #icgate .icg-panel { padding: 1.15rem 1rem; }
  #icgate .icg-plan { padding: 0.7rem 2.2rem 0.7rem 0.75rem; gap: 0.5rem; }
  #icgate .icg-plan-note { display: none; }
  #icgate .icg-plan-name { font-size: 0.9rem; }
  #icgate .icg-plan-fallback { font-size: 0.74rem; }
}
@media (max-width: 720px) {
  #icgate .icg-top { flex-wrap: wrap; gap: 0.6rem 0.9rem; padding: 0.65rem 1rem; }
  #icgate .icg-top:empty { min-height: 110px; }
  #icgate .icg-foot:empty { min-height: 83px; }
  #icgate .icg-skills { order: 3; flex-basis: 100%; margin: 0; }
  #icgate .icg-skills a { flex: 1; text-align: center; padding: 0.4rem 0.25rem; font-size: 0.8rem; }
  #icgate .icg-top-app { margin-left: auto; }
  #icgate .icg-h1 { font-size: 1.6rem; }
  #icgate .icg-sub { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  #icgate .icg-wrap { animation: none; }
  #icgate .icg-spin { animation-duration: 2s; }
  #icgate .icg-btn, #icgate .icg-cta, #icgate .icg-plan { transition: none; }
}
