/* ============================================================
   Lingadoo Grammar Worksheets — Shared Stylesheet
   A4, print-first, Grammar-in-Use style
   ============================================================ */

/* --- Page setup ------------------------------------------- */

@page {
  margin: 0;
}

/* --- Reset & base ----------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 10.5pt;
  color: #111;
  line-height: 1.55;
  background-color: #FBF6E9;
  background-image:
    repeating-linear-gradient(2deg, rgba(115, 91, 59, .018) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(91deg, rgba(255,255,255,.15) 0 1px, transparent 1px 11px),
    radial-gradient(ellipse at 16% 19%, rgba(230, 174, 47, .055) 0 1px, transparent 1.7px),
    radial-gradient(ellipse at 78% 67%, rgba(91, 70, 43, .04) 0 .8px, transparent 1.5px),
    linear-gradient(105deg, rgba(255,255,255,.08), transparent 38%, rgba(126,98,62,.025));
  background-repeat: repeat, repeat, repeat, repeat, no-repeat;
  background-size: auto, auto, 23px 21px, 31px 29px, 100% 100%;
  background-attachment: fixed;
}

/* --- A4 page simulation (screen only) --------------------- */

@media screen {
  .page {
    width: 210mm;
    min-height: 297mm;
    margin: 24px auto;
    padding: 1.8cm 1.9cm 1.6cm;
    background: #fff;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.18);
  }

  body {
    padding: 70px 0 48px; /* 70px = 46px toolbar + 24px gap */
  }
}

@media print {
  html, body {
    background: white;
    margin: 0;
    padding: 0;
  }

  .page {
    width: 100%;
    margin: 0;
    padding: 1.8cm 1.9cm 1.6cm;
    box-shadow: none;
  }

  .no-print {
    display: none;
  }
}

/* ============================================================
   TEACHER TOOLBAR  (screen only — hidden in print)
   ============================================================ */

.ws-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #f0f6ff;
  border-bottom: 1px solid #dce8f8;
  height: 42px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.ws-toolbar-label {
  font-size: 8pt;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-right: 4px;
}

.ws-toolbar-hint {
  margin-left: auto;
  font-size: 8pt;
  color: #94a3b8;
}

.ws-toolbar-btn {
  padding: 5px 13px;
  font-size: 9pt;
  font-weight: 600;
  font-family: inherit;
  border-radius: 3px;
  border: 1px solid #c7d8f0;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.ws-toolbar-btn:hover {
  background: #e8f0fc;
  border-color: #a8c0e8;
  color: #1e3a5f;
}

.ws-toolbar-btn.primary {
  background: #5b7fe8;
  border-color: #5b7fe8;
  color: #fff;
}

.ws-toolbar-btn.primary:hover {
  background: #4a6dd4;
  border-color: #4a6dd4;
}

@media print {
  .ws-toolbar { display: none; }
}

/* --- Page break helpers ----------------------------------- */

.page-break-before { page-break-before: always; break-before: page; }
.page-break-after  { page-break-after: always;  break-after: page;  }
.avoid-break       { page-break-inside: avoid;  break-inside: avoid; }

/* ============================================================
   HEADER
   ============================================================ */

.ws-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2.5px solid #111;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.ws-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-logo img {
  height: 30px;
  display: block;
}

.ws-logo-fallback {
  font-size: 16pt;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #111;
  line-height: 1;
}

.ws-logo-fallback span {
  color: #555;
  font-weight: 400;
}

.ws-title-block {
  text-align: right;
  flex: 1;
}

.ws-worksheet-label {
  font-size: 7.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #777;
  margin-bottom: 2px;
}

.ws-title {
  font-size: 15pt;
  font-weight: 800;
  line-height: 1.2;
  color: #111;
}

.ws-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ws-badge {
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 7px;
  border-radius: 2px;
  line-height: 1.4;
}

.ws-badge-level {
  background: #111;
  color: #fff;
}

.ws-badge-focus {
  background: transparent;
  color: #111;
  border: 1px solid #777;
}

/* ============================================================
   SECTIONS — generic container
   ============================================================ */

.ws-section {
  margin-bottom: 14px;
}

.ws-section-title {
  font-size: 7.5pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #444;
  border-left: 3px solid #111;
  padding-left: 6px;
  margin-bottom: 7px;
  line-height: 1.2;
}

