/* ---------- Theme: viridian, light and dark ----------
   Every color comes from these variables. The light theme is the default;
   the dark theme applies when <html data-theme="dark">. */
:root {
  color-scheme: light;
  --bg: #f2f6f4;
  --surface: #ffffff;
  --surface-2: #eaf3ef;
  --text: #1d2925;
  --muted: #586a64;
  --faint: #98a8a2;
  --primary: #2c6b5a;
  --primary-strong: #1f5144;
  --on-primary: #ffffff;
  --accent: #40826d;
  --highlight: #e1f0ea;
  --line: #d3e0db;
  --line-soft: #e6eeeb;
  --input-bg: #fbfdfc;
  --input-border: #c6d5cf;
  --toolbar: #dfeee8;
  --danger: #b3473f;
  --shadow: 0 1px 4px rgba(20, 50, 40, 0.08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1815;
  --surface: #15231f;
  --surface-2: #1a2c26;
  --text: #e2ebe7;
  --muted: #9cb1a9;
  --faint: #66796f;
  --primary: #6cc3a6;
  --primary-strong: #8dd6bd;
  --on-primary: #0e1815;
  --accent: #4fae90;
  --highlight: #1c382f;
  --line: #2a3f38;
  --line-soft: #21332d;
  --input-bg: #111e1a;
  --input-border: #2e463d;
  --toolbar: #12201c;
  --danger: #e2786e;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: var(--toolbar);
  border-bottom: 3px solid var(--accent);
}
/* Small square sidebar toggles: the form's in the form's top-left corner, the map's in the
   map's top-right corner. The filled side of each icon is the panel it controls; it's hollow
   while that panel is hidden. */
.panel-bar {
  display: flex;
  justify-content: space-between;
  margin: 0 0 6px;
}
.panel-bar.overlay {
  /* Sits over the map's top corners and stays there while the map scrolls */
  position: sticky;
  top: 0;
  z-index: 1;
  height: 0;
  margin: 0;
  padding: 8px 8px 0;
  overflow: visible;
}
.panel-bar .icon-btn { background: var(--surface); }
.show-only-when-map-hidden,
.show-only-when-form-hidden { visibility: hidden; }
.workspace[data-view="editor"] .show-only-when-map-hidden,
.workspace[data-view="preview"] .show-only-when-form-hidden { visibility: visible; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.icon-btn[aria-pressed="false"] .fill { opacity: 0; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.brand {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.brand:hover { color: var(--primary); }
.toolbar h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary);
}
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn {
  display: inline-block;
  border: 0;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: var(--primary-strong); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.btn-outline:hover { background: var(--primary); color: var(--on-primary); }

/* ---------- Workspace: form on the left, map on the right ---------- */
.workspace {
  display: grid;
  grid-template-columns: var(--editor-width, 420px) 16px minmax(0, 1fr);
  gap: 6px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}
/* Each part keeps its own column, so hiding one doesn't shift the others over */
.workspace > .editor { grid-column: 1; }
.workspace > .splitter { grid-column: 2; }
.workspace > .preview { grid-column: 3; }
/* Form hidden: the map gets the whole width. Map hidden: the form does. No divider either way. */
.workspace[data-view="preview"] { grid-template-columns: 0 0 minmax(0, 1fr); column-gap: 0; }
.workspace[data-view="preview"] .editor { display: none; }
.workspace[data-view="editor"] { grid-template-columns: minmax(0, 1fr) 0 0; column-gap: 0; }
.workspace[data-view="editor"] .preview { display: none; }
.workspace:not([data-view="both"]) .splitter { display: none; }
.workspace[data-view="editor"] .editor { width: 100%; max-width: 820px; justify-self: center; }
.workspace[data-view="preview"] .map { max-width: 1050px; margin: 0 auto; }
@media (max-width: 900px) {
  .workspace,
  .workspace[data-view] { grid-template-columns: minmax(0, 1fr); }
  .workspace > .editor,
  .workspace > .splitter,
  .workspace > .preview { grid-column: 1; }
}

/* The divider between the form and the map: drag it to resize */
.splitter {
  align-self: stretch;
  min-height: calc(100vh - 140px);
  cursor: col-resize;
  touch-action: none;
  border-radius: 8px;
  background: linear-gradient(var(--line), var(--line)) center / 2px 100% no-repeat;
}
.splitter:hover,
.splitter.dragging,
.splitter:focus-visible {
  background-image: linear-gradient(var(--accent), var(--accent));
  outline: none;
}
@media (max-width: 900px) {
  .splitter { display: none; } /* stacked on small screens: nothing to drag */
}
.preview {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 10px;
}
@media (max-width: 900px) {
  .preview { position: static; max-height: none; }
}
.hint {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Form ---------- */
.panel {
  margin: 0 0 16px;
  padding: 14px 16px 6px;
  background: var(--surface);
  border: 0;
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.panel legend {
  float: left;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  font-weight: 700;
  color: var(--primary);
}
/* Folding form boxes: click the header to hide or show a box */
.editor-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 10px;
}
.panel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
}
.panel-toggle:hover .panel-title { text-decoration: underline; }
.panel-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chevron {
  flex-shrink: 0;
  display: inline-block;
  width: 1em;
  transition: transform 0.15s;
}
.panel.collapsed .chevron { transform: rotate(-90deg); }

/* Foldable sections inside a unit: Overview, Knowledge, Skills, Learning activities, Assessment */
.section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
}
.section-toggle:hover span:last-child { text-decoration: underline; }
.unit-section.collapsed { padding-bottom: 4px; }
.unit-section.collapsed .section-toggle { margin-bottom: 4px; }
.unit-section.collapsed .section-body { display: none; }
.unit-section.collapsed .chevron { transform: rotate(-90deg); }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed { padding-bottom: 8px; }
.panel { min-width: 0; } /* a long header shortens with "…" instead of widening the box */
.panel legend { min-width: 0; overflow: hidden; }
.panel.collapsed .unit-controls { margin-bottom: 0; }

.field {
  display: block;
  clear: both;
  margin: 0 0 10px;
}
.field-label {
  display: block;
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 600;
}
.field input,
.field textarea,
.row input,
.row textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--input-bg);
  resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder,
.row input::placeholder,
.row textarea::placeholder { color: var(--faint); }
.field input:focus,
.field textarea:focus,
.row input:focus,
.row textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
  background: var(--surface);
}
.field-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
}
.field-group {
  clear: both;
  margin: 4px 0 12px;
  padding: 10px 12px 2px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.field-group-title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--primary);
}

