/* Sign-up start and rate (SPEC-PRE-SPRINT §I) and the rating nudge (§E): one stylesheet for stoareads.app and
   stoareads.com. Every colour, font and radius is an --ob-* custom property each site maps to its own tokens. */

.ob-page {
  max-width: var(--ob-col, 40rem);
  margin: 0 auto;
  padding-top: 1rem;
  padding-bottom: calc(var(--ob-bar-h, 4.5rem) + env(safe-area-inset-bottom, 0px));
}

.ob-step {
  margin: 0 0 0.5rem;
  font: 400 0.875rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

.ob-h1 {
  margin: 0 0 0.5rem;
  font: 500 1.75rem / 2.125rem var(--ob-display);
  color: var(--ob-ink);
}

.ob-h1:focus {
  outline: none;
}

.ob-line {
  margin: 0 0 1.5rem;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

.ob-status {
  color: var(--ob-ink);
}

.ob-status.ob-error,
.ob-value .ob-error {
  color: var(--ob-error);
}

/* The subject list: two columns of hairline rows, each a toggle. Selected is the tick, weight 600 and a wash;
   nothing is boxed and nothing moves. */
.ob-subjects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

button.ob-subject {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.375rem;
  width: 100%;
  min-height: 3.5rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-ink);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ob-rule);
  border-radius: 0;
  box-shadow: none;
  transform: none;
  cursor: pointer;
}

/* A rule above the first row of both columns, as on Discover (§2.2). */
/* Each cell fills its grid row, so the two columns' hairlines line up when one label wraps (Vera, app PR 238). */
.ob-subjects > li {
  display: flex;
}

.ob-subjects > li:nth-child(-n + 2) > button.ob-subject {
  border-top: 1px solid var(--ob-rule);
}

@media (hover: hover) {
  button.ob-subject:hover {
    color: var(--ob-ink);
    background: var(--ob-hover);
    border-color: var(--ob-rule);
  }
}

button.ob-subject:focus-visible {
  outline: 2px solid var(--ob-link);
  outline-offset: -2px;
}

button.ob-subject[aria-pressed='true'] {
  font-weight: 600;
  background: var(--ob-hover);
}

.ob-tick {
  width: 1em;
  flex: none;
  visibility: hidden;
}

button.ob-subject[aria-pressed='true'] .ob-tick {
  visibility: visible;
}

/* The sticky bar at the bottom: the main button and Skip. */
.ob-bar {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 1.5rem;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--ob-bg);
  border-top: 1px solid var(--ob-rule);
}

.ob-bar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

button.ob-main {
  min-height: 2.75rem;
  padding: 0 1.5rem;
  font: 600 0.9375rem / 1 var(--ob-font);
  color: var(--ob-on-accent);
  background: var(--ob-accent);
  border: 0;
  border-radius: var(--ob-radius);
  cursor: pointer;
}

button.ob-text {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin: 0;
  padding: 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-ink);
  background: none;
  border: 0;
  box-shadow: none;
  transform: none;
  cursor: pointer;
}

@media (hover: hover) {
  button.ob-text:hover {
    color: var(--ob-ink);
    background: none;
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* The strip. */
/* The count's box is as wide as "300 rated", so it never grows into the heading when the ratings arrive. From 400 the
   heading and the count share a line; below it the count always has its own line, so nothing re-lays, and the app's
   wider heading face never wraps beside it (Juno and Vera, PR 397 and app Home at 360). */
.ob-strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.ob-h2 {
  margin: 0 0 0.25rem;
  font: 500 1.375rem / 1.75rem var(--ob-display);
  color: var(--ob-ink);
}

/* On home the heading opens Your taste (M3): a 44 px target, grown with padding the line doesn't feel (Vera, PR 390). */
.ob-h2 a {
  display: inline-block;
  padding: 0.5rem 0;
  margin: -0.5rem 0;
  color: inherit;
}

/* Home (R3-41): the heading is a rail's (the page's h2.sh and .sec-h set its size and the Start link); the count shares
   the line under it, at the right. */
.ob-strip-head.sec-h > .ob-h2 {
  margin: 0;
}

.ob-start {
  font: 600 0.9375rem / 1.375rem var(--ob-font);
  color: var(--ob-link, var(--ob-ink));
  text-underline-offset: 3px;
  padding: 0.6875rem 0;
  white-space: nowrap;
}

.ob-sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.ob-sub > .ob-line {
  min-width: 0;
}

.ob-progress {
  font: 400 0.875rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
  white-space: nowrap;
  flex: none;
  min-width: 4.625em;
  text-align: right;
}

@media (max-width: 399px) {
  .ob-strip-head {
    flex-direction: column;
    gap: 0;
  }

  .ob-strip-head > .ob-h2 {
    margin-bottom: 0;
  }

  .ob-progress {
    min-width: 0;
    text-align: left;
    margin-bottom: 0.25rem;
  }

  /* A rail's head keeps its link on the right at every width (R3-41). */
  .ob-strip-head.sec-h {
    flex-direction: row;
    gap: 0.75rem;
  }

  .ob-sub > .ob-progress {
    text-align: right;
    margin-bottom: 0;
  }
}

/* 10 px under the last row, where its "Haven't read it" target ends, so it never runs under the tools' buttons. */
.ob-rows {
  margin: 0 0 0.625rem;
  padding: 0;
  list-style: none;
}

.ob-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  column-gap: 1rem;
  align-items: start;
  min-height: 8.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ob-rule);
}

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

