/*
  The app's frame: navigation and the page beside or beneath it. There are three layouts and each
  user picks their own; <html data-layout> says which. The HTML is the same for all three.

    rail   navigation down the left, foldable to icons
    top    a slim bar across the top
    tabs   a slim bar whose middle holds the programmes and plans the user has open
*/

html, body {
  height: 100%;
}

/* Three faces, each with a job: Archivo for titles and big numbers, IBM Plex Sans for the interface,
   IBM Plex Mono for dates and figures so columns line up. They load from Google Fonts; without a
   connection the fallbacks after them are used. */
:root {
  --font-display: Archivo, "Segoe UI", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

body {
  margin: 0;
  font: 14px/20px var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* One page title per page. */
h1, .h1, .h3, .h4 {
  font-family: var(--font-display);
  font-weight: 650;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}

main h1 {
  font-size: 26px;
  line-height: 32px;
}

h2, h3, .h5, .h6, .modal-title {
  font-family: var(--font-display);
  font-weight: 650;
}

/* Icons: 16px line drawings in the colour of the text beside them. */
.icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app {
  display: flex;
  height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The page scrolls inside the frame, so the navigation stays put. */
main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

/* Ordinary pages keep to a readable width; chart pages take everything. */
main:not(.wide) > * {
  max-width: 1280px;
}

main.wide {
  padding: 20px 24px 16px;
}

/* ---------------------------------------------------------------- navigation, common */

.app-nav {
  flex: none;
  display: flex;
  background: var(--stp-nav-bg);
  color: var(--stp-nav-text);
}

.nav-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-brand,
.nav-brand:hover {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--stp-nav-text) !important;
  font: 650 15px/20px var(--font-display);
  font-stretch: 112%;
  text-decoration: none;
  white-space: nowrap;
}

/* The mark: two offset bars, a Gantt chart in miniature. The upper one is the brand colour. */
.nav-mark {
  flex: none;
  width: 18px;
  height: 18px;
}

.nav-mark .a {
  fill: var(--stp-brand);
}

.nav-mark .b {
  fill: var(--stp-nav-text);
}

.nav-fold {
  display: none;
  margin-left: auto;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  opacity: 0.7;
}

.nav-fold:hover {
  opacity: 1;
}

.nav-places {
  display: flex;
  gap: 2px;
}

.nav-place {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--stp-nav-text) !important;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  opacity: 0.78;
}

.nav-place:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--stp-nav-text) 10%, transparent);
}

/* Where you are: a raised pill in the product's own theme, a tinted one where the bar is dark. */
.nav-place.current {
  opacity: 1;
  background: var(--stp-nav-current, color-mix(in srgb, var(--stp-nav-text) 16%, transparent));
  box-shadow: var(--stp-nav-current-shadow, none);
}

.nav-user .nav-place {
  height: auto;
  padding-block: 6px;
  line-height: 16px;
}

/* The person's initials, in the brand colour. */
.nav-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--stp-brand);
  color: var(--stp-on-brand);
  font-size: 12px;
  font-weight: 600;
}

.nav-company {
  display: block;
  font-size: 12px;
  opacity: 0.7;
}

.nav-tabs-strip {
  display: none;
}

/* ---------------------------------------------------------------- rail */

[data-layout="rail"] .app-nav {
  flex-direction: column;
  width: 224px;
  padding: 12px;
  gap: 12px;
}

[data-layout="rail"] .nav-head {
  padding: 0 6px 0 10px;
}

[data-layout="rail"] .nav-fold {
  display: block;
}

[data-layout="rail"] .nav-places {
  flex-direction: column;
}

[data-layout="rail"] .nav-user {
  margin-top: auto;
}

[data-layout="rail"] .nav-user .nav-place {
  width: 100%;
}

/* Folded: icons only. js/site.js puts data-nav="folded" on <html> and remembers it. */
[data-layout="rail"][data-nav="folded"] .app-nav {
  width: 56px;
  padding-inline: 10px;
}

[data-layout="rail"][data-nav="folded"] .nav-place {
  padding: 0;
}

[data-layout="rail"][data-nav="folded"] .nav-mark {
  display: none;
}

[data-layout="rail"][data-nav="folded"] .nav-brand,
[data-layout="rail"][data-nav="folded"] .nav-place span:not(.nav-avatar) {
  display: none;
}

[data-layout="rail"][data-nav="folded"] .nav-head {
  padding: 0;
  justify-content: center;
}

[data-layout="rail"][data-nav="folded"] .nav-fold {
  margin: 0;
}

[data-layout="rail"][data-nav="folded"] .nav-place {
  justify-content: center;
}

/* ---------------------------------------------------------------- top and tabs */

[data-layout="top"] .app,
[data-layout="tabs"] .app {
  flex-direction: column;
}

