/*--- Shared UI utilities ----------------------------------------------------*/

/*
  Reusable, component-level classes shared by BOTH pages and toys. Pages get
  this via the page() shell (part.page.js links it); toys <link> it directly
  alongside base.css. base.css holds only globals (tokens, fonts, resets); the
  markup that uses these classes is rendered by the matching part.* module
  (part.picker.js, part.icon-button.js, part.settings.js) on the page side, and
  hand-written in the toys. All values resolve to base.css tokens, so these
  theme in light and dark automatically.
*/

.scrollable {
  overflow-y: auto;
  scrollbar-color: var(--color-surface-raised) var(--color-surface-base);
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
}

.icon-button {
  background: transparent;
  border: 0;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: inline-grid;
  padding: var(--size-sm);
  place-items: center;

  &:hover {
    background: var(--color-surface-raised);
  }

  svg {
    block-size: var(--size-lg);
    fill: currentColor;
    inline-size: var(--size-lg);
  }

  &:hover svg {
    fill: var(--color-accent-brand-1);
  }
}

.picker {
  background: var(--color-surface-raised);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-surface-line);
  display: inline-flex;

  button {
    background: transparent;
    border: 0;
    color: var(--color-accent-muted);
    cursor: pointer;
    padding: var(--size-xs) var(--size-sm);
    transition: background 0.15s ease, color 0.15s ease;

    & + button {
      border-inline-start: 1px solid var(--color-surface-line);
    }

    &:hover {
      color: var(--color-accent-brand-1);
    }

    &[data-is-active="true"] {
      background: var(--color-surface-base);
      color: var(--color-accent-base);
    }
  }
}

.modal-backdrop {
  background: color-mix(in srgb, var(--color-surface-deep) 70%, transparent);
  display: none;
  inset: 0;
  position: fixed;
  z-index: 199;

  &[data-is-open="true"] {
    display: grid;
    place-items: center;
  }

  .modal {
    align-items: center;
    background: var(--color-surface-base);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-surface-line);
    display: flex;
    flex-direction: column;
    gap: var(--size-xl);
    inline-size: 22rem;
    max-block-size: 90vh;
    max-inline-size: 90vw;
    overflow-y: auto;
    padding: var(--size-2xl) var(--size-xl);

    .modal-about {
      align-items: center;
      display: flex;
      flex-direction: column;
      gap: var(--size-sm);

      > div, > h3 {
        margin-block: 0;
      }

      .modal-about-meta {
        display: flex;
        font-size: var(--font-size-en-xs);
        gap: var(--size-md);
      }
    }

    .modal-settings {
      align-items: center;
      display: flex;
      flex-direction: column;
      gap: var(--size-lg);
    }
  }
}

.floater {
  background: var(--color-surface-base);
  border: 1px solid var(--color-surface-line);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-surface-deep) 40%, transparent);
  max-inline-size: 16rem;
  min-inline-size: 8rem;
  position: fixed;
  z-index: 300;

  &[data-pinned="true"] {
    box-shadow: 0 6px 24px color-mix(in srgb, var(--color-surface-deep) 55%, transparent);
  }

  &[data-dragging="true"] .floater-grip { cursor: grabbing; }
}

.floater-grip {
  align-items: center;
  cursor: grab;
  display: flex;
  justify-content: center;
  padding-block: var(--size-xs);
  touch-action: none;        /* keep the browser from hijacking the drag as a scroll */
  user-select: none;

  &::before {
    background: var(--color-surface-line);
    block-size: 3px;
    border-radius: 999px;
    content: "";
    inline-size: 2rem;
  }
}

.floater-pin {
  background: none;
  border: 0;
  color: var(--color-surface-line);
  cursor: pointer;
  inset-block-start: var(--size-xs);
  inset-inline-end: var(--size-xs);
  line-height: 0;
  opacity: 0.6;
  padding: 0;
  position: absolute;
  transition: color 0.12s, opacity 0.12s;

  svg { block-size: 0.85rem; fill: currentColor; inline-size: 0.85rem; }

  &:hover { color: var(--color-accent-muted); opacity: 1; }

  .floater[data-pinned="true"] & {
    color: var(--color-accent-brand-1);
    opacity: 1;
  }
}

.floater-body {
  max-block-size: 60vh;
  overflow-y: auto;
  padding: var(--size-sm);
}

/* work-in-progress fragment: banner + rotating Sanskrit quote */
.banner {
  background-color: var(--color-surface-raised);
  border: 1px dashed var(--color-surface-line);
  border-radius: var(--border-radius);
  margin-block: var(--size-md);
  padding: var(--size-sm) var(--size-lg);
  text-align: center;
}

.sa_text {
  margin-block: var(--size-md);
  text-align: center;
  word-break: keep-all;
}

.quote {
  margin-block: var(--size-4xl);

  blockquote {
    font-family: var(--font-family-hand-written);
    margin-block: var(--size-md);
  }
}

