/* ============================================================
   Markup English Extra — visual identity
   Warm paper, vivid violet + coral, friendly and modern.
   The classic exercise engines keep their behaviour; this file
   frames them in a fresh, coherent look.
   ============================================================ */
:root {
  --paper: #fbf8f1;
  --card: #ffffff;
  --ink: #23233f;
  --muted: #6f6f8a;
  --line: #e9e1d1;
  --brand: #5b3df5;
  --brand-deep: #4128c4;
  --coral: #ff6b4a;
  --sun: #ffd23f;
  --teal: #12a594;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(35, 35, 63, 0.10);
  --font: "Avenir Next", "Segoe UI", Verdana, Geneva, Arial, sans-serif;
}

body {
  background-image: none !important;
  background-color: var(--paper) !important;
  font-family: var(--font) !important;
  margin: 0 !important;
  padding: 0 !important;
  color: var(--ink);
  line-height: 1.55;
}

/* ---------------- top bar ---------------- */
.mee-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(100deg, #23233f 0%, var(--brand-deep) 70%, var(--brand) 100%);
  color: #fff;
  padding: 0.7rem 1.4rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 18px rgba(35, 35, 63, 0.28);
}
.mee-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff !important;
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.mee-brand::before {
  content: "";
  display: inline-block;
  width: 3.8rem;
  height: 2.1rem;
  border-radius: 0.3rem;
  background: url("logo-ex.png") center / contain no-repeat;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.mee-nav { display: flex; gap: 0.4rem; }
.mee-nav a {
  color: #fff !important;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s ease, transform 0.15s ease;
}
.mee-nav a:hover { background: rgba(255, 255, 255, 0.24); transform: translateY(-1px); }

/* ---------------- footer ---------------- */
.mee-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 1.6rem 1rem 2.2rem;
  margin-top: 2.5rem;
  border-top: 2px solid var(--line);
}
.mee-footer a { color: var(--muted); }

/* ---------------- exercise buttons, modernised ---------------- */
.mee-page button,
div[id] button,
table button,
button.FuncButton,
button.FuncButtonUp,
button.FuncButtonDown {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.35rem;
  margin: 0.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(91, 61, 245, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.mee-page button:hover,
div[id] button:hover,
table button:hover,
button.FuncButtonUp {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(91, 61, 245, 0.45);
}

/* text inputs on gap-fill pages */
input[type="text"] {
  font-family: var(--font);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91, 61, 245, 0.18);
}

/* ---------------- media ---------------- */
audio.mee-audio {
  margin: 0.4rem 0;
  max-width: 100%;
  vertical-align: middle;
  border-radius: 999px;
}
video.mee-video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.9rem auto;
  background: #101024;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------------- voice recorder ---------------- */
.mee-voice-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  background: var(--card);
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 0.8rem 0;
  max-width: 680px;
  box-shadow: var(--shadow);
}
.mee-voice-label { font-weight: 700; color: var(--ink); }
.mee-voice-btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), #ff8a5c);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 74, 0.4);
  transition: transform 0.12s ease;
}
.mee-voice-btn:hover { transform: translateY(-2px); }
.mee-voice-box.mee-recording .mee-voice-btn {
  background: linear-gradient(135deg, #e5484d, #f76b15);
  animation: mee-pulse 1.2s ease-in-out infinite;
}
@keyframes mee-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); }
}
.mee-voice-status { font-size: 0.88rem; color: var(--muted); font-style: italic; }
.mee-voice-box.mee-recording .mee-voice-status { color: #e5484d; font-style: normal; font-weight: 700; }
.mee-voice-player { max-width: 100%; }

/* ---------------- MOOC pages ---------------- */
.mee-page { max-width: 1060px; margin: 0 auto; padding: 1.6rem 1.25rem 3rem; }

.mee-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 3.4rem 1.5rem 2.6rem;
  background: linear-gradient(120deg, #23233f 0%, var(--brand-deep) 55%, var(--brand) 100%);
  color: #fff;
  border-radius: 22px;
  margin-bottom: 2.2rem;
  box-shadow: var(--shadow);
}
.mee-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  pointer-events: none;
}
.mee-hero > * { position: relative; }
.mee-hero h1 {
  margin: 0 0 0.5rem;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.mee-hero h1 .mee-accent { color: var(--sun); }
.mee-hero p { margin: 0.3rem 0; font-size: 1.08rem; opacity: 0.96; }
.mee-hero .mee-sub { font-size: 0.9rem; opacity: 0.78; }
.mee-hero-cta {
  display: inline-block;
  margin-top: 1.2rem;
  background: linear-gradient(135deg, var(--coral), #ff8a5c);
  color: #fff !important;
  font-weight: 800;
  text-decoration: none;
  padding: 0.7rem 1.8rem;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(255, 107, 74, 0.45);
  transition: transform 0.15s ease;
}
.mee-hero-cta:hover { transform: translateY(-2px) scale(1.02); }

.mee-section-title {
  color: var(--ink);
  margin: 2.2rem 0 1.1rem;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.mee-section-title::before {
  content: "";
  width: 0.55rem;
  height: 1.6rem;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--coral), var(--sun));
}

.mee-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; }
.mee-card {
  position: relative;
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem 1.15rem;
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.mee-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand), var(--coral));
}
.mee-cards > a:nth-child(4n+2)::before { background: linear-gradient(90deg, var(--teal), var(--brand)); }
.mee-cards > a:nth-child(4n+3)::before { background: linear-gradient(90deg, var(--sun), var(--coral)); }
.mee-cards > a:nth-child(4n+4)::before { background: linear-gradient(90deg, var(--coral), var(--brand-deep)); }
.mee-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.mee-card h3 { margin: 0 0 0.35rem; font-size: 1.08rem; font-weight: 800; color: var(--ink); }
.mee-card p { margin: 0; font-size: 0.87rem; color: var(--muted); }
.mee-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #efe9ff;
  color: var(--brand-deep);
  border-radius: 999px;
  padding: 0.18rem 0.7rem;
  margin-bottom: 0.55rem;
}

