/* Lato, hosted in this repo (SIL Open Font License, see fonts/ folder) */
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/Lato-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/Lato-Italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/Lato-Bold.woff2') format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/Lato-BoldItalic.woff2') format('woff2');
}

:root {
  --page: #f6f7f8;
  --blue: #0072ce;
  --blue-button: #006fbf;
  --blue-button-hover: #005a9c;
  --gold: #c99700;
  --text: #202122;
  --field-border: #6e7477;
  --secondary: #e3e9f1;
  --secondary-hover: #d3dbe6;
  --rule: #cdd5dc;
}

/* A hidden thing stays hidden, no matter what other rules say about its display */
[hidden] {
  display: none !important;
}

html {
  scroll-padding-bottom: 110px;
}

body {
  margin: 0;
  font-family: Lato, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
}

/* --- the tiny bar at the very top of the web page -- */
.top-bar {
  background: #ffffff;
  border-top: 3px solid var(--gold);
  padding: 16px 32px;
}

.top-bar .site-name {
  font-size: 1.6rem;
}

/* -- the next few items handle the progressive menu bar at the top -- */
.nav-bar {
  background: var(--blue);
  color: #ffffff;
  padding: 14px 32px;
  font-size: 1.1rem;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  padding: 4px 14px;
  border-radius: 4px;
}

.steps li[aria-current="step"] {
  background: #ffffff;
  color: var(--blue);
  font-weight: 700;
}

main {
  padding: 0 32px 130px;
}

h1 {
  margin: 24px 0 32px;
  font-size: 2.6rem;
  font-weight: 400;
  line-height: 1.2;
}

h2 {
  margin: 0 0 24px;
  font-size: 2rem;
  font-weight: 400;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 360px;
  box-sizing: border-box;
  padding: 12px;
  font: inherit;
  font-size: 1.1rem;
  background: #ffffff;
  border: 1px solid var(--field-border);
  border-radius: 6px;
}

/* the front-page paste box: nearly the full window. The 460px is everything around it: top bars, heading, label, help sentences, bottom padding. Tune it. */
#markdown-input {
  height: calc(100vh - 460px);
  min-height: 360px;
}

/* -- formatting for the box text during organize -- */
.box-text {
  margin: 0;
  white-space: pre-wrap;   /* keeps line breaks, so list items stay on separate lines */
}

/* The boxes area gets focus from Python when the screen switches; no outline needed on a plain container */
#boxes:focus-visible {
  outline: none;
}

button {
  padding: 10px 24px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.primary {
  color: #ffffff;
  background: var(--blue-button);
}

.primary:hover {
  background: var(--blue-button-hover);
}

/* --- disabled buttons should be grey and unclickable --- */
.primary:disabled,
.primary:disabled:hover {
  color: #6e7477;
  background: var(--secondary);
  cursor: not-allowed;
}

.secondary {
  color: var(--text);
  background: var(--secondary);
}

.secondary:hover {
  background: var(--secondary-hover);
}

.card {
  background: #ffffff;
  border: 1px solid var(--secondary);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
}

.columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 48px;
  align-items: start;
}

@media (max-width: 800px) {
  .columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 12px;
  padding: 14px 32px;
  background: #ffffff;
  border-top: 1px solid var(--rule);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.08);
}

/* -- I don't remember what this is for but it's not for data entry boxes -- */
:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

/* -- Text (data entry) boxes: the focus ring IS the border, like Brightspace (blue, 2px) -- */
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--blue-button);
  box-shadow: 0 0 0 1px var(--blue-button);   /* adds a second pixel so the border reads as 2px without shifting the layout */
}

.status {
  color: #4a4d4e;
  font-size: 0.9rem;
}

/* -- Hidden on screen, still read aloud by screen readers (the next two style groups) -- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

textarea::placeholder {
  color: var(--field-border);
  opacity: 1;
}

/* ---------- Boxes on the Organize screen ---------- */
.box-frame {
  background: #ffffff;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  margin-bottom: 16px;
}

.box-toolbar {
  display: flex;
  justify-content: flex-end;     /* push the controls to the right, like the Brightspace editor */
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
}

.box-number {
  font-weight: 700;
}

.box-toolbar select {
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--field-border);
  border-radius: 4px;
}

/* ---------- The preview: the box's words, styled like the finished page ---------- */

.preview {
  padding: 16px 24px;
  font-size: 19px;
  line-height: 1.55;
  color: #494c4e;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  color: #0D4471;
  font-weight: 400;          /* regular weight, not bold */
  line-height: 1.2;
  margin: 0 0 0.5em;
}

