/*
 * The project board ("Prosjekttavle", js/components/ProjectBoard.js): one
 * project's sessions side by side, with its work before, in and after class.
 *   body.project-board-on   the project board is shown instead of the storyboard
 * Each session is a column (.pb-col) of seven cells. On a wide screen the
 * columns are laid out by the grid (display: contents); on a phone they stack
 * and each cell names its row.
 */

.project-board {
  display: none;
}

body.project-board-on .project-board {
  display: block;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 3px solid var(--bh-black, #111);
  background: #fff;
}

body.project-board-on #storyboard-container,
body.project-board-on .course-plan-strip {
  display: none;
}

.pb-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  margin-bottom: 0.4rem;
}

.pb-title-main {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--bh-navy, #1B2A4A);
}

.pb-project-pick {
  margin: 0;
}

.pb-project-pick select {
  width: auto;
  max-width: 24rem;
  border: 2px solid var(--bh-black, #111);
  border-left: 10px solid var(--cb-color, #555);
  font-weight: 700;
}

.pb-span {
  font-size: 0.85rem;
  color: #444;
}

.pb-span i {
  color: var(--cb-color, #555);
}

.pb-edit-project {
  margin-left: auto;
}

.pb-hint,
.pb-empty {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: #555;
}

/* --- The grid ------------------------------------------------------------------------ */

/* Positioned, so the hidden row names of the cells stay inside it */
.pb-scroll {
  position: relative;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.pb-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, auto);
  grid-template-columns: 8.5rem repeat(var(--pb-columns, 1), 12.5rem) 10rem;
  width: max-content;
  border-top: 2px solid var(--bh-black, #111);
  border-left: 2px solid var(--bh-black, #111);
}

.pb-col {
  display: contents;
}

.pb-col > * {
  border-right: 2px solid var(--bh-black, #111);
  border-bottom: 2px solid var(--bh-black, #111);
}

/* Each cell names its row for a screen reader; on a phone it shows */
.pb-cell-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pb-corner,
.pb-row-label {
  background: var(--bh-cream, #F5F0E6);
}

.pb-row-label {
  display: flex;
  flex-direction: column;
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--bh-navy, #1B2A4A);
}

.pb-row-label small {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
  color: #666;
}

.pb-head {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  background: var(--bh-cream, #F5F0E6);
}

.pb-col.is-current .pb-head {
  box-shadow: inset 0 0 0 3px var(--bh-gold, #E8A820);
}

.pb-pos {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a5200;
}

.pb-session-title {
  padding: 0;
  border: 0;
  background: none;
  color: var(--bh-navy, #1B2A4A);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
}

.pb-session-title:hover,
.pb-session-title:focus-visible {
  text-decoration: underline;
}

.pb-meta {
  font-size: 0.75rem;
  color: #555;
}

.pb-total-head {
  background: var(--bh-navy, #1B2A4A);
  color: #fff;
}

.pb-total-head .pb-pos,
.pb-total-head .pb-meta {
  color: #fff;
  opacity: 0.85;
}

.pb-total-big {
  font-size: 1rem;
  font-weight: 800;
}

.pb-cell {
  min-height: 2.75rem;
  padding: 4px;
  background: #fff;
}

.pb-focus-text {
  min-height: 5.6rem;
  font-size: 0.8rem;
  line-height: 1.3;
  resize: vertical;
}

.pb-work {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* A learning type dragged in from the left, over the cell it will go into */
.pb-work.is-drop {
  outline: 2px solid var(--bh-gold, #E8A820);
  outline-offset: -2px;
  background: #fff6dd;
}

.pb-card-name {
  grid-column: 2;
  font-size: 0.78rem;
  font-weight: 700;
}

.pb-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0.5rem;
}

.pb-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.1rem 0.35rem;
  padding: 0.3rem 0.4rem;
  border: 2px solid var(--bh-black, #111);
  border-left: 8px solid var(--cb-color, #555);
  background: color-mix(in srgb, var(--cb-color, #555) 10%, #fff);
  font-size: 0.78rem;
  line-height: 1.25;
  cursor: grab;
}

.pb-card-type i {
  color: var(--cb-color, #555);
}

.pb-card-title {
  grid-column: 2;
  font-weight: 700;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.pb-card-title:hover,
.pb-card-title:focus-visible {
  text-decoration: underline;
}

.pb-card-min {
  grid-column: 2;
  color: #555;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A card whose name has the keyboard focus can be moved with Alt and the arrow keys
   (ProjectBoard._onKeydown); the keys show beside its minutes, "⌥" on a Mac (data-keys) */
.pb-card:has(> .pb-card-title:focus-visible) {
  outline: 3px solid var(--bh-gold, #E8A820);
  outline-offset: 1px;
}

/* The card's outline is the focus ring; the name keeps its underline */
.pb-card > .pb-card-title:focus-visible {
  outline: 0;
}

.pb-card:has(> .pb-card-title:focus-visible)::after {
  content: attr(data-keys) / "";
  grid-column: 3;
  align-self: end;
  padding: 0 0.3rem;
  background: var(--bh-navy, #1B2A4A);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

/* The ×: the card is deleted at once, as on the storyboard and the course board */
.pb-delete {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  padding: 0 0.15rem;
  border: 0;
  background: none;
  color: #999;
  font-size: 0.75rem;
  line-height: 1.2;
}

.pb-delete:hover,
.pb-delete:focus-visible {
  color: #b02a37;
}

.pb-add {
  align-self: flex-start;
  padding: 0.05rem 0.45rem;
  border: 2px dashed #9a9384;
  background: none;
  color: #555;
  font-size: 0.75rem;
}

.pb-add:hover,
.pb-add:focus-visible {
  border-color: var(--bh-black, #111);
  color: var(--bh-black, #111);
}

.pb-milestones {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pb-flag {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.1rem 0.35rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid #e4b4b9;
  background: #fbeeee;
  font-size: 0.75rem;
  line-height: 1.25;
}

.pb-flag i {
  color: #b02a37;
}

.pb-flag span {
  color: #444;
  overflow-wrap: anywhere;
}

.pb-flag-remove {
  margin-left: auto;
  padding: 0 0.2rem;
  border: 0;
  background: none;
  color: #666;
}

.pb-milestone-new {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pb-milestone-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
}

.pb-sum {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: #faf8f3;
  font-size: 0.8rem;
}

.pb-sum-split {
  color: #555;
  font-size: 0.74rem;
}

.pb-mix {
  display: flex;
  height: 8px;
  border: 1px solid var(--bh-black, #111);
}

.pb-mix.is-empty {
  border-style: dashed;
  border-color: #bbb;
}

.pb-total {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: #f1eee6;
  font-size: 0.8rem;
}

.pb-total span {
  color: #555;
  font-size: 0.74rem;
}

/* --- A phone: the sessions stack --------------------------------------------------- */

@media (max-width: 767.98px) {
  .pb-edit-project {
    margin-left: 0;
  }

  .pb-project-pick,
  .pb-project-pick select {
    max-width: 100%;
  }

  .pb-scroll {
    overflow: visible;
  }

  .pb-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: auto;
    border: 0;
  }

  .pb-col {
    display: block;
    border: 2px solid var(--bh-black, #111);
  }

  .pb-col > * {
    border-right: 0;
    border-bottom: 1px solid #d8d2c4;
  }

  .pb-col > *:last-child {
    border-bottom: 0;
  }

  .pb-labels {
    display: none;
  }

  .pb-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.1rem 0.5rem;
  }

  .pb-cell-label {
    position: static;
    display: block;
    width: auto;
    height: auto;
    margin-bottom: 2px;
    overflow: visible;
    clip: auto;
    color: var(--bh-navy, #1B2A4A);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
  }
}

/* --- Print: the project board on A3 landscape ----------------------------------------- */

@media print {
  @page project-board {
    size: A3 landscape;
    margin: 10mm;
  }

  body.project-board-on {
    page: project-board;
    min-height: 0 !important;
  }

  body.project-board-on .project-board {
    padding: 0;
    border: 0;
  }

  body.project-board-on #storyboard-container,
  body.project-board-on .focus-strip,
  body.project-board-on #analytics-container,
  body.project-board-on .print-links {
    display: none !important;
  }

  .pb-scroll {
    overflow: visible;
  }

  .pb-grid {
    width: auto;
    grid-template-columns: 7rem repeat(var(--pb-columns, 1), minmax(0, 1fr)) 8rem;
  }

  .pb-card,
  .pb-flag {
    break-inside: avoid;
    font-size: 7.5pt;
  }

  .pb-focus-text {
    border: 0;
    padding: 0;
    resize: none;
    font-size: 7.5pt;
  }
}

/* The editor's "Del av prosjekt", with "Åpne prosjekttavla" beside it */
.activity-project-select {
  flex: 1 1 14rem;
  width: auto;
}