/* ============================================================
   EXPLANATION
   ============================================================ */

.ws-explanation p {
  font-size: 10.5pt;
  line-height: 1.6;
  margin-bottom: 4px;
}

/* ============================================================
   FORM BOX
   ============================================================ */

.ws-form-box {
  border: 1.5px solid #111;
  padding: 10px 14px 12px;
  margin-top: 2px;
}

.ws-form-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.ws-form-table th {
  text-align: left;
  font-size: 7.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #444;
  padding: 2px 10px 4px 0;
  border-bottom: 1px solid #ccc;
  white-space: nowrap;
}

.ws-form-table th:last-child { padding-right: 0; }

.ws-form-table td {
  font-size: 10pt;
  padding: 5px 10px 5px 0;
  vertical-align: top;
  border-bottom: 1px dotted #ddd;
}

.ws-form-table td:last-child { padding-right: 0; }
.ws-form-table tr:last-child td { border-bottom: none; }

.ws-form-table td:first-child {
  font-style: italic;
  color: #333;
  width: 36%;
}

.ws-form-table td:nth-child(2) {
  font-weight: 700;
  width: 14%;
}

.ws-form-table td:nth-child(3) {
  color: #111;
}

.ws-form-rules {
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

.ws-form-rules p {
  font-size: 10pt;
  line-height: 1.6;
  margin-bottom: 2px;
}

.formula {
  font-family: 'Courier New', Courier, monospace;
  font-size: 9.5pt;
  background: #f4f4f4;
  border: 1px solid #ccc;
  padding: 1px 5px;
  border-radius: 2px;
}

@media print {
  .formula { background: #f0f0f0; }
  .ws-form-box { background: white; }
}

/* ============================================================
   EXAMPLES
   ============================================================ */

.ws-examples ol {
  padding-left: 20px;
  columns: 2;
  column-gap: 24px;
}

.ws-examples li {
  font-size: 10.5pt;
  line-height: 1.5;
  margin-bottom: 4px;
  break-inside: avoid;
}

.ws-examples li em {
  font-style: normal;
  font-weight: 600;
}

/* ============================================================
   COMMON MISTAKES
   ============================================================ */

.ws-mistakes-list {
  list-style: none;
  padding: 0;
}

.ws-mistakes-list li {
  font-size: 10pt;
  line-height: 1.5;
  margin-bottom: 8px;
  padding-left: 4px;
  break-inside: avoid;
}

.mistake-wrong {
  color: #b00;
  text-decoration: line-through;
  text-decoration-color: #b00;
}

.mistake-arrow {
  color: #555;
  margin: 0 4px;
  font-size: 10pt;
}

.mistake-right {
  font-weight: 700;
  color: #111;
}

.mistake-note {
  display: block;
  font-size: 9pt;
  color: #555;
  margin-top: 1px;
  padding-left: 14px;
}

/* ============================================================
   EXERCISES
   ============================================================ */

.ws-exercises {
  margin-bottom: 2px;
}

.ws-exercise {
  margin-bottom: 14px;
  break-inside: avoid;
}

/* Two-column grid for side-by-side exercises */
.ws-exercises-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.ws-exercises-grid .ws-exercise {
  margin-bottom: 12px;
}

.ws-exercises-grid .ws-exercise:nth-child(odd) {
  padding-right: 18px;
  border-right: 1px solid #ddd;
}

.ws-exercises-grid .ws-exercise:nth-child(even) {
  padding-left: 18px;
}

/* Tighter list spacing inside the grid */
.ws-exercises-grid .ws-exercise li {
  margin-bottom: 12px;
}

.ws-exercise-header {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 3px;
}

.ex-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  background: #111;
  color: #fff;
  font-size: 8.5pt;
  font-weight: 800;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}

.ex-name {
  font-weight: 800;
  font-size: 10.5pt;
}

.ex-instruction {
  font-size: 9.5pt;
  color: #444;
  font-style: italic;
  margin-bottom: 8px;
  padding-left: 24px;
}

.ex-example {
  font-size: 9pt;
  color: #555;
  font-style: italic;
  margin-bottom: 7px;
  padding-left: 24px;
}

.ws-exercise ol {
  padding-left: 20px;
}

.ws-exercise li {
  font-size: 10.5pt;
  line-height: 1.45;
  margin-bottom: 16px;
}

/* Short answer line */
.ans {
  display: inline-block;
  border-bottom: 1px solid #555;
  min-width: 90px;
  min-height: 1.2em;
  line-height: 1.2;
  vertical-align: baseline;
  margin: 0 2px;
  padding: 0 3px 2px;
}

/* Empty blank: give it height so there is a visible writing line */
.ans:empty {
  height: 1.2em;
  padding-bottom: 3px;
}

/* Full-width answer line below the item */
.ans-line {
  display: block;
  border-bottom: 1px solid #555;
  width: 100%;
  min-height: 20px;
  height: 20px;
  margin-top: 5px;
  padding-bottom: 4px; /* keeps text above border */
}

.ans-line + .ans-line {
  margin-top: 8px;
}

/* T/F box */
.tf-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid #555;
  font-size: 9pt;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 4px;
}

