/* DM ORIGINALS: chapter 4, share.
   The ready post sits in a quiet bezel. The actions under it are the 30 seconds. */

.share [hidden],
.share__sheet [hidden] { display: none !important; }

/* ------------------------------------------------------------------ layout */

/* Phones: the head, step 1 (pick a version), the post, step 2 (share). */
.share__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "pick" "preview" "deck";
  row-gap: var(--s-8);
}
.share__head { grid-area: head; }
.share__pick { grid-area: pick; min-width: 0; }
.share__preview { grid-area: preview; width: 100%; max-width: 520px; }
.share__deck {
  grid-area: deck;
  width: 100%;
  max-width: 680px;
  container-type: inline-size;
  display: grid;
  gap: var(--s-5);
  align-content: start;
}

/* Each step opens with a short name */
.share__step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--s-4);
  font-family: var(--font-ui);
  font-size: var(--step-body);
  font-weight: 600;
  line-height: 1.2;
  color: var(--paper);
}
.share__deck > .share__step-title { margin-bottom: 0; }
/* the title breaks where the content puts its line break ("30 שניות" / "שיתוף אחד") */
.share__head .chapter-title { white-space: pre-line; }

/* Wide: the head across the top; under it the two steps on the reading side and the post beside them,
   all starting on one line. The post stays in view while a version is picked. */
@media (min-width: 1024px) {
  .share__grid {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "head head" "pick preview" "deck preview";
    column-gap: clamp(48px, 6vw, 104px);
    row-gap: var(--s-8);
    align-items: start;
  }
  .share__preview {
    max-width: none;
    position: sticky;
    top: calc(env(safe-area-inset-top, 0px) + 24px);
  }
  /* the steps share one width, so the choices, agent M's panel and the actions line up as one column */
  .share__pick, .share__deck { max-width: 520px; }
  /* step 1 reads as a list of choices, the edit button under it */
  .share__pick .share__toolbar { flex-direction: column; align-items: stretch; }
  .share__pick .share__variants { flex-direction: column; align-items: stretch; }
  .share__pick .share__variant { justify-content: flex-start; }
  .share__pick .share__edit { margin-inline-start: 0; align-self: flex-start; }
}

/* ------------------------------------------------------------------ toolbar above the post */

.share__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
}
.share__tool {
  min-height: 44px;
  padding-block: 4px;
  padding-inline: 18px 4px;
  gap: 10px;
  font-size: 0.9375rem;
}
.share__edit { margin-inline-start: auto; }

.share__variants {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.share__variant {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 18px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-micro) var(--ease-out), background-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out), transform 160ms var(--ease-out);
}
.share__variant:active { transform: scale(0.97); }
.share__variant:hover { color: var(--paper); }
.share__variant.is-on {
  color: var(--paper);
  background: rgba(242, 238, 230, 0.1);
  box-shadow: inset 0 0 0 1px rgba(242, 238, 230, 0.5);
}
.share__radio {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.share__variant:has(.share__radio:focus-visible) {
  outline: 2px solid var(--tungsten);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ the post */

.share__core { overflow: hidden; }
.share__body { padding: 18px 20px 16px; }

.share__text {
  color: var(--paper);
  font-size: 1rem;
  line-height: 1.62;
}
.share__para {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  unicode-bidi: plaintext;
  text-align: start;
}
.share__para + .share__para { margin-top: 0.7em; }
.share__text.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.share__more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 2px;
  margin-inline-start: -12px;
  padding-inline: 12px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color var(--t-micro) var(--ease-out), background-color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out);
}
.share__more:active { transform: scale(0.97); }
.share__more:hover { color: var(--paper); background: rgba(242, 238, 230, 0.06); }

/* Edit in place: the field keeps the text exactly where it was */
.share__editwrap {
  display: grid;
  gap: var(--s-3);
}
.share__editor {
  display: block;
  width: calc(100% + 32px);
  min-height: calc(1.62em * 4 + 28px);
  margin: -14px -16px 0;
  padding: 13px 15px;
  border: 0;
  border-radius: var(--r-core);
  background: rgba(5, 9, 20, 0.34);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--paper);
  font-size: 1rem;
  line-height: 1.62;
  unicode-bidi: plaintext;
  text-align: start;
  resize: none;
  overflow: hidden;
  transition: background-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out);
}
.share__editor:focus { background: rgba(5, 9, 20, 0.5); }
.share__editor::selection { background: var(--tungsten); color: var(--abyss); }
.share__hint {
  color: var(--paper);
  font-size: var(--step-small);
  line-height: 1.5;
}
.share__reset { justify-self: end; }