[data-layout="top"] .app-nav,
[data-layout="tabs"] .app-nav {
  align-items: center;
  gap: 18px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--stp-border);
}

[data-layout="top"] .nav-user,
[data-layout="tabs"] .nav-user {
  margin-left: auto;
}

[data-layout="top"] .nav-company,
[data-layout="tabs"] .nav-company {
  display: inline;
  margin-left: 6px;
}

[data-layout="top"] .nav-place .icon {
  display: none;
}



/* Tabs: the places shrink to icons to leave the bar to what is open. */
[data-layout="tabs"] .nav-places .nav-place span {
  display: none;
}

[data-layout="tabs"] .nav-places .nav-place {
  padding: 0 9px;
}

[data-layout="tabs"] .nav-tabs-strip {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 4px;
  align-self: flex-end;
  margin-bottom: -7px;
  overflow: hidden;
}

.open-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 240px;
  padding: 6px 6px 8px 12px;
  border-radius: 8px 8px 0 0;
  color: var(--stp-nav-text) !important;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.75;
}

.open-tab:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--stp-nav-text) 10%, transparent);
}

/* The open tab is part of the page beneath it. */
.open-tab.current {
  opacity: 1;
  font-weight: 600;
  background: var(--stp-bg);
  color: var(--stp-text) !important;
}

.open-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.open-tab button {
  display: flex;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  opacity: 0.6;
}

.open-tab button:hover {
  opacity: 1;
  background: color-mix(in srgb, currentColor 15%, transparent);
}

.open-tab .icon {
  width: 13px;
  height: 13px;
}

.open-tabs-hint {
  align-self: center;
  padding-bottom: 6px;
  font-size: 13px;
  opacity: 0.6;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the home page */

/* The key numbers: one strip divided by hairlines, so it does not read as more panels. */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-1);
  background: var(--stp-surface);
  overflow: hidden;
}

/* The label reads first though it is written second: small capitals above the figure. */
.stat {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 6px;
  padding: 16px;
  box-shadow: -1px 0 0 var(--stp-border);
}

.stat .stat-value {
  font: 600 30px/34px var(--font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .stat-label {
  font: 600 11.5px/16px var(--font-sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stp-muted);
}

.stat.alert-late .stat-value {
  color: var(--stp-danger);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

/* A panel is lifted off the page by a soft shadow rather than boxed in by a border. */
.panel {
  border-radius: 8px;
  box-shadow: var(--shadow-1);
  background: var(--stp-surface);
  overflow: hidden;
}

/* A panel that is itself the content, rather than a list of rows. */
.panel-pad {
  padding: 16px 18px;
  overflow: visible;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stp-border);
  font: 650 15px/20px var(--font-display);
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--stp-border);
}

.panel-row:hover {
  background: color-mix(in srgb, var(--stp-surface-2) 55%, var(--stp-surface));
}

.panel-row .small,
.panel-row small {
  font-size: 12px;
  line-height: 16px;
}

.panel-row:last-child {
  border-bottom: 0;
}

.panel-row .grow {
  flex: 1;
  min-width: 0;
}

.panel-row .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.panel-empty {
  padding: 18px 16px;
  color: var(--stp-muted);
}

.meter {
  flex: none;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: var(--stp-surface-2);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--stp-accent);
}

/* ---------------------------------------------------------------- choosing a layout */

.layout-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.layout-tile {
  padding: 10px;
  border: 2px solid var(--stp-border);
  border-radius: 10px;
  background: var(--stp-surface);
  color: var(--stp-text);
  text-align: left;
}

.layout-tile.current {
  outline: 3px solid var(--stp-accent);
  outline-offset: 2px;
}

/* A small drawing of the frame: the dark part is the navigation. */
.layout-sketch {
  display: flex;
  height: 84px;
  margin-bottom: 8px;
  border: 1px solid var(--stp-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--stp-bg);
}

.layout-sketch i {
  background: var(--stp-nav-bg);
  border: 0 solid var(--stp-border);
}

.layout-sketch.rail i {
  width: 26%;
  border-right-width: 1px;
}

.layout-sketch.top,
.layout-sketch.tabs {
  flex-direction: column;
}

.layout-sketch.top i,
.layout-sketch.tabs i {
  height: 22%;
  border-bottom-width: 1px;
}

.layout-sketch.tabs i {
  position: relative;
}

.layout-sketch.tabs i::after {
  content: "";
  position: absolute;
  left: 22%;
  bottom: 0;
  width: 24%;
  height: 70%;
  border-radius: 4px 4px 0 0;
  background: var(--stp-bg);
}

.layout-tile small {
  display: block;
  color: var(--stp-muted);
}

/* ---------------------------------------------------------------- lean planning */

