/*
 * InstaTuner on the website (TDBFS_Insta): the Download button beside a file (search dialog, shop rows, buy box),
 * the offer everyone else sees beside Add to cart, and the plan under the account name in the header, the phone
 * bar and the phone menu. Theme tokens only, so light and dark follow the site.
 */

/* ---- the button beside a file ----------------------------------------------------------------------------- */
.tdbfs-insta__get {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--accent-ink);
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-1) ease, color var(--dur-1) ease, border-color var(--dur-1) ease;
}
.tdbfs-insta__get:hover:not(:disabled) {
  background: var(--accent);
  color: var(--on-accent);
}
.tdbfs-insta__get:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.tdbfs-insta__get.is-theirs {
  border-color: var(--ok);
  color: var(--ok);
}
.tdbfs-insta__get.is-theirs:hover:not(:disabled) {
  background: var(--ok);
  color: var(--bg);
}
.tdbfs-insta__get:disabled {
  border-color: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}
.tdbfs-insta__get.is-busy {
  cursor: progress;
  opacity: 0.7;
}
.tdbfs-insta__get svg {
  flex: none;
}

/* In the search dialog: the file's row, and the button beside it. */
.tdbfs-offers li.has-insta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-2);
}
.tdbfs-offers li.has-insta .tdbfs-insta__get {
  min-height: 56px;
}

/* On the file page's table of files: beside Add to cart. */
.pf-family__buy .tdbfs-insta__get {
  margin-left: var(--sp-2);
}

/* In the shop: one more column before the row's menu. */
.fs-row.has-insta {
  grid-template-columns: 44px minmax(0, 1fr) auto auto auto auto 44px;
}

/* ---- the buy box ------------------------------------------------------------------------------------------- */
.tdbfs-insta {
  margin: var(--sp-3) 0 0;
}
.tdbfs-insta .tdbfs-insta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 48px;
}
.tdbfs-insta .tdbfs-insta__btn.is-theirs {
  background: var(--ok);
  color: var(--bg);
}
.tdbfs-insta__note {
  margin: var(--sp-2) 0 0;
  color: var(--ink-2);
  font-size: var(--step--1);
}
.tdbfs-insta__note b {
  color: var(--ink);
}
.tdbfs-insta--offer {
  padding: var(--sp-2) var(--sp-3);
  border-left: 3px solid var(--accent);
  background: var(--bg-sunk);
  color: var(--ink-2);
  font-size: var(--step--1);
}
.tdbfs-insta--offer b {
  color: var(--ink);
}
.tdbfs-insta--offer a {
  color: var(--link);
  font-weight: 600;
  white-space: nowrap;
}

/* ---- the header: the plan under the account name (laptops), a pill in the phone bar, a card in the phone menu - */
/* Two classes: the theme's .btn prints after this sheet and wins a tie. */
.v3-tools .v3-acct {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding-block: var(--sp-1);
  line-height: 1.15;
  text-align: left;
}
.v3-acct__name {
  max-width: 16ch;
  overflow: hidden;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v3-acct__plan {
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.v3-acct__plan b,
.v3-insta-bar b,
.v3-acct-card b {
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
/* Phones and tablets: a slim line under the bar (the bar itself has no room left at 390 px). */
.v3-insta-bar {
  display: block;
  padding: var(--sp-1) var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--header-bg);
  color: var(--ink-2);
  font-size: 0.8rem;
  text-align: center;
  text-decoration: none;
}
.v3-insta-bar:hover {
  color: var(--ink);
}
.v3-acct-card {
  display: grid;
  grid-column: 1 / -1;
  gap: 2px;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--bg-raised);
  color: var(--ink-2);
  font-size: var(--step--1);
  text-decoration: none;
}
.v3-acct-card__name {
  color: var(--ink);
  font-size: var(--step-0);
  font-weight: 600;
}
@media (min-width: 1200px) {
  .v3-insta-bar {
    display: none;
  }
}

/* ---- phones: the shop hides View under 600 px (shop.css), and the button keeps only its icon ----------------- */
@media (max-width: 600px) {
  .fs-row.has-insta {
    grid-template-columns: 44px minmax(0, 1fr) auto auto auto 44px;
  }
  .fs-row .tdbfs-insta__get span,
  .tdbfs-offers .tdbfs-insta__get span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .fs-row .tdbfs-insta__get,
  .tdbfs-offers .tdbfs-insta__get {
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tdbfs-insta__get {
    transition: none;
  }
}