/* The image, and its stand-in while it is being drawn: the same composition without the type */
.share__stage {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(80% 80% at 50% 46%, rgba(5, 9, 20, 0) 42.5%, rgba(5, 9, 20, 0.66) 100%),
    radial-gradient(46% 46% at var(--bulb-x, 50%) var(--bulb-y, 35%), rgba(255, 201, 120, 0.17), rgba(255, 201, 120, 0.06) 40%, rgba(255, 201, 120, 0) 100%),
    radial-gradient(86% 86% at 50% -14%, rgba(43, 64, 105, 0.62), rgba(43, 64, 105, 0) 100%),
    linear-gradient(180deg, var(--navy-800) 0%, var(--deep) 46%, var(--abyss) 100%);
}
.share__mark {
  position: absolute;
  z-index: 0;
  top: var(--mark-top, 14.667%);
  inset-inline: 0;
  width: var(--mark-w, 35.8%);
  margin-inline: auto;
}
.share__img {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}
.js-motion .share__img { filter: blur(14px); transform: scale(1.04); }
.share__stage.is-ready .share__img {
  opacity: 1;
  filter: none;
  transform: none;
  transition: opacity 1100ms var(--ease-out) 120ms, filter 1100ms var(--ease-out) 120ms, transform 1600ms var(--ease-out) 120ms;
}

/* The bulb ignites once, as the image arrives. Image coordinates, so physical left and top. */
.share__bloom {
  position: absolute;
  z-index: 2;
  left: var(--bulb-x, 50%);
  top: var(--bulb-y, 35%);
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 236, 200, 0.9), rgba(255, 201, 120, 0.34) 32%, rgba(255, 201, 120, 0) 100%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.js-motion .share__stage.is-ready .share__bloom {
  animation: share-ignite 2200ms var(--ease-out) 260ms both;
}
@keyframes share-ignite {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* ------------------------------------------------------------------ actions */

.share__lead { display: grid; gap: var(--s-3); }
.share__primary {
  width: 100%;
  min-height: 56px;
  justify-content: space-between;
  padding-inline: 26px 8px;
  font-size: 1.0625rem;
}
.share__primary .btn__icon { width: 40px; height: 40px; }
.share__lead-note {
  color: var(--ink-3);
  font-size: var(--step-small);
  line-height: 1.5;
}

/* The three beats. Narrow: a vertical rail, cue beside each action. Wide: a horizontal rail under the row.
   A beat's stretch of rail lights when its action has really happened. */
.share__beats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.share__beat {
  display: grid;
  grid-template-columns: 4.25rem 2px minmax(0, 1fr);
  grid-template-areas: "cue rail slot";
  column-gap: var(--s-4);
  align-items: center;
}
.share__cue {
  grid-area: cue;
  color: var(--ink-3);
  font-size: var(--step-small);
  font-weight: 500;
  line-height: 1.2;
  transition: color 600ms var(--ease-out);
}
.share__rail {
  grid-area: rail;
  align-self: stretch;
  position: relative;
  background: var(--line-strong);
}
.share__rail::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tungsten);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 800ms var(--ease-out);
}
.share__slot { grid-area: slot; padding-block: 6px; min-width: 0; }
.share__action { width: 100%; justify-content: space-between; }
.share__label { overflow: hidden; text-overflow: ellipsis; }

.share__beat.is-done .share__cue { color: var(--paper); }
.share__beat.is-done .share__rail::after { transform: none; }

@container (min-width: 600px) {
  .share__beats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .share__beat {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 2px auto;
    grid-template-areas: "slot" "rail" "cue";
    row-gap: var(--s-3);
    align-items: stretch;
  }
  .share__slot { padding-block: 0; padding-inline-end: var(--s-3); }
  .share__beat:last-child .share__slot { padding-inline-end: 0; }
  .share__rail::after { transform: scaleX(0); transform-origin: 100% 50%; }
  .share__beat.is-done .share__rail::after { transform: none; }
}