.preview h1 { font-size: 40px; }
.preview h2 { font-size: 30px; }
.preview h3 { font-size: 26px; }
.preview h4 { font-size: 22px; }   /* guess, no number yet */
.preview h5 { font-size: 20px; }   /* guess, no number yet */
.preview h6 { font-size: 19px; }   /* guess, no number yet */

.preview > :first-child { margin-top: 0; }
.preview > :last-child { margin-bottom: 0; }

.text-center { text-align: center; }     /* the engine's H1 class */
.text-left { text-align: left; }         /* the engine's H2 to H6 class */

.sr-only {                               /* the engine's hidden "(opens in a new tab)" text */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* PLACEHOLDER SIZES: stand-ins until we match a real finished page */
.preview h1 { font-size: 2.5rem;  font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }
.preview h2 { font-size: 2rem;    font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }
.preview h3 { font-size: 1.75rem; font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }
.preview h4 { font-size: 1.5rem;  font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }
.preview h5 { font-size: 1.25rem; font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }

/* Boxes sit quietly in gray... */
.box-frame {
  border-color: var(--rule);
}

/* ...until you're working in one. Then it gets the dark outline. */
.box-frame:focus-within {
  border-color: var(--text);
}

/* problems in the right hand card */
#issues { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); }
#issues-list { padding-left: 20px; overflow-wrap: anywhere; }   /* long urls wrap instead of poking out of the card */
#issues-list li { margin-bottom: 0.75em; } /* about half a line between each repair item */
aside li { margin-bottom: 0.75em; } /* about half a line between each repair item */
.preview h6 { font-size: 1rem;    font-weight: 500; line-height: 1.2; margin: 0 0 0.5rem; }

.edit-toggle { padding: 4px 12px; font-size: 0.9rem; margin-left: 8px; }   /* small, so it sits nicely beside the dropdown */
.box-editor {
  display: block; box-sizing: border-box;
  width: calc(100% - 48px); margin: 16px 24px;
  height: auto; min-height: 6em;                 /* the global textarea rule says 360px; this box should fit its words */
  font-family: inherit; font-size: 19px; line-height: 1.55; resize: vertical;
}

.box-hint { margin: 8px 24px 0; font-size: 0.9rem; color: #494c4e; }

/* --- step 3: the page preview (a simulation of the template's own styles) --- */
#page-preview:focus-visible { outline: none; }
.preview .fas { color: #0D4471; }
.preview .card-gold {
  background: #fff8e1;
  border: 1px solid var(--rule);
  border-left: 8px solid var(--gold);
  border-radius: 0;
  padding: 0;
  margin-bottom: 1rem;
}
.preview .card-gold .card-body { padding: 12px 16px; }
.preview .list-unstyled { list-style: none; padding: 0; margin: 0 0 1rem; }
.preview .mb-0 { margin-bottom: 0; }
.preview .d-flex { display: flex; }
.preview .align-items-baseline { align-items: baseline; }
.preview .mb-1 { margin-bottom: .25rem; }
.preview .mr-3 { margin-right: 1rem; }
.preview .fa-fw { width: 1.25em; text-align: center; flex: 0 0 1.25em; }

/* page details (step 3): label above field, padded rounded boxes, times in a row */
#page-details label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

#page-details .detail-field {
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  background: #fff;
  border: 1px solid var(--field-border, #8a97a3);
  border-radius: 6px;
}

#page-details textarea.detail-field {
  resize: vertical;
}

.detail-times {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-times > div {
  flex: 1 1 140px;
}

/* blue callout card in the preview (the real page gets its look from the Brightspace template) */
.preview .card-graphic {
  background: #EDF8FE;
  border: 3px solid #0D4471;
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 0;
}

.preview .card-graphic .card-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 16px;
}

.preview .card-graphic .card-icon p {
  margin: 0;
  font-size: 2rem;
}

.preview .card-graphic .card-text {
  flex: 1;
}

.preview .card-graphic .card-text > :first-child {
  margin-top: 0;
}

.preview .card-graphic .card-text > :last-child {
  margin-bottom: 0;
}

/* the right-hand card follows you down the page; if it's taller than the window, it scrolls inside itself */
aside.card {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}

aside.card:focus-visible {
  outline: 3px solid #0D4471;
  outline-offset: 2px;
}

/* narrow windows stack the layout, so the card goes back to behaving like a normal block */
@media (max-width: 800px) {
  aside.card {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* the stand-in banner at the top of the preview */
.preview-banner {
  display: block;
  width: 100%;
  height: auto;               /* keeps the picture's shape as the card gets wider or narrower */
  margin-bottom: 16px;
}

/* the template keeps content in 10 of 12 columns, centered; the banner above it runs wider */
.preview-content {
  width: 83.333%;
  margin: 0 auto;
}

/* on phone-width screens the real page uses the full width, so the preview does too */
@media (max-width: 575px) {
  .preview-content {
    width: 100%;
  }
}

/* ACCORDIONS IN THE PREVIEW: always shown open, like Brightspace's editing view; only the finished-page preview gets this */
#page-preview .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

#page-preview .accordion {
    border: 1px solid #cdd5dc;
    margin: 1em 0;
}

#page-preview .accordion .card {            /* undo the app's own .card look (padding, border, rounding) */
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #ffffff;
}

#page-preview .accordion .card + .card {    /* the thicker line between one accordion and the next */
    border-top: 2px solid #cdd5dc;
}

#page-preview .accordion .card-header {
    position: relative;
    padding: 20px 20px 20px 70px;           /* leaves room on the left for the chevron */
    background: #ffffff;
    border-bottom: 2px solid #cdd5dc;       /* the line under the title, because the content is always open here */
}

