/* ============================================================
   Course Map Builder — page-specific styles
   Loaded after base.css and document.css.
   ============================================================ */

:root {
  --content-width: 900px; /* wider than the default document measure */
}

.subtitle {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* The step cards (section.step, .step-body, .step-num, .step-lead), the
   .primary-btn / .small-btn pair and the .two-col grid moved to
   document.css on September 11, 2026, when the credit hour planner
   adopted the same layout. Only what is unique to this page is here. */

/* ---- guidance panel extras (the base panel is in document.css) ---- */

.guide { line-height: 1.55; }
.guide ul { margin: 8px 0 4px 0; padding-left: 22px; }
.guide li { margin-bottom: 6px; }
.guide p { margin: 10px 0 4px 0; }

/* ---- form controls ---- */

label {
  font-weight: bold;
}

input[type="text"],
textarea,
select {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  box-sizing: border-box;
}

input[type="number"] {
  font-family: inherit;
  font-size: 16px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
  width: 80px;
}

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.45;
}

.basics {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}

.basics .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.basics input[type="text"] {
  min-width: 320px;
}

/* Dynamic rows (goals, topics) */
.row-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
}

.row-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.row-list input[type="text"] {
  flex: 1;
  min-width: 240px;
}

/* Evidence rows: goal text shown above its evidence blank.
   (The UI says "assessment"; the state field is still `evidence`
   for saved-data compatibility, and these class names follow it.) */
.ev-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ev-list li {
  border-left: 4px solid var(--blue-mid);
  padding: 4px 0 4px 14px;
  margin-bottom: 14px;
}

.ev-goal {
  display: block;
  font-style: italic;
  margin-bottom: 6px;
}

.ev-goal.placeholder {
  color: var(--muted-light);
}

.ev-assess {
  display: block;
  font-size: 14px;
  color: var(--text-soft);
  margin: -2px 0 6px 0;
}

.ev-assess.placeholder {
  color: var(--muted-light);
  font-style: italic;
}

.ev-list input[type="text"] {
  width: 100%;
}

/* ---- buttons ---- */

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
}

.add-btn {
  display: inline-block;
  padding: 6px 16px;
  font-size: 15px;
  background: var(--surface);
  color: var(--blue);
  border: 2px solid var(--blue);
}

.add-btn:hover {
  background: var(--blue-light);
}

.remove-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  border-radius: 6px;
  font-size: 14px;
  padding: 4px 10px;
}

.remove-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ---- module schedule cards ---- */

/* Second home for the module count, beside the cards it controls. The
   first is in Course basics; both edit the same value. */
/* Label, box and hint share one line; the hint drops below only when the
   row runs out of width. */
.module-count {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 16px 0;
}

.module-count .hint {
  flex: 1 1 240px;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

.mod-card {
  border: 1px solid var(--blue-mid);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.mod-card header {
  background: var(--blue-light);
  padding: 8px 14px;
  font-weight: bold;
  display: flex;
  gap: 12px;
  align-items: center;
}

.mod-card header input {
  flex: 1;
  font-size: 15px;
}

/* "Module N" is a real <button> disclosure rather than a <summary>: the
   topic field has to stay outside the collapsing region and clickable,
   which <summary> cannot do (a click on an input inside a summary toggles
   the panel). aria-expanded/aria-controls are set in the JS. */
.mod-toggle {
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 4px;
  /* padding keeps the target clear of the 24px WCAG 2.5.8 minimum */
  padding: 4px 6px;
  margin-left: -6px;
  cursor: pointer;
  white-space: nowrap;
}

.mod-toggle::before {
  content: "\25B8"; /* right-pointing triangle, matching a closed <summary> */
  display: inline-block;
  margin-right: 6px;
}

.mod-toggle[aria-expanded="true"]::before {
  content: "\25BE"; /* down-pointing when open */
}

.mod-card .card-body {
  padding: 12px 14px;
}

.mod-card .card-row {
  margin-bottom: 12px;
}

.mod-card .card-row:last-child {
  margin-bottom: 0;
}

.mod-card label {
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}

.mod-card input[type="text"],
.mod-card textarea {
  width: 100%;
  border: 1px solid var(--rule-light);
  font-size: 15px;
  padding: 6px 8px;
}

.mod-card textarea {
  min-height: 60px;
}

.opt {
  font-weight: normal;
  color: var(--muted-light);
  font-style: italic;
}

/* Course-objective key shown above the module cards, so the CO1/CO2
   alignment checkboxes inside each card can be read at a glance */
/* The key lives inside a .guide panel, which supplies the fill, border
   and padding - and its 16px type, so the key is not a step smaller than
   the guidance around it (the August 26, 2026 rule). */
#goalLegend {
  line-height: 1.7;
  margin: 6px 0 0 0;
}

/* One course objective per line (September 10, 2026): the run-on
   "CO1 - ... · CO2 - ..." string read as a wall of text once the
   objectives were more than a few words each. */
#goalLegend .legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#goalLegend .legend-goal {
  white-space: normal;
}

/* Module objectives: a repeatable row of "objective + alignment" */
.obj-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
}

.obj-head,
.obj-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 34px;
  gap: 10px;
  align-items: start;
}

.obj-row {
  margin-bottom: 8px;
}