.mee-crumb { font-size: 0.86rem; color: var(--muted); margin-bottom: 1rem; }
.mee-crumb a { color: var(--brand-deep); font-weight: 600; }

.mee-actlist { list-style: none; padding: 0; margin: 0; }
.mee-actlist li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.6rem;
  padding: 0.75rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.14s ease, transform 0.14s ease;
}
.mee-actlist li:hover { box-shadow: var(--shadow); transform: translateX(3px); }
.mee-actlist a { color: var(--brand-deep); font-weight: 700; text-decoration: none; }
.mee-actlist a:hover { text-decoration: underline; }

/* Old exercise pages paint every link yellow (#ffff00) for the old navy theme.
   The audio file name shown under the exercise title sits on a white
   background, so yellow on white is unreadable. Give those title links a
   dark, high-contrast colour. Links inside the navy exercise boxes keep
   their yellow, which reads fine on navy. */
h2.ExerciseTitle a { color: var(--brand-deep); }
h2.ExerciseTitle a:visited { color: #551a8b; }
h2.ExerciseTitle a:hover { color: #b82135; }
.mee-actlist .mee-type { font-size: 0.75rem; font-weight: 700; color: var(--muted); white-space: nowrap; }

@media (max-width: 640px) {
  .mee-topbar { flex-wrap: wrap; padding: 0.7rem 0.9rem; }
  .mee-hero { padding: 2.2rem 1rem 1.8rem; }
  .mee-hero h1 { font-size: 1.7rem; }
  .mee-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .mee-cards { grid-template-columns: 1fr; }
}

/* ---------------- responsive: dictation pages & small screens ---------------- */
div.Titles{overflow-x:auto}
@media (max-width:760px){
  /* Stack the "Listen to the dictation / Record your voice" header columns */
  body.mee-dictation div.Titles>table,
  body.mee-dictation div.Titles>table tbody,
  body.mee-dictation div.Titles>table tr{display:block;width:100%!important}
  body.mee-dictation div.Titles>table th{display:block;width:100%!important;margin:0 0 1rem;text-align:left}
  /* Stack the Guess-controls / story columns of the dictation exercise */
  body.mee-dictation div.StdDiv>table,
  body.mee-dictation div.StdDiv>table tbody,
  body.mee-dictation div.StdDiv>table tr{display:block;width:100%!important;margin:0 auto}
  body.mee-dictation div.StdDiv>table td{display:block;width:100%!important;box-sizing:border-box}
}

/* ================= Modern quiz design (JQuiz multichoice) ================= */
body:has(ol.MCAnswers) div.StdDiv{
  background:#ffffff;
  color:var(--ink);
  border:1px solid var(--line);
  border-radius:22px;
  box-shadow:var(--shadow);
  max-width:800px;
  margin:1.5rem auto;
  padding:clamp(1.25rem,4vw,2.5rem);
  text-align:left;
}
/* HP's embedded 2008 stylesheet paints every div/span/td white directly
   (for the old navy theme). A direct element rule beats the ink color
   inherited from the card above, so grammar/instructions text inside the
   white cards rendered white-on-white. Force them to inherit the ink. */
body:has(ol.MCAnswers) div.StdDiv div,
body:has(ol.MCAnswers) div.StdDiv span,
body:has(ol.MCAnswers) div.StdDiv td,
body:has(ol.MCAnswers) div.ExerciseDiv div,
body:has(ol.MCAnswers) div.ExerciseDiv span,
body:has(ol.MCAnswers) div.ExerciseDiv td{
  color:inherit;
}
body:has(ol.MCAnswers) #ReadingDiv h3.ExerciseSubtitle{
  color:var(--brand-deep);
}
/* the Check-button strip becomes borderless */
body:has(ol.MCAnswers) div#CheckButtonDiv{
  background:transparent;border:none;box-shadow:none;
  text-align:center;padding:.4rem;max-width:800px;
}
/* question navigation */
body:has(ol.MCAnswers) .QuestionNavigation{margin-bottom:1.4rem}
body:has(ol.MCAnswers) .QuestionNavigation p{margin:.4rem 0}
body:has(ol.MCAnswers) #OneByOneReadout{
  display:flex;align-items:center;justify-content:center;gap:.6rem;flex-wrap:wrap;
  font-weight:700;color:var(--muted);
}
/* hide the question list bullets */
body:has(ol.MCAnswers) li.QuizQuestion{list-style:none}
body:has(ol.MCAnswers) li.QuizQuestion > ol:first-child{list-style:none}
/* question text */
body:has(ol.MCAnswers) .QuestionText{
  font-size:clamp(1.15rem,2.6vw,1.45rem);
  font-weight:800;color:var(--ink);line-height:1.45;
  margin:0 0 1.1rem;
}
/* GAE quizzes: stack the grammar/reading panel above the quiz
   (the old 50/50 floats squeezed both columns and left gaps) */