.ob-cover-link,
.ob-cover {
  display: block;
  width: 48px;
  height: 72px;
  line-height: 0;
}

.ob-cover-link > * {
  width: 48px;
  height: 72px;
}

.ob-title {
  margin: 0;
  font: 600 1rem / 1.375rem var(--ob-font);
}

/* A 44 px target around the title without moving it: padding out, the same margin back (audit P1 #7). */
.ob-title a {
  display: inline-block;
  padding-block: calc((2.75rem - 1lh) / 2);
  margin-block: calc((1lh - 2.75rem) / 2);
  color: var(--ob-ink);
  text-decoration: none;
}

@media (hover: hover) {
  .ob-title a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* One line at the full width, never an ellipsis: onboarding.js picks the longest §7.2a form that fits, so a row keeps
   its height when "Haven't read it" swaps in another book (§E.1: CLS 0). */
.ob-authors {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

/* "Haven't read it" (§E.1): in the value line under the stars, 15/20 like it. The stars sit above it and keep the
   8 px where the line overlaps their 44 px targets, so the button is 52 px tall to leave a whole 44 px of its own
   below them, and 8 px wider each side. Negative margins keep the line at 24 px, so the row stays 132 px; the extra
   10 px lies in the next row's empty top padding. */
button.ob-text.ob-skip {
  align-items: flex-start;
  min-height: 3.25rem;
  margin: -0.125rem -0.5rem -1.875rem;
  padding: 0.125rem 0.5rem 0;
  font: inherit;
  color: var(--ob-mut);
  white-space: nowrap;
}

@media (hover: hover) {
  button.ob-text.ob-skip:hover {
    color: var(--ob-mut);
    text-decoration: none;
  }
}

@media (hover: hover) {
  button.ob-text.ob-skip:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.ob-rate {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
}

/* The value line is always there, empty or not, so Saving, Saved and Undo never move what's below (§H.3). */
.ob-value {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.5rem;
  margin-top: -0.5rem; /* 4 px under the stars' glyphs */
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

/* "Skipped {Title}." stays on one line; onboarding.js shortens it to fit. */
.ob-fit {
  white-space: nowrap;
}

button.ob-text.ob-undo {
  min-height: 1.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ob-skel .ob-cover {
  background: var(--ob-hover);
  border-radius: 2px;
}

.ob-skel-lines {
  display: block;
  height: 5.5rem;
  background: linear-gradient(var(--ob-hover) 0 1rem, transparent 1rem 1.5rem, var(--ob-hover) 1.5rem 2.5rem, transparent 2.5rem);
  border-radius: 2px;
  max-width: 16rem;
}

.ob-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
}

.ob-tools-next .ob-more {
  font-weight: 600;
}

/* "Show other books" reads as a link, like the other text links (Juno, 01:54). */
button.ob-text.ob-more {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* R3-41: one row, one baseline. The top margin on button.ob-more is for stacked lists, not this row. */
.ob-tools > button.ob-more {
  margin-top: 0;
}

/* "Not now" is a quiet text button on the right (Juno, R3-41). */
.ob-tools > button.ob-later {
  color: var(--ob-mut);
  margin-left: auto;
}

.ob-muted {
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

.ob-thanks {
  margin: 0;
  padding: 0.75rem 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-ink);
}

.ob-thanks a {
  color: var(--ob-link);
}

.ob-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* A member's rating in laurels (SPEC-STOA-GRADE, 18:30 Nov 15): five in a row, each in a 44 px box with no gaps;
   a box narrows only when its row has no room for 220 px. A given laurel is filled in --ob-laurel; the others are
   the same drawing at 30%. */
.ob-stars {
  position: relative;
  z-index: 1; /* above the value line it overlaps by 8 px, so a tap there is always a laurel */
  display: flex;
  width: max-content;
  max-width: calc(100% + 10px); /* in a column narrower than five boxes, the boxes give up their spare room (Juno on PR 364) */
  margin-left: -10px;
  cursor: pointer;
  border-radius: var(--ob-radius);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ob-star {
  display: grid;
  place-items: center;
  flex: 0 1 44px;
  width: 44px;
  min-width: 0;
  height: 44px;
  border-radius: var(--ob-radius);
  color: var(--ob-laurel);
}

.ob-star:focus {
  outline: none;
}

.ob-star:focus-visible {
  outline: 2px solid var(--ob-link);
  outline-offset: -4px;
}

.ob-star svg {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.ob-stars-lg {
  max-width: calc(100% + 6px);
  margin-left: -6px;
}

.ob-stars-lg .ob-star svg {
  width: 32px;
  height: 32px;
}

/* A rating's words under its laurels (R3-95): "Only you see your rating." until rated, then "Loved it (only you)"
   and Remove rating, on one 44 px row at every width (the longest words, a 12 px gap and the button take 281 of 288 px), so nothing below
   it moves when the words change. */
.ob-rated {
  display: flex;
  flex-wrap: wrap; /* a font wider than measured wraps the button under the words rather than run off the sheet */
  align-items: center;
  column-gap: 12px;
  min-height: 44px;
  margin: 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

.ob-rated > * {
  white-space: nowrap;
}

.ob-rated-rm {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font: inherit;
  color: var(--ob-ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  background: none;
  border: 0;
  cursor: pointer;
}

/* Read to a screen reader only: "Rating removed. Undo available." */
.ob-vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ob-rated-rm:focus-visible {
  outline: 2px solid var(--ob-link);
  outline-offset: 2px;
}

/* How far a laurel not given dims: 30% light, 40% dark. Defined here too, at the lowest specificity, so a page that
   loads only onboarding.css still dims to 40% in dark (Juno, PR 606). */
:where(:root) {
  --laurel-off: 0.3;
}

@media (prefers-color-scheme: dark) {
  :where(:root) {
    --laurel-off: 0.4;
  }
}

/* One laurel's drawing (Juno's v2): stroked stems and filled leaves; a laurel not given is the same drawing, dimmed. */
.lr-stem {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
}

.lr-leaf {
  fill: currentColor;
  stroke: none;
}

:is(.ob-star, .ob-glyph, .ri-star):not(.on) svg {
  opacity: var(--laurel-off, 0.3);
}

/* A stored rating, read only: five 18 px laurels 3 px apart, never closer, or they merge into a chain (Juno). */
.ob-glyphs {
  display: inline-flex;
  gap: 3px;
  vertical-align: -3px;
  color: var(--ob-laurel);
}

.ob-glyph svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* R3-99 (Juno): an old half value draws a half laurel: a dimmed laurel, its left half drawn whole over it (a 12-unit
   view of the same laurel, half as wide). */
.ob-glyphs .ob-glyph.ob-half {
  position: relative;
}
.ob-glyphs .ob-glyph.ob-half > svg:first-child {
  opacity: var(--laurel-off, 0.3);
}
.ob-glyphs .ob-glyph.ob-half > svg.ob-half-on {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  opacity: 1;
}

/* ---- Topics (M4 step 1): under a ticked subject, a row of text toggles across the grid -------------------------- */
/* The row follows its subject's cell and the grid packs densely, so the row sits right under that cell's row. */
.ob-subjects {
  grid-auto-flow: row dense;
}

/* The first row's top rule counts subject cells only, so an open topic row never takes it from a cell. */
.ob-subjects > li:nth-child(-n + 2 of :not(.ob-topics)) > button.ob-subject {
  border-top: 1px solid var(--ob-rule);
}

.ob-subjects > li:nth-child(n + 3 of :not(.ob-topics)) > button.ob-subject {
  border-top: 0;
}

.ob-subjects > li.ob-topics {
  display: grid;
  grid-column: 1 / -1;
  grid-template-rows: 0fr;
  transition: grid-template-rows 150ms ease;
}

.ob-subjects > li.ob-topics.ob-open {
  grid-template-rows: 1fr;
}

@media (prefers-reduced-motion: reduce) {
  .ob-subjects > li.ob-topics {
    transition: none;
  }
}

.ob-topics-in {
  min-height: 0;
  overflow: hidden;
}

.ob-topic-list {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.25rem;
  margin: 0;
  padding: 0 0 0.25rem 2rem;
  list-style: none;
  border-bottom: 1px solid var(--ob-rule);
}

button.ob-topic {
  min-height: 2.75rem;
  margin: 0;
  padding: 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
  background: none;
  border: 0;
  box-shadow: none;
  transform: none;
  cursor: pointer;
}

button.ob-topic[aria-pressed='true'] {
  color: var(--ob-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

@media (hover: hover) {
  button.ob-topic:hover {
    color: var(--ob-ink);
    background: none;
  }
}

/* ---- Tap books you loved (M4 step 2) ------------------------------------------------------------------------------ */
/* Wider than the other steps, for six covers a row from 768; three a row on a phone, filling the width. */
.ob-page.ob-loved {
  max-width: var(--ob-wide, 60rem);
}

.ob-loved .ob-gr {
  margin-top: -0.75rem;
}

.ob-line a {
  color: var(--ob-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.ob-covers {
  display: grid;
  /* Covers fill their tracks, so the row never spreads apart between phone and tablet widths (Juno after PR 399).
     1rem keeps two picked neighbours' 5px rings apart on narrow phones (Juno, app PR 282). */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 560px) {
  .ob-covers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* 6 a row from 768 keeps covers between about 100 and 170 px at every width, never over 200 px at 4 a row
   (Juno on PRs 400, 401); 6, not 5, so a load of 12 fills two whole rows. */
@media (min-width: 768px) {
  .ob-covers {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1.5rem;
  }
}

.ob-covers > li {
  min-width: 0;
}

button.ob-cover-b {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: 0;
  background: none;
  border: 0;
  border-radius: 3px;
  box-shadow: none;
  transform: none;
  cursor: pointer;
}

button.ob-cover-b > :first-child,
.ob-cover-ph {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
}

.ob-cover-ph {
  background: var(--ob-hover);
  border-radius: 2px;
}

/* Picked: a 3 px ring in the accent, 2 px off the cover in the page's colour so it shows on a navy cover too
   (Juno on PR 399), drawn outside so the cover never shrinks, and a 24 px tick. */
button.ob-cover-b[aria-pressed='true'] {
  box-shadow:
    0 0 0 2px var(--ob-bg),
    0 0 0 5px var(--ob-accent);
}

/* Every typeset title shows in the picker (Juno on PR 399): no small-cover hide, never under 11 px, broken with hyphens
   like the shelf's; one that still can't fit gets its caption under the cover (lovedStep). */
.ob-covers .ob-cover-b .cv-box .cv-none b {
  visibility: visible;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: anywhere;
}

.ob-covers .ob-cover-b .cv-box .cv-none b:is(.cv-m, .cv-s) {
  font-size: max(11px, 11.5cqi);
}

.ob-cap {
  margin: 0.5rem 0 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-ink);
  overflow-wrap: break-word;
}

.ob-check {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font: 600 0.875rem / 1 var(--ob-font);
  color: var(--ob-on-accent);
  background: var(--ob-accent);
  border-radius: 50%;
}

button.ob-cover-b[aria-pressed='true'] .ob-check {
  display: flex;
}

button.ob-cover-b:focus-visible {
  outline: 2px solid var(--ob-link);
  outline-offset: 5px;
}

.ob-none {
  grid-column: 1 / -1;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

button.ob-more {
  margin-top: 1rem;
}

.ob-picked {
  margin: 0;
  font: 400 0.9375rem / 1.25rem var(--ob-font);
  color: var(--ob-mut);
}

.ob-picked.ob-good {
  color: var(--ob-ink);
}

/* On a wide screen the bar is the page's foot, right-aligned, not a sticky band. */
@media (min-width: 900px) {
  .ob-loved .ob-bar {
    position: static;
    border-top: 0;
  }

  .ob-loved .ob-bar-in {
    justify-content: flex-end;
    gap: 1.5rem;
  }
}
