
/* MyLinks design system: component layer. Every color, space, radius, shadow and family comes from tokens.json. */

/* ==========================================================================
   Shared: box model, stack, row, preview body
   ========================================================================== */
[class^="ml-"],
[class*=" ml-"] {
  box-sizing: border-box;
}

/* Vertical stack with the standard gap between sibling blocks */
.ml-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Horizontal row that wraps */
.ml-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* Body of every live preview */
.ml-preview {
  padding: var(--space-5);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  min-height: 100%;
}

/* ==========================================================================
   Button: pill action, variants primary / secondary / ghost / accent / danger
   ========================================================================== */
.ml-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-m);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.ml-button__icon,
.ml-button > svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.ml-button--primary {
  background: var(--ink);
  color: var(--on-ink);
}
.ml-button--secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.ml-button--ghost {
  background: transparent;
  color: var(--ink);
}
.ml-button--accent {
  background: var(--accent);
  color: var(--on-accent);
}
.ml-button--danger {
  background: var(--danger);
  color: var(--paper);
}

.ml-button--s {
  height: var(--control-s);
  padding: 0 var(--space-3);
}
.ml-button--m {
  height: var(--control-m);
}
.ml-button--l {
  height: var(--control-l);
  padding: 0 var(--space-5);
}
.ml-button--icon {
  width: var(--control-m);
  padding: 0;
}
.ml-button--icon.ml-button--s {
  width: var(--control-s);
}
.ml-button--icon.ml-button--l {
  width: var(--control-l);
}
.ml-button--block {
  display: flex;
  width: 100%;
}

.ml-button:hover:not(:disabled):not([aria-disabled="true"]) {
  box-shadow: var(--shadow-1);
}
.ml-button--primary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--ink-muted);
}
.ml-button--secondary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--surface-sunken);
  border-color: var(--ink-muted);
}
.ml-button--ghost:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--surface-sunken);
  box-shadow: none;
}
.ml-button:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(1px);
}
.ml-button:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}
.ml-button:disabled,
.ml-button[aria-disabled="true"] {
  background: var(--surface-sunken);
  color: var(--ink-faint);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
}
.ml-button--ghost:disabled,
.ml-button--ghost[aria-disabled="true"] {
  background: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .ml-button {
    transition: background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out, transform 160ms ease-out;
  }
}

/* ==========================================================================
   Field: label + input box + help / error, with address variant (prefix)
   ========================================================================== */
.ml-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-sans);
  color: var(--ink);
}
.ml-field__label {
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  color: var(--ink);
}
.ml-field__control {
  display: flex;
  align-items: center;
  height: var(--control-m);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  cursor: text;
}
.ml-field__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-m);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  outline: 0;
}
.ml-field__input::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}
.ml-field__prefix {
  flex: none;
  padding-left: var(--space-4);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 22px;
  font-weight: 500;
  color: var(--ink-muted);
  user-select: none;
}
.ml-field__prefix + .ml-field__input {
  padding-left: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 22px;
  font-weight: 500;
  color: var(--ink);
}
.ml-field__help {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--ink-muted);
}
.ml-field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--danger);
}
.ml-field__error > svg,
.ml-field__error-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.ml-field__control:hover {
  border-color: var(--ink-muted);
}
.ml-field__control:focus-within {
  border-color: var(--accent-ink);
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}
.ml-field--error .ml-field__control,
.ml-field--error .ml-field__control:hover {
  border-color: var(--danger);
}
.ml-field--error .ml-field__control:focus-within {
  border-color: var(--accent-ink);
}
.ml-field--disabled .ml-field__label {
  color: var(--ink-faint);
}
.ml-field--disabled .ml-field__control,
.ml-field--disabled .ml-field__control:hover {
  background: var(--surface-sunken);
  border-color: var(--line);
  cursor: not-allowed;
}
.ml-field__input:disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
}
.ml-field--disabled .ml-field__prefix {
  color: var(--ink-faint);
}

@media (prefers-reduced-motion: no-preference) {
  .ml-field__control {
    transition: background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out;
  }
}

/* ==========================================================================
   Switch: 40x24 pill track, native checkbox with role="switch"
   ========================================================================== */
