/*
  Gener8 style kit — stories (js/story-player.js, js/story-maker.js, js/stories.js).

  .story        the Stories panel: list of stories, then a story a page at a time.
                Floating (float.css): docked to the left of the Tools panel on the reach
                line. Viewers with a wider Tools panel move it in their own CSS.
  .storymaker   the staff story maker: set the model up, Add page, and so on.
                Floating too; docked in the bottom band, centred.
*/

/* ---- Stories panel -------------------------------------------------------------------- */
.story {
  position: absolute; z-index: 6; top: var(--reach); transform: translateY(-50%);
  right: calc(var(--u) * 28); width: calc(var(--u) * 42);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.4) calc(var(--u) * 1.4);
  border-radius: var(--r-lg); display: flex; flex-direction: column; gap: calc(var(--u) * .8);
}
.story-list { display: flex; flex-direction: column; gap: calc(var(--u) * .6); }
.story-item {
  display: flex; flex-direction: column; gap: calc(var(--u) * .25); text-align: left;
  padding: calc(var(--u) * 1) calc(var(--u) * 1.2); border-radius: var(--r); background: var(--well);
}
.story-item:active { background: var(--press); }
.story-item b { font-family: var(--font-display); font-size: calc(var(--tu) * 1.7); font-weight: 700; color: var(--ink); }
.story-item span { font-size: calc(var(--tu) * 1.25); color: var(--muted); line-height: 1.35; }
.story-item i { font-style: normal; font-size: calc(var(--tu) * 1.2); color: var(--faint); }
.story-run { display: flex; flex-direction: column; gap: calc(var(--u) * .8); }
.story-top { display: flex; justify-content: space-between; align-items: baseline; }
.story-top .kicker { padding: 0; }
.story-count { font-family: var(--font-mono); font-size: calc(var(--tu) * 1.2); color: var(--muted); }
.story-dots { display: flex; flex-wrap: wrap; gap: calc(var(--u) * .5); }
.story-dots button {
  width: calc(var(--u) * 3.2); height: calc(var(--u) * 3.2); border-radius: 50%; position: relative;
}
.story-dots button::after {
  content: ''; position: absolute; inset: calc(var(--u) * 1); border-radius: 50%; background: var(--line);
}
.story-dots button[aria-pressed="true"]::after { background: var(--accent); inset: calc(var(--u) * .8); }
/* Chapters (story-player.js): tap Chapters and a box opens beside the panel (on its left,
   level with its top) with every page as a tile, two to a row (number and title, the one
   showing marked); tap a tile to go to it. The page's details stay in the panel. */
.story-chapters { display: flex; flex-direction: column; gap: calc(var(--u) * .8); }
.story-chapters ol {
  list-style: none; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * .6); align-content: start;
  position: absolute; top: 0; right: calc(100% + var(--u) * 1); width: calc(var(--u) * 42); box-sizing: border-box;
  max-height: calc(100vh - var(--u) * 4); overflow-y: auto; scrollbar-width: none;
  padding: calc(var(--u) * 1.2); border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--panel-line); box-shadow: var(--panel-shadow);
}
.story-chapters ol::-webkit-scrollbar { display: none; }
.story-chapters ol[hidden] { display: none; }
.story-chapters button[data-k] {
  width: 100%; height: 100%; min-height: calc(var(--u) * 7); display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  gap: calc(var(--u) * .4); text-align: left; padding: calc(var(--u) * .8) calc(var(--u) * 1);
  border-radius: var(--r); background: var(--well); color: var(--ink); font-size: calc(var(--tu) * 1.35); line-height: 1.25;
}
.story-chapters button[data-k]:active { background: var(--press); }
.story-chapters .n { display: inline-grid; place-items: center; width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8);
  border-radius: 50%; background: var(--line); font-size: calc(var(--tu) * 1.15); font-weight: 700; }