/* Rows of paired inputs: standards (code + text) and assessment pairs (objective + artifact) */
.row,
.row-head {
  display: grid;
  gap: 6px;
  align-items: start;
}
.row { margin: 0 0 6px; }
.row.std { grid-template-columns: 96px 1fr auto; }
.row.std.single { grid-template-columns: 96px 1fr; }
/* Knowledge and skill rows: name (with the remove button) on top, description full width under it */
.row.named { grid-template-columns: 1fr auto; margin-bottom: 10px; }
.row.named > :nth-child(1) { grid-column: 1; grid-row: 1; }
.row.named > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
.row.named > :nth-child(3) { grid-column: 2; grid-row: 1; margin-top: 6px; }
.row.named input { font-weight: 600; }
/* Skill rows: type dropdown, name and remove on top; custom type (when chosen) and description under */
.row.skill {
  grid-template-columns: 128px 1fr auto;
  grid-template-areas:
    "type name remove"
    "custom custom custom"
    "desc desc desc";
  margin-bottom: 10px;
}
.row.skill .skill-type { grid-area: type; }
.row.skill .skill-name { grid-area: name; font-weight: 600; }
.row.skill .skill-custom { grid-area: custom; }
.row.skill .skill-custom[hidden] { display: none; }
.row.skill .skill-description { grid-area: desc; }
.row.skill > button { grid-area: remove; margin-top: 6px; }
.row select {
  width: 100%;
  padding: 7px 6px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--input-bg);
}
.row select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.row.pair,
.row-head.pair { grid-template-columns: 1fr 1fr auto; }
.row.pair.single,
.row-head.pair.single { grid-template-columns: 1fr 1fr; }
/* Assessment rows in the form, stacked to fit the narrow column: objective title, its
   description, then the artifact title and its description, with the remove button by the title.
   (The map and PDF still show the artifact beside its objective.) */
.row.pair {
  grid-template-columns: 1fr auto;
  grid-template-areas: "title remove" "desc ." "artifact ." "adesc .";
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.row.pair.single {
  grid-template-columns: 1fr;
  grid-template-areas: "title" "desc" "artifact" "adesc";
  border-bottom: 0;
}
.row.pair .pair-artifact { margin-top: 4px; }
.row.pair .pair-title { grid-area: title; font-weight: 600; }
.row.pair .pair-description { grid-area: desc; }
.row.pair .pair-artifact { grid-area: artifact; font-weight: 600; }
.row.pair .pair-artifact-description { grid-area: adesc; }
.row.pair > button { grid-area: remove; }
.row-head {
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 600;
}
.row .btn-small { margin-top: 6px; }
.rows > .btn-small { margin-top: 2px; }

.unit-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  clear: both;
  margin: 0 0 10px;
}
.btn-small {
  border: 1px solid var(--input-border);
  background: var(--surface);
  color: var(--primary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.btn-small:hover:not(:disabled) { border-color: var(--primary); }
.btn-small:disabled { opacity: 0.4; cursor: default; }
.btn-small.danger { color: var(--danger); }
.btn-small.danger:hover:not(:disabled) { border-color: var(--danger); }
.add-unit { width: 100%; }

/* ---------- The map ---------- */
.map {
  background: var(--surface);
  border-radius: 10px;
  padding: 36px 40px;
  box-shadow: var(--shadow);
}
.map-head h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary);
}
.map-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
  margin: 0 0 12px;
}
/* Each "Label: value" pair moves to the next line as a whole instead of wrapping its value
   (it only wraps inside if the pair is wider than the whole line) */