/* ============================================================
   REVEAL ANSWER BUTTON  (screen only — hidden in print)
   ============================================================ */

.reveal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  padding: 0;
  background: #f0f0f0;
  border: 1px solid #bbb;
  border-radius: 3px;
  cursor: pointer;
  font-size: 9pt;
  line-height: 1;
  color: #aaa;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: -1px;
  margin-right: 6px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.reveal-btn:hover {
  background: #e8eeff;
  border-color: #5b7fe8;
  color: #5b7fe8;
}

li.revealed .reveal-btn {
  background: #5b7fe8;
  border-color: #5b7fe8;
  color: #fff;
}

li.revealed .ans {
  min-height: 1.2em;
  line-height: 1.2;
  vertical-align: baseline;
  color: #3d5fc0;
  font-style: italic;
  font-weight: 600;
  border-bottom-color: #5b7fe8;
}

li.revealed .ans-line {
  padding-left: 2px;
  padding-bottom: 4px;
  color: #3d5fc0;
  font-style: italic;
  border-bottom-color: #5b7fe8;
}

@media print {
  .reveal-btn { display: none; }
}

/* ============================================================
   SPEAKING ACTIVITY
   ============================================================ */

.ws-speaking {
  border: 1.5px dashed #777;
  padding: 10px 14px;
  margin-bottom: 14px;
  break-inside: avoid;
}

.ws-speaking-header {
  font-weight: 800;
  font-size: 7.5pt;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #444;
}

.ws-speaking p {
  font-size: 10pt;
  margin-bottom: 6px;
}

.ws-speaking ul {
  padding-left: 18px;
  margin-bottom: 6px;
}

.ws-speaking li {
  font-size: 10pt;
  font-style: italic;
  margin-bottom: 3px;
  line-height: 1.4;
}

.ws-speaking-followup {
  font-size: 9.5pt;
  color: #333;
  font-style: italic;
  margin-top: 6px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.ws-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8pt;
  color: #888;
}

.ws-footer a { color: #888; text-decoration: none; }

/* ============================================================
   ANSWER KEY PAGE
   ============================================================ */

.ws-answer-key {
  page-break-before: always;
  break-before: page;
}

@media screen {
  .ws-answer-key {
    page-break-before: auto;
    break-before: auto;
  }
}

.ws-answer-key-banner {
  background: #111;
  color: #fff;
  padding: 9px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.ws-answer-key-banner h2 {
  font-size: 12pt;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.ws-answer-key-banner .ak-subtitle {
  font-size: 9pt;
  opacity: 0.7;
  font-style: italic;
}

.ws-ak-section {
  margin-bottom: 16px;
  break-inside: avoid;
}

.ws-ak-section h3 {
  font-size: 9pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #444;
  border-bottom: 1px solid #ddd;
  padding-bottom: 3px;
  margin-bottom: 7px;
}

.ws-ak-section ol {
  padding-left: 20px;
}

.ws-ak-section li {
  font-size: 10pt;
  margin-bottom: 5px;
  line-height: 1.45;
}

.ws-ak-section li strong {
  font-weight: 700;
  color: #111;
}

.ws-ak-note {
  font-size: 9pt;
  color: #555;
  font-style: italic;
  margin-top: 6px;
}

.ws-ak-inline {
  font-size: 10pt;
  line-height: 1.7;
}
