/* Learn page: quick-start guides for every feature, one copy per device.
   Everything sits under .learn. Colours come from the theme tokens only, so
   every theme, light and dark, carries over without a rule of its own here. */

/* Device copy. The page carries data-device (iphone, ipad or duo): iphone in the
   HTML, set by theme-boot.js before the first paint and by learn.js's switch.
   An element with data-device-only lists the devices it applies to and is
   hidden on the others. */

[data-device="iphone"] .learn [data-device-only]:not([data-device-only~="iphone"]),
[data-device="ipad"] .learn [data-device-only]:not([data-device-only~="ipad"]),
[data-device="duo"] .learn [data-device-only]:not([data-device-only~="duo"]) {
  display: none;
}

.learn {
  /* The screenshot column beside a guide on a wide screen, and its largest
     size when it sits inside the guide on a narrow one. */
  --learn-shot-w: 15rem;
  --learn-shot-max: 15rem;
  --learn-text-w: 46rem;
  /* How far a jump to a guide or topic stops below the top, for the sticky nav. */
  --learn-jump: 6rem;
}

[data-device="ipad"] .learn {
  --learn-shot-w: 24rem;
  --learn-shot-max: 30rem;
}

[data-device="duo"] .learn {
  --learn-shot-w: 26rem;
  --learn-shot-max: 32rem;
}

/* Hero */

.learn .learn-hero {
  padding-block-end: clamp(12px, 2vw, 20px);
}

/* Device switch: a glass segmented control whose selection slides between
   iPhone, iPad and iPhone Duo. The radios inside keep the arrow keys and the
   group semantics; learn.js shows the control. The slide animates --at, the
   selected position, rather than the thumb's transform, so the switch changing
   between a row and a column moves the thumb at once instead of sweeping it. */

@property --at {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.learn .device-switch {
  --at: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 27rem);
  margin-top: clamp(20px, 4vw, 32px);
  padding: 5px;
  border-radius: 999px;
  transition: --at 0.45s cubic-bezier(0.3, 1.25, 0.5, 1);
}

.learn .device-switch[hidden] {
  display: none;
}

/* With scripts (data-scripted, set by theme-boot.js before the first paint) the
   switch and the finder hold their places from the start, unseen until learn.js
   shows them, so nothing moves when it does and nothing can be used before it
   works. The finder shares its place with the topic list that stands in for it
   without scripts, which stays until learn.js takes it away, and for good
   should learn.js never run. */
[data-scripted] .learn .device-switch[hidden] {
  display: grid;
  visibility: hidden;
}

[data-scripted] .learn .learn-index {
  display: grid;
  grid-template-areas: "find";
  grid-template-columns: minmax(0, 1fr);
}

[data-scripted] .learn .learn-index > :is(.learn-find, .learn-topics) {
  grid-area: find;
}

[data-scripted] .learn .learn-find[hidden] {
  display: block;
  visibility: hidden;
}

[data-device="ipad"] .learn .device-switch {
  --at: 1;
}

[data-device="duo"] .learn .device-switch {
  --at: 2;
}

.learn .device-thumb {
  position: absolute;
  inset-block: 5px;
  inset-inline-start: 5px;
  width: calc((100% - 10px) / 3);
  border-radius: 999px;
  background: var(--glass-hover);
  box-shadow:
    inset 0 1px 1px var(--rim-in),
    0 6px 14px -8px rgba(0, 0, 0, 0.45);
  transform: translateX(calc(var(--at) * 100%));
}

.learn .device-choice {
  position: relative;
  display: grid;
  cursor: pointer;
}

/* The real radio stays focusable and clickable; the label shows its state. */
.learn .device-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.learn .device-choice span {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: color 0.2s ease;
}

/* The choice on show follows data-device, as the thumb does, so the switch is
   right from the first paint, before learn.js checks the matching input. */
[data-device="iphone"] .learn .device-choice input[value="iphone"] + span,
[data-device="ipad"] .learn .device-choice input[value="ipad"] + span,
[data-device="duo"] .learn .device-choice input[value="duo"] + span {
  color: var(--link);
}

.learn .device-choice input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* When the labels no longer fit side by side at the visitor's text size, the
   choices stack and the selection slides down instead. The hero is the query
   container, so the em below follows the text size, not the screen alone. */
.learn .learn-hero {
  container-type: inline-size;
}

