/* The e-reader and the phone, as drawn on the landing page and in the docs.
   Only the devices and what is still on their screens live here: the page, a selection,
   a highlight, a note, a chat. The demo's motion is in landing.css. */

/* E-reader. Sizes inside the screen are in cqw so the page lays out the same at any width. */

.reader {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 4.5% 4.5% 9%;
  border-radius: 1.4rem;
  background: var(--bezel);
  box-shadow: 0 1.2rem 2.5rem -1.2rem rgb(0 0 0 / 0.45);
}
.reader-screen {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--eink);
  color: var(--eink-ink);
}
/* The name on the frame, where a hardware reader has its maker's. */
.reader-brand {
  position: absolute;
  inset: auto 0 0;
  height: 9%;
  display: grid;
  place-items: center;
  color: #8d8d86;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}
/* The plugin's status in the corner of the screen. */
.reader-mcp {
  position: absolute;
  top: 2.4cqw;
  right: 3cqw;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.8cqw;
  padding: 0.6cqw 1.6cqw;
  border-radius: 1cqw;
  font-family: var(--sans);
  font-size: 2.9cqw;
  font-weight: 600;
  line-height: 1.2;
}
.reader-mcp svg {
  width: 4.4cqw;
  height: 3.2cqw;
  fill: currentColor;
}
.reader-page {
  position: relative;
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 3cqw 7cqw 0;
  font-family: var(--serif);
  font-size: 4.4cqw;
  line-height: 1.5;
}
/* The running head: the book's title, as KOReader can show it above the text. */
.reader-head {
  margin-bottom: 4.6cqw;
  font-family: var(--sans);
  font-size: 3.1cqw;
  line-height: 1.2;
}
.reader-text {
  /* A whole number of lines, so the last line is never cut in half. */
  height: 24em;
  overflow: hidden;
  text-align: justify;
  hyphens: auto;
}
.reader-text p {
  margin: 0;
}
.reader-text p + p {
  text-indent: 1.3em;
}
.reader-status {
  margin-top: auto;
  padding-block: 1.6cqw 2cqw;
  font-family: var(--sans);
  font-size: 3.1cqw;
  text-align: center;
}
.reader-status::before {
  content: "";
  display: block;
  height: 0.5cqw;
  margin-bottom: 1.2cqw;
  background: linear-gradient(to right, var(--eink-ink) var(--progress, 1%), #b9b9b1 0);
}

.reader[data-page="6"] .reader-page[data-p="6"],
.reader[data-page="8"] .reader-page[data-p="8"] {
  display: flex;
}
/* The passage: a selection is grey, a saved highlight is dithered. */
.reader .passage {
  background: linear-gradient(rgb(28 28 28 / 0.3), rgb(28 28 28 / 0.3)) no-repeat 0 0 / 0% 100%;
  color: inherit;
}
.reader[data-mark="select"] .passage {
  background-size: 100% 100%;
}
.reader[data-mark="highlight"] .passage,
.reader[data-mark="note"] .passage {
  background: conic-gradient(rgb(28 28 28 / 0.5) 25%, transparent 0) 0 0 / 0.9cqw 0.9cqw;
}
.reader[data-mark="highlight"] .passage::after,
.reader[data-mark="note"] .passage::after {
  /* KOReader marks a highlight that has a note in the margin. */
  content: "✎";
  position: absolute;
  right: 1.6cqw;
  font-size: 1.15em;
  line-height: 1.3;
}
/* The note that opens when a highlight is tapped. */
.reader-note {
  position: absolute;
  inset: auto 7cqw 3.5cqw;
  visibility: hidden;
  border: 0.6cqw solid var(--eink-ink);
  border-radius: 1.6cqw;
  background: var(--eink);
  font-family: var(--serif);
  font-size: 4.2cqw;
  line-height: 1.4;
}
.reader-note b {
  display: block;
  padding: 1.6cqw 3cqw;
  border-bottom: 0.4cqw solid var(--eink-ink);
  font-family: var(--sans);
  font-size: 3.3cqw;
}
.reader-note p {
  margin: 0;
  padding: 2.6cqw 3cqw 3.2cqw;
}
.reader[data-mark="note"] .reader-note {
  visibility: visible;
}

/* Phone. The colours are a generic chat app's, light or dark with the page. */

.phone {
  --chat-bg: #ffffff;
  --chat-ink: #1c1c1c;
  --chat-soft: #6b6b73;
  --chat-bubble: #f0f0f3;
  --chat-accent: #2a3fe0;
  display: flex;
  flex-direction: column;
  border: 0.5rem solid var(--bezel);
  border-radius: 2.3rem;
  background: var(--chat-bg);
  color: var(--chat-ink);
  font-size: 0.86rem;
  line-height: 1.42;
  overflow: hidden;
  box-shadow: 0 1.2rem 2.5rem -1.2rem rgb(0 0 0 / 0.45);
}
@media (prefers-color-scheme: dark) {
  .phone {
    --chat-bg: #1d1d22;
    --chat-ink: #ececf1;
    --chat-soft: #a2a2ad;
    --chat-bubble: #2b2b33;
    --chat-accent: #5364f5;
  }
}
.phone-status {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 1.1rem 0;
  font-size: 0.72rem;
  font-weight: 600;
}
.phone-status span {
  margin-right: auto;
}
.phone-status svg {
  height: 0.7rem;
  fill: currentColor;
}

/* The assistant's face: an orange dot with two white eyes. Each expression is a small
   drawing. An answer can carry data-mood="joke|wink" for the face beside it; on the
   landing page demo.js also changes the face in the header. */
.phone {
  --face-idle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cellipse cx='14' cy='20' rx='3.5' ry='6' fill='white'/%3E%3Cellipse cx='26' cy='20' rx='3.5' ry='6' fill='white'/%3E%3C/svg%3E");
  --face-look: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cellipse cx='10.5' cy='20.5' rx='3.5' ry='6' fill='white'/%3E%3Cellipse cx='22.5' cy='20.5' rx='3.5' ry='6' fill='white'/%3E%3C/svg%3E");
  --face-think: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cellipse cx='16.5' cy='15.5' rx='3.5' ry='5' fill='white'/%3E%3Cellipse cx='28.5' cy='15.5' rx='3.5' ry='5' fill='white'/%3E%3C/svg%3E");
  --face-joke: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M8.5 23 L12.5 17 L16.5 23 M23.5 23 L27.5 17 L31.5 23' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --face-wink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cellipse cx='14' cy='20' rx='3.5' ry='6' fill='white'/%3E%3Cpath d='M21.5 21.5 Q26 16 30.5 21.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --face-blink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M10.5 20.5 H17.5 M22.5 20.5 H29.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --face: var(--face-idle);
}
.chat .ai[data-mood="joke"]:not(.is-typing) {
  --face: var(--face-joke);
}
.chat .ai[data-mood="wink"]:not(.is-typing) {
  --face: var(--face-wink);
}
.buddy,
.chat .ai::before {
  border-radius: 50%;
  background: #d97757 var(--face) center / 100% no-repeat;
}
.buddy {
  align-self: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.45rem;
}
.phone-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.1rem;
  padding: 0.6rem 1rem 0.7rem;
  border-bottom: 1px solid var(--chat-bubble);
  font-weight: 600;
}
.phone-bar small {
  margin-left: auto;
  color: var(--chat-soft);
  font-size: 0.78rem;
  font-weight: 400;
}
.phone-bar small::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: #2f9e60;
}
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
  padding: 1.2rem 0.8rem 0.7rem;
  overflow: hidden;
  /* Older messages fade out at the top as the conversation grows. */
  -webkit-mask-image: linear-gradient(transparent, #000 1.2rem);
  mask-image: linear-gradient(transparent, #000 1.2rem);
}
.chat ol {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chat li {
  max-width: 94%;
  margin: 0;
}
.chat .cue,
.chat li.is-waiting {
  display: none;
}
.chat .you {
  align-self: flex-end;
  padding: 0.5rem 0.8rem;
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
  background: var(--chat-accent);
  color: #fff;
}
.chat .ai {
  position: relative;
  margin-left: 1.75rem;
  padding: 0.55rem 0.8rem;
  border-radius: 1.1rem 1.1rem 1.1rem 0.3rem;
  background: var(--chat-bubble);
}
.chat .ai::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  bottom: 0;
  width: 1.4rem;
  height: 1.4rem;
}
.chat .tool {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--chat-soft);
  font-size: 0.8rem;
}
.chat .tool::before {
  /* A circled check, drawn as a mask so it takes the text colour. */
  content: "";
  flex: none;
  width: 1.15em;
  height: 1.15em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8.6' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M6.2 10.4 L8.9 13 L13.8 7.6' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8.6' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M6.2 10.4 L8.9 13 L13.8 7.6' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.phone-input {
  margin: 0 0.8rem 0.9rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--chat-bubble);
  border-radius: 1.3rem;
}
.phone-input span:empty::before {
  content: attr(data-placeholder);
  color: var(--chat-soft);
}