.ml-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-m);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.ml-switch__input {
  position: absolute;
  left: 0;
  top: 50%;
  width: 40px;
  height: 24px;
  margin: 0;
  transform: translateY(-50%);
  opacity: 0;
  cursor: inherit;
}
.ml-switch__track {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
}
.ml-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.ml-switch__label {
  min-width: 0;
}
.ml-switch__input:checked + .ml-switch__track {
  background: var(--ink);
  border-color: var(--ink);
}
.ml-switch__input:checked + .ml-switch__track::after {
  background: var(--on-ink);
  transform: translateX(16px);
}
.ml-switch:hover .ml-switch__input:not(:disabled):not(:checked) + .ml-switch__track {
  border-color: var(--ink-muted);
}
.ml-switch:hover .ml-switch__input:not(:disabled):checked + .ml-switch__track {
  background: var(--ink-muted);
  border-color: var(--ink-muted);
}
.ml-switch__input:focus-visible + .ml-switch__track {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}
.ml-switch:has(.ml-switch__input:disabled) {
  color: var(--ink-faint);
  cursor: not-allowed;
}
.ml-switch__input:disabled + .ml-switch__track {
  background: var(--surface-sunken);
  border-color: var(--line);
}
.ml-switch__input:disabled + .ml-switch__track::after {
  background: var(--ink-faint);
  box-shadow: none;
}
.ml-switch__input:disabled:checked + .ml-switch__track::after {
  background: var(--surface-sunken);
}
.ml-switch__input:disabled:checked + .ml-switch__track {
  background: var(--ink-faint);
  border-color: var(--ink-faint);
}

@media (prefers-reduced-motion: no-preference) {
  .ml-switch__track {
    transition: background-color 160ms ease-out, border-color 160ms ease-out;
  }
  .ml-switch__track::after {
    transition: background-color 160ms ease-out, transform 160ms ease-out;
  }
}

/* ==========================================================================
   SegmentedControl: pill container, radio inputs + labels
   ========================================================================== */
.ml-segmented {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  width: fit-content;
  max-width: 100%;
  height: var(--control-m);
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  font-family: var(--font-sans);
}
.ml-segmented--full {
  display: flex;
  width: 100%;
}
.ml-segmented--full .ml-segmented__item {
  flex: 1;
}
.ml-segmented__item {
  position: relative;
  display: flex;
  height: 100%;
  cursor: pointer;
}
.ml-segmented__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.ml-segmented__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  color: var(--ink-muted);
  white-space: nowrap;
  user-select: none;
}
.ml-segmented__item:hover .ml-segmented__input:not(:disabled):not(:checked) + .ml-segmented__label {
  color: var(--ink);
}
.ml-segmented__input:checked + .ml-segmented__label {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.ml-segmented__input:focus-visible + .ml-segmented__label {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}
.ml-segmented__item:has(.ml-segmented__input:disabled) {
  cursor: not-allowed;
}
.ml-segmented__input:disabled + .ml-segmented__label {
  color: var(--ink-faint);
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ml-segmented__label {
    transition: background-color 160ms ease-out, box-shadow 160ms ease-out;
  }
}

/* ==========================================================================
   Badge: 24px pill with word (and dot or icon), tones neutral / plan / success / warning / danger
   ========================================================================== */
.ml-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
}
.ml-badge__dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: var(--radius-full);
  background: currentColor;
}
.ml-badge__icon,
.ml-badge > svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.ml-badge--neutral {
  background: var(--surface-sunken);
  color: var(--ink-muted);
}
.ml-badge--plan {
  background: var(--accent-soft);
  color: var(--ink);
}
.ml-badge--plan .ml-badge__dot {
  background: var(--accent-ink);
}
.ml-badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.ml-badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.ml-badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   Card: surface container with optional header and footer
   ========================================================================== */
.ml-card {
  padding: var(--space-5);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  font-family: var(--font-sans);
}
.ml-card--raised {
  box-shadow: var(--shadow-2);
}
.ml-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.ml-card__heading {
  min-width: 0;
}
.ml-card__title {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  color: var(--ink);
}
.ml-card__subtitle {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--ink-muted);
}
.ml-card__action {
  flex: none;
}
.ml-card__body {
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--ink);
}
.ml-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   LinkRow: pill link of the public page, 3-column grid keeps the label centered
   ========================================================================== */