/* The dot that says how a commitment or a constraint stands. */
.outcome {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--stp-muted);
}

.outcome.done {
  border-color: var(--stp-accent);
  background: var(--stp-accent);
}

.outcome.missed {
  border-color: var(--g-critical-done);
  background: var(--g-critical-done);
}

/* Percent Plan Complete by week: one thin bar a week, standing on a shared baseline. */
.ppc-chart {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 190px;
  padding: 14px 16px 0;
  border-bottom: 1px solid var(--g-grid);
}

.ppc-col {
  flex: 1;
  max-width: 56px;
  display: grid;
  grid-template-rows: 18px 1fr 22px;
  justify-items: center;
  text-decoration: none;
  color: var(--stp-text) !important;
}

/* The bar's height is a share of the middle row, so 100% is the full height of the plot. */
.ppc-bar {
  align-self: end;
  width: 60%;
  max-width: 22px;
  border-radius: 2px 2px 0 0;
  background: var(--g-master);
}

/* The latest week is the one being read; the rest are its history. */
.ppc-col:last-child .ppc-bar,
.ppc-col:hover .ppc-bar {
  background: var(--stp-accent);
}

.ppc-value {
  font-size: 12px;
  font-weight: 600;
}

.ppc-week {
  align-self: center;
  font-size: 11px;
  color: var(--stp-muted);
  white-space: nowrap;
}

.reason-bar {
  display: block;
  height: 8px;
  min-width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--stp-accent);
}

/* ---------------------------------------------------------------- tabs */

/* The views of one plan, as underlined tabs directly under its title. */
.cp-tabs {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  border-bottom: 1px solid var(--stp-border);
}

.cp-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--stp-muted);
  font: 500 13.5px/20px var(--font-sans);
  text-decoration: none;
}

.cp-tab:hover {
  color: var(--stp-text);
}

.cp-tab[aria-current="page"] {
  color: var(--stp-text);
  border-bottom-color: var(--stp-accent);
}

/* The row of actions under the tabs: making and editing on the left, the view on the right. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
}

.toolbar .spacer {
  flex: 1;
}

.page-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--stp-muted);
}

.tile {
  border-radius: 8px;
}

/* ---------------------------------------------------------------- the home dashboard */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* A stat's foot line says what the number means or what to do about it. */
.stat .stat-foot {
  font-size: 12px;
  line-height: 16px;
  color: var(--stp-muted);
}

/* Wide left column for the week's work, narrow right column for the trend and the person's own list. */
.dash {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (max-width: 1000px) {
  .dash {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* This week on site: a row per task against the seven days, like a slice of the chart. */
.wk-head,
.wk-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  border-bottom: 1px solid var(--stp-border);
}

.wk-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.wk-days span {
  padding: 8px;
  font: 600 11.5px/16px var(--font-sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stp-muted);
}

.wk-days span.today {
  color: var(--stp-text);
}

.wk-name {
  padding: 8px 16px;
  min-width: 0;
}

.wk-name > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The track is ruled into days, with the weekend shaded and a line for today. */
.wk-track {
  position: relative;
  background:
    linear-gradient(90deg, transparent calc(100% / 7 * 5), var(--g-weekend) calc(100% / 7 * 5)),
    repeating-linear-gradient(90deg, transparent 0 calc(100% / 7 - 1px), var(--stp-border) calc(100% / 7 - 1px) calc(100% / 7));
}

.wk-bar {
  position: absolute;
  top: 50%;
  height: 12px;
  margin-top: -6px;
  border-radius: 2px;
  background: var(--g-stp);
  overflow: hidden;
}

.wk-bar > span {
  display: block;
  height: 100%;
  background: var(--g-stp-done);
}

.wk-bar.late {
  background: var(--g-critical);
}

.wk-bar.late > span {
  background: var(--g-critical-done);
}

.wk-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--g-today);
}

/* A status: a dot and a word. */
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--stp-surface-2);
  font: 500 12px/18px var(--font-sans);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stp-muted);
}

.chip.late::before {
  background: var(--stp-danger);
}

/* Nothing here yet: what the space is for, and where it gets filled from. */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--stp-surface-2);
  color: var(--stp-muted);
}

.empty h3 {
  margin: 0;
  font: 650 15px/20px var(--font-display);
}

.empty p {
  margin: 0 0 6px;
  max-width: 36ch;
  color: var(--stp-muted);
}

/* Percent Plan Complete on the home page: fewer weeks, so each can carry its figure. */
.ppc-chart.compact {
  height: 170px;
}

.ppc-chart.compact .ppc-value {
  font: 500 11.5px/16px var(--font-sans);
  color: var(--stp-muted);
  font-variant-numeric: tabular-nums;
}

/* What someone can open in one of their companies: a run of buttons that wraps. */
.company-work {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