.story-chapters button[aria-current="step"] { background: var(--accent-soft); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
.story-chapters button[aria-current="step"] .n { background: var(--accent); color: var(--accent-ink); }
#sChaptersBtn { min-height: calc(var(--u) * 5.4); font-size: calc(var(--tu) * 1.5); justify-content: center; }
.story-run .title { margin: 0; font-size: calc(var(--tu) * 2.3); }
/* Page tools (story-player.js #sTools): controls the page showing needs, e.g. Pull apart */
.story-tools { display: flex; flex-direction: column; gap: calc(var(--u) * .6); }
.story-tools:not(:has(> :not([hidden]))) { display: none; }   /* nothing showing: no room */
.story-text { margin: 0; font-size: calc(var(--tu) * 1.5); line-height: 1.5; color: var(--ink); }
.story-run .pair .btn { min-height: calc(var(--u) * 6); font-size: calc(var(--tu) * 1.6); }
#sBack:disabled { opacity: .4; }
.story-empty { margin: 0; color: var(--muted); font-size: calc(var(--tu) * 1.3); }

/* ---- Story maker (staff) ----------------------------------------------------------------
   Big touch targets: it is used standing at the wall as often as at a desk. */
.storymaker {
  position: absolute; z-index: 7; left: 50%; bottom: calc(var(--u) * 2); transform: translateX(-50%);
  width: min(94vw, calc(var(--u) * 100)); max-height: 60vh; overflow: auto;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.4) calc(var(--u) * 1.4);
  border-radius: var(--r-lg); display: flex; flex-direction: column; gap: calc(var(--u) * 1);
}
.storymaker .fhead { padding-bottom: 0; }
.storymaker .sm-status { font-size: calc(var(--tu) * 1.2); color: var(--muted); }
.storymaker .sm-status.err { color: var(--danger); }
.storymaker input[type=text], .storymaker textarea {
  font: inherit; font-size: calc(var(--tu) * 1.45); color: var(--ink); width: 100%; box-sizing: border-box;
  background: var(--well); border: 1px solid var(--line); border-radius: var(--r);
  padding: calc(var(--u) * .9) calc(var(--u) * 1.1);
  user-select: text; -webkit-user-select: text;
}
.storymaker textarea { min-height: calc(var(--u) * 7.5); resize: vertical; line-height: 1.4; }
.storymaker label { display: flex; flex-direction: column; gap: calc(var(--u) * .35); font-size: calc(var(--tu) * 1.2); font-weight: 400; color: var(--muted); }
.storymaker label.check { flex-direction: row; align-items: center; gap: calc(var(--u) * .7); color: var(--ink); font-size: calc(var(--tu) * 1.3); font-weight: 400; white-space: nowrap; }
.storymaker label.check input { width: calc(var(--u) * 2.4); height: calc(var(--u) * 2.4); accent-color: var(--accent); }
.storymaker .btn { width: auto; min-height: calc(var(--u) * 5.2); justify-content: center; }
.storymaker .btn:disabled { opacity: .4; }
.storymaker .btn.danger { color: var(--danger); }
.sm-story { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: calc(var(--u) * 1); align-items: end; }

/* The pages as a strip of pictures; tap one to go to it */
.sm-strip { display: flex; gap: calc(var(--u) * .8); overflow-x: auto; padding-bottom: calc(var(--u) * .3); }
.sm-page {
  flex: none; width: calc(var(--u) * 15); display: flex; flex-direction: column; gap: calc(var(--u) * .3);
  padding: calc(var(--u) * .5); border-radius: var(--r); background: var(--well); border: 2px solid transparent; text-align: left;
}
.sm-page[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.sm-page img, .sm-page .sm-noimg { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: calc(var(--r) * .6); background: var(--press); display: block; }
.sm-page b { font-size: calc(var(--tu) * 1.2); font-weight: 400; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-page i { font-style: normal; font-family: var(--font-mono); font-size: calc(var(--tu) * 1.2); color: var(--faint); }
.sm-add {
  flex: none; width: calc(var(--u) * 15); min-height: calc(var(--u) * 13); border-radius: var(--r);
  border: 2px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * .4);
  font-size: calc(var(--tu) * 1.35); font-weight: 400; color: var(--ink);
}
.sm-add small { font-size: calc(var(--tu) * 1.2); color: var(--muted); font-weight: 400; text-align: center; padding: 0 calc(var(--u) * .6); }

/* The chosen page: its words and what can be done to it */
.sm-edit { display: grid; grid-template-columns: 1fr auto; gap: calc(var(--u) * 1); align-items: start; }
.sm-edit .sm-fields { display: flex; flex-direction: column; gap: calc(var(--u) * .7); }
.sm-edit .sm-acts { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * .6); width: calc(var(--u) * 26); }
.sm-edit .sm-acts .wide { grid-column: 1 / -1; }
.sm-hint { margin: 0; font-size: calc(var(--tu) * 1.2); color: var(--muted); line-height: 1.4; }
.sm-foot { display: flex; flex-wrap: wrap; gap: calc(var(--u) * .8); align-items: center; }
.sm-foot .spacer { flex: 1; }

/* While making a story the saved view note and tour bar keep out of the way */
.making-story .vnote, .making-story .tourbar { display: none !important; }