@container (max-width: 18em) {
  .learn .device-switch {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: 1fr;
    border-radius: 24px;
  }

  .learn .device-thumb {
    inset-block-end: auto;
    inset-inline-end: 5px;
    width: auto;
    height: calc((100% - 10px) / 3);
    transform: translateY(calc(var(--at) * 100%));
  }
}

@media (prefers-reduced-motion: reduce) {
  .learn .device-switch {
    transition: none;
  }
}

@media (forced-colors: active) {
  [data-device="iphone"] .learn .device-choice input[value="iphone"] + span,
  [data-device="ipad"] .learn .device-choice input[value="ipad"] + span,
  [data-device="duo"] .learn .device-choice input[value="duo"] + span {
    outline: 2px solid Highlight;
  }
}

/* Guide finder: a search field with a glass list under it, built by learn.js.
   Without scripts it stays hidden and the plain topic list shows instead. */

.learn .learn-index {
  scroll-margin-top: var(--learn-jump);
}

.learn .learn-find {
  position: relative;
  z-index: 5;
  width: min(100%, 34rem);
}

.learn .learn-find-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 8px 0 18px;
  border-radius: 999px;
}

.learn .learn-find-field:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.learn .learn-find-field svg {
  flex: none;
  width: 20px;
  height: 20px;
  stroke: var(--ink-soft);
}

.learn .learn-find-field input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  /* 16px or more, so iOS does not zoom the page into the field. */
  font: inherit;
  font-size: max(1rem, 16px);
  outline: none;
}

.learn .learn-find-field input::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

.learn .learn-find-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(28rem, 60dvh, var(--find-room, 60dvh));
  padding: 6px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 22px;
}

.learn .learn-find-heading {
  padding: 12px 12px 4px;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.learn .learn-find-option {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 14px;
  cursor: pointer;
}

.learn .learn-find-option[aria-selected="true"] {
  background: var(--glass-hover);
  box-shadow: inset 0 1px 1px var(--rim-in);
}

@media (hover: hover) {
  .learn .learn-find-option:hover {
    background: var(--glass-hover);
  }
}

.learn .learn-find-title {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
}

.learn .learn-find-topic {
  color: var(--link);
  font-size: 0.8rem;
  font-weight: 600;
}

.learn .learn-find-detail {
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.35;
}

.learn .learn-find-option mark {
  background: none;
  color: var(--link);
  font-weight: 700;
}

.learn .learn-find-empty {
  margin: 0;
  padding: 14px 12px;
  color: var(--ink-soft);
}

@media (forced-colors: active) {
  .learn .learn-find-option[aria-selected="true"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

/* Without scripts: every topic, in a list that opens from one button. */

.learn .learn-topics {
  width: min(100%, 34rem);
}

.learn .learn-topics summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--glass);
  box-shadow: inset 0 1px 1px var(--rim-in), inset 0 0 0 1px var(--hairline);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.learn .learn-topics summary::-webkit-details-marker {
  display: none;
}

.learn .learn-topics ul {
  display: grid;
  gap: 2px;
  margin: 8px 0 0;
  padding: 6px;
  border-radius: 22px;
  background: var(--glass);
  box-shadow: inset 0 1px 1px var(--rim-in), inset 0 0 0 1px var(--hairline);
  list-style: none;
}

.learn .learn-topics a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

@media (hover: hover) {
  .learn .learn-topics a:hover {
    background: var(--glass-hover);
  }
}

/* Topics */

.learn .learn-group {
  padding-block: clamp(20px, 4vw, 36px) 0;
  scroll-margin-top: calc(var(--learn-jump) - 24px);
}

.learn .learn-index + .learn-group {
  padding-block-start: clamp(28px, 5vw, 48px);
}

.learn .learn-group .section-head {
  margin-bottom: clamp(14px, 2.5vw, 22px);
}

.learn .learn-group h2 {
  font-size: clamp(1.5rem, 1.15rem + 1.4vw, 2.2rem);
}

.learn .learn-guides {
  display: grid;
  gap: clamp(16px, 2.5vw, 24px);
}

.learn .learn-back {
  margin-top: 6px;
}

.learn .learn-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 600;
}

/* A guide. A single column on a narrow screen, with the screenshot between the
   introduction and the steps; text beside the screenshot on a wide one. */

.learn .learn-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 14px;
  padding: clamp(18px, 4vw, 32px);
  scroll-margin-top: var(--learn-jump);
}

.learn .learn-guide > * {
  min-width: 0;
}

/* A long word wraps instead of pushing the page wider at the largest text sizes. */
.learn .learn-guide,
.learn .learn-group h2 {
  overflow-wrap: anywhere;
}

