/* Components: buttons, the brand, the theme button, the dialog shell, form fields, switches, dropdown menus, a moment's state, generation errors, the guide's three steps and the rows of books */

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.button:hover:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(-2px);
}

.button:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(0);
}

.button-primary {
  color: #fff;
  background: var(--violet-fill);
  box-shadow: 0 8px 18px rgba(102, 87, 199, 0.24);
}

.button-primary:hover:not(:disabled) {
  background: var(--violet-fill-hover);
  box-shadow: 0 11px 24px rgba(79, 65, 161, 0.29);
}

.button-secondary {
  color: var(--violet-dark);
  border-color: var(--violet-line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--violet);
  background: var(--violet-pale);
}

.button-quiet {
  color: var(--ink-soft);
  background: transparent;
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(102, 87, 199, 0.08);
}

.button-large {
  min-height: 54px;
  padding: 14px 22px;
  border-radius: 15px;
  font-size: 1.03rem;
}

.button-small {
  min-height: 44px;
  padding: 8px 13px;
  border-radius: 11px;
  font-size: 0.9rem;
}

.button-full {
  width: 100%;
}

.eyebrow,
.dialog-kicker {
  margin-bottom: 8px;
  color: var(--violet-dark);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 900;
  letter-spacing: -0.035em;
  text-decoration: none;
}

/* Signed in, the brand is a link to My books. */
.brand[href] {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 13px 13px 13px 5px;
  background: var(--violet-fill);
  box-shadow: 0 5px 14px rgba(102, 87, 199, 0.25);
  transform: rotate(-3deg);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  content: "";
}

.brand-mark::before {
  top: 10px;
  left: 8px;
  width: 21px;
  height: 17px;
  border: 2px solid #fff;
  border-top: 0;
  border-radius: 2px 2px 7px 7px;
  transform: skewY(-7deg);
}

.brand-mark::after {
  top: 5px;
  right: 5px;
  width: 9px;
  height: 9px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 37%);
}

/* In the top bars and on the sign-in screens: a moon in light, a sun in
   dark (js/theme.js). */
.theme-toggle {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--control-line);
  border-radius: 50%;
  color: var(--violet-dark);
  background: var(--surface);
}

.theme-toggle:hover {
  border-color: var(--violet);
  background: var(--violet-pale);
}

.theme-toggle > span {
  display: contents;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-moon,
.theme-toggle[aria-pressed="false"] .theme-toggle-sun {
  display: none;
}

.auth-error-summary,
.account-inline-error,
.logout-warning {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--error-line);
  border-radius: 14px;
  color: var(--error-deep);
  background: var(--error-pale);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.45;
}

.auth-error-summary::before,
.account-inline-error > span,
.logout-warning > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--error);
  content: "!";
  font-size: 0.76rem;
  font-weight: 900;
}

.auth-error-summary:focus,
.account-inline-error:focus,
.logout-warning:focus {
  outline: 3px solid var(--error-focus);
  outline-offset: 2px;
}

.story-dialog {
  width: min(calc(100% - 32px), 700px);
  max-height: min(90vh, 850px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 26px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}

.story-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);
}

.story-dialog > form,
.recipe-dialog > .dialog-heading,
.recipe-dialog > form,
.guide-dialog > .dialog-heading,
.guide-dialog > .guide-steps,
.guide-dialog > .story-loop,
.guide-dialog > .dialog-actions {
  position: relative;
  z-index: 2;
}

.dialog-glow {
  position: absolute;
  top: -90px;
  right: -70px;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--dialog-glow), transparent 68%);
  pointer-events: none;
}

.dialog-heading {
  margin-bottom: 26px;
}

.dialog-heading h2 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  line-height: 1.05;
}

.dialog-heading p {
  margin-bottom: 0;
  color: var(--ink-soft);
}

.dialog-heading-centered {
  text-align: center;
}

.mini-spark {
  color: var(--gold);
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field-label {
  display: block;
  font-weight: 900;
}

.field-label > span,
.field-label > small {
  display: block;
}

.field-label > small {
  margin: 2px 0 7px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.field-label input,
.field-label textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--field-line);
  border-radius: 13px;
  background: var(--field);
  font-weight: 500;
}

.field-label input::placeholder,
.field-label textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.field-label input {
  min-height: 52px;
  padding: 12px 14px;
}