.ml-link-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  column-gap: var(--space-2);
  width: 100%;
  max-width: var(--page-column);
  min-height: var(--link-row);
  margin-inline: auto;
  padding: var(--space-2);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-1);
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ml-link-row__lead {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}
.ml-link-row__thumb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--sand);
  color: var(--ink);
}
.ml-link-row__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ml-link-row__thumb > svg {
  width: 20px;
  height: 20px;
}
.ml-link-row__label {
  grid-column: 2;
  min-width: 0;
  padding: var(--space-1) 0;
  text-align: center;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: inherit;
  overflow-wrap: anywhere;
}
.ml-link-row__trail {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--ink-muted);
}
.ml-link-row__trail > svg,
.ml-link-row__icon {
  width: 20px;
  height: 20px;
}

.ml-link-row:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}
.ml-link-row:active {
  transform: translateY(1px);
}
.ml-link-row:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.ml-link-row--featured,
.ml-link-row--featured:hover {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}
.ml-link-row--featured .ml-link-row__trail {
  color: var(--on-accent);
}
.ml-link-row--featured .ml-link-row__thumb {
  background: var(--surface);
}

.ml-link-row--locked .ml-link-row__label {
  color: var(--ink-muted);
}
.ml-link-row--locked .ml-link-row__trail {
  color: var(--ink-muted);
}

.ml-link-row--sensitive {
  border-color: var(--line-strong);
}
.ml-link-row--sensitive:hover {
  border-color: var(--ink-muted);
}

@media (prefers-reduced-motion: no-preference) {
  .ml-link-row {
    transition: background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out, transform 160ms ease-out;
  }
}

/* ==========================================================================
   ProfileHeader: avatar, name, bio and social icon buttons
   ========================================================================== */
.ml-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  font-family: var(--font-sans);
  color: var(--ink);
}
.ml-profile__avatar {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 38px;
  font-weight: 600;
  letter-spacing: -0.02em;
  user-select: none;
}
.ml-profile__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.ml-profile__bio {
  max-width: 40ch;
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--ink-muted);
  text-wrap: pretty;
}
.ml-profile__socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}
.ml-profile__social {
  display: inline-grid;
  place-items: center;
  width: var(--control-m);
  height: var(--control-m);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ml-profile__social > svg {
  width: 20px;
  height: 20px;
}
.ml-profile__social:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-1);
}
.ml-profile__social:active {
  transform: translateY(1px);
}
.ml-profile__social:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .ml-profile__social {
    transition: background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out, transform 160ms ease-out;
  }
}

/* ==========================================================================
   MadeWith: free-plan footer badge "Hecha con MyLinks"
   ========================================================================== */
.ml-made-with {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.ml-made-with__dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--accent);
}
.ml-made-with__brand {
  font-weight: 600;
  color: var(--ink);
}
a.ml-made-with {
  cursor: pointer;
}
a.ml-made-with:hover {
  border-color: var(--line-strong);
}
a.ml-made-with:active {
  transform: translateY(1px);
}
a.ml-made-with:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .ml-made-with {
    transition: background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out, transform 160ms ease-out;
  }
}

/* ==========================================================================
   Stat: panel metric with label, tabular value, delta line and locked state
   ========================================================================== */
.ml-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  font-family: var(--font-sans);
  color: var(--ink);
}
.ml-stat__label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-muted);
}
.ml-stat__label > svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.ml-stat__value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 38px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ml-stat__delta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--ink-muted);
}
.ml-stat__delta > svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.ml-stat__delta--up {
  color: var(--success);
}
.ml-stat__delta--down {
  color: var(--danger);
}
.ml-stat__note {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--ink-muted);
}
.ml-stat__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--control-s);
  margin: var(--space-1) 0 0 calc(-1 * var(--space-3));
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.ml-stat__link > svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.ml-stat__link:hover {
  background: var(--surface-sunken);
}
.ml-stat__link:active {
  transform: translateY(1px);
}
.ml-stat__link:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}
.ml-stat--locked .ml-stat__label {
  font-size: 15px;
  line-height: 20px;
  color: var(--ink-muted);
}
.ml-stat--locked .ml-stat__label > svg {
  width: 20px;
  height: 20px;
}

@media (prefers-reduced-motion: no-preference) {
  .ml-stat__link {
    transition: background-color 160ms ease-out, transform 160ms ease-out;
  }
}