.obj-head span {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 4px;
}

.align-box {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  align-items: center;
  padding-top: 7px;
  font-size: 13px;
}

.mod-card .align-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 13px;
  font-weight: normal;
  white-space: nowrap;
  cursor: pointer;
}

.align-chip input[type="checkbox"] {
  margin: 0;
  accent-color: var(--red);
}

/* The chip's tooltip, carrying the full course objective text. It
   replaces the native `title` popup, whose type size the browser owns
   and the page cannot set (August 27, 2026).

   It opens to the *left* of the chip, over the objective field, rather
   than below it. Below looks tidier but the chips wrap to several lines
   inside their 150px column, so a dropped tooltip sits on top of the
   next chip down and swallows clicks meant for it. Leftward it clears
   every other chip, and it stays inside the card, which is
   `overflow: hidden`.

   It is a sibling of the <label>, not a child, so hovering or clicking
   the tooltip cannot toggle the checkbox. */
.align-chip-wrap {
  position: relative;
  display: inline-flex;
}

.align-tip {
  display: none;
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: max-content;
  max-width: 260px;
  white-space: normal;
  /* 20% larger than the 13px chip label it explains */
  font-size: 1.2em;
  line-height: 1.4;
  font-weight: normal;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--blue);
  border-radius: 6px;
  padding: 6px 9px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* `tips-off` goes on <body> when Escape is pressed and comes off at the
   next pointer move or focus change — see the keydown handler in
   course_map_builder.html. It *gates* the show rules below rather than
   following them with a `display: none` override. An override has to
   out-specify every show rule, and when it loses it fails silently:
   Escape simply stops dismissing, with nothing to see in the stylesheet.
   Gating leaves no cascade race to lose. Any future show rule wants the
   same `body:not(.tips-off)` prefix. */

body:not(.tips-off) .align-chip-wrap:hover .align-tip {
  display: block;
}

/* Keyboard users get it on focus. :focus-visible rather than
   :focus-within, so a mouse click does not leave a tooltip standing over
   the objective field after the pointer has moved away. Kept as its own
   rule: a browser without :has() then still has the hover rule above. */
body:not(.tips-off) .align-chip-wrap:has(input:focus-visible) .align-tip {
  display: block;
}

.align-none {
  font-size: 13px;
}

/* Only shown when the row stacks on a narrow screen */
.align-mini {
  display: none;
  font-weight: bold;
  font-size: 13px;
}

.obj-row .remove-btn {
  padding: 5px 0;
  width: 34px;
  text-align: center;
}

@media (max-width: 640px) {

  /* Stacked: objective and its remove button on one line, the
     alignment checkboxes on the line below */
  .obj-head {
    grid-template-columns: 1fr;
  }

  .obj-head span:nth-child(n+2) {
    display: none;
  }

  .obj-row {
    grid-template-columns: minmax(0, 1fr) 34px;
    margin-bottom: 14px;
  }

  .obj-row>input[type="text"] {
    grid-column: 1;
    grid-row: 1;
  }

  .obj-row .remove-btn {
    grid-column: 2;
    grid-row: 1;
  }

  .align-box {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: 0;
  }

  .align-mini {
    display: inline;
  }

  /* Stacked, the chips run along the left edge, so a tooltip opening
     leftward would run out through the card's clipped edge. Hang it off
     the whole alignment box instead and drop it underneath, where the
     chips have already wrapped and there is nothing of theirs to cover. */
  .align-box {
    position: relative;
  }

  .align-chip-wrap {
    position: static;
  }

  .align-tip {
    left: 0;
    right: auto;
    top: calc(100% + 4px);
    transform: none;
    width: auto;
    max-width: 100%;
  }
}

/* ---- generated plan ---- */

#planWrap {
  display: none;
  background: var(--surface);
  border: 2px solid var(--red);
  border-radius: 8px;
  padding: 24px;
  margin-top: 8px;
}

#planWrap h2 {
  margin-top: 0;
}

#plan h3 {
  color: var(--red);
  border-bottom: 1px solid var(--blue-mid);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

#plan table {
  width: 100%;
  border-collapse: collapse;
}

#plan th,
#plan td {
  border: 1px solid var(--blue-mid);
  padding: 8px;
  vertical-align: top;
  text-align: left;
  font-size: 15px;
  line-height: 1.5;
}

#plan th {
  background: var(--blue-light);
}

#plan .plan-module {
  margin-bottom: 12px;
  line-height: 1.6;
}

#plan ul {
  margin: 6px 0;
  padding-left: 24px;
}

#plan li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.muted {
  color: var(--muted-light);
  font-style: italic;
}

footer {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 30px 0;
  line-height: 1.6;
}

a {
  color: var(--red);
}

a:hover,
a:focus {
  color: var(--red-dark);
}

/* ---- printing: show only the generated plan ----
   The hide rule must target `main > :not(#planWrap)`. An earlier
   `body > ...` selector hid <main> itself and printed a blank page. */
@media print {
  body {
    background: var(--surface);
    max-width: none;
    margin: 0;
  }

  main> :not(#planWrap),
  #planWrap .small-btn {
    display: none !important;
  }

  #planWrap {
    display: block !important;
    border: none;
    padding: 0;
  }
}