/* Pictures in the docs. The devices come from _includes/reader.html and phone.html. */

/* In the docs the frame is sized on its own, not from the stage around it. */
.screens .reader,
.pair .reader {
  padding: 1rem 1rem 2rem;
}
.screens .reader-brand,
.pair .reader-brand {
  height: 2rem;
}
.screens .phone,
.pair .phone {
  border-width: 0.4rem;
  border-radius: 1.8rem;
}

/* The reader and the phone side by side: what you ask, and what it does on the reader. */
.pair {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin: 1.8rem 0 2rem;
}
.pair .reader {
  flex: 0 1 17rem;
}
.pair .phone {
  flex: 0 0 14rem;
  min-height: 20rem;
  font-size: 0.78rem;
}
@media (max-width: 36rem) {
  .pair {
    flex-direction: column;
  }
  .pair .reader {
    flex: none;
    width: min(100%, 17rem);
  }
  .pair .phone {
    flex: none;
    width: 14rem;
    min-height: 0;
  }
}

/* A short row of screens, each with a numbered caption under it (setup-screens.html). */

.screens {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.2rem 1.5rem;
  margin: 1.6rem 0 1.2rem;
  padding: 0;
  list-style: none;
  counter-reset: screen;
}
.screens li {
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  margin: 0;
  counter-increment: screen;
}
.screens .reader {
  width: min(100%, 17rem);
}
.screens .phone {
  width: min(82%, 13.5rem);
  aspect-ratio: 5 / 8;
}
.screens li > p {
  justify-self: stretch;
  margin: 1rem 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}