.field-label textarea {
  min-height: 105px;
  padding: 13px 14px;
  line-height: 1.5;
  resize: vertical;
}

.field-label input:focus,
.field-label textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--focus-glow);
  outline: 0;
}

/* A visually hidden checkbox drawn as a switch, its track and thumb, in a
   label of its own layout: the publication's "Readers can translate it"
   (css/publishing.css) and the reader's Show moments (css/reading.css). */
.publication-translation-switch input,
.reading-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.publication-switch-track,
.reading-switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid var(--book-muted);
  border-radius: 999px;
  background: var(--book-line);
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.publication-switch-track::after,
.reading-switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 150ms ease;
}

.publication-translation-switch input:checked ~ .publication-switch-track,
.reading-switch input:checked ~ .reading-switch-track {
  border-color: var(--violet-fill);
  background: var(--violet-fill);
}

.publication-translation-switch input:checked ~ .publication-switch-track::after,
.reading-switch input:checked ~ .reading-switch-track::after {
  transform: translateX(18px);
}

.publication-translation-switch input:focus-visible ~ .publication-switch-track,
.reading-switch input:focus-visible ~ .reading-switch-track {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.publication-translation-switch input:disabled ~ .publication-switch-track,
.reading-switch input:disabled ~ .reading-switch-track {
  opacity: 0.6;
}

/* A dropdown menu under its button, or over it with is-up: a moment's ⋯
   (css/moments.css) and a moment's mark in the reader (css/reading.css). */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 6;
  display: grid;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--card-line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}

.dropdown-menu.is-up {
  top: auto;
  bottom: calc(100% + 4px);
}

.dropdown-menu-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: none;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: left;
}

.dropdown-menu-item .book-icon {
  width: 19px;
  height: 19px;
  color: var(--violet-dark);
}

.dropdown-menu-item:hover:not([aria-disabled="true"]) {
  background: var(--violet-faint);
}

.dropdown-menu-item[aria-disabled="true"] {
  opacity: 0.5;
}

.dropdown-menu-item:focus-visible {
  background: var(--violet-pale);
  outline: 2px solid var(--violet);
  outline-offset: -2px;
}

.dropdown-menu-item.is-delete,
.dropdown-menu-item.is-delete .book-icon {
  color: var(--delete-ink);
}

.dropdown-menu-item.is-delete:hover {
  background: var(--delete-tile);
}

.dropdown-menu-divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--line-soft);
}

/* A moment's state in its chapter's moment plan: calm when written, quiet
   when new, amber when it changed or may no longer fit. On its card
   (css/moments.css) and in its mark's menu in the reader
   (css/reading.css). */
.moment-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.3;
}

.moment-state[data-moment-state="written"] {
  color: var(--book-status-fresh-ink);
  background: var(--green-pale);
}

.moment-state[data-moment-state="new"] {
  border-color: var(--moment-tool-line);
  color: var(--ink-soft);
}

.moment-state[data-moment-state="changed"],
.moment-state[data-moment-state="doubt"] {
  border-color: var(--status-outdated-line);
  color: var(--book-status-outdated-ink);
  background: var(--gold-pale);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 27px;
}

.dialog-actions-end {
  justify-content: flex-end;
}

.dialog-actions-centered {
  justify-content: center;
}

.generation-error {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 13px 14px;
  margin: 13px 0;
  border: 1px solid var(--error-line);
  border-radius: 14px;
  color: var(--error-deep);
  background: var(--error-pale);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.45;
}

.generation-error:focus {
  outline: 3px solid var(--error-focus);
  outline-offset: 2px;
}

.generation-error > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--error);
  font-size: 0.76rem;
  font-weight: 900;
}

.generation-error p {
  margin: 1px 0 0;
}

/* The three steps of How Qiyal works: on the sign-in screen and in the guide
   dialog. */
.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: guide;
}

.guide-steps li {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 15px;
  border-radius: 17px;
  background: var(--guide-step-violet);
}

.guide-steps li:nth-child(2) {
  background: var(--guide-step-blue);
}

.guide-steps li:nth-child(3) {
  background: var(--guide-step-peach);
}

.guide-steps li:not(:last-child)::after {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: -12px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--violet);
  background: var(--surface);
  content: "›";
  font-weight: 900;
  transform: translateY(-50%);
}

.guide-number {
  display: none;
}

.guide-step-icon {
  position: relative;
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(52, 43, 105, 0.08);
}