/* A brief check where the action succeeded */
.share .is-confirmed .btn__icon { animation: share-check 460ms var(--ease-out); }
@keyframes share-check {
  from { transform: scale(0.55); opacity: 0.2; }
  to { transform: none; opacity: 1; }
}

.share__note {
  max-width: 46ch;
  color: var(--ink-2);
  font-size: var(--step-small);
  line-height: 1.55;
}

/* ------------------------------------------------------------------ iOS save sheet */

.share__sheet {
  display: grid;
  justify-items: center;
  gap: var(--s-4);
  margin: 0;
  padding-block: var(--s-2) var(--s-4);
}
.share__sheet-img {
  width: min(100%, 520px);
  border-radius: var(--r-poster);
  box-shadow: 0 30px 60px -30px rgba(2, 5, 14, 0.9);
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
.share__sheet-img.is-mark { padding: 12%; background: var(--paper); }
.share__sheet-hint {
  max-width: 36ch;
  color: var(--ink-2);
  text-align: center;
}

/* ------------------------------------------------------------------ preferences */

@media (forced-colors: active) {
  .share__rail { background: CanvasText; }
  .share__rail::after { background: Highlight; }
  .share__variant.is-on { outline: 2px solid Highlight; }
  .share__editor { border: 1px solid CanvasText; }
}

/* The reminder to tag Dor: tags do not survive a pre-filled text, so the visitor adds it by hand */
.share__tagnote {
  margin-top: var(--s-3);
  padding-inline: 4px;
  font-size: var(--step-small);
  color: var(--ink-2);
}
/* English versions read left to right, inside the right-to-left page */
.share__text[dir="ltr"],
.share__editor[dir="ltr"] { text-align: left; }

/* ------------------------------------------------------------------ agent M */

/* the M: the agent from the USB in the box, a small paper coin */
.share__agent-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-inline-end: 8px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--abyss);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
}
.share__variant--agent { padding-inline-start: 8px; }
.share__variant--agent:not(.is-on) { color: var(--paper); }

.share__agent { margin-bottom: var(--s-4); }
.share__agent[hidden] { display: none; }
.share__agent-core { padding: clamp(16px, 3vw, 22px); display: grid; gap: var(--s-4); container-type: inline-size; }
.share__agent-intro { display: flex; align-items: flex-start; gap: 0; font-size: var(--step-body); color: var(--paper); line-height: 1.5; }
.share__agent-intro .share__agent-badge { margin-top: 1px; }
.share__agent-grid { display: grid; gap: var(--s-4); }
.share__agent-q { margin: 0; padding: 0; border: 0; min-width: 0; }
.share__agent-text { padding: 0; margin-bottom: var(--s-2); font-size: var(--step-small); font-weight: 500; color: var(--ink-2); }
.share__agent-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.share__chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding-inline: 14px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink-2);
  font-size: var(--step-small);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-micro) var(--ease-out), background-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out), transform 160ms var(--ease-out);
}
.share__chip:active { transform: scale(0.97); }
.share__chip:hover { color: var(--paper); }
.share__chip.is-on { color: var(--abyss); background: var(--paper); box-shadow: none; }
.share__chip:has(.share__radio:focus-visible) { outline: 2px solid var(--tungsten); outline-offset: 3px; }
.share__agent-actions:not(:has(> :not([hidden]))) { display: none; }
.share__agent-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.share__agent-polish { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.share__agent-polish[hidden] { display: none; }
.share__agent-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.share__agent-copy {
  min-height: 44px;
  padding-inline: 8px;
  font-size: var(--step-small);
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}
.share__agent-copy:hover { color: var(--paper); text-decoration-color: var(--tungsten); }
.share__agent-note { margin-top: var(--s-2); font-size: var(--step-micro); color: var(--ink-3); }
/* two questions a row only where the panel itself is wide (it sits in a narrow column on a desktop) */
@container (min-width: 600px) {
  .share__agent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-6); }
}

/* the post while agent M waits for answers */
.share__text.is-waiting .share__para { color: var(--ink-3); font-style: normal; }
