/*==============================================*\
|| TerraLoc – Social Share Studio               ||
\*==============================================*/

/* The same corner as every other floating card on the page. 18px next to the
   statistics panel's 14px read as a different component. */
.tl-share-modal .modal-content {
  border-radius: var(--tl-card-radius, 14px);
  overflow: hidden;
}

.tl-share-modal .tl-share-subtitle {
  font-size: 0.82rem;
  color: var(--tl-muted);
  margin-top: 2px;
}

.tl-share-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 991.98px) {
  .tl-share-grid {
    grid-template-columns: 1fr;
  }
}

/* Preview: sticky only in the two-column desktop layout. On mobile the
   grid stacks, and a sticky preview would sit on top of the controls. */
@media (min-width: 992px) {
  .tl-share-preview-col {
    position: sticky;
    top: 0;
  }
}

@media (max-width: 991.98px) {
  .tl-share-preview canvas {
    max-height: 46vh;
  }
}

.tl-share-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-conic-gradient(rgba(128, 140, 152, 0.12) 0% 25%, transparent 0% 50%)
    50% / 22px 22px;
  border: 1px solid var(--tl-hairline);
  border-radius: 14px;
  padding: 14px;
  min-height: 320px;
}

.tl-share-preview canvas {
  max-width: 100%;
  max-height: min(58vh, 640px);
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
}

.tl-share-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--tl-accent);
  background: rgba(10, 14, 19, 0.25);
  border-radius: 14px;
}

.tl-share-dim {
  margin-top: 0.45rem;
  text-align: center;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--tl-muted);
}

/* Controls */
.tl-share-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--tl-muted);
  margin: 0.9rem 0 0.45rem;
}

.tl-share-group-label:first-child {
  margin-top: 0;
}

.tl-share-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The photo picker sits where the layout chips used to: a button, and a
   Remove link that only appears once there is something to remove. */
.tl-share-photo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tl-share-photo-row .btn-link {
  padding-left: 0;
  padding-right: 0;
  color: var(--tl-muted);
}

.tl-share-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--tl-hairline);
  border-radius: 12px;
  background: var(--tl-panel);
  color: var(--tl-ink);
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tl-share-chip:hover {
  border-color: var(--tl-accent);
  transform: translateY(-1px);
}

.tl-share-chip.is-active {
  border-color: var(--tl-accent);
  box-shadow: 0 0 0 2px rgba(var(--tl-accent-rgb), 0.28);
}

.tl-share-chip-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.tl-share-chip-copy strong {
  font-size: 0.83rem;
  font-weight: 700;
}

.tl-share-chip-copy small {
  font-size: 0.68rem;
  color: var(--tl-muted);
}

.tl-share-ratio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.tl-share-ratio span {
  display: block;
  border: 2px solid var(--tl-accent);
  border-radius: 4px;
}

.tl-share-swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Motion toggle */
.tl-share-motion-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.tl-share-motion {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--tl-hairline);
  border-radius: 999px;
  background: var(--tl-panel);
  color: var(--tl-ink);
  font-weight: 700;
  font-size: 0.85rem;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tl-share-motion:hover {
  border-color: var(--tl-accent);
}

.tl-share-motion.is-active {
  background: var(--tl-accent);
  border-color: var(--tl-accent);
  color: var(--tl-accent-ink);
}

.tl-share-motion-hint {
  font-size: 0.74rem;
  color: var(--tl-muted);
  flex: 1 1 180px;
  min-width: 160px;
}

/* 3D clip panel */
.tl-share-clip {
  margin-top: 0.4rem;
}

.tl-share-clip-range {
  width: 100%;
  margin: 0.15rem 0 0.35rem;
  accent-color: var(--tl-accent);
}

.tl-share-clip-meta {
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--tl-muted);
  margin-bottom: 0.3rem;
}

.tl-share-caption {
  font-size: 0.85rem;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  resize: vertical;
}

.tl-share-status {
  min-height: 1.3rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--tl-accent);
}

.tl-share-status[data-tone='err'] {
  color: #e5484d;
}

/* Floating share button (task page), sits left of the screenshot button
   and inherits its base styles via the shared class. */
.terraloc-share-btn.terraloc-screenshot-btn {
  right: calc(4.6rem + env(safe-area-inset-right, 0px)) !important;
}

@media (max-width: 575.98px) {
  .terraloc-share-btn.terraloc-screenshot-btn {
    right: calc(4.3rem + env(safe-area-inset-right, 0px)) !important;
  }
}

/* ------------------------------------------------------------------
   THE STUDIO AS A PANEL, beside the rail rather than over the track.

   .tl-track-panel in track.css does the anchoring and the card chrome; all
   that is needed here is the width, because a studio holds a preview and the
   statistics panel holds numbers. 412px would put the preview canvas and its
   controls in one 380px column.
   ------------------------------------------------------------------ */

.tl-share-modal.tl-track-panel .modal-dialog {
  width: 720px;
  max-width: calc(100vw - var(--tl-rail-w, 64px) - 2.5rem);
}

/* One column below the two column breakpoint, which at this width is most
   phones and every narrow window. The grid rule above already stacks at
   991.98px; this makes the panel itself stop pretending it has the room. */
@media (max-width: 991.98px) {
  .tl-share-modal.tl-track-panel .modal-dialog {
    width: 420px;
  }
}

/*
 * On a phone it is a sheet across the screen, like every other panel here.
 *
 * width:auto alone was not enough: the max-width above is three classes to
 * the phone reset's two, so it survived it, and the studio sat 350px wide
 * against the left edge with a 40px strip of map down the right. The rail is
 * a bar along the bottom by then and owns no width at all, so there is
 * nothing left for the sheet to keep clear of.
 */
@media (max-width: 575.98px) {
  .tl-share-modal.tl-track-panel .modal-dialog {
    width: auto;
    max-width: none;
  }

  /*
   * Rounded at the top, flat where it meets the bar, like Comments.
   *
   * The studio sets all four corners so its preview and its controls cannot
   * bleed past the card, and that rule is further down the cascade than the
   * phone sheet's, so the studio alone kept its bottom corners and floated
   * over the rail instead of resting on it.
   */
  .tl-share-modal .modal-content {
    border-radius: var(--tl-card-radius, 14px) var(--tl-card-radius, 14px) 0 0;
  }

  /*
   * And the foot is a block, not a ragged right edge.
   *
   * Bootstrap packs the footer to the right and wraps what does not fit, so
   * three buttons on a 390px phone came out two and one, with Download hung
   * on its own against the right margin. They share the width instead and
   * the last line fills, which is the same shape whether there are three of
   * them or the five a phone with a native share sheet gets.
   */
  .tl-share-modal .modal-footer {
    justify-content: stretch;
  }

  .tl-share-modal .modal-footer > .btn {
    flex: 1 1 8rem;
  }
}