#page-preview .accordion .card-header::before {    /* the little down arrow, from Font Awesome 5 (chevron-down) */
    content: "\f078";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 13px;
    color: #b9c2d0;
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
}

#page-preview .accordion .card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #494c4e;
    text-align: left;
}

#page-preview .accordion .card-body {
    background: #f7f7f7;
    padding: 20px;
}

#page-preview .accordion .card-body > :last-child {
    margin-bottom: 0;                       /* no extra gap under the last thing in the panel */
}

/* THE VIDEO FIELDS UNDER A VIDEO BOX: TITLE, LENGTH, LANGUAGE */
.video-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-top: 12px;
}

.video-fields[hidden] {                     /* display:flex above would otherwise beat the hidden attribute */
    display: none;
}

.video-fields > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.video-field-title {
    flex: 3 1 260px;
}

.video-field-length {
    flex: 1 1 120px;
}

.video-field-language {
    flex: 2 1 200px;
}

.video-fields label {
    margin: 0;                              /* the gap under the label was the app's own label margin */
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.video-fields input {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
    padding: 0.4em 0.5em;
}

/* VIDEOS IN THE PREVIEW: THE APP DOESN'T HAVE BOOTSTRAP'S VIDEO RULES OR BRIGHTSPACE'S LINK ICON, SO WE IMITATE THEM */
.preview .video-wrapper {
    max-width: 640px;
}

.preview .embed-responsive {                /* a 16:9 box that scales with the width, like Bootstrap's */
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.preview .embed-responsive::before {
    display: block;
    content: "";
}

.preview .embed-responsive-16by9::before {
    padding-top: 56.25%;
}

.preview .embed-responsive-item {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.preview .video-text {
    margin-top: 0.5em;
}

.preview .video-text p {
    margin: 0 0 0.25em;
    text-align: center;
}

.preview a.new-window::after {              /* the little "opens in a new window" arrow, from Font Awesome 5 (external-link-alt) */
    content: "\f35d";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.75em;
    margin-left: 0.35em;
}

/* ---------- The banner picker in the right-hand column: styled like the box dropdowns ---------- */
.banner-area {
  margin-bottom: 24px;
}

.banner-area select {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--field-border);
  border-radius: 4px;
}


/* TABS IN THE PREVIEW: THE APP DOESN'T HAVE BOOTSTRAP, SO WE IMITATE IT; EVERY PANEL SHOWS, STACKED, LIKE BRIGHTSPACE'S EDITING VIEW */
/* the colors are the app's own: --blue (the nav bar blue), --page (the light gray), --rule (the thin borders) */
.preview .tabs-wrapper {
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
    margin: 1em 0;
}

.preview .list-group {
    display: flex;
    flex-direction: row;
    text-align: center;
}

.preview .list-group-item {
    flex: 1 1 0;
    padding: 22px 12px;
    font-weight: 700;
    color: inherit;                         /* the preview's own gray text */
    background: var(--page);
    border-left: 1px solid var(--rule);
}

.preview .list-group-item:first-child {
    border-left: 0;
}

.preview .list-group-item.active {
    color: #ffffff;                         /* white on --blue; the finished page does this, and Brightspace's editing view shows dark text instead */
    background: var(--blue);
}

.preview .tab-pane {
    padding: 24px 30px;
    background: #ffffff;
    border-top: 1px solid var(--rule);
}

.preview .tab-pane > :first-child { margin-top: 0; }
.preview .tab-pane > :last-child { margin-bottom: 0; }

@media (max-width: 767px) {                 /* narrow windows stack the tab labels, like flex-md-row does */
    .preview .list-group { flex-direction: column; }
    .preview .list-group-item { border-left: 0; border-top: 1px solid var(--rule); }
    .preview .list-group-item:first-child { border-top: 0; }
}