/* A guide is for reading, so it does not lift on hover as other cards do. */
.learn .learn-guide:hover {
  transform: none;
}

.learn .learn-guide:target {
  outline: 3px solid var(--link);
  outline-offset: 4px;
}

.learn .learn-steps,
.learn .learn-more {
  order: 2;
}

.learn .learn-guide-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.learn .learn-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--primary-a), var(--primary-b));
  color: var(--on-primary);
  box-shadow: inset 0 1px 1px var(--rim-in);
}

.learn .learn-icon:empty {
  display: none;
}

.learn .learn-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.learn .learn-guide-titles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
}

.learn .learn-guide h3 {
  margin: 0;
  font-size: clamp(1.3rem, 1.15rem + 0.5vw, 1.55rem);
}

.learn .learn-anchor {
  color: inherit;
  text-decoration: none;
}

.learn .learn-anchor:hover {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

.learn .learn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--glass-inner);
  box-shadow:
    inset 0 0 0 1px var(--hairline),
    inset 0 1px 1px var(--rim-in);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.learn .learn-badge svg {
  flex: none;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.learn .learn-guide .learn-hook {
  max-width: var(--learn-text-w);
  margin: 0;
  color: var(--ink-soft);
}

.learn .learn-guide .learn-intro {
  max-width: var(--learn-text-w);
  margin: 0;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.45;
}

/* Steps */

.learn .learn-steps {
  max-width: var(--learn-text-w);
}

.learn .learn-steps h4 {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.learn .learn-steps ol {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.learn .learn-steps li {
  position: relative;
  min-height: 2rem;
  padding: 0.2rem 0 0 3rem;
  counter-increment: step;
}

.learn .learn-steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b));
  color: var(--on-primary);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
}

@media (forced-colors: active) {
  .learn .learn-steps li::before {
    border: 1px solid CanvasText;
  }
}

/* More details: collapsed until opened, as in the app. */

.learn .learn-more {
  max-width: var(--learn-text-w);
  border-radius: 18px;
  background: var(--glass-inner);
  box-shadow:
    inset 0 1px 1px var(--rim-in),
    inset 0 -1px 1px var(--rim-in-low);
}

.learn .learn-more summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 52px 10px 18px;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.35;
  list-style: none;
}

.learn .learn-more summary::-webkit-details-marker {
  display: none;
}

.learn .learn-more summary::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: translateY(-72%) rotate(45deg);
  transition: transform 0.25s ease;
}

.learn .learn-more[open] summary::after {
  transform: translateY(-28%) rotate(-135deg);
}

@media (hover: hover) {
  .learn .learn-more summary:hover {
    background: var(--glass-hover);
  }
}

.learn .learn-more ul {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 2px 18px 18px 38px;
}

.learn .learn-more li::marker {
  color: var(--link);
}

/* Screenshot. The slot stays out of the layout until it holds something for
   the device being shown. */

.learn .learn-shot {
  display: none;
  order: 1;
  justify-self: center;
  width: min(100%, var(--learn-shot-max));
  margin: 0;
}

[data-device="iphone"] .learn .learn-shot:has(> :is(:not([data-device-only]), [data-device-only~="iphone"])),
[data-device="ipad"] .learn .learn-shot:has(> :is(:not([data-device-only]), [data-device-only~="ipad"])),
[data-device="duo"] .learn .learn-shot:has(> :is(:not([data-device-only]), [data-device-only~="duo"])) {
  display: block;
}

/* A screenshot is a themed cutout (.themed-shot, shots.css) or, where a guide has
   none for the device, a plain image. */
.learn .learn-shot > img,
.learn .learn-shot > .themed-shot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px var(--hairline),
    var(--shadow);
}

.learn .learn-shot figcaption {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* Wide: the text on the left, the screenshot beside it. The breakpoint is in em
   so that a larger default text size moves it out, as it should. */

@media (min-width: 52.5em) {
  .learn .learn-guide {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: repeat(4, auto) 1fr;
    align-content: start;
  }

  .learn .learn-guide > :not(.learn-shot) {
    grid-column: 1;
    align-self: start;
  }

  .learn .learn-shot {
    grid-column: 2;
    grid-row: 1 / span 5;
    align-self: start;
    justify-self: end;
    width: var(--learn-shot-w);
    margin-inline-start: clamp(24px, 3vw, 40px);
  }
}

/* Closing call to action */

.learn .learn-cta {
  padding-block-start: clamp(36px, 6vw, 64px);
}