.screens li > p::before {
  content: counter(screen) ". ";
  font-weight: 600;
}
@media (max-width: 34rem) {
  .screens {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A KOReader dialog over the page. */
.reader-dialog {
  position: absolute;
  inset: 50% 5cqw auto;
  transform: translateY(-50%);
  border: 0.6cqw solid var(--eink-ink);
  border-radius: 1.6cqw;
  background: var(--eink);
  font-family: var(--sans);
  font-size: 4.5cqw;
  line-height: 1.35;
  text-align: center;
}
.reader-dialog > b {
  display: block;
  padding: 2.4cqw 3cqw;
  border-bottom: 0.4cqw solid var(--eink-ink);
}
.reader-dialog p {
  margin: 3cqw 5cqw;
}
.reader-dialog small {
  font-size: 3.8cqw;
}
.reader-dialog .reader-code {
  margin-block: 1cqw;
  font-size: 14cqw;
  font-weight: 700;
  line-height: 1.15;
}
/* A message with nothing to choose: KOReader shows these with an "i" beside the text. */
.reader-dialog.is-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3cqw 4cqw;
  padding: 5cqw;
  text-align: left;
}
.reader-dialog.is-info::before {
  content: "i";
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 8cqw;
  height: 8cqw;
  border: 0.7cqw solid;
  border-radius: 50%;
  font-family: var(--serif);
  font-weight: 700;
}
.reader-dialog.is-info p {
  margin: 0;
}
.reader-buttons {
  display: flex;
  border-top: 0.4cqw solid var(--eink-ink);
  font-weight: 600;
}
.reader-buttons span {
  flex: 1;
  padding: 2.4cqw;
}
.reader-buttons span + span {
  border-left: 0.4cqw solid var(--eink-ink);
}

/* One screen of an app on the phone: a title, a few fields and a button. */
.phone-app {
  container-type: inline-size;
  flex: 1;
  padding-top: 1rem;
}
.screens .phone-app > * {
  display: block;
  margin: 0 7cqw 4.5cqw;
}
.screens .phone-app .phone-url {
  margin: 0 5cqw 8cqw;
  padding: 2cqw 4cqw;
  border-radius: 5cqw;
  background: var(--chat-bubble);
  color: var(--chat-soft);
  font-size: 5cqw;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-app b {
  font-size: 8cqw;
  line-height: 1.2;
}
.phone-app p,
.phone-app label {
  color: var(--chat-soft);
  font-size: 5.6cqw;
  line-height: 1.4;
}
.phone-field {
  display: block;
  margin-top: 1.6cqw;
  padding: 3cqw 3.6cqw;
  border: 1px solid var(--chat-soft);
  border-radius: 3cqw;
  color: var(--chat-ink);
  font-size: 5.6cqw;
  line-height: 1.35;
}
.phone-field.is-address {
  font-size: 4.8cqw;
}
.phone-field.is-code {
  font-size: 11cqw;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
}
.screens .phone-app .phone-button {
  margin-top: 7cqw;
  padding: 3.4cqw;
  border-radius: 3cqw;
  background: var(--chat-accent);
  color: #fff;
  font-size: 6cqw;
  font-weight: 600;
  text-align: center;
}