body:has(ol.MCAnswers) .LeftContainer,
body:has(ol.MCAnswers) .RightContainer{
  float:none;width:100%;max-width:800px;margin:0 auto 1.2rem;
}
/* answer word chips (game-style word choice) */
body:has(ol.MCAnswers) ol.MCAnswers{
  list-style:none;margin:.4rem 0 0;padding:0;
  display:flex;flex-wrap:wrap;gap:.6rem;
}
body:has(ol.MCAnswers) ol.MCAnswers > li{
  position:relative;
  flex:0 0 auto;
  background:var(--card);
  border:2px solid var(--line);
  border-radius:999px;
  padding:.55rem 1.5rem;
  cursor:pointer;
  color:var(--ink);font-size:1.08rem;font-weight:600;line-height:1.4;
  transition:border-color .15s ease,transform .15s ease,box-shadow .15s ease,background .15s ease,color .15s ease;
}
body:has(ol.MCAnswers) ol.MCAnswers > li:hover{
  border-color:var(--brand);transform:translateY(-2px);box-shadow:var(--shadow);
}
body:has(ol.MCAnswers) ol.MCAnswers > li:focus-visible{
  outline:3px solid var(--brand);outline-offset:2px;
}
/* HP's tiny "?" button is hidden; the chip itself is the control (see mee-quiz.js) */
body:has(ol.MCAnswers) ol.MCAnswers > li button{display:none !important}
/* correct / wrong states (classes added by mee-quiz.js) */
body:has(ol.MCAnswers) ol.MCAnswers > li.mee-correct{
  border-color:#12a594;background:#12a594;color:#fff;
  box-shadow:0 6px 16px rgba(18,165,148,.4);
}
body:has(ol.MCAnswers) ol.MCAnswers > li.mee-wrong{
  border-color:#e5484d;background:#fef2f2;color:#e5484d;
}
/* feedback popup as a modern card */
body:has(ol.MCAnswers) div#FeedbackDiv{
  background:#fff;color:var(--ink);
  border:1px solid var(--line);border-radius:18px;
  box-shadow:0 24px 70px rgba(23,12,70,.28);
  padding:1.5rem 1.7rem;max-width:430px;
}
body:has(ol.MCAnswers) div#FeedbackDiv .FeedbackText{color:var(--ink);font-size:1rem;line-height:1.55}
/* score readout */
body:has(ol.MCAnswers) .QuizScore,body:has(ol.MCAnswers) #ScoreDiv{font-weight:700}
@media (max-width:560px){
  body:has(ol.MCAnswers) ol.MCAnswers > li{font-size:1rem;padding:.5rem 1.2rem}
}

/* Quiz prev/next: replace the ugly "<=" / "=>" text with clean chevrons */
#PrevQButton,#NextQButton{
  font-size:0 !important;
  width:2.8rem;height:2.8rem;border-radius:50% !important;
  padding:0 !important;margin:.25rem;
  display:inline-flex;align-items:center;justify-content:center;
  vertical-align:middle;
}
#PrevQButton::after{content:'‹';font-size:1.6rem;line-height:1;color:#fff;font-weight:700}
#NextQButton::after{content:'›';font-size:1.6rem;line-height:1;color:#fff;font-weight:700}
#PrevQButton:hover,#NextQButton:hover{transform:translateY(-2px)}

.mee-hero .mee-logo {
  width: 150px;
  height: auto;
  margin-bottom: 0.9rem;
}