.map-facts div { display: flex; gap: 6px; flex: 0 0 auto; max-width: 100%; }
.map-facts dt { font-weight: 600; }
.map-facts dt::after { content: ":"; }
.map-facts dd { margin: 0; }
.map-description { margin: 0 0 8px; }

.unit {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 4px solid var(--accent);
}
.unit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}
.unit-number {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}
.unit-head h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}
.unit-weeks {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.big-idea-block { margin-top: 10px; }
.big-idea-block h4 {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}
.big-idea {
  margin: 0;
  font-style: italic;
}

/* Year at a glance: every unit in one table, before the units */
.overview { margin-top: 24px; }
.overview-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
}
.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.overview-table th,
.overview-table td {
  padding: 6px 10px 6px 0;
  text-align: left;
  vertical-align: top;
  white-space: pre-line;
  border-top: 1px solid var(--line-soft);
}
.overview-table th {
  font-weight: 600;
  color: var(--primary);
  border-top: 0;
  border-bottom: 2px solid var(--accent);
}
.overview-table th:nth-child(1) { width: 26%; }
.overview-table th:nth-child(2) { width: 8%; }
.overview-table th:nth-child(3) { width: 36%; }
.overview-number {
  display: inline-block;
  min-width: 1.4em;
  font-weight: 700;
  color: var(--accent);
}
.overview-unit { font-weight: 600; }
.overview-table .std-code { width: auto; }
.overview-total td {
  font-weight: 600;
  border-top: 2px solid var(--line);
}
.overview-table tr { break-inside: avoid; }
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px 28px;
  margin-top: 14px;
}
.unit-block h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}
.unit-block ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.92rem;
}

/* Knowledge and skill entries: bold name, description under it */
.named-list {
  margin: 0;
  font-size: 0.92rem;
}
.named-list > div + div {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--line-soft);
}
.named-list dt { font-weight: 600; }
.named-list dd {
  margin: 0;
  white-space: pre-line;
}
.named-list > div { break-inside: avoid; }

/* Knowledge, Skills and Assessment: full-width groups with their own heading */
.unit-group {
  grid-column: 1 / -1;
  padding: 8px 0 10px;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}
.unit-group + .unit-group { border-top: 0; }
.unit-group-title {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.unit-group .unit-grid { margin-top: 0; }

/* Standards and assessment pairs: tables, so each code lines up with its text
   and each objective lines up with its artifact, on screen and in the PDF */
.unit-block.wide { grid-column: 1 / -1; }
.std-table,
.pair-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.std-table td,
.pair-table td,
.pair-table th {
  padding: 4px 10px 4px 0;
  text-align: left;
  vertical-align: top;
  white-space: pre-line;
}
.std-table tr + tr td,
.pair-table tbody tr + tr td { border-top: 1px solid var(--line-soft); }
.std-code {
  width: 8.5em;
  font-weight: 600;
}
.pair-table { table-layout: fixed; margin: 0 0 10px; }
.pair-table th {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}
.std-table tr,
.pair-table tr { break-inside: avoid; }
.pair-table .pair-title { font-weight: 600; }

/* Key standard: highlighted so the priority standard stands out */
.unit-block.key {
  padding: 8px 12px;
  background: var(--highlight);
  border-left: 4px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.unit-block.key h4 { color: var(--accent); }

.unit-block .empty,
.unit-group > .empty,
.pair-table td.empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--faint);
  font-style: italic;
}
.map-footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Printing / PDF: always the light theme ---------- */
@page { margin: 0.6in; }
@media print {
  :root[data-theme="dark"] {
    color-scheme: light;
    --surface: #ffffff;
    --text: #1d2925;
    --muted: #586a64;
    --faint: #98a8a2;
    --primary: #2c6b5a;
    --accent: #40826d;
    --highlight: #e1f0ea;
    --line: #d3e0db;
    --line-soft: #e6eeeb;
  }
  body { background: white; }
  .toolbar, .editor, .splitter, .panel-bar { display: none !important; }
  .workspace { display: block; max-width: none; padding: 0; }
  .preview { display: block !important; position: static; max-height: none; overflow: visible; }
  .workspace[data-view] .map { max-width: none; }
  .map { box-shadow: none; padding: 0; border-radius: 0; }
  .unit { break-inside: avoid-page; }
  .overview { break-after: page; } /* the year at a glance gets the first page; units start after */
  .unit-grid { grid-template-columns: 1fr 1fr; }
  .unit-block.key {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  a { color: inherit; text-decoration: none; }
}