.guide-step-icon::before,
.guide-step-icon::after {
  position: absolute;
  content: "";
}

.guide-map-icon::before {
  inset: 10px 9px;
  border: 2px solid var(--violet);
  border-radius: 3px;
  transform: skewY(-7deg);
}

.guide-map-icon::after {
  top: 9px;
  bottom: 9px;
  left: 20px;
  border-left: 2px dashed #b4aae4;
}

.guide-pages-icon::before {
  top: 10px;
  left: 9px;
  width: 24px;
  height: 21px;
  border: 2px solid var(--blue);
  border-top: 0;
  border-radius: 3px 3px 7px 7px;
}

.guide-pages-icon::after {
  top: 11px;
  left: 20px;
  height: 19px;
  border-left: 2px solid #9cc7eb;
}

.guide-tweak-icon::before {
  top: 9px;
  left: 19px;
  width: 5px;
  height: 24px;
  border-radius: 8px;
  background: var(--coral);
  transform: rotate(42deg);
}

.guide-tweak-icon::after {
  top: 7px;
  right: 7px;
  width: 10px;
  height: 10px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

.guide-steps strong,
.guide-steps small {
  display: block;
}

.guide-steps strong {
  margin-bottom: 3px;
  font-size: 0.94rem;
}

.guide-steps small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

.guide-steps-dialog {
  grid-template-columns: 1fr;
  gap: 9px;
}

.guide-steps-dialog li {
  grid-template-columns: 30px 42px minmax(0, 1fr);
  min-height: 76px;
}

.guide-steps-dialog li:not(:last-child)::after {
  display: none;
}

.guide-steps-dialog .guide-number {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--guide-number);
  font-size: 0.75rem;
  font-weight: 900;
}

.guide-steps-dialog strong {
  font-size: 1rem;
}

.guide-steps-dialog small {
  font-size: 0.82rem;
}

/* The list of books, a row each: My books and Explore books. The title's
   button covers its row, and a tool in the row (.book-row-tool) sits above
   it. */
.book-list {
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--card-line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  list-style: none;
}

.book-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
}

.book-row + .book-row {
  border-top: 1px solid var(--line-soft);
}

.book-row:hover {
  background: var(--violet-faint);
}

.book-cover {
  display: grid;
  width: 52px;
  height: 68px;
  place-items: center;
  border-radius: 5px 10px 10px 5px;
  color: #fff;
  background: linear-gradient(145deg, hsl(var(--cover-hue) 55% 45%), hsl(calc(var(--cover-hue) + 30) 52% 27%));
  box-shadow:
    inset 4px 0 0 rgba(0, 0, 0, 0.14),
    0 4px 10px rgba(52, 43, 105, 0.16);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
}

.cover-moon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffe4a2;
  box-shadow:
    0 0 0 5px rgba(255, 229, 163, 0.12),
    0 0 14px rgba(255, 226, 147, 0.3);
}

.book-row-text {
  min-width: 0;
}

.book-row-text h2 {
  margin: 0 0 2px;
  font-size: 1.12rem;
  line-height: 1.25;
}

.book-row-open {
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* The title's button covers the row, so a tap anywhere on it opens the book. */
.book-row-open::after {
  position: absolute;
  inset: 0;
  content: "";
}

.book-row-open:focus-visible {
  outline: none;
}

.book-row-open:focus-visible::after {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  align-items: center;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

/* The last column in every row, whatever tools the row has. */
.book-row-chevron {
  grid-column: 4;
  color: var(--ink-soft);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

/* A control in a row, above the title's button that covers the row. */
.book-row-tool {
  position: relative;
  z-index: 1;
}

.empty-state {
  padding: 80px 30px;
  text-align: center;
}

@media (max-width: 780px) {
  .book-row {
    gap: 12px;
    padding: 12px 14px;
  }

  .guide-steps {
    grid-template-columns: 1fr;
  }

  .guide-steps li:not(:last-child)::after {
    top: auto;
    right: 50%;
    bottom: -13px;
    transform: translateX(50%) rotate(90deg);
  }
}

@media (max-width: 560px) {
  .book-row-text h2 {
    margin-bottom: 5px;
  }
}

@media (max-width: 500px) {
  .book-cover {
    width: 44px;
    height: 58px;
    font-size: 1.25rem;
  }

  .brand {
    font-size: 1.08rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .read-header-label {
    display: none;
  }
}
